1jQuery(document).ready(function($){ 2 function onYouTubeIframeAPIReady() { 3 } 4 $.widget( "jerzy.lightbox", { 5 options: { 6 childSelector: 'img', 7 clickSelector: '', 8 srcAttribute: 'src', 9 handlerElement: '', 10 currentElement: null, 11 targetFilter: function(src){return src;}, 12 zoomin: false, 13 zoomerRatio: 1.5, 14 zoomerSize: '300', 15 descriptionAttr: 'title', 16 description: false 17 }, 18 _create: function() { 19 this.element.addClass('jerzy-lightbox'); 20 this.options.clickSelector = ((this.options.childSelector === 'iframe' && this.options.clickSelector === '')) ? '.iframeSelector' : (this.options.clickSelector === '') ? this.options.childSelector : this.options.clickSelector; 21 that = this ; 22 this._on(this._getClickSelector(), { 23 click: "_imgClick" 24 }); 25 }, 26 _imgClick: function(e){ 27 e.preventDefault(); 28 if($(e.target).hasClass('iframeSelector')){ 29 this.options.currentElement = $(e.target).children('iframe'); 30 }else{ 31 this.options.currentElement = $(e.target); 32 } 33 this._createModal(); 34 }, 35 _getChildren: function(){ 36 return this.element.find(this.options.childSelector); 37 }, 38 _getClickSelector: function(){ 39 return this.element.find(this.options.clickSelector); 40 }, 41 _createModal: function(){ 42 modal = $('<div/>') 43 .addClass('lightbox_modal'); 44 closeButton = $('<span/>') 45 .addClass('glyphicon glyphicon-remove'); 46 this._on(closeButton, { 47 click: $.proxy(this._closeModal, this) 48 });
49 secondContainer = $('<div/>') 50 .addClass('lightbox_modal_container'); 51 if(this._getChildren().size() > 1){ 52 toleftButton = $('<span/>') 53 .addClass('glyphicon glyphicon-chevron-left'); 54 torightButton = $('<span/>') 55 .addClass('glyphicon glyphicon-chevron-right'); 56 secondContainer.append(toleftButton).append(torightButton); 57 } 58 secondContainer.append(this._getCentralElement()); 59 if(this.options.description === true){ 60 this._setDescription(); 61 } 62 modal.append(closeButton).append(secondContainer); 63 $('body').append(modal); 64 if(this._getChildren().size() > 1){ 65 this._setChevronColor(); 66 this._setChevronEvent(); 67 this._bindKeyEvent(); 68 } 69 this._bindBackButton(); 70 }, 71 _closeModal: function(){ 72 $('.lightbox_modal').hide('swing').remove(); 73 this._unbindEvents(); 74 }, 75 _getSrcUrl: function(){ 76 return this.options.currentElement.attr(this.options.srcAttribute); 77 }, 78 _getTargetUrl: function(){ 79 return this.options.targetFilter(this._getSrcUrl()); 80 }, 81 _getCentralElement: function(){ 82 img = $('<img/>').addClass('lightbox_modal_frame') 83 .attr('src', this._getTargetUrl()) 84 .css('opacity', '0') 85 .imagesLoaded($.proxy(this._centerModal, this)); 86 if(this.options.zoomin === true){ 87 that = this; 88 img.imagesLoaded('done', function(){ 89 img.zoomin({ 90 'zoomerSize': that.options.zoomerSize, 91 'zoomerRatio': that.options.zoomerRatio 92 }); 93 }); 94 } 95 if(this.options.description === true){ 96 descrContent = $('<p/>') 97 .addClass('lightbox_modal_description'); 98 return [img, descrContent]; 99 } 100 return img; 101 }, 102 _setChevronColor: function(){ 103 $('.lightbox_modal').find('.glyphicon-chevron-left').css('color', this._getChevronLeftColor()); 104 $('.lightbox_modal').find('.glyphicon-chevron-right').css('color', this._getChevronRightColor()); 105 }, 106 // couleur de chevron gauche en fonction de l'index 107 _getChevronLeftColor: function(){ 108 if(this._getChevronLeftActive()){ 109 return '#ffffff' ; 110 }else{ 111 return '#505050' ; 112 } 113 }, 114 // couleur de chevron doit en fonction de l'index 115 _getChevronRightColor: function(){ 116 if(this._getChevronRightActive()){ 117 return '#ffffff' ; 118 }else{ 119 return '#505050' ; 120 } 121 }, 122 // chevron gauche actif si pas 1ere 123 _getChevronLeftActive: function(){ 124 if(this._getImageIndex() === 0){ 125 return false ; 126 }else{ 127 return true ; 128 } 129 }, 130 // chevron droit actif si pas dernière 131 _getChevronRightActive: function(){ 132 if(this._getImageIndex() === this._getChildren().size()-1){ 133 return false ; 134 }else{ 135 return true ; 136 } 137 }, 138 _getImageIndex: function(){ 139 resp = false ; 140 if(this._getChildren().size() > 0){ 141 that = this ; 142 this._getChildren().each(function(index){ 143 if($(this).attr(that.options.srcAttribute) === that._getSrcUrl()){ 144 resp = index ; 145 } 146 }); 147 } 148 return resp ; 149 }, 150 _bindEvents: function(){ 151 this._bindBackButton(); 152 this._bindKeyEvent(); 153 }, 154 _unbindEvents: function(){ 155 this._unbindBackButton(); 156 this._unbindKeyEvent(); 157 }, 158 _bindBackButton: function(){ 159 jQuery(window).bind( 'statechange', $.proxy(function() { 160 this._closeModal(); 161 }, this)); 162 }, 163 _unbindBackButton: function(){ 164 $(window).unbind('.backbutton'); 165 }, 166 _bindKeyEvent: function(){ 167 $(window).bind('keydown.changeimg', $.proxy(this._keyEvent, this)); 168 }, 169 _unbindKeyEvent: function(){ 170 $(window).unbind('.changeimg'); 171 }, 172 _keyEvent: function(e){ 173 switch(e.which) { 174 case 37: // left 175 this._prevImg(); 176 break; 177 178 case 39: // right 179 this._nextImg(); 180 break; 181 case $.ui.keyCode.ESCAPE: 182 this._closeModal(); 183 break; 184 185 default: return; // exit this handler for other keys 186 } 187 e.preventDefault(); // prevent the default action (scroll / move caret) 188 }, 189 // bind event au chevron 190 _setChevronEvent: function(){ 191 toleftButton = $('.lightbox_modal').find('.glyphicon-chevron-left') ; 192 torightButton = $('.lightbox_modal').find('.glyphicon-chevron-right') ; 193 toleftButton.off('click'); 194 torightButton.off('click'); 195 if(this._getChevronLeftActive()){ 196 this._on(toleftButton, { 197 click: $.proxy(this._prevImg, this) 198 }); 199 toleftButton.css('cursor', 'pointer'); 200 }else{ 201 torightButton.css('cursor', 'default'); 202 } 203 if(this._getChevronRightActive()){ 204 this._on(torightButton, { 205 click: $.proxy(this._nextImg, this) 206 }); 207 torightButton.css('cursor', 'pointer'); 208 }else{ 209 torightButton.css('cursor', 'default'); 210 } 211 }, 212 // changer image 213 _changeImg: function(newImg){ 214 that = this; 215 $('.lightbox_modal_frame').animate({'opacity': '0'}, 100, function(){ 216 $(this).attr(that.options.srcAttribute, newImg); 217 $('.lightbox_modal_frame').imagesLoaded('always', $.proxy(that._centerModal, this)); 218 }); 219 }, 220 _setDescription: function(){ 221 if(this.options.currentElement.attr(this.options.descriptionAttr)){ 222 $('.lightbox_modal_description').html(this.options.currentElement.attr(this.options.descriptionAttr)).show('fast'); 223 }else{ 224 $('.lightbox_modal_description').html('').hide('fast'); 225 } 226 }, 227 // image suivante 228 _nextImg: function(){ 229 this.options.currentElement = $(this._getChildren().get(this._getImageIndex()+1)); 230 this._setDescription(); 231 this._changeImg(this._getTargetUrl()); 232 this._setChevronColor(); 233 this._setChevronEvent(); 234 }, 235 // image précédente 236 _prevImg: function(){ 237 this.options.currentElement = $(this._getChildren().get(this._getImageIndex()-1)); 238 this._setDescription(); 239 this._changeImg(this._getTargetUrl()); 240 this._setChevronColor(); 241 this._setChevronEvent(); 242 }, 243 _centerModal: function(){ 244 topHeight = ( ($('.lightbox_modal_container').height() - $('.lightbox_modal_frame').height()) /2 )+'px' ; 245 $('.lightbox_modal_frame').animate({ 246 'marginTop' : topHeight 247 }, 200).animate({ 248 'opacity': '1' 249 }, 300, function(){ 250 $('.lightbox_modal').animate({ 251 'opacity': '1' 252 }, 300); 253 }); 254 } 255 }); 256 257 $.widget('jerzy.ytLightbox', $.jerzy.lightbox, { 258 _player: null, 259 options: { 260 childSelector: 'iframe', 261 srcAttribute: 'id' 262 }, 263 _create: function(){ 264 this._super(); 265 }, 266 _createModal: function(){ 267 this._super(); 268 }, 269 _videoEmbed: function(){ 270 onPlayerReady = function(e){ 271 if(categorizr.isDesktop === true){ 272 e.target.playVideo() ; 273 } 274 this._centerModal(); 275 }; 276 onPlayerStateChange = function(e){ 277 if(e.data === 0){ 278 this._nextImg(); 279 } 280 }; 281 this._player = new YT.Player('lightbox_modal_frame', { 282 height: heightVideo + 'px', 283 width: widthVideo + 'px', 284 playerVars: { 285 autohide: 1, 286 allowfullscreean: 1 287 }, 288 suggestQuality: 'default', 289 videoId: this._getTargetUrl(), 290 events: { 291 'onReady': $.proxy(onPlayerReady, that), 292 'onStateChange': $.proxy(onPlayerStateChange, that) 293 } 294 }); 295 }, 296 _getCentralElement: function(){ 297 widthVideo = ($(window).width() < 640 ) ? ($(window).width() * 0.9) : '640' ; 298 heightVideo = widthVideo * 9 /16 ; 299 return this._player = iframeVideo = $('<iframe/>') 300 .addClass('lightbox_modal_frame') 301 .attr({ 302 'id': 'lightbox_modal_frame', 303 'height': heightVideo+'px', 304 'width': widthVideo+'px', 305 'allowfullscreen': '', 306 'src': this._getTargetUrl() 307 }) 308 .css({ 309 'display': 'block', 310 'margin': '0 auto' 311 }) 312 .on('load', $.proxy(this._centerModal, this)); 313 }, 314 // chargement du script src au chargement de la page 315 _loadYtApiScript: function(){ 316 tag = document.createElement('script'); 317 tag.src = "https://www.youtube.com/iframe_api"; 318 firstScriptTag = document.getElementsByTagName('script')[0]; 319 firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); 320 }, 321 _closeModal: function(){ 322 this._super(); 323 }, 324 // video suivante 325 _nextImg: function(){ 326 this._super(); 327 this._player.attr('src', this._getTargetUrl()); 328 }, 329 // video précédente 330 _prevImg: function(){ 331 this._super(); 332 this._player.attr('src', this._getTargetUrl()); 333 }, 334 }); 335});
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.