Участник:T kns/imagebox.js

$(function() {
    importStylesheetURI('//yandex.st/jquery/fancybox/2.1.3/jquery.fancybox.css');

    $.ajax({
        url:'//yandex.st/jquery/fancybox/2.1.3/jquery.fancybox.min.js',
        dataType:'script',
        cache:true,
        success:function() {
            $('a.image').click(function(e){
                if(e.which > 1) {return;}

                var _this = $(this), img = _this.children('img');

                if(!_this.data('imageDirectLink')) {
                    _this.data('imageDirectLink', img.attr('src')
                                                .replace(/\/thumb(\/.\/..\/[^\/]+)\/.*$/,'$1'));

                    _this.data('imagePage', _this.data('imageDirectLink')
                                                .replace(/^.*\/([^\/]+)$/,'$1'));

                    _this.data('imageTitle', img.attr('alt') || _this.data('imagePage'));

                    _this.attr({
                        'data-image-direct-link': _this.data('imageDirectLink'),
                        'data-image-page': _this.data('imagePage'),
                        'data-image-title': _this.data('imageTitle')
                    });
                }

                $.fancybox({
                    type:'image',
                    href:_this.data('imageDirectLink'),
                    title:'<a href="/wiki/Image:'+_this.data('imagePage')+'" style="color: #ffffff"'
                        +'>'+decodeURIComponent(_this.data('imageTitle')).replace(/_/g,' ')+'</a>',
                    openOpacity:'0.1',
                    openSpeed:100,
                    closeSpeed:50,
                    helpers: {
                        title: {
                            type: 'over'
                        },
                        overlay: {
                            speedOut: 50
                        }
                    },
                    afterShow: function() {
                        var op = '0.2', ti = $('.fancybox-title-over-wrap');
                        ti.css('opacity', op)
                            .hover(function() {ti.stop(true).fadeTo('fast', 1)}, function() {ti.stop(true).fadeTo('fast', op)});
                    }
                });

                return false;
            });
        }
    });
});
Prefix: a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 8 9

Portal di Ensiklopedia Dunia

Kembali kehalaman sebelumnya