1/** 2 * @preserve Galleria Twelve Theme 2011-06-09 3 * http://galleria.aino.se 4 * 5 * Copyright (c) 2011, Aino 6 */ 7 8/*global jQuery, Galleria */ 9 10(function($) { 11 12Galleria.addTheme({ 13 name: 'twelve', 14 author: 'Galleria', 15 css: 'galleria.twelve.css', 16 defaults: { 17 transition: 'fade', 18 transitionSpeed: 500, 19 imageCrop: false, 20 thumbCrop: true, 21 carousel: false, 22 autoplay: true, 23 navhide: true, 24 25 // theme specific defaults: 26 _locale: { 27 show_thumbnails: 'Show thumbnails', 28 hide_thumbnails: 'Hide thumbnails', 29 play: 'Play slideshow', 30 pause: 'Pause slideshow', 31 enter_fullscreen: 'Enter fullscreen', 32 exit_fullscreen: 'Exit fullscreen', 33 popout_image: 'Popout image', 34 showing_image: 'Showing image %s of %s' 35 }, 36 _showFullscreen: true, 37 _showPopout: true, 38 _showProgress: true, 39 _showTooltip: true 40 }, 41 init: function(options) { 42 43 // add some elements 44 this.addElement('bar','fullscreen','play','popout','thumblink','s1','s2','s3','s4','progress'); 45 this.append({ 46 'stage' : 'progress', 47 'container': ['bar','tooltip'], 48 'bar' : ['fullscreen','play','popout','thumblink','info','s1','s2','s3','s4'] 49 }); 50 this.prependChild('info','counter'); 51 52 // copy the scope 53 var gallery = this, 54 55 // cache some stuff 56 thumbs = this.$('thumbnails-container'), 57 thumb_link = this.$('thumblink'), 58 fs_link = this.$('fullscreen'), 59 play_link = this.$('play'), 60 pop_link = this.$('popout'), 61 bar = this.$('bar'), 62 progress = this.$('progress'), 63 transition = options.transition, 64 lang = options._locale, 65 66 // statics 67 OPEN = false, 68 FULLSCREEN = false, 69 PLAYING = !!options.autoplay, 70 CONTINUE = false, 71 72 // helper functions 73 scaleThumbs = function() { 74 thumbs.height( gallery.getStageHeight() ).width( gallery.getStageWidth() ).css('top', OPEN ? 0 : gallery.getStageHeight()+30 ); 75 }, 76 77 toggleThumbs = function(e) { 78 if (OPEN && CONTINUE) { 79 gallery.play(); 80 } else { 81 CONTINUE = PLAYING; 82 gallery.pause(); 83 } 84 Galleria.utils.animate( thumbs, { top: OPEN ? gallery.getStageHeight()+30 : 0 } , { 85 easing:'galleria', 86 duration:400, 87 complete: function() { 88 gallery.defineTooltip('thumblink', OPEN ? lang.show_thumbnails : lang.hide_thumbnails); 89 thumb_link[OPEN ? 'removeClass' : 'addClass']('open'); 90 OPEN = !OPEN; 91 } 92 }); 93 }; 94 95 // scale the thumbnail container 96 scaleThumbs(); 97 98 // bind the tooltips 99 if (options._showTooltip) { 100 101 gallery.bindTooltip({ 102 103 'thumblink': lang.show_thumbnails, 104 105 'fullscreen': lang.enter_fullscreen, 106 107 'play': lang.play, 108 109 'popout': lang.popout_image, 110 111 'caption': function() { 112 var data = gallery.getData(); 113 var str = ''; 114 if (data) { 115 if (data.title && data.title.length) { 116 str+='<strong>'+data.title+'</strong>'; 117 } 118 if (data.description && data.description.length) { 119 str+='<br>'+data.description; 120 } 121 } 122 return str; 123 }, 124 125 'counter': function() { 126 return lang.showing_image.replace( /\%s/, gallery.getIndex() + 1 ).replace( /\%s/, gallery.getDataLength() ); 127 } 128 }); 129 } 130 131 if ( options.navhide ) { 132 this.addIdleState(this.get('bar'), {bottom:-31}); 133 window.setTimeout(this.proxy(function() { 134 this._idle.hide(); 135 }),100); 136 } 137 138 if ( !options.showInfo ) { 139 this.$( 'info' ).hide(); 140 } 141 142 // bind galleria events 143 this.bind( 'play', function() { 144 PLAYING = true; 145 play_link.addClass('playing'); 146 }); 147 148 this.bind( 'pause', function() { 149 PLAYING = false;
150 play_link.removeClass('playing'); 151 progress.width(0); 152 }); 153 154 if (options._showProgress) { 155 this.bind( 'progress', function(e) { 156 progress.width( e.percent/100 * this.getStageWidth() ); 157 }); 158 } 159 160 this.bind( 'loadstart', function(e) { 161 if (!e.cached) { 162 this.$('loader').show(); 163 } 164 }); 165 166 this.bind( 'loadfinish', function(e) { 167 progress.width(0); 168 this.$('loader').hide(); 169 this.refreshTooltip('counter','caption'); 170 }); 171 172 this.bind( 'thumbnail', function(e) { 173 $(e.thumbTarget).hover(function() { 174 gallery.setInfo(e.thumbOrder); 175 gallery.setCounter(e.thumbOrder); 176 }, function() { 177 gallery.setInfo(); 178 gallery.setCounter(); 179 }).click(function() { 180 toggleThumbs(); 181 }); 182 }); 183 184 this.bind( 'fullscreen_enter', function(e) { 185 FULLSCREEN = true; 186 gallery.setOptions('transition', false); 187 fs_link.addClass('open'); 188 bar.css('bottom',0); 189 this.defineTooltip('fullscreen', lang.exit_fullscreen); 190 if ( !Galleria.TOUCH ) { 191 this.addIdleState(bar, { bottom: -31 }); 192 } 193 }); 194 195 this.bind( 'fullscreen_exit', function(e) { 196 FULLSCREEN = false; 197 Galleria.utils.clearTimer('bar'); 198 gallery.setOptions('transition',transition); 199 200 fs_link.removeClass('open'); 201 bar.css('bottom',0); 202 203 this.defineTooltip('fullscreen', lang.enter_fullscreen); 204 205 if ( !Galleria.TOUCH ) { 206 this.removeIdleState(bar, { bottom:-31 }); 207 } 208 }); 209 210 this.bind( 'rescale', scaleThumbs); 211 212 if ( !Galleria.TOUCH ) { 213 214 this.addIdleState(this.get('image-nav-left'), {left:-36}); 215 this.addIdleState(this.get('image-nav-right'), {right:-36}); 216 217 } 218 219 // bind thumblink 220 thumb_link.click( toggleThumbs ); 221 222 // bind popup 223 if (options._showPopout) { 224 pop_link.click(function(e) { 225 gallery.openLightbox(); 226 e.preventDefault(); 227 }); 228 } else { 229 pop_link.remove(); 230 if (options._showFullscreen) { 231 this.$('s4').remove(); 232 this.$('info').css('right',40); 233 fs_link.css('right',0); 234 } 235 } 236 237 // bind play button 238 play_link.click(function() { 239 gallery.defineTooltip('play', PLAYING ? lang.play : lang.pause); 240 if (PLAYING) { 241 gallery.pause(); 242 } else { 243 if (OPEN) { 244 thumb_link.click(); 245 } 246 gallery.play(); 247 } 248 }); 249 250 // bind fullscreen 251 if (options._showFullscreen) { 252 fs_link.click(function() { 253 if (FULLSCREEN) { 254 gallery.exitFullscreen(); 255 } else { 256 gallery.enterFullscreen(); 257 } 258 }); 259 } else { 260 fs_link.remove(); 261 if (options._show_popout) { 262 this.$('s4').remove(); 263 this.$('info').css('right',40); 264 pop_link.css('right',0); 265 } 266 } 267 268 if (!options._showFullscreen && !options._showPopout) { 269 this.$('s3,s4').remove(); 270 this.$('info').css('right',10); 271 } 272 273 if (options.autoplay) { 274 this.trigger( 'play' ); 275 } 276 } 277}); 278 279}( 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.