/** * LC Lightbox * yet.. another jQuery lightbox.. or not? * * @version : 1.2.10 * @copyright : Luca Montanari aka LCweb * @website : https://lcweb.it * @requires : jQuery v1.7 or later * Commercial license */ /* : Luca Montanari aka LCweb @website : https://lcweb.it @requires : jQuery v1.7 or later Commercial license */ (function(b){lcl_objs=[];lcl_is_active=lcl_shown=!1;lcl_slideshow=void 0;lcl_on_mobile=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);lcl_hashless_url=lcl_deeplink_tracked=lcl_curr_vars=lcl_curr_opts=lcl_curr_obj=!1;lcl_url_hash="";lcl_vid_instance_num=0;lc_lightbox=function(p,N){if("string"!=typeof p&&("object"!=typeof p||!p.length))return!1;var z=!1;b.each(lcl_objs,function(q,h){if(JSON.stringify(h)==JSON.stringify(p))return z=h,!1});if(!1===z){var A= new ja(p,N);lcl_objs.push(A);return A}return z};lcl_destroy=function(p){p=b.inArray(p,lcl_objs);-1!==p&&lcl_objs.splice(p,1)};var ja=function(p,N){var z=b.extend({gallery:!0,gallery_hook:"rel",live_elements:!0,preload_all:!1,global_type:!1,deeplink:!1,img_zoom:!1,comments:!1,src_attr:"href",title_attr:"title",txt_attr:"data-lcl-txt",author_attr:"data-lcl-author",slideshow:!0,open_close_time:400,ol_time_diff:100,fading_time:80,animation_time:250,slideshow_time:6E3,autoplay:!1,counter:!1,progressbar:!0, carousel:!0,max_width:"93%",max_height:"93%",wrap_padding:!1,ol_opacity:.7,ol_color:"#111",ol_pattern:!1,border_w:0,border_col:"#ddd",padding:0,radius:0,shadow:!0,remove_scrollbar:!0,wrap_class:"",skin:"light",data_position:"over",cmd_position:"inner",ins_close_pos:"normal",nav_btn_pos:"normal",txt_hidden:500,show_title:!0,show_descr:!0,show_author:!0,thumbs_nav:!0,tn_icons:!0,tn_hidden:500,thumbs_w:110,thumbs_h:110,thumb_attr:!1,thumbs_maker_url:!1,fullscreen:!1,fs_img_behavior:"fit",fs_only:500, browser_fs_mode:!0,socials:!1,fb_share_params:!1,txt_toggle_cmd:!0,download:!1,touchswipe:!0,mousewheel:!0,modal:!1,rclick_prevent:!1,elems_parsed:function(){},html_is_ready:function(){},on_open:function(){},on_elem_switch:function(){},slideshow_start:function(){},slideshow_end:function(){},on_fs_enter:function(){},on_fs_exit:function(){},on_close:function(){}},N),A={elems:[],is_arr_instance:"string"!=typeof p&&"undefined"==typeof p[0].childNodes?!0:!1,elems_count:"string"!=typeof p&&"undefined"== typeof p[0].childNodes?p.length:b(p).length,elems_selector:"string"==typeof p?p:!1,elem_index:!1,gallery_hook_val:!1,preload_all_used:!1,img_sizes_cache:[],vimeo_thumb_cache:[],inner_cmd_w:!1,txt_exists:!1,txt_und_sizes:!1,force_fullscreen:!1,html_style:"",body_style:""};"string"==typeof p&&(p=b(p));var q=b.data(p,"lcl_settings",z),h=b.data(p,"lcl_vars",A),I=function(c){if("string"!=typeof c)return c;for(var d=0,e=0,f=c.toString().length;ed?-1*d:d},ka= function(c){var d=!1;b.each(h.elems,function(e,f){if(f.hash==c)return d=f,!1});return d},U=function(c,d){var e="";switch(c){case "youtube":e=(e=d.src.match(/^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#&\?]*).*/))&&11==e[7].length?e[7]:!1;break;case "vimeo":e=d.src.split("/");e=e[e.length-1];break;case "dailymotion":e=d.src.split("/"),e=e[e.length-1].split("_")[0]}return e},K=function(c){if(!c)return c;c=c.replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&").replace(/"/g, '"').replace(/'/g,"'");return b.trim(c)},O=function(c,d){var e=q[d];return-1!==e.indexOf("> ")?c.find(e.replace("> ","")).length?b.trim(c.find(e.replace("> ","")).html()):"":"undefined"!=typeof c.attr(e)?K(c.attr(e)):""},la=function(c){var d=q,e=[];c.each(function(){var f=b(this),g=f.attr(d.src_attr),k=I(g);if(h.gallery_hook_val&&f.attr(d.gallery_hook)!=h.gallery_hook_val)return!0;k=ka(k);if(!k){k=g;var n=f.data("lcl-type");"undefined"==typeof n&&(n=q.global_type);if(-1===b.inArray(n,"image video youtube vimeo dailymotion html iframe".split(" "))){k= k.toLowerCase();n=/^(http|https)?:\/\/(?:[a-z\-]+\.)+[a-z]{2,6}(?:\/[^\/#?]+)+\.(?:mp4|ogg|webm)$/;var l=/^(?:https?:\/\/)?(?:www\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))((\w|-){11})(?:\S+)?$/,m=/^(http|https)?:\/\/[a-zA-Z0-9-\.]+\.[a-z]{2,4}/;n=/^(http|https)?:\/\/(?:[a-z\-]+\.)+[a-z]{2,6}(?:\/[^\/#?]+)+\.(?:jpe?g|gif|png)$/.test(k)?"image":n.test(k)?"video":l.test(k)?"youtube":-1!==k.indexOf("vimeo.com/")?"vimeo":-1!==k.indexOf("dailymotion.com/video")?"dailymotion": m.test(k)?"iframe":"#"==k.substr(0,1)&&b(k).length?"html":"unknown"}"unknown"!=n?(k={src:g,type:n,hash:d.deeplink?I(g):!1,title:d.show_title?O(f,"title_attr"):"",txt:d.show_descr?O(f,"txt_attr"):"",author:d.show_author?O(f,"author_attr"):"",thumb:d.thumb_attr&&"undefined"!=typeof d.thumb_attr?f.attr(d.thumb_attr):"",width:"image"!=n&&"undefined"!=typeof f.data("lcl-w")?f.data("lcl-w"):!1,height:"image"!=n&&"undefined"!=typeof f.data("lcl-h")?f.data("lcl-h"):!1,force_over_data:"undefined"!=typeof f.data("lcl-force-over-data")? parseInt(f.data("lcl-force-over-data"),10):"",force_outer_cmd:"undefined"!=typeof f.data("lcl-outer-cmd")?f.data("lcl-outer-cmd"):"",canonical_url:"undefined"!=typeof f.data("lcl-canonical-url")?f.data("lcl-canonical-url"):""},k.download="image"==n?"undefined"!=typeof f.data("lcl-path")?f.data("lcl-path"):g:"video"!=n&&"html"!=n||"undefined"==typeof f.data("lcl-path")?!1:f.data("lcl-path"),-1!==b.inArray(n,["youtube","vimeo","dailymotion"])&&(k.video_id=U(n,k)),"image"!=n&&"undefined"!=typeof f.data("lcl-poster")&& ("youtube"==n&&"auto"==f.data("lcl-poster")?k.poster="https://img.youtube.com/vi/"+k.video_id+"/maxresdefault.jpg":k.poster=f.data("lcl-poster"))):k={src:g,type:n,hash:d.deeplink?I(g):!1}}e.push(k)});2>e.length&&b(".lcl_prev, .lcl_next, #lcl_thumb_nav").remove();if(!e.length)return!1;h.elems=e;return!0},V=function(){if(2>h.elems.length||!q.gallery)return!1;0").bind("load",function(){f.img_sizes_cache[g]={w:this.width,h:this.height};c&&d==f.elem_index&&W()}).attr("src",g):((c||"undefined"!=typeof e)&&b("#lcl_loader").addClass("no_loader"),c&&W())};b(document).on("click", ".lcl_postered_video:not(.lcl_poster_clicked)",function(){var c=b(this).find("iframe");b(this).addClass("lcl_poster_clicked");c.attr("src",c.data("lazy-src"));c.on("load",function(){b("#lcl_wrap").addClass("lcl_playing_video");setTimeout(function(){c.parent().removeAttr("style")},100)})});var ma=function(){var c=b("#lcl_wrap[lc-lelem="+h.elem_index+"] #lcl_elem_wrap > iframe");if(!c.length)return!1;b("#lcl_wrap").addClass("lcl_loading_iframe");X();c.on("load",function(){b("#lcl_wrap").removeClass("lcl_loading_iframe"); setTimeout(function(){b("iframe.lcl_elem").length&&b("iframe.lcl_elem")[0].contentWindow.focus()},20);b(".lcl_is_playing").length&&lcl_start_slideshow(!0)})},Y=function(c,d){var e=b.data(c,"lcl_settings"),f=b.data(c,"lcl_vars");if(f.is_arr_instance){var g=[];b.each(c,function(n,l){var m={},t="undefined"==typeof l.type&&e.global_type?e.global_type:!1;"undefined"!=typeof l.type&&(t=l.type);t&&-1!==b.inArray(t,"image video youtube vimeo dailymotion html iframe".split(" "))?"undefined"!=typeof l.src&& l.src&&(m.src=l.src,m.type=t,m.hash=I(l.src),m.title="undefined"==typeof l.title?"":K(l.title),m.txt="undefined"==typeof l.txt?"":K(l.txt),m.author="undefined"==typeof l.author?"":K(l.author),m.width="undefined"==typeof l.width?!1:l.width,m.height="undefined"==typeof l.height?!1:l.height,m.force_over_data="undefined"==typeof l.force_over_data?!1:parseInt(l.force_over_data,10),m.force_outer_cmd="undefined"==typeof l.force_outer_cmd?!1:l.force_outer_cmd,m.canonical_url="undefined"==typeof l.canonical_url? !1:l.canonical_url,m.thumb="undefined"==typeof l.thumb?!1:l.thumb,m.download="image"==t?"undefined"!=typeof l.download?l.download:l.src:"video"!=t&&"html"!=t||"undefined"==typeof l.download?!1:l.download,-1!==b.inArray(t,["youtube","vimeo","dailymotion"])&&(m.video_id=U(t,l)),m.poster="image"==t||"undefined"==typeof l.poster?"":l.poster,g.push(m)):(m={src:m.src,type:"unknown",hash:e.deeplink?I(m.src):!1},g.push(m))});f.elems=g}else{var k=c;e.live_elements&&f.elems_selector&&(k=d&&e.gallery&&e.gallery_hook&& "undefined"!=typeof b(p[0]).attr(e.gallery_hook)?f.elems_selector+"["+e.gallery_hook+"="+d.attr(e.gallery_hook)+"]":f.elems_selector,k=b(k));if(!la(k))return(!e.live_elements||e.live_elements&&!f.elems_selector)&&console.error("LC Lightbox - no valid elements found"),!1}e.preload_all&&!f.preload_all_used&&(f.preload_all_used=!0,b(document).ready(function(n){b.each(f.elems,function(l,m){E(!1,l)})}));"function"==typeof e.elems_parsed&&e.elems_parsed.call(null,q,h);f.is_arr_instance||(k=f.elems_selector? b(f.elems_selector):c,k.first().trigger("lcl_elems_parsed",[f.elems]));return!0};Y(p);var Q=function(c,d){if(lcl_shown||lcl_is_active)return!1;lcl_is_active=lcl_shown=!0;lcl_curr_obj=c;q=b.data(c,"lcl_settings");h=b.data(c,"lcl_vars");lcl_curr_opts=q;lcl_curr_vars=h;var e=q,f=h,g="undefined"!=typeof d?d:!1;if(!h)return console.error("LC Lightbox - cannot open. Object not initialized"),!1;f.gallery_hook_val=g&&e.gallery&&e.gallery_hook&&"undefined"!=typeof g.attr(e.gallery_hook)?g.attr(e.gallery_hook): !1;if(!Y(c,d))return!1;if(g)b.each(f.elems,function(k,n){if(n.src==g.attr(e.src_attr))return f.elem_index=k,!1});else if(parseInt(f.elem_index,10)>=f.elems_count)return console.error("LC Lightbox - selected index does not exist"),!1;E(!1);na();oa();f.force_fullscreen&&P(!0,!0);b("#lcl_thumbs_nav").length&&pa();E(!0);V()},Z=function(){b("#lcl_wrap").removeClass("lcl_pre_show").addClass("lcl_shown");b("#lcl_loader").removeClass("lcl_loader_pre_first_el")},na=function(){var c=q,d=h,e=[],f="";"number"== typeof document.documentMode&&(b("body").addClass("lcl_old_ie"),"outer"!=c.cmd_position&&(c.nav_btn_pos="normal"));b("#lcl_wrap").length&&b("#lcl_wrap").remove();b("body").append('
'); b("#lcl_wrap").attr("data-lcl-max-w",c.max_width).attr("data-lcl-max-h",c.max_height);e.push("lcl_"+c.ins_close_pos+"_close lcl_nav_btn_"+c.nav_btn_pos+" lcl_"+c.ins_close_pos+"_close lcl_nav_btn_"+c.nav_btn_pos);(!0===c.tn_hidden||"number"==typeof c.tn_hidden&&(b(window).width()d.elems.length||!c.gallery)&& b(".lcl_counter").remove();d.force_fullscreen=!1;if(!c.fullscreen)b(".lcl_fullscreen").remove();else if(!0===c.fs_only||"number"==typeof c.fs_only&&(b(window).width()d.elems.length||!c.gallery?b(".lcl_prev, .lcl_play, .lcl_next").remove():"middle"==c.nav_btn_pos&&(f+=".lcl_prev, .lcl_next {margin: "+c.padding+"px;}");!c.thumbs_nav||2>h.elems.length||!c.gallery?b("#lcl_thumbs_nav, .lcl_thumbs_toggle").remove(): (b("#lcl_thumbs_nav").css("height",c.thumbs_h),g=b("#lcl_thumbs_nav").outerHeight(!0)-c.thumbs_h,f+="#lcl_window {margin-top: "+-1*(c.thumbs_h-g)+"px;}",f+=".lcl_tn_hidden.lcl_outer_cmd:not(.lcl_fullscreen_mode) #lcl_window {margin-bottom: "+-1*b(".lcl_close").outerHeight(!0)+"px;}");e.push("lcl_txt_"+c.data_position+" lcl_"+c.skin);f+="#lcl_overlay {background-color: "+c.thumbs_h+"px; opacity: "+c.ol_opacity+";}";c.ol_pattern&&b("#lcl_overlay").addClass("lcl_pattern_"+c.ol_pattern);c.modal&&b("#lcl_overlay").addClass("lcl_modal"); c.wrap_padding&&(f+="#lcl_wrap {padding: "+c.wrap_padding+";}");c.border_w&&(f+="#lcl_window {border: "+c.border_w+"px solid "+c.border_col+";}");c.padding&&(f+="#lcl_subj, #lcl_txt, #lcl_nav_cmd {margin: "+c.padding+"px;}");c.radius&&(f+="#lcl_window, #lcl_contents_wrap {border-radius: "+c.radius+"px;}");c.shadow&&(f+="#lcl_window {box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);}");"inner"==c.cmd_position&&"corner"==c.ins_close_pos&&(f+="#lcl_corner_close {top: "+-1*(c.border_w+Math.ceil(b("#lcl_corner_close").outerWidth()/ 2))+"px;right: "+-1*(c.border_w+Math.ceil(b("#lcl_corner_close").outerHeight()/2))+";}",b("#lcl_nav_cmd > *:not(.lcl_close)").length||(f+="#lcl_wrap:not(.lcl_fullscreen_mode):not(.lcl_forced_outer_cmd) #lcl_nav_cmd {display: none;}"));b("#lcl_inline_style").length&&b("#lcl_inline_style").remove();b("head").append('");c.remove_scrollbar&&(h.html_style="undefined"!=typeof jQuery("html").attr("style")?jQuery("html").attr("style"):"",h.body_style="undefined"!=typeof jQuery("body").attr("style")?jQuery("body").attr("style"):"",f=b(window).width(),b("html").css("overflow","hidden"),b("html").css({"margin-right":b(window).width()-f,"touch-action":"none"}),b("body").css({overflow:"visible","touch-action":"none"}));f=h.elems[d.elem_index];"image"!=f.type||"image"==f.type&&"undefined"!=typeof d.img_sizes_cache[f.src]? e.push("lcl_show_already_shaped"):Z();b("#lcl_wrap").addClass(e.join(" "));"function"==typeof c.html_is_ready&&c.html_is_ready.call(null,q,h);h.is_arr_instance||(h.elems_selector?b(h.elems_selector):lcl_curr_obj).first().trigger("lcl_html_is_ready",[q,h])},qa=function(c){var d=b(c)[0],e=null;d.addEventListener("touchstart",function(f){1===f.targetTouches.length&&(e=f.targetTouches[0].clientY)},!1);d.addEventListener("touchmove",function(f){if(1===f.targetTouches.length){var g=f.targetTouches[0].clientY- e;0===d.scrollTop&&0g&&f.preventDefault()}},!1)},W=function(){if(!lcl_shown)return!1;var c=h,d=c.elems[c.elem_index];b("#lcl_wrap").attr("lc-lelem",c.elem_index);q.carousel||(b("#lcl_wrap").removeClass("lcl_first_elem lcl_last_elem"),c.elem_index?c.elem_index==c.elems.length-1&&b("#lcl_wrap").addClass("lcl_last_elem"):b("#lcl_wrap").addClass("lcl_first_elem"));b(document).trigger("lcl_before_populate_global",[d,c.elem_index]);aa(d); if(!c.is_arr_instance){var e=c.elems_selector?b(c.elems_selector):lcl_curr_obj;e.first().trigger("lcl_before_show",[d,c.elem_index])}b(document).trigger("lcl_before_show_global",[d,c.elem_index]);b("#lcl_wrap").hasClass("lcl_pre_first_el")&&("function"==typeof q.on_open&&q.on_open.call(null,q,h),c.is_arr_instance||(e=c.elems_selector?b(c.elems_selector):lcl_curr_obj,e.first().trigger("lcl_on_open",[d,c.elem_index])));B(d);b("#lcl_subj").removeClass("lcl_switching_el")},L=function(c){return c.title|| c.txt||c.author?!0:!1},aa=function(c){var d=h.elem_index;b("#lcl_elem_wrap").removeAttr("style").removeAttr("class").empty();b("#lcl_wrap").attr("lcl-type",c.type);b("#lcl_elem_wrap").addClass("lcl_"+c.type+"_elem");switch(c.type){case "image":b("#lcl_elem_wrap").css("background-image","url('"+c.src+"')");break;case "video":b("#lcl_videojs_css").length||(b("head").append(''),"function"!=typeof videojs&& b("head").append('