1;(function($, window, document, undefined){ 2 "use strict" 3 4 if ( typeof wilokeInitPhotoSwipeFromDOM == 'undefined' ) 5 { 6 window.wilokeInitPhotoSwipeFromDOM = function(gallerySelector) { 7 8 // parse slide data (url, title, size ...) from DOM elements 9 // (children of gallerySelector) 10 var parseThumbnailElements = function(el) { 11 var thumbElements = el.childNodes, 12 numNodes = thumbElements.length, 13 items = [], 14 linkEl, 15 size, 16 item; 17 18 for(var i = 0; i < numNodes; i++) { 19 20 if ( thumbElements[i].tagName.toUpperCase() === 'A' ) 21 { 22 linkEl = thumbElements[i]; // <a> element 23 24 // include only element nodes 25 if(linkEl.nodeType !== 1) { 26 continue; 27 } 28 29 size = linkEl.getAttribute('data-size').split('x'); 30 31 // create slide object 32 item = { 33 src: linkEl.getAttribute('href'), 34 w: parseInt(size[0], 10), 35 h: parseInt(size[1], 10) 36 }; 37 38 if(linkEl.children.length > 0) { 39 item.msrc = linkEl.children[0].getAttribute('src'); 40 } 41 42 if(linkEl.getAttribute('data-caption') && linkEl.getAttribute('data-link')) 43 { 44 item.title = '<a href="'+linkEl.getAttribute('data-link')+'" target="_blank">'+linkEl.getAttribute('data-caption') + '</a>'; 45 }else{ 46 item.title = linkEl.getAttribute('data-caption'); 47 } 48 49 item.el = linkEl; // save link to element for getThumbBoundsFn 50 items.push(item); 51 } 52 } 53 54 return items; 55 }; 56 57 // find nearest parent element 58 var closest = function closest(el, fn) { 59 return el && ( fn(el) ? el : closest(el.parentNode, fn) ); 60 }; 61 62 // triggers when user clicks on thumbnail 63 var onThumbnailsClick = function(e) { 64 e = e || window.event; 65 e.preventDefault ? e.preventDefault() : e.returnValue = false; 66 67 var eTarget = e.target || e.srcElement; 68 69 // find root element of slide 70 var clickedListItem = closest(eTarget, function(el) { 71 return (el.tagName && el.tagName.toUpperCase() === 'A'); 72 }); 73 74 if(!clickedListItem) { 75 return; 76 } 77 78 // find index of clicked item by looping through all child nodes 79 // alternatively, you may define index via data- attribute 80 var clickedGallery = clickedListItem.parentNode, 81 childNodes = clickedListItem.parentNode.childNodes, 82 numChildNodes = childNodes.length, 83 nodeIndex = 0, 84 index; 85 86 for (var i = 0; i < numChildNodes; i++) { 87 if(childNodes[i].nodeType !== 1) { 88 continue; 89 } 90 91 if(childNodes[i] === clickedListItem) { 92 index = nodeIndex; 93 break; 94 } 95 nodeIndex++; 96 } 97 98 if(index >= 0) { 99 // open PhotoSwipe if valid index found 100 openPhotoSwipe( index, clickedGallery ); 101 } 102 return false; 103 }; 104 105 // parse picture index and gallery index from URL (#&pid=1&gid=2) 106 var photoswipeParseHash = function() { 107 var hash = window.location.hash.substring(1), 108 params = {}; 109 110 if(hash.length < 5) { 111 return params; 112 } 113 114 var vars = hash.split('&'); 115 for (var i = 0; i < vars.length; i++) { 116 if(!vars[i]) { 117 continue; 118 } 119 var pair = vars[i].split('='); 120 if(pair.length < 2) { 121 continue; 122 } 123 params[pair[0]] = pair[1]; 124 } 125 126 if(params.gid) { 127 params.gid = parseInt(params.gid, 10); 128 } 129 130 return params; 131 }; 132 133 var openPhotoSwipe = function(index, galleryElement, disableAnimation, fromURL) { 134 var pswpElement = document.querySelectorAll('.wiloke-pswp-ui')[0], 135 gallery, 136 options, 137 items; 138 139 items = parseThumbnailElements(galleryElement); 140 141 // define options (if needed) 142 options = { 143 144 // define gallery index (for URL) 145 galleryUID: galleryElement.getAttribute('data-pswp-uid'), 146 147 getThumbBoundsFn: function(index) 148 { 149 //console.log(); 150 // See Options -> getThumbBoundsFn section of documentation for more info 151 var thumbnail = items[index].el.getElementsByTagName('img')[0], // find thumbnail 152 pageYScroll = window.pageYOffset || document.documentElement.scrollTop, 153 rect = thumbnail.getBoundingClientRect(); 154 return {x:rect.left, y:rect.top + pageYScroll, w:rect.width}; 155 } 156 157 }; 158 159 // PhotoSwipe opened from URL 160 if(fromURL) { 161 if(options.galleryPIDs) { 162 // parse real index when custom PIDs are used 163 // http://photoswipe.com/documentation/faq.html#custom-pid-in-url 164 for(var j = 0; j < items.length; j++) { 165 if(items[j].pid == index) { 166 options.index = j; 167 break; 168 } 169 } 170 } else { 171 // in URL indexes start from 1 172 options.index = parseInt(index, 10) - 1; 173 } 174 } else { 175 options.index = parseInt(index, 10); 176 } 177 178 // exit if index not found 179 if( isNaN(options.index) ) { 180 return; 181 } 182 183 if(disableAnimation) { 184 options.showAnimationDuration = 0; 185 } 186 187 188 // Pass data to PhotoSwipe and initialize it 189 gallery = new PhotoSwipe( pswpElement, PhotoSwipeUI_Default, items, options); 190 gallery.init(); 191 }; 192 193 // loop through all gallery elements and bind events 194 var galleryElements = document.querySelectorAll( gallerySelector ); 195 196 for(var i = 0, l = galleryElements.length; i < l; i++) { 197 galleryElements[i].setAttribute('data-pswp-uid', i+1); 198 galleryElements[i].onclick = onThumbnailsClick; 199 } 200 201 // Parse URL and open gallery if it contains #&pid=3&gid=1 202 var hashData = photoswipeParseHash(); 203 if(hashData.pid && hashData.gid) { 204 openPhotoSwipe( hashData.pid , galleryElements[ hashData.gid - 1 ], true, true ); 205 } 206 }; 207 } 208 209 function pi_run_justified_gallery($this, $settings) 210 { 211 var oPutSettings = { 212 rowHeight : $settings.pi_rowheight ? $settings.pi_rowheight : 120, 213 maxRowHeight : $settings.pi_maxrowheight ? $settings.pi_maxrowheight : '200%', 214 lastRow : $settings.pi_lastrow, 215 fixedHeight : $settings.pi_fixedheight == 'false' ? false : true, 216 captions : $settings.pi_showcaption == 'false' ? false : true, 217 randomize : $settings.pi_randomize == 'false' ? false : true, 218 margins : $settings.pi_margin 219 }; 220 221 222 $this.justifiedGallery(oPutSettings); 223 } 224 225 function pi_run_owl($this, $settings) 226 { 227 $settings.pi_slideshow_single_item = $settings.pi_slideshow_single_item == '1' ? true : false;
228 $settings.pi_slideshow_autoplay = $settings.pi_slideshow_autoplay == 0 ? false : $settings.pi_slideshow_autoplay; 229 $this.addClass('owl-carousel owl-theme'); 230 231 var oArgs = { 232 lazyLoad: true, 233 nav: false, 234 loop: true, 235 dots: true, 236 autoHeight: $settings.pi_slideshow_auto_height, 237 items: $settings.pi_slideshow_items, 238 239 autoPlay: $settings.pi_slideshow_autoplay 240 } 241 242 if ( !$settings.pi_slideshow_single_item ) { 243 oArgs = $.extend(oArgs, { 0 : { 244 nav: false, 245 dots: true, 246 items: $settings.pi_slideshow_items_mobile 247 }, 248 480: { 249 nav: false, 250 dots: true, 251 items: $settings.pi_slideshow_items_tablet 252 }, 253 769: { 254 nav: false, 255 dots: true, 256 items: $settings.pi_slideshow_items_desktop 257 } 258 }); 259 }else{ 260 oArgs.items = 1; 261 } 262 263 $this.owlCarousel(oArgs); 264 } 265 266 $.fn.wilokeSetImageSize = function() 267 { 268 var $this = $(this), 269 srcImage = $this.attr('src'), 270 oDetectSize = {}, 271 image = new Image(); 272 273 image.src = srcImage; 274 image.onload = function () { 275 var width = this.width, 276 height = this.height; 277 278 $this.parent().attr('data-size', width + 'x' + height); 279 280 }; 281 282 return oDetectSize; 283 } 284 285 $.fn.piGetFlickr = function(_oOptions) 286 { 287 var _oDefault = { 288 limit : 5, 289 id : '', 290 itemTemplate : '', 291 callback : '', 292 settings : {} 293 }, 294 $self = $(this); 295 296 _oOptions = $.extend({}, _oDefault, _oOptions); 297 298 $self.jflickrfeed({ 299 limit: _oOptions.limit, 300 qstrings: { 301 id: _oOptions.id 302 }, 303 itemTemplate: _oOptions.item_template 304 }, function(func) { 305 306 $self.find('img').each(function(){ 307 $(this).wilokeSetImageSize(); 308 }) 309 310 if ( _oOptions.callback == 'tiled_gallery') 311 { 312 pi_run_justified_gallery($self, _oOptions.settings); 313 }else{ 314 pi_run_owl($self, _oOptions.settings); 315 } 316 }); 317 } 318 319 if ( !$().imageCover ) 320 { 321 $.fn.imageCover = function() { 322 $(this).each(function() { 323 var self = $(this), 324 image = self.find('img'), 325 heightWrap = self.outerHeight(), 326 widthImage = image.outerWidth(), 327 heightImage = image.outerHeight(); 328 if (heightImage < heightWrap) { 329 image.css({ 330 'height': '400px', 331 'width': 'auto' 332 }); 333 } 334 }); 335 } 336 } 337 338 /*Instagram*/ 339 function pi_get_instagram($this, $data) 340 { 341 var url = ""; 342 343 switch ( $data.pi_instagram_get ) 344 { 345 case 'tag': 346 url = 'https://api.instagram.com/v1/tags/'+$data.pi_instagram_tagname+'/media/recent?access_token='+$data.pi_instagram_access_token; 347 //url = 'https://api.instagram.com/v1/tags/search?q='+$data.pi_instagram_tagname+'&access_token='+$data.pi_instagram_access_token; 348 break; 349 350 case 'users': 351 url = "https://api.instagram.com/v1/users/"+$data.pi_instagram_user_id+"/media/recent/?access_token="+$data.pi_instagram_access_token+'&limit=5'; 352 break; 353 354 default: 355 url = 'https://api.instagram.com/v1/media/popular?client_id='+$data.pi_instagram_client_id; 356 break; 357 } 358 359 var piLoading = setTimeout(function(){ 360 alert("Request timeout"); 361 }, 60000); 362 363 $.ajax({ 364 dataType: "jsonp", 365 cache: false, 366 crossDomain: true, 367 url: url, 368 success: function(data) 369 { 370 371 clearTimeout(piLoading); 372 373 if ( data.meta.code == 200 ) 374 { 375 376 var _length = 0, parsedLimit=20; 377 _length = data.data.length; 378 379 if ( $data.pi_style == 'tiled_gallery' ) 380 { 381 parsedLimit = parseInt($data.pi_tiled_gallery_limit, 10); 382 if (($data.pi_tiled_gallery_limit != null) && _length > parsedLimit) 383 { 384 _length = parsedLimit; 385 } 386 }else{
387 parsedLimit = parseInt($data.pi_slideshow_limit, 10); 388 if (($data.pi_slideshow_limit != null) && _length > parsedLimit) 389 { 390 _length = parsedLimit; 391 } 392 } 393 394 for ( var i=0; i<_length; i++ ) 395 { 396 var _size = '', text=''; 397 _size = data['data'][i]['images']['standard_resolution']['width'] + 'x' + data['data'][i]['images']['standard_resolution']['height']; 398 399 if ( data['data'][i]['caption'] === null ) 400 { 401 text = ''; 402 }else{ 403 text = data['data'][i]['caption']['text']; 404 } 405 406 if ( $data.pi_style == 'tiled_gallery' ) 407 { 408 $this.append('<a class="item" href="'+data['data'][i]['images']['standard_resolution']['url'] + '" data-caption="'+text+'" data-size="'+_size+'" data-link="'+data['data'][i]['link']+'"><img src="' + data['data'][i]['images']['thumbnail']['url'] + '" alt="' + text + '" /></a>'); 409 }else { 410 $this.append('<div class="wiloke-gallery-image-cover"><a class="item" data-caption="'+text+'" href="' + data['data'][i]['images']['standard_resolution']['url'] + '" data-size="'+_size+'" data-link="'+data['data'][i]['link']+'"><img src="' + data['data'][i]['images']['standard_resolution']['url'] + '" alt="'+text+'" /></a></div>'); 411 } 412 } 413 414 if ( $data.pi_style != 'tiled_gallery' ) { 415 pi_run_owl($this, $data); 416 }else{ 417 pi_run_justified_gallery($this, $data); 418 } 419 }else{ 420 alert(data.meta.error_message); 421 } 422 423 } 424 }); 425 426 } 427 428 $(document).ready(function(){ 429 var $piFlickrJustifiedGallery = $(".pi_wiloke_gallery"), template=''; 430 431 /*Flickr and picasa*/ 432 $piFlickrJustifiedGallery.each(function() 433 { 434 var $this = $(this), $settings; 435 $settings = $this.data("settings"); 436 437 if ( $settings != "" && typeof $settings != 'undefined' ) 438 { 439 440 $this.parent().css({width: $settings.pi_maximun_width}); 441 442 if ( $settings.pi_style != 'tiled_gallery' ) 443 { 444 template = '<div class="item wiloke-gallery-image-cover" data-caption="{{title}}"><a href="{{image_b}}" data-link="{{link}}"><img src="{{image}}" alt="{{title}}" /></a></div>'; 445 }else{ 446 template = '<a href="{{image_b}}" data-caption="{{title}}" data-link="{{link}}"><img src="{{image}}" alt="{{title}}" /></a>'; 447 } 448 449 if ($this.hasClass("flickr")) { 450 451 $this.piGetFlickr({ 452 limit: $settings.limit, 453 id: $settings.pi_user_id, 454 item_template: template, 455 settings: $settings, 456 callback: $settings.pi_style 457 }); 458 459 } else if ($this.hasClass("instagram")) { 460 pi_get_instagram($this, $settings); 461 }else{ 462 463 if ( $settings.pi_style == 'tiled_gallery' ) 464 { 465 pi_run_justified_gallery($this, $settings); 466 }else{ 467 pi_run_owl($this, $settings); 468 } 469 } 470 471 }else{ 472 $this.remove(); 473 } 474 }); 475 476 if ( $('.wiloke-is-wiloke-gallery.pswp') ) 477 { 478 wilokeInitPhotoSwipeFromDOM('.pi-pswp'); 479 } 480 481 // $('.wiloke-gallery-image-cover').imageCover(); 482 483 }) 484 485})(jQuery, window, document);
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.