// source --> //hulu-split.hr/wp-content/plugins/genesis-simple-share/lib/sharrre/jquery.sharrre.min.js?ver=0.1.0 ;(function($,window,document,undefined){var pluginName='sharrre',defaults={className:'sharrre',share:{googlePlus:false,facebook:false,twitter:false,digg:false,delicious:false,stumbleupon:false,linkedin:false,pinterest:false},shareTotal:0,template:'',title:'',url:document.location.href,text:document.title,urlCurl:'sharrre.php',count:{},total:0,shorterTotal:true,enableHover:true,enableCounter:true,enableTracking:false,hover:function(){},hide:function(){},click:function(){},render:function(){},buttons:{googlePlus:{url:'',urlCount:false,size:'medium',lang:'en-US',annotation:''},facebook:{url:'',urlCount:false,action:'like',layout:'button_count',width:'',send:'false',faces:'false',colorscheme:'',font:'',lang:'en_US'},twitter:{url:'',urlCount:false,count:'horizontal',hashtags:'',via:'',related:'',lang:'en'},digg:{url:'',urlCount:false,type:'DiggCompact'},delicious:{url:'',urlCount:false,size:'medium'},stumbleupon:{url:'',urlCount:false,layout:'1'},linkedin:{url:'',urlCount:false,counter:''},pinterest:{url:'',media:'',description:'',layout:'horizontal'}}},urlJson={googlePlus:"",facebook:"https://graph.facebook.com/fql?q=SELECT%20url,%20normalized_url,%20share_count,%20like_count,%20comment_count,%20total_count,commentsbox_count,%20comments_fbid,%20click_count%20FROM%20link_stat%20WHERE%20url=%27{url}%27&callback=?",twitter:"//cdn.api.twitter.com/1/urls/count.json?url={url}&callback=?",digg:"//services.digg.com/2.0/story.getInfo?links={url}&type=javascript&callback=?",delicious:'//feeds.delicious.com/v2/json/urlinfo/data?url={url}&callback=?',stumbleupon:"",linkedin:"//www.linkedin.com/countserv/count/share?format=jsonp&url={url}&callback=?",pinterest:"//api.pinterest.com/v1/urls/count.json?url={url}&callback=?"},loadButton={googlePlus:function(self){var sett=self.options.buttons.googlePlus;$(self.element).find('.buttons').append('
');window.___gcfg={lang:self.options.buttons.googlePlus.lang};var loading=0;if(typeof gapi==='undefined'&&loading==0){loading=1;(function(){var po=document.createElement('script');po.type='text/javascript';po.async=true;po.src='//apis.google.com/js/plusone.js';var s=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(po,s);})();} else{gapi.plusone.go();}},facebook:function(self){var sett=self.options.buttons.facebook;$(self.element).find('.buttons').append('
');var loading=0;if(typeof FB==='undefined'&&loading==0){loading=1;(function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(d.getElementById(id)){return;} js=d.createElement(s);js.id=id;js.src='//connect.facebook.net/'+sett.lang+'/all.js#xfbml=1';fjs.parentNode.insertBefore(js,fjs);}(document,'script','facebook-jssdk'));} else{FB.XFBML.parse();}},twitter:function(self){var sett=self.options.buttons.twitter;$(self.element).find('.buttons').append('
Tweet
');var loading=0;if(typeof twttr==='undefined'&&loading==0){loading=1;(function(){var twitterScriptTag=document.createElement('script');twitterScriptTag.type='text/javascript';twitterScriptTag.async=true;twitterScriptTag.src='//platform.twitter.com/widgets.js';var s=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(twitterScriptTag,s);})();} else{$.ajax({url:'//platform.twitter.com/widgets.js',dataType:'script',cache:true});}},digg:function(self){var sett=self.options.buttons.digg;$(self.element).find('.buttons').append('
');var loading=0;if(typeof __DBW==='undefined'&&loading==0){loading=1;(function(){var s=document.createElement('SCRIPT'),s1=document.getElementsByTagName('SCRIPT')[0];s.type='text/javascript';s.async=true;s.src='//widgets.digg.com/buttons.js';s1.parentNode.insertBefore(s,s1);})();}},delicious:function(self){if(self.options.buttons.delicious.size=='tall'){var css='width:50px;',cssCount='height:35px;width:50px;font-size:15px;line-height:35px;',cssShare='height:18px;line-height:18px;margin-top:3px;';} else{var css='width:93px;',cssCount='float:right;padding:0 3px;height:20px;width:26px;line-height:20px;',cssShare='float:left;height:20px;line-height:20px;';} var count=self.shorterTotal(self.options.count.delicious);if(typeof count==="undefined"){count=0;} $(self.element).find('.buttons').append('
'+'
'+count+'
'+'
'+'Delicious Add
');$(self.element).find('.delicious').on('click',function(){self.openPopup('delicious');});},stumbleupon:function(self){var sett=self.options.buttons.stumbleupon;$(self.element).find('.buttons').append('
');var loading=0;if(typeof STMBLPN==='undefined'&&loading==0){loading=1;(function(){var li=document.createElement('script');li.type='text/javascript';li.async=true;li.src='//platform.stumbleupon.com/1/widgets.js';var s=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(li,s);})();s=window.setTimeout(function(){if(typeof STMBLPN!=='undefined'){STMBLPN.processWidgets();clearInterval(s);}},500);} else{STMBLPN.processWidgets();}},linkedin:function(self){var sett=self.options.buttons.linkedin;$(self.element).find('.buttons').append('
');var loading=0;if(typeof window.IN==='undefined'&&loading==0){loading=1;(function(){var li=document.createElement('script');li.type='text/javascript';li.async=true;li.src='//platform.linkedin.com/in.js';var s=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(li,s);})();} else{window.IN.init();}},pinterest:function(self){var sett=self.options.buttons.pinterest;$(self.element).find('.buttons').append('
Pin It
');(function(){var li=document.createElement('script');li.type='text/javascript';li.async=true;li.src='//assets.pinterest.com/js/pinit.js';var s=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(li,s);})();}},tracking={googlePlus:function(){},facebook:function(){fb=window.setInterval(function(){if(typeof FB!=='undefined'){FB.Event.subscribe('edge.create',function(targetUrl){_gaq.push(['_trackSocial','facebook','like',targetUrl]);});FB.Event.subscribe('edge.remove',function(targetUrl){_gaq.push(['_trackSocial','facebook','unlike',targetUrl]);});FB.Event.subscribe('message.send',function(targetUrl){_gaq.push(['_trackSocial','facebook','send',targetUrl]);});clearInterval(fb);}},1000);},twitter:function(){tw=window.setInterval(function(){if(typeof twttr!=='undefined'){twttr.events.bind('tweet',function(event){if(event){_gaq.push(['_trackSocial','twitter','tweet']);}});clearInterval(tw);}},1000);},digg:function(){},delicious:function(){},stumbleupon:function(){},linkedin:function(){function LinkedInShare(){_gaq.push(['_trackSocial','linkedin','share']);}},pinterest:function(){}},popup={googlePlus:function(opt){window.open("https://plus.google.com/share?hl="+opt.buttons.googlePlus.lang+"&url="+encodeURIComponent((opt.buttons.googlePlus.url!==''?opt.buttons.googlePlus.url:opt.url)),"","toolbar=0, status=0, width=900, height=500");},facebook:function(opt){window.open("//www.facebook.com/sharer/sharer.php?u="+encodeURIComponent((opt.buttons.facebook.url!==''?opt.buttons.facebook.url:opt.url))+"&t="+opt.text+"","","toolbar=0, status=0, width=900, height=500");},twitter:function(opt){window.open("https://twitter.com/intent/tweet?text="+encodeURIComponent(opt.text)+"&url="+encodeURIComponent((opt.buttons.twitter.url!==''?opt.buttons.twitter.url:opt.url))+(opt.buttons.twitter.via!==''?'&via='+opt.buttons.twitter.via:''),"","toolbar=0, status=0, width=650, height=360");},digg:function(opt){window.open("//digg.com/tools/diggthis/submit?url="+encodeURIComponent((opt.buttons.digg.url!==''?opt.buttons.digg.url:opt.url))+"&title="+opt.text+"&related=true&style=true","","toolbar=0, status=0, width=650, height=360");},delicious:function(opt){window.open('//www.delicious.com/save?v=5&noui&jump=close&url='+encodeURIComponent((opt.buttons.delicious.url!==''?opt.buttons.delicious.url:opt.url))+'&title='+opt.text,'delicious','toolbar=no,width=550,height=550');},stumbleupon:function(opt){window.open('//www.stumbleupon.com/badge/?url='+encodeURIComponent((opt.buttons.delicious.url!==''?opt.buttons.delicious.url:opt.url)),'stumbleupon','toolbar=no,width=550,height=550');},linkedin:function(opt){window.open('https://www.linkedin.com/cws/share?url='+encodeURIComponent((opt.buttons.delicious.url!==''?opt.buttons.delicious.url:opt.url))+'&token=&isFramed=true','linkedin','toolbar=no,width=550,height=550');},pinterest:function(opt){window.open('//pinterest.com/pin/create/button/?url='+encodeURIComponent((opt.buttons.pinterest.url!==''?opt.buttons.pinterest.url:opt.url))+'&media='+encodeURIComponent(opt.buttons.pinterest.media)+'&description='+opt.buttons.pinterest.description,'pinterest','toolbar=no,width=700,height=300');}};function Plugin(element,options){this.element=element;this.options=$.extend(true,{},defaults,options);this.options.share=options.share;this._defaults=defaults;this._name=pluginName;this.init();};Plugin.prototype.init=function(){var self=this;if(this.options.urlCurl!==''){urlJson.googlePlus=this.options.urlCurl+'?url={url}&type=googlePlus';urlJson.stumbleupon=this.options.urlCurl+'?url={url}&type=stumbleupon';} $(this.element).addClass(this.options.className);if(typeof $(this.element).data('title')!=='undefined'){this.options.title=$(this.element).attr('data-title');} if(typeof $(this.element).data('url')!=='undefined'){this.options.url=$(this.element).data('url');} if(typeof $(this.element).data('urlalt')!=='undefined'){this.options.urlalt=$(this.element).data('urlalt');} if(typeof $(this.element).data('text')!=='undefined'){this.options.text=$(this.element).data('text');} $.each(this.options.share,function(name,val){if(val===true){self.options.shareTotal++;}});if(self.options.enableCounter===true){$.each(this.options.share,function(name,val){if(val===true){try{self.getSocialJson(name);self.getSocialJson(getSocialAltJson);}catch(e){}}});} else if(self.options.template!==''){this.options.render(this,this.options);} else{this.loadButtons();} $(this.element).hover(function(){if($(this).find('.buttons').length===0&&self.options.enableHover===true){self.loadButtons();} self.options.hover(self,self.options);},function(){self.options.hide(self,self.options);});$(this.element).click(function(){self.options.click(self,self.options);return false;});};Plugin.prototype.loadButtons=function(){var self=this;$(this.element).append('
');$.each(self.options.share,function(name,val){if(val==true){loadButton[name](self);if(self.options.enableTracking===true){tracking[name]();}}});};Plugin.prototype.getSocialJson=function(name){var self=this,count=0,url=urlJson[name].replace('{url}',encodeURIComponent(this.options.url));if('twitter'==name){self.options.hideCount=1;self.renderer();self.options.count[name]=0;self.rendererPerso();}else{self.options.hideCount=0;if(this.options.buttons[name].urlCount===true&&this.options.buttons[name].url!==''){url=urlJson[name].replace('{url}',this.options.buttons[name].url);} if(url!=''&&self.options.urlCurl!==''){$.getJSON(url,function(json){if(null!=json){if(typeof json.count!=="undefined"){var temp=json.count+'';temp=temp.replace('\u00c2\u00a0','');count+=parseInt(temp,10);} else if(json.data&&json.data.length>0&&typeof json.data[0].total_count!=="undefined"){count+=parseInt(json.data[0].total_count,10);} else if(typeof json[0]!=="undefined"){count+=parseInt(json[0].total_posts,10);} else if(typeof json[0]!=="undefined"){} self.options.count[name]=count;self.options.total+=count;self.renderer();self.rendererPerso();} else{self.renderer();self.options.count[name]=0;self.rendererPerso();}}).fail(function(){self.options.hideCount=1;self.renderer();self.options.count[name]=0;self.rendererPerso();});} else{self.renderer();self.options.count[name]=0;self.rendererPerso();}}};Plugin.prototype.getSocialAltJson=function(name){var self=this,count=0,url=urlJson[name].replace('{url}',encodeURIComponent(this.options.urlalt));self.options.hideCount=0;if(this.options.buttons[name].urlCount===true&&this.options.buttons[name].url!==''){url=urlJson[name].replace('{url}',this.options.buttons[name].url);} if(url!=''&&self.options.urlCurl!==''){$.getJSON(url,function(json){if(null!=json){if(typeof json.count!=="undefined"){var temp=json.count+'';temp=temp.replace('\u00c2\u00a0','');count+=parseInt(temp,10);} else if(json.data&&json.data.length>0&&typeof json.data[0].total_count!=="undefined"){count+=parseInt(json.data[0].total_count,10);} else if(typeof json[0]!=="undefined"){count+=parseInt(json[0].total_posts,10);} else if(typeof json[0]!=="undefined"){} self.options.count[name]+=count;self.options.total+=count;self.renderer();self.rendererPerso();} else{self.renderer();self.rendererPerso();}}).fail(function(){self.renderer();self.rendererPerso();});} else{self.renderer();self.rendererPerso();}};Plugin.prototype.rendererPerso=function(){var shareCount=0;for(e in this.options.count){shareCount++;} if(shareCount===this.options.shareTotal){this.options.render(this,this.options);}};Plugin.prototype.renderer=function(){var total=this.options.total,template=this.options.template hideCount=this.options.hideCount;if(hideCount){$(this.element).html('
'+ (this.options.title!==''?''+this.options.title+'':'')+'
');} else{if(this.options.shorterTotal===true){total=this.shorterTotal(total);} if(template!==''){template=template.replace('{total}',total);$(this.element).html(template);} else{$(this.element).html('
'+total+''+ (this.options.title!==''?''+this.options.title+'':'')+'
');}}};Plugin.prototype.shorterTotal=function(num){if(num>=1e6){num=(num/1e6).toFixed(2)+"M"}else if(num>=1e3){num=(num/1e3).toFixed(1)+"k"} return num;};Plugin.prototype.openPopup=function(site){popup[site](this.options);if(this.options.enableTracking===true){var tracking={googlePlus:{site:'Google',action:'+1'},facebook:{site:'facebook',action:'like'},twitter:{site:'twitter',action:'tweet'},digg:{site:'digg',action:'add'},delicious:{site:'delicious',action:'add'},stumbleupon:{site:'stumbleupon',action:'add'},linkedin:{site:'linkedin',action:'share'},pinterest:{site:'pinterest',action:'pin'}};_gaq.push(['_trackSocial',tracking[site].site,tracking[site].action]);}};Plugin.prototype.simulateClick=function(){var html=$(this.element).html();$(this.element).html(html.replace(this.options.total,this.options.total+1));};Plugin.prototype.update=function(url,text){if(url!==''){this.options.url=url;} if(text!==''){this.options.text=text;}};$.fn[pluginName]=function(options){var args=arguments;if(options===undefined||typeof options==='object'){return this.each(function(){if(!$.data(this,'plugin_'+pluginName)){$.data(this,'plugin_'+pluginName,new Plugin(this,options));}});}else if(typeof options==='string'&&options[0]!=='_'&&options!=='init'){return this.each(function(){var instance=$.data(this,'plugin_'+pluginName);if(instance instanceof Plugin&&typeof instance[options]==='function'){instance[options].apply(instance,Array.prototype.slice.call(args,1));}});}};})(jQuery,window,document); // source --> https://hulu-split.hr/wp-content/plugins/alphabetic-pagination/js/scripts.js?ver=4.4.33 // JavaScript Document jQuery(document).ready(function($){ var ap_methods = { load_sub_items: function(type){ $.post(ajaxurl, {action: 'ap_tax_types',"type":type}, function(response) { response = jQuery.parseJSON(response); if(response.msg){ var data = response.data; var selected = response.selected; var selected_x = response.selected_x; var items = ''; var items_x = ''; //console.log(typeof selected=='object'); //console.log(typeof selected_x=='boolean'); $.each(data, function(i, v){ var is_selected = false; var is_selected_x = false; if(typeof selected=='object'){ $.each(selected, function(is, vs){ //console.log(is+' > '+vs+' > '+i+' > '+v); if(vs==i) is_selected = 'selected="selected"'; }); } if(typeof selected_x=='object'){ $.each(selected_x, function(is, vs){ //console.log(is+' > '+vs+' > '+i+' > '+v); if(vs==i) is_selected_x = 'selected="selected"'; }); } items+=''; items_x+=''; }); //return; $('#tax_types_selector').html(items); $('#tax_types_selector_x').html(items_x); $('div.ap_tax_types').show(); } }); } } $('#tax_selector').change(function(){ //console.log($(this)); var type = $(this).val(); if(type!='') ap_methods.load_sub_items(type); }); $('div.ap_shortcode code, div.ap_shortcode div').click(function(){ var o = $( "div.ap_shortcode.hide > a" ); }); setInterval(highlightBlock, 10000); function highlightBlock() { $('.ap_video_tutorial').css('color', 'red').fadeIn(10000); setTimeout(function() { $('.ap_video_tutorial').css('color', 'blue').fadeOut(10000); }, 10000); } $('.ap_video_tutorial').click(function(){ $('.ap_video_slide').fadeIn('slow'); }); $('.ap_slide_close').click(function(){ $('.ap_video_slide').hide(); }); setTimeout(function(){ jQuery('#tax_selector').change(); }, 3000); $('#ap_lang_selector').on('change', function(){ var val = $(this).val().toLowerCase(); var sel = 'ul.ap_pagination'; $(sel).hide(); $(sel+'.ap_'+val).fadeIn(); }); }); function disable_ap_letters(obj){ //console.log(obj); if(jQuery(obj).length>0){ var obj = jQuery(obj); var letter = obj.find('a').html(); //obj.html(letter); } }; // source --> https://hulu-split.hr/wp-content/themes/hulu/js/lightgallery.js?ver=1 (function($, window, document, undefined) { 'use strict'; var defaults = { mode: 'lg-slide', // Ex : 'ease' cssEasing: 'ease', //'for jquery animation' easing: 'linear', speed: 600, height: '100%', width: '100%', addClass: '', startClass: 'lg-start-zoom', backdropDuration: 150, hideBarsDelay: 6000, useLeft: false, closable: true, loop: true, escKey: true, keyPress: true, controls: true, slideEndAnimatoin: true, hideControlOnEnd: false, mousewheel: true, // .lg-item || '.lg-sub-html' appendSubHtmlTo: '.lg-sub-html', /** * @desc number of preload slides * will exicute only after the current slide is fully loaded. * * @ex you clicked on 4th image and if preload = 1 then 3rd slide and 5th * slide will be loaded in the background after the 4th slide is fully loaded.. * if preload is 2 then 2nd 3rd 5th 6th slides will be preloaded.. ... ... * */ preload: 1, showAfterLoad: true, selector: '', selectWithin: '', nextHtml: '', prevHtml: '', // 0, 1 index: false, iframeMaxWidth: '100%', download: true, counter: true, appendCounterTo: '.lg-toolbar', swipeThreshold: 50, enableSwipe: true, enableDrag: true, dynamic: false, dynamicEl: [], galleryId: 1 }; function Plugin(element, options) { // Current lightGallery element this.el = element; // Current jquery element this.$el = $(element); // lightGallery settings this.s = $.extend({}, defaults, options); // When using dynamic mode, ensure dynamicEl is an array if (this.s.dynamic && this.s.dynamicEl !== 'undefined' && this.s.dynamicEl.constructor === Array && !this.s.dynamicEl.length) { throw ('When using dynamic mode, you must also define dynamicEl as an Array.'); } // lightGallery modules this.modules = {}; // false when lightgallery complete first slide; this.lGalleryOn = false; this.lgBusy = false; // Timeout function for hiding controls; this.hideBartimeout = false; // To determine browser supports for touch events; this.isTouch = ('ontouchstart' in document.documentElement); // Disable hideControlOnEnd if sildeEndAnimation is true if (this.s.slideEndAnimatoin) { this.s.hideControlOnEnd = false; } // Gallery items if (this.s.dynamic) { this.$items = this.s.dynamicEl; } else { if (this.s.selector === 'this') { this.$items = this.$el; } else if (this.s.selector !== '') { if (this.s.selectWithin) { this.$items = $(this.s.selectWithin).find(this.s.selector); } else { this.$items = this.$el.find($(this.s.selector)); } } else { this.$items = this.$el.children(); } } // .lg-item this.$slide = ''; // .lg-outer this.$outer = ''; this.init(); return this; } Plugin.prototype.init = function() { var _this = this; // s.preload should not be more than $item.length if (_this.s.preload > _this.$items.length) { _this.s.preload = _this.$items.length; } // if dynamic option is enabled execute immediately var _hash = window.location.hash; if (_hash.indexOf('lg=' + this.s.galleryId) > 0) { _this.index = parseInt(_hash.split('&slide=')[1], 10); $('body').addClass('lg-from-hash'); if (!$('body').hasClass('lg-on')) { setTimeout(function() { _this.build(_this.index); $('body').addClass('lg-on'); }); } } if (_this.s.dynamic) { _this.$el.trigger('onBeforeOpen.lg'); _this.index = _this.s.index || 0; // prevent accidental double execution if (!$('body').hasClass('lg-on')) { setTimeout(function() { _this.build(_this.index); $('body').addClass('lg-on'); }); } } else { // Using different namespace for click because click event should not unbind if selector is same object('this') _this.$items.on('click.lgcustom', function(event) { // For IE8 try { event.preventDefault(); event.preventDefault(); } catch (er) { event.returnValue = false; } _this.$el.trigger('onBeforeOpen.lg'); _this.index = _this.s.index || _this.$items.index(this); // prevent accidental double execution if (!$('body').hasClass('lg-on')) { _this.build(_this.index); $('body').addClass('lg-on'); } }); } }; Plugin.prototype.build = function(index) { var _this = this; _this.structure(); // module constructor $.each($.fn.lightGallery.modules, function(key) { _this.modules[key] = new $.fn.lightGallery.modules[key](_this.el); }); // initiate slide function _this.slide(index, false, false); if (_this.s.keyPress) { _this.keyPress(); } if (_this.$items.length > 1) { _this.arrow(); setTimeout(function() { _this.enableDrag(); _this.enableSwipe(); }, 50); if (_this.s.mousewheel) { _this.mousewheel(); } } _this.counter(); _this.closeGallery(); _this.$el.trigger('onAfterOpen.lg'); // Hide controllers if mouse doesn't move for some period _this.$outer.on('mousemove.lg click.lg touchstart.lg', function() { _this.$outer.removeClass('lg-hide-items'); clearTimeout(_this.hideBartimeout); // Timeout will be cleared on each slide movement also _this.hideBartimeout = setTimeout(function() { _this.$outer.addClass('lg-hide-items'); }, _this.s.hideBarsDelay); }); }; Plugin.prototype.structure = function() { var list = ''; var controls = ''; var i = 0; var subHtmlCont = ''; var template; var _this = this; $('body').append('
'); $('.lg-backdrop').css('transition-duration', this.s.backdropDuration + 'ms'); // Create gallery items for (i = 0; i < this.$items.length; i++) { list += '
'; } // Create controlls if (this.s.controls && this.$items.length > 1) { controls = '
' + '
' + this.s.prevHtml + '
' + '
' + this.s.nextHtml + '
' + '
'; } if (this.s.appendSubHtmlTo === '.lg-sub-html') { subHtmlCont = '
'; } template = '
' + '
' + '
' + list + '
' + '
' + '' + '
' + controls + subHtmlCont + '
' + '
'; $('body').append(template); this.$outer = $('.lg-outer'); this.$slide = this.$outer.find('.lg-item'); if (this.s.useLeft) { this.$outer.addClass('lg-use-left'); // Set mode lg-slide if use left is true; this.s.mode = 'lg-slide'; } else { this.$outer.addClass('lg-use-css3'); } // For fixed height gallery _this.setTop(); $(window).on('resize.lg orientationchange.lg', function() { setTimeout(function() { _this.setTop(); }, 100); }); // add class lg-current to remove initial transition this.$slide.eq(this.index).addClass('lg-current'); // add Class for css support and transition mode if (this.doCss()) { this.$outer.addClass('lg-css3'); } else { this.$outer.addClass('lg-css'); // Set speed 0 because no animation will happen if browser doesn't support css3 this.s.speed = 0; } this.$outer.addClass(this.s.mode); if (this.s.enableDrag && this.$items.length > 1) { this.$outer.addClass('lg-grab'); } if (this.s.showAfterLoad) { this.$outer.addClass('lg-show-after-load'); } if (this.doCss()) { var $inner = this.$outer.find('.lg-inner'); $inner.css('transition-timing-function', this.s.cssEasing); $inner.css('transition-duration', this.s.speed + 'ms'); } $('.lg-backdrop').addClass('in'); setTimeout(function() { _this.$outer.addClass('lg-visible'); }, this.s.backdropDuration); if (this.s.download) { this.$outer.find('.lg-toolbar').append(''); } // Store the current scroll top value to scroll back after closing the gallery.. this.prevScrollTop = $(window).scrollTop(); }; // For fixed height gallery Plugin.prototype.setTop = function() { if (this.s.height !== '100%') { var wH = $(window).height(); var top = (wH - parseInt(this.s.height, 10)) / 2; var $lGallery = this.$outer.find('.lg'); if (wH >= parseInt(this.s.height, 10)) { $lGallery.css('top', top + 'px'); } else { $lGallery.css('top', '0px'); } } }; // Find css3 support Plugin.prototype.doCss = function() { // check for css animation support var support = function() { var transition = ['transition', 'MozTransition', 'WebkitTransition', 'OTransition', 'msTransition', 'KhtmlTransition']; var root = document.documentElement; var i = 0; for (i = 0; i < transition.length; i++) { if (transition[i] in root.style) { return true; } } }; if (support()) { return true; } return false; }; /** * @desc Check the given src is video * @param {String} src * @return {Object} video type * Ex:{ youtube : ["//www.youtube.com/watch?v=c0asJgSyxcY", "c0asJgSyxcY"] } */ Plugin.prototype.isVideo = function(src, index) { var html; if (this.s.dynamic) { html = this.s.dynamicEl[index].html; } else { html = this.$items.eq(index).attr('data-html'); } if (!src && html) { return { html5: true }; } var youtube = src.match(/\/\/(?:www\.)?youtu(?:\.be|be\.com)\/(?:watch\?v=|embed\/)?([a-z0-9\-\_\%]+)/i); var vimeo = src.match(/\/\/(?:www\.)?vimeo.com\/([0-9a-z\-_]+)/i); var dailymotion = src.match(/\/\/(?:www\.)?dai.ly\/([0-9a-z\-_]+)/i); var vk = src.match(/\/\/(?:www\.)?(?:vk\.com|vkontakte\.ru)\/(?:video_ext\.php\?)(.*)/i); if (youtube) { return { youtube: youtube }; } else if (vimeo) { return { vimeo: vimeo }; } else if (dailymotion) { return { dailymotion: dailymotion }; } else if (vk) { return { vk: vk }; } }; /** * @desc Create image counter * Ex: 1/10 */ Plugin.prototype.counter = function() { if (this.s.counter) { $(this.s.appendCounterTo).append('
' + (parseInt(this.index, 10) + 1) + ' / ' + this.$items.length + '
'); } }; /** * @desc add sub-html into the slide * @param {Number} index - index of the slide */ Plugin.prototype.addHtml = function(index) { var subHtml = null; var subHtmlUrl; if (this.s.dynamic) { if (this.s.dynamicEl[index].subHtmlUrl) { subHtmlUrl = this.s.dynamicEl[index].subHtmlUrl; } else { subHtml = this.s.dynamicEl[index].subHtml; } } else { if (this.$items.eq(index).attr('data-sub-html-url')) { subHtmlUrl = this.$items.eq(index).attr('data-sub-html-url'); } else { subHtml = this.$items.eq(index).attr('data-sub-html'); } } if (!subHtmlUrl) { if (typeof subHtml !== 'undefined' && subHtml !== null) { // get first letter of subhtml // if first letter starts with . or # get the html form the jQuery object var fL = subHtml.substring(0, 1); if (fL === '.' || fL === '#') { subHtml = $(subHtml).html(); } else { subHtml = subHtml; } } else { subHtml = ''; } } if (this.s.appendSubHtmlTo === '.lg-sub-html') { if (subHtmlUrl) { this.$outer.find(this.s.appendSubHtmlTo).load(subHtmlUrl); } else { this.$outer.find(this.s.appendSubHtmlTo).html(subHtml); } } else { if (subHtmlUrl) { this.$slide.eq(index).load(subHtmlUrl); } else { this.$slide.eq(index).append(subHtml); } } // Add lg-empty-html class if title doesn't exist if (typeof subHtml !== 'undefined' && subHtml !== null) { if (subHtml === '') { this.$outer.find(this.s.appendSubHtmlTo).addClass('lg-empty-html'); } else { this.$outer.find(this.s.appendSubHtmlTo).removeClass('lg-empty-html'); } } this.$el.trigger('onAfterAppendSubHtml.lg', [index]); }; /** * @desc Preload slides * @param {Number} index - index of the slide */ Plugin.prototype.preload = function(index) { var i = 1; var j = 1; for (i = 1; i <= this.s.preload; i++) { if (i >= this.$items.length - index) { break; } this.loadContent(index + i, false, 0); } for (j = 1; j <= this.s.preload; j++) { if (index - j < 0) { break; } this.loadContent(index - j, false, 0); } }; /** * @desc Load slide content into slide. * @param {Number} index - index of the slide. * @param {Boolean} rec - if true call loadcontent() function again. * @param {Boolean} delay - delay for adding complete class. it is 0 except first time. */ Plugin.prototype.loadContent = function(index, rec, delay) { var _this = this; var _hasPoster = false; var _$img; var _src; var _poster; var _srcset; var _sizes; var _html; var getResponsiveSrc = function(srcItms) { var rsWidth = []; var rsSrc = []; for (var i = 0; i < srcItms.length; i++) { var __src = srcItms[i].split(' '); // Manage empty space if (__src[0] === '') { __src.splice(0, 1); } rsSrc.push(__src[0]); rsWidth.push(__src[1]); } var wWidth = $(window).width(); for (var j = 0; j < rsWidth.length; j++) { if (parseInt(rsWidth[j], 10) > wWidth) { _src = rsSrc[j]; break; } } }; if (_this.s.dynamic) { if (_this.s.dynamicEl[index].poster) { _hasPoster = true; _poster = _this.s.dynamicEl[index].poster; } _html = _this.s.dynamicEl[index].html; _src = _this.s.dynamicEl[index].src; if (_this.s.dynamicEl[index].responsive) { var srcDyItms = _this.s.dynamicEl[index].responsive.split(','); getResponsiveSrc(srcDyItms); } _srcset = _this.s.dynamicEl[index].srcset; _sizes = _this.s.dynamicEl[index].sizes; } else { if (_this.$items.eq(index).attr('data-poster')) { _hasPoster = true; _poster = _this.$items.eq(index).attr('data-poster'); } _html = _this.$items.eq(index).attr('data-html'); _src = _this.$items.eq(index).attr('href') || _this.$items.eq(index).attr('data-src'); if (_this.$items.eq(index).attr('data-responsive')) { var srcItms = _this.$items.eq(index).attr('data-responsive').split(','); getResponsiveSrc(srcItms); } _srcset = _this.$items.eq(index).attr('data-srcset'); _sizes = _this.$items.eq(index).attr('data-sizes'); } //if (_src || _srcset || _sizes || _poster) { var iframe = false; if (_this.s.dynamic) { if (_this.s.dynamicEl[index].iframe) { iframe = true; } } else { if (_this.$items.eq(index).attr('data-iframe') === 'true') { iframe = true; } } var _isVideo = _this.isVideo(_src, index); if (!_this.$slide.eq(index).hasClass('lg-loaded')) { if (iframe) { _this.$slide.eq(index).prepend('
'); } else if (_hasPoster) { var videoClass = ''; if (_isVideo && _isVideo.youtube) { videoClass = 'lg-has-youtube'; } else if (_isVideo && _isVideo.vimeo) { videoClass = 'lg-has-vimeo'; } else { videoClass = 'lg-has-html5'; } _this.$slide.eq(index).prepend('
'); } else if (_isVideo) { _this.$slide.eq(index).prepend('
'); _this.$el.trigger('hasVideo.lg', [index, _src, _html]); } else { _this.$slide.eq(index).prepend('
'); } _this.$el.trigger('onAferAppendSlide.lg', [index]); _$img = _this.$slide.eq(index).find('.lg-object'); if (_sizes) { _$img.attr('sizes', _sizes); } if (_srcset) { _$img.attr('srcset', _srcset); try { picturefill({ elements: [_$img[0]] }); } catch (e) { console.error('Make sure you have included Picturefill version 2'); } } if (this.s.appendSubHtmlTo !== '.lg-sub-html') { _this.addHtml(index); } _this.$slide.eq(index).addClass('lg-loaded'); } _this.$slide.eq(index).find('.lg-object').on('load.lg error.lg', function() { // For first time add some delay for displaying the start animation. var _speed = 0; // Do not change the delay value because it is required for zoom plugin. // If gallery opened from direct url (hash) speed value should be 0 if (delay && !$('body').hasClass('lg-from-hash')) { _speed = delay; } setTimeout(function() { _this.$slide.eq(index).addClass('lg-complete'); _this.$el.trigger('onSlideItemLoad.lg', [index, delay || 0]); }, _speed); }); // @todo check load state for html5 videos if (_isVideo && _isVideo.html5 && !_hasPoster) { _this.$slide.eq(index).addClass('lg-complete'); } if (rec === true) { if (!_this.$slide.eq(index).hasClass('lg-complete')) { _this.$slide.eq(index).find('.lg-object').on('load.lg error.lg', function() { _this.preload(index); }); } else { _this.preload(index); } } //} }; /** * @desc slide function for lightgallery ** Slide() gets call on start ** ** Set lg.on true once slide() function gets called. ** Call loadContent() on slide() function inside setTimeout ** ** On first slide we do not want any animation like slide of fade ** ** So on first slide( if lg.on if false that is first slide) loadContent() should start loading immediately ** ** Else loadContent() should wait for the transition to complete. ** ** So set timeout s.speed + 50 <=> ** loadContent() will load slide content in to the particular slide ** ** It has recursion (rec) parameter. if rec === true loadContent() will call preload() function. ** ** preload will execute only when the previous slide is fully loaded (images iframe) ** ** avoid simultaneous image load <=> ** Preload() will check for s.preload value and call loadContent() again accoring to preload value ** loadContent() <====> Preload(); * @param {Number} index - index of the slide * @param {Boolean} fromTouch - true if slide function called via touch event or mouse drag * @param {Boolean} fromThumb - true if slide function called via thumbnail click */ Plugin.prototype.slide = function(index, fromTouch, fromThumb) { var _prevIndex = this.$outer.find('.lg-current').index(); var _this = this; // Prevent if multiple call // Required for hsh plugin if (_this.lGalleryOn && (_prevIndex === index)) { return; } var _length = this.$slide.length; var _time = _this.lGalleryOn ? this.s.speed : 0; var _next = false; var _prev = false; if (!_this.lgBusy) { if (this.s.download) { var _src; if (_this.s.dynamic) { _src = _this.s.dynamicEl[index].downloadUrl !== false && (_this.s.dynamicEl[index].downloadUrl || _this.s.dynamicEl[index].src); } else { _src = _this.$items.eq(index).attr('data-download-url') !== 'false' && (_this.$items.eq(index).attr('data-download-url') || _this.$items.eq(index).attr('href') || _this.$items.eq(index).attr('data-src')); } if (_src) { $('#lg-download').attr('href', _src); _this.$outer.removeClass('lg-hide-download'); } else { _this.$outer.addClass('lg-hide-download'); } } this.$el.trigger('onBeforeSlide.lg', [_prevIndex, index, fromTouch, fromThumb]); _this.lgBusy = true; clearTimeout(_this.hideBartimeout); // Add title if this.s.appendSubHtmlTo === lg-sub-html if (this.s.appendSubHtmlTo === '.lg-sub-html') { // wait for slide animation to complete setTimeout(function() { _this.addHtml(index); }, _time); } this.arrowDisable(index); if (!fromTouch) { // remove all transitions _this.$outer.addClass('lg-no-trans'); this.$slide.removeClass('lg-prev-slide lg-next-slide'); if (index < _prevIndex) { _prev = true; if ((index === 0) && (_prevIndex === _length - 1) && !fromThumb) { _prev = false; _next = true; } } else if (index > _prevIndex) { _next = true; if ((index === _length - 1) && (_prevIndex === 0) && !fromThumb) { _prev = true; _next = false; } } if (_prev) { //prevslide this.$slide.eq(index).addClass('lg-prev-slide'); this.$slide.eq(_prevIndex).addClass('lg-next-slide'); } else if (_next) { // next slide this.$slide.eq(index).addClass('lg-next-slide'); this.$slide.eq(_prevIndex).addClass('lg-prev-slide'); } // give 50 ms for browser to add/remove class setTimeout(function() { _this.$slide.removeClass('lg-current'); //_this.$slide.eq(_prevIndex).removeClass('lg-current'); _this.$slide.eq(index).addClass('lg-current'); // reset all transitions _this.$outer.removeClass('lg-no-trans'); }, 50); } else { var touchPrev = index - 1; var touchNext = index + 1; if ((index === 0) && (_prevIndex === _length - 1)) { // next slide touchNext = 0; touchPrev = _length - 1; } else if ((index === _length - 1) && (_prevIndex === 0)) { // prev slide touchNext = 0; touchPrev = _length - 1; } this.$slide.removeClass('lg-prev-slide lg-current lg-next-slide'); _this.$slide.eq(touchPrev).addClass('lg-prev-slide'); _this.$slide.eq(touchNext).addClass('lg-next-slide'); _this.$slide.eq(index).addClass('lg-current'); } if (_this.lGalleryOn) { setTimeout(function() { _this.loadContent(index, true, 0); }, this.s.speed + 50); setTimeout(function() { _this.lgBusy = false; _this.$el.trigger('onAfterSlide.lg', [_prevIndex, index, fromTouch, fromThumb]); }, this.s.speed); } else { _this.loadContent(index, true, _this.s.backdropDuration); _this.lgBusy = false; _this.$el.trigger('onAfterSlide.lg', [_prevIndex, index, fromTouch, fromThumb]); } _this.lGalleryOn = true; if (this.s.counter) { $('#lg-counter-current').text(index + 1); } } }; /** * @desc Go to next slide * @param {Boolean} fromTouch - true if slide function called via touch event */ Plugin.prototype.goToNextSlide = function(fromTouch) { var _this = this; if (!_this.lgBusy) { if ((_this.index + 1) < _this.$slide.length) { _this.index++; _this.$el.trigger('onBeforeNextSlide.lg', [_this.index]); _this.slide(_this.index, fromTouch, false); } else { if (_this.s.loop) { _this.index = 0; _this.$el.trigger('onBeforeNextSlide.lg', [_this.index]); _this.slide(_this.index, fromTouch, false); } else if (_this.s.slideEndAnimatoin) { _this.$outer.addClass('lg-right-end'); setTimeout(function() { _this.$outer.removeClass('lg-right-end'); }, 400); } } } }; /** * @desc Go to previous slide * @param {Boolean} fromTouch - true if slide function called via touch event */ Plugin.prototype.goToPrevSlide = function(fromTouch) { var _this = this; if (!_this.lgBusy) { if (_this.index > 0) { _this.index--; _this.$el.trigger('onBeforePrevSlide.lg', [_this.index, fromTouch]); _this.slide(_this.index, fromTouch, false); } else { if (_this.s.loop) { _this.index = _this.$items.length - 1; _this.$el.trigger('onBeforePrevSlide.lg', [_this.index, fromTouch]); _this.slide(_this.index, fromTouch, false); } else if (_this.s.slideEndAnimatoin) { _this.$outer.addClass('lg-left-end'); setTimeout(function() { _this.$outer.removeClass('lg-left-end'); }, 400); } } } }; Plugin.prototype.keyPress = function() { var _this = this; if (this.$items.length > 1) { $(window).on('keyup.lg', function(e) { if (_this.$items.length > 1) { if (e.keyCode === 37) { e.preventDefault(); _this.goToPrevSlide(); } if (e.keyCode === 39) { e.preventDefault(); _this.goToNextSlide(); } } }); } $(window).on('keydown.lg', function(e) { if (_this.s.escKey === true && e.keyCode === 27) { e.preventDefault(); if (!_this.$outer.hasClass('lg-thumb-open')) { _this.destroy(); } else { _this.$outer.removeClass('lg-thumb-open'); } } }); }; Plugin.prototype.arrow = function() { var _this = this; this.$outer.find('.lg-prev').on('click.lg', function() { _this.goToPrevSlide(); }); this.$outer.find('.lg-next').on('click.lg', function() { _this.goToNextSlide(); }); }; Plugin.prototype.arrowDisable = function(index) { // Disable arrows if s.hideControlOnEnd is true if (!this.s.loop && this.s.hideControlOnEnd) { if ((index + 1) < this.$slide.length) { this.$outer.find('.lg-next').removeAttr('disabled').removeClass('disabled'); } else { this.$outer.find('.lg-next').attr('disabled', 'disabled').addClass('disabled'); } if (index > 0) { this.$outer.find('.lg-prev').removeAttr('disabled').removeClass('disabled'); } else { this.$outer.find('.lg-prev').attr('disabled', 'disabled').addClass('disabled'); } } }; Plugin.prototype.setTranslate = function($el, xValue, yValue) { // jQuery supports Automatic CSS prefixing since jQuery 1.8.0 if (this.s.useLeft) { $el.css('left', xValue); } else { $el.css({ transform: 'translate3d(' + (xValue) + 'px, ' + yValue + 'px, 0px)' }); } }; Plugin.prototype.touchMove = function(startCoords, endCoords) { var distance = endCoords - startCoords; if (Math.abs(distance) > 15) { // reset opacity and transition duration this.$outer.addClass('lg-dragging'); // move current slide this.setTranslate(this.$slide.eq(this.index), distance, 0); // move next and prev slide with current slide this.setTranslate($('.lg-prev-slide'), -this.$slide.eq(this.index).width() + distance, 0); this.setTranslate($('.lg-next-slide'), this.$slide.eq(this.index).width() + distance, 0); } }; Plugin.prototype.touchEnd = function(distance) { var _this = this; // keep slide animation for any mode while dragg/swipe if (_this.s.mode !== 'lg-slide') { _this.$outer.addClass('lg-slide'); } this.$slide.not('.lg-current, .lg-prev-slide, .lg-next-slide').css('opacity', '0'); // set transition duration setTimeout(function() { _this.$outer.removeClass('lg-dragging'); if ((distance < 0) && (Math.abs(distance) > _this.s.swipeThreshold)) { _this.goToNextSlide(true); } else if ((distance > 0) && (Math.abs(distance) > _this.s.swipeThreshold)) { _this.goToPrevSlide(true); } else if (Math.abs(distance) < 5) { // Trigger click if distance is less than 5 pix _this.$el.trigger('onSlideClick.lg'); } _this.$slide.removeAttr('style'); }); // remove slide class once drag/swipe is completed if mode is not slide setTimeout(function() { if (!_this.$outer.hasClass('lg-dragging') && _this.s.mode !== 'lg-slide') { _this.$outer.removeClass('lg-slide'); } }, _this.s.speed + 100); }; Plugin.prototype.enableSwipe = function() { var _this = this; var startCoords = 0; var endCoords = 0; var isMoved = false; if (_this.s.enableSwipe && _this.isTouch && _this.doCss()) { _this.$slide.on('touchstart.lg', function(e) { if (!_this.$outer.hasClass('lg-zoomed') && !_this.lgBusy) { e.preventDefault(); _this.manageSwipeClass(); startCoords = e.originalEvent.targetTouches[0].pageX; } }); _this.$slide.on('touchmove.lg', function(e) { if (!_this.$outer.hasClass('lg-zoomed')) { e.preventDefault(); endCoords = e.originalEvent.targetTouches[0].pageX; _this.touchMove(startCoords, endCoords); isMoved = true; } }); _this.$slide.on('touchend.lg', function() { if (!_this.$outer.hasClass('lg-zoomed')) { if (isMoved) { isMoved = false; _this.touchEnd(endCoords - startCoords); } else { _this.$el.trigger('onSlideClick.lg'); } } }); } }; Plugin.prototype.enableDrag = function() { var _this = this; var startCoords = 0; var endCoords = 0; var isDraging = false; var isMoved = false; if (_this.s.enableDrag && !_this.isTouch && _this.doCss()) { _this.$slide.on('mousedown.lg', function(e) { // execute only on .lg-object if (!_this.$outer.hasClass('lg-zoomed')) { if ($(e.target).hasClass('lg-object') || $(e.target).hasClass('lg-video-play')) { e.preventDefault(); if (!_this.lgBusy) { _this.manageSwipeClass(); startCoords = e.pageX; isDraging = true; // ** Fix for webkit cursor issue https://code.google.com/p/chromium/issues/detail?id=26723 _this.$outer.scrollLeft += 1; _this.$outer.scrollLeft -= 1; // * _this.$outer.removeClass('lg-grab').addClass('lg-grabbing'); _this.$el.trigger('onDragstart.lg'); } } } }); $(window).on('mousemove.lg', function(e) { if (isDraging) { isMoved = true; endCoords = e.pageX; _this.touchMove(startCoords, endCoords); _this.$el.trigger('onDragmove.lg'); } }); $(window).on('mouseup.lg', function(e) { if (isMoved) { isMoved = false; _this.touchEnd(endCoords - startCoords); _this.$el.trigger('onDragend.lg'); } else if ($(e.target).hasClass('lg-object') || $(e.target).hasClass('lg-video-play')) { _this.$el.trigger('onSlideClick.lg'); } // Prevent execution on click if (isDraging) { isDraging = false; _this.$outer.removeClass('lg-grabbing').addClass('lg-grab'); } }); } }; Plugin.prototype.manageSwipeClass = function() { var touchNext = this.index + 1; var touchPrev = this.index - 1; var length = this.$slide.length; if (this.s.loop) { if (this.index === 0) { touchPrev = length - 1; } else if (this.index === length - 1) { touchNext = 0; } } this.$slide.removeClass('lg-next-slide lg-prev-slide'); if (touchPrev > -1) { this.$slide.eq(touchPrev).addClass('lg-prev-slide'); } this.$slide.eq(touchNext).addClass('lg-next-slide'); }; Plugin.prototype.mousewheel = function() { var _this = this; _this.$outer.on('mousewheel.lg', function(e) { if (!e.deltaY) { return; } if (e.deltaY > 0) { _this.goToPrevSlide(); } else { _this.goToNextSlide(); } e.preventDefault(); }); }; Plugin.prototype.closeGallery = function() { var _this = this; var mousedown = false; this.$outer.find('.lg-close').on('click.lg', function() { _this.destroy(); }); if (_this.s.closable) { // If you drag the slide and release outside gallery gets close on chrome // for preventing this check mousedown and mouseup happened on .lg-item or lg-outer _this.$outer.on('mousedown.lg', function(e) { if ($(e.target).is('.lg-outer') || $(e.target).is('.lg-item ') || $(e.target).is('.lg-img-wrap')) { mousedown = true; } else { mousedown = false; } }); _this.$outer.on('mouseup.lg', function(e) { if ($(e.target).is('.lg-outer') || $(e.target).is('.lg-item ') || $(e.target).is('.lg-img-wrap') && mousedown) { if (!_this.$outer.hasClass('lg-dragging')) { _this.destroy(); } } }); } }; Plugin.prototype.destroy = function(d) { var _this = this; if (!d) { _this.$el.trigger('onBeforeClose.lg'); } $(window).scrollTop(_this.prevScrollTop); /** * if d is false or undefined destroy will only close the gallery * plugins instance remains with the element * * if d is true destroy will completely remove the plugin */ if (d) { if (!_this.s.dynamic) { // only when not using dynamic mode is $items a jquery collection this.$items.off('click.lg click.lgcustom'); } $.removeData(_this.el, 'lightGallery'); } // Unbind all events added by lightGallery this.$el.off('.lg.tm'); // Distroy all lightGallery modules $.each($.fn.lightGallery.modules, function(key) { if (_this.modules[key]) { _this.modules[key].destroy(); } }); this.lGalleryOn = false; clearTimeout(_this.hideBartimeout); this.hideBartimeout = false; $(window).off('.lg'); $('body').removeClass('lg-on lg-from-hash'); if (_this.$outer) { _this.$outer.removeClass('lg-visible'); } $('.lg-backdrop').removeClass('in'); setTimeout(function() { if (_this.$outer) { _this.$outer.remove(); } $('.lg-backdrop').remove(); if (!d) { _this.$el.trigger('onCloseAfter.lg'); } }, _this.s.backdropDuration + 50); }; $.fn.lightGallery = function(options) { return this.each(function() { if (!$.data(this, 'lightGallery')) { $.data(this, 'lightGallery', new Plugin(this, options)); } else { try { $(this).data('lightGallery').init(); } catch (err) { console.error('lightGallery has not initiated properly'); } } }); }; $.fn.lightGallery.modules = {}; })(jQuery, window, document);