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