1jQuery(document).ready(function ($) { 2 3 $("a.open_lightbox").mwFrontLightbox(); 4 5}); 6 7(function($){ 8 9 let $content; 10 let $inContent; 11 let $container; 12 let $overlay; 13 let $box; 14 let $inline; 15 let $related; 16 let index; 17 let contentType; 18 19 $.fn.mwFrontLightbox = function(options) { 20 21 // for more selected elements 22 if (this.length > 1){ 23 this.each(function() { 24 $(this).mwFrontLightbox(options); 25 }); 26 return this; 27 } 28 29 let $close; 30 let $next; 31 let $prev; 32 let $element; 33 34 // default setting 35 let defaults = { 36 html: false, 37 inline: false, 38 href: false, 39 ajax: false, 40 41 width: false, 42 maxWidth: false, 43 height: false, 44 open: false, 45 overlayColor: false, 46 id: 'mw_lightbox_default', 47 class: '', 48 hideClose: false, 49 target: document.body, 50 51 onClosed: false, 52 onComplete: false, 53 }; 54 55 // setting 56 let settings = $.extend( {}, defaults, options ); 57 58 $element = $(this); 59 60 if(!settings.href) { 61 settings.href = $element.attr('href'); 62 } 63 64 if(settings.hideClose) { 65 settings.class += ' mw_popup_hide_close'; 66 } 67 68 let $tag = function(tag, id = '', className = '', css = '') { 69 let element = document.createElement(tag); 70 71 if (id) { 72 element.id = id; 73 } 74 75 if (className) { 76 element.classList.add(className); 77 } 78 79 if (css) { 80 element.style.cssText = css; 81 } 82 83 return $(element); 84 } 85 86 let open = function() { 87 88 if(isOpen()) { 89 returnInlineContent(); 90 } 91 92 loadContent(); 93 94 if(!isOpen()) { 95 96 getRelated(); 97 98 create(); 99 100 setTimeout(function () { 101 $container.addClass('mw_popup_opened'); 102 $overlay.addClass('mw_popup_opened'); 103 $close.focus(); 104 }, 10); 105 106 $('html').css('overflow', 'hidden'); 107 108 $('.mw_popup_container, .mw_popup_box').click(function(e){ 109 if(e.target === this) { 110 close(); 111 } 112 }); 113 114 if(contentType === 'image') { 115 $('.mw_popup_next').click(function(e){ 116 index = getIndex(1); 117 let $nextItem = $($related[index]); 118 let $oldImg = $content.find('img'); 119 let $nextImg = $tag('img', '', 'mw_popup_next_img').attr('src', $nextItem.attr('href')); 120 $content.append($nextImg); 121 $oldImg.addClass('mw_popup_prev_img'); 122 setTimeout(function () { 123 $oldImg.remove(); 124 $nextImg.removeClass('mw_popup_next_img'); 125 }, 100); 126 }); 127 128 $('.mw_popup_prev').click(function(e){ 129 index = getIndex(-1); 130 let $nextItem = $($related[index]); 131 let $oldImg = $content.find('img'); 132 let $prevImg = $tag('img', '', 'mw_popup_prev_img').attr('src', $nextItem.attr('href')); 133 $content.append($prevImg); 134 $oldImg.addClass('mw_popup_next_img'); 135 setTimeout(function () { 136 $oldImg.remove(); 137 $prevImg.removeClass('mw_popup_prev_img'); 138 }, 100); 139 }); 140 } 141 142 if (contentType === 'ajax') { 143 addLoading(); 144 } 145 146 $box.on('click', '.mw_popup_close', function(e){ 147 e.stopPropagation(); 148 e.preventDefault(); 149 close(); 150 }); 151 152 // Key Bindings 153 $(document).bind('keydown.mw_lightbox', function (e) { 154 let key = e.keyCode; 155 if (isOpen() && key === 27) { 156 e.preventDefault(); 157 close(); 158 } 159 if (isOpen() && $related[1] && !e.altKey) { 160 if (key === 37) { 161 e.preventDefault(); 162 $prev.click(); 163 } else if (key === 39) { 164 e.preventDefault(); 165 $next.click(); 166 } 167 } 168 }); 169 170 } else { 171 addStyles(); 172 $container.attr('class', 'mw_popup_container mw_popup_opened ' + settings.class); 173 } 174 175 addContent(); 176 177 if (settings.onComplete) { 178 settings.onComplete.call(this, $content, $element); 179 } 180 181 }; 182 183 let close = function() { 184 $container.removeClass('mw_popup_opened'); 185 $overlay.removeClass('mw_popup_opened'); 186 187 if(settings.onClosed) { 188 settings.onClosed.call(); 189 } 190 191 returnInlineContent(); 192 193 // unbind keybind 194 $(document).unbind('keydown.mw_lightbox'); 195 196 // remove lightbox 197 setTimeout(function () { 198 $content = undefined; 199 $('.mw_popup_overlay').remove(); 200 $('.mw_popup_container').remove(); 201 $('html').css('overflow', 'auto'); 202 }, 200); 203 }; 204 205 $element.close = function() { 206 close(); 207 }; 208 209 let returnInlineContent = function() { 210 // return content for inline mode
211 if ($inline) { 212 $inline.replaceWith($inContent); 213 } 214 } 215 216 let create = function() { 217 218 $overlay = $tag('div', '', 'mw_popup_overlay'); 219 $container = $tag('div', settings.id, 'mw_popup_container').addClass(settings.class); 220 $box = $tag('div', '', 'mw_popup_box'); 221 $content = $tag('div', '', 'mw_popup_content'); 222 223 $close = $tag('a', '', 'mw_popup_close').attr('href', '#').html( 224 '<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 24 24" xml:space="preserve">' + 225 '<path d="M13.4 12l5.3-5.3c0.4-0.4 0.4-1 0-1.4s-1-0.4-1.4 0l-5.3 5.3-5.3-5.3c-0.4-0.4-1-0.4-1.4 0s-0.4 1 0 1.4l5.3 5.3-5.3 5.3c-0.4 0.4-0.4 1 0 1.4 0.2 0.2 0.4 0.3 0.7 0.3s0.5-0.1 0.7-0.3l5.3-5.3 5.3 5.3c0.2 0.2 0.5 0.3 0.7 0.3s0.5-0.1 0.7-0.3c0.4-0.4 0.4-1 0-1.4l-5.3-5.3z"></path>' + 226 '</svg>' 227 ); 228 $next = $tag('a', '', 'mw_popup_next').attr('href', '#').html( 229 '<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 24 24" xml:space="preserve">' + 230 '<path d="M15.7 11.3l-6-6c-0.4-0.4-1-0.4-1.4 0s-0.4 1 0 1.4l5.3 5.3-5.3 5.3c-0.4 0.4-0.4 1 0 1.4 0.2 0.2 0.4 0.3 0.7 0.3s0.5-0.1 0.7-0.3l6-6c0.4-0.4 0.4-1 0-1.4z"></path>' + 231 '</svg>' 232 ); 233 $prev = $tag('a', '', 'mw_popup_prev').attr('href', '#').html( 234 '<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 24 24" xml:space="preserve">' + 235 '<path d="M10.4 12l5.3-5.3c0.4-0.4 0.4-1 0-1.4s-1-0.4-1.4 0l-6 6c-0.4 0.4-0.4 1 0 1.4l6 6c0.2 0.2 0.5 0.3 0.7 0.3s0.5-0.1 0.7-0.3c0.4-0.4 0.4-1 0-1.4l-5.3-5.3z"></path>\n' + 236 '</svg>' 237 ); 238 239 $box.append($close); 240 $box.append($content) 241 242 if(contentType === 'image' && $related.length > 1) { 243 $box.append($next, $prev); 244 } 245 246 addStyles(); 247 248 $(settings.target).append($overlay, $container.append($box)); 249 250 }; 251 252 let addStyles = function() { 253 if(settings.width) { 254 $box.css({width:settings.width}); 255 } 256 if(settings.maxWidth) { 257 $box.css({maxWidth:settings.maxWidth}); 258 } 259 if(settings.height) { 260 $content.css({height:settings.height}); 261 } 262 if(settings.overlayColor) { 263 $overlay.css({backgroundColor:settings.overlayColor}); 264 } 265 } 266 267 let loadContent = function() { 268 269 if(settings.html) { 270 271 $inContent = $(settings.html); 272 contentType = 'html'; 273 274 } else if(settings.ajax) { 275 276 contentType = 'ajax'; 277 278 } else if (settings.inline) { 279 280 $inContent = $(settings.href).eq(0); 281 $inline = $('<div>').hide().insertBefore($inContent); 282 contentType = 'inline'; 283 284 } else if(isImage(settings.href)) { 285 let photo = new Image(); 286 photo.src = settings.href; 287 $inContent = $(photo).addClass('mw_popup_image'); 288 contentType = 'image'; 289 } else { 290 $inContent = $('<div class="mw_popup_error">NepodaÅilo se naÄÃst obsah</div>'); 291 } 292 293 } 294 295 let addContent = function() { 296 297 if(contentType === 'image') { 298 $container.addClass('mw_image_popup'); 299 } else { 300 $container.removeClass('mw_image_popup'); 301 } 302 if(contentType !== 'ajax') { 303 $content.html(''); 304 $content.append($inContent); 305 306 // bind videos 307 if ($content.find('.mw_video_container').length) { 308 $content.find('.mw_video_container').mwVideo(); 309 } 310 // bind carousel 311 if ($content.find('.miocarousel').length) { 312 setTimeout(function() { 313 $content.find('.miocarousel').MioCarousel({}); 314 }, 200); // becouse of lightbox animation 315 } 316 } 317 } 318 319 function isImage(url) { 320 let pattern = /\.(gif|png|jp(e|g|eg)|bmp|ico|webp|jxr|svg)((#|\?).*)?$/i; 321 return pattern.test(url); 322 } 323 324 function getRelated() { 325 index = 0; 326 let rel = $element.attr('rel'); 327 328 if (rel && rel !== false && rel !== 'nofollow') { 329 $related = $('[rel="' + rel + '"]'); 330 index = $related.index($element); 331 } else { 332 $related = $element; 333 } 334 335 } 336 337 function getIndex(increment) { 338 let 339 max = $related.length, 340 newIndex = (index + increment) % max; 341 342 return (newIndex < 0) ? max + newIndex : newIndex; 343 } 344 345 let isOpen = function() { 346 347 if($content) { 348 return true; 349 } 350 351 return false;
352 } 353 354 let addLoading = function() { 355 $content.addClass('mw_loading'); 356 } 357 let removeLoading = function() { 358 $content.removeClass('mw_loading'); 359 } 360 361 // open on $.mwLightbox(); 362 if (settings.open) { 363 open(); 364 // click action on $.fn.mwLightbox() 365 } else { 366 this.click(function(e){ 367 open(); 368 e.preventDefault(); 369 }); 370 } 371 372 return this; 373 374 } 375 376 $.mwFrontLightbox = function(options){ 377 options.open = true; 378 $.fn.mwFrontLightbox(options); 379 } 380 381})(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.