1(function($) { 2 Galleria.addTheme({ 3 name: 'nextgen_pro_slideshow', 4 author: 'Imagely', 5 version: 2.0, 6 defaults: { 7 carousel: false, 8 thumbnails: false, 9 autoplay: true, 10 showInfo: false, 11 fullscreenDoubleTap: false, 12 trueFullscreen: false 13 }, 14 init: function(options) { 15 Galleria.requires(1.41, 'This version of NextGen Pro Slideshow theme requires Galleria 1.4.1 or later'); 16 17 var self = this; 18 19 // Adjust some settings specific to this gallery 20 options.showInfo = (options.showInfo && options._nggCaptionClass.length > 0) ? true : false; 21 options._nggCaptionPadding = parseInt(window.ngg_galleria.get_setting(options._nggGalleryID, 'caption_padding', '5')); 22 23 // Galleria doesn't correctly position images with borders 24 var adjust_border_positioning = function($img) { 25 if (options._nggBorderSize > 0 && options.imageCrop !== true) { 26 var top = (parseInt($img.css('top')) - options._nggBorderSize); 27 var left = (parseInt($img.css('left')) - options._nggBorderSize); 28 if (top < 0) top = 0; 29 if (left < 0) left = 0; 30 $img.css('top', top + 'px'); 31 $img.css('left', left + 'px'); 32 } 33 }; 34 35 // It's much faster to add this by CSS than hooking onto 'loadfinish' 36 if (options._nggBorderSize > 0 && options.imageCrop !== true) { 37 $("<style type='text/css'>#displayed_gallery_" + options._nggGalleryID + " .galleria-stage .galleria-image img {" 38 + "border: solid " + parseInt(options._nggBorderSize) + 'px ' + options._nggBorderColor 39 + " } </style>").appendTo("head"); 40 } 41 42 // Adjust some dimensions before Galleria starts the display 43 this.$('info').css('max-height', options._nggCaptionHeight + 'px'); 44 45 if (!Galleria.TOUCH) { 46 this.addIdleState(this.get('image-nav-left'), { left: -50 }); 47 this.addIdleState(this.get('image-nav-right'), { right: -50 }); 48 this.addIdleState(this.get('counter'), { opacity: 0 }); 49 } 50 51 // Add the caption class to the Galleria container 52 if (options.showInfo && options._nggCaptionClass.length > 0) { 53 this.$('info').show(); 54 this.$('container').addClass(options._nggCaptionClass); 55 56 // if the info overflows its container this effect will let viewers read the remaining description 57 this.$('info').on('mouseenter', function() { 58 var $info = $(this); 59 var text = self.$('info-text'); 60 var diff = $info.outerHeight() - text.outerHeight(); 61 if (diff < 0) { 62 $info.stop().animate({ scrollTop: -diff }, ((-diff) / 17) * 450); 63 } 64 }); 65 this.$('info').on('mouseleave', function() { 66 var $info = $(this); 67 var text = self.$('info-text'); 68 var diff = $info.outerHeight() - text.outerHeight(); 69 if (diff < 0) { 70 $info.stop().animate({ scrollTop: 0 }, 'fast'); 71 } 72 }); 73 74 // Adjust the dimensions of the stage to fit captions 75 switch (options._nggCaptionClass) { 76 case 'caption_above_stage': { 77 this.$('stage').css({ top: parseInt(options._nggCaptionHeight) + options.imageMargin }); 78 break; 79 } 80 case 'caption_below_stage': { 81 this.$('stage').css({ 82 bottom: parseInt(options._nggCaptionHeight) 83 + (options._nggCaptionPadding) 84 + options.imageMargin 85 }); 86 break; 87 } 88 } 89 90 this.rescale(); 91 } 92 93 // Automatically begin playback 94 this.setPlaytime(options._nggSlideshowSpeed); 95 96 if (options._nggShowPlaybackControls) { 97 var playback_button = $('<div/>').addClass('galleria-playback-button'); 98 if (this._playing) { 99 playback_button.removeClass('play').addClass('pause'); 100 } else { 101 playback_button.removeClass('pause').addClass('play'); 102 } 103 $(this._dom.stage).append(playback_button); 104 105 var button = $('<a/>') 106 .on('mouseenter', function() { $(this).parent().css('opacity', 0.9); }) 107 .on('mouseleave', function() { $(this).parent().css('opacity', 0.7); }) 108 .on('click', this.proxy(function(e) { 109 var controls = $(e.target).parent(); 110 if (this._playing) { 111 this.pause(); 112 controls.removeClass('pause').addClass('play'); 113 } else { 114 this.play().next(); 115 controls.removeClass('play').addClass('pause'); 116 } 117 })); 118 playback_button.append(button); 119 120 playback_button 121 .on('mouseenter', function() { $(this).css( 'opacity', 0.7); }) 122 .on('mouseleave', function() { $(this).animate({ opacity: 0.0}); }); 123 } 124 125 this.bind('rescale', this.proxy(function(e) { 126 var $img = $(self.getActiveImage()); 127 setTimeout(function() { 128 adjust_border_positioning($img); 129 }, 30); 130 })); 131 132 this.bind('loadfinish', this.proxy(function(e) { 133 var $img = $(e.imageTarget); 134 adjust_border_positioning($img); 135 136 // Adjust the Pro Lightbox triggers if they exist 137 $(options._nggGalleryParent).siblings('div.ngg-trigger-buttons').each(function() { 138 $(this).width(self.$('stage').width()); 139 $(this).css('margin', '0 auto'); 140 $(this).find('i').each(function() { 141 $(this).data('nplmodal-image-id', self.getData(self.getIndex()).image_id); 142 }); 143 }); 144 })); 145 146 // Disable image right-click and drag when requested 147 if (window.ngg_galleria.get_setting(options._nggGalleryID, 'protect_images', false)) { 148 this.addElement('image-protection'); 149 document.oncontextmenu = function(event) { 150 event = event || window.event; 151 event.preventDefault(); 152 }; 153 this.prependChild('images', 'image-protection'); 154 this.$('image').bind('dragstart', function(event) { 155 event.preventDefault(); 156 }); 157 } 158 } 159 160 }); 161 162 $(window).trigger('ngg.galleria.themeadded', ['nextgen_pro_slideshow']); 163 164}(jQuery));
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.