1"use strict"; 2 3/** 4 * @version 1.2 5 */ 6 7var gallery; // globálnà reprezentace objektu PhotoSwipe galerie 8 9$(function () { 10 // Zobrazenà celého popisu na mobilnà verzi 11 $('.hoteldiv').each(function () { 12 $(this).find('.hotel-popis') 13 .find('.hotel-ajax-cely-popis').click(function (e) { 14 e.preventDefault(); 15 16 var parent = $(this).parent(), 17 text = parent.find('.hotel-ajax-popis').text(); 18 19 parent.append(document.createTextNode(text)); 20 parent.find('.hotel-ajax-popis, .hotel-ajax-tecky, .hotel-ajax-cely-popis').remove(); 21 }) 22 }); 23 24 //pomocný div pro prevenci kliknutà na odkaz pod galerià (jinak je snadné se pÅekliknout) 25 $("#fotoDialogContainer").hide(); 26 27 // Posun na zvýraznÄný hotel 28 var selectedHotel = $('.hoteldiv.highlighted'); 29 30 if (selectedHotel.length > 0) { 31 var hashId = "hotel" + window.location.hash.replace("#", ""); 32 33 if (selectedHotel.attr("id") === hashId || selectedHotel.attr("data-lastminute-id") === hashId) 34 $(window).scrollTop($(selectedHotel[0]).offset().top - 50); 35 } 36 37 $(window).on('hashchange', function (e) { 38 e.preventDefault(); 39 40 // zavÅenà galerie 41 if ((window.location.hash.indexOf('galerie') === -1 && window.location.hash.indexOf('cenik') === -1) 42 && gallery instanceof PhotoSwipe) 43 gallery.close(); 44 45 return false; 46 }); 47}); 48 49function toggleCalendar(id, from, to) 50{ 51 console.log(id); 52 var calendar = $('#kalendar_' + id); 53 54 if (calendar.hasClass('kalendar-expand')) 55 { 56 calendar.removeClass('kalendar-expand'); 57 $('#hotel_' + id).html(zobrazKalendar); 58 hideKalendar(id); 59 } 60 else 61 { 62 calendar.addClass('kalendar-expand'); 63 $('#hotel_' + id).html(skrytKalendar); 64 Kalendar(id, from, to); 65 } 66} 67 68// zobrazenà termÃnu v kalendáÅi 69function Kalendar(id, from, to) { 70 var element = $("#kalendar_" + id); 71 if (!element.hasClass('visible')) { 72 element.addClass('visible') 73 .show() 74 .flatpickr({ 75 mode: 'range', 76 inline: true, 77 monthSelectorType: 'static', 78 minDate: element.data('calendarStart'), 79 maxDate: element.data('calendarEnd'), 80 appendTo: element[0], 81 defaultDate: [element.data('calendarStart'), element.data('calendarEnd')], 82 }); 83 element.parent() 84 .slideDown(); 85 } 86} 87 88function hideKalendar(id) { 89 var element = $("#kalendar_" + id); 90 element.removeClass('visible') 91 .parent().slideUp(function () { 92 element.hide(); 93 }); 94} 95 96// pro testovánà na lokálu, kde nejsou vÅ¡echny fotky 97var bTestOnServer = false; 98 99function getPhotoLink(slozka, n) { 100 return (bTestOnServer ? 'https://www.ceskehory.cz' : '') + photoBase + slozka + "/x" + n + ".jpg"; 101} 102 103function createPhotoObjects(slozka, foto_string, n) { 104 var pages = foto_string.toString().split('').map(function (item) { 105 return Number(item); 106 }); 107 108 var objects = { 109 count: pages.length - n, 110 data: [] 111 }; 112 113 for (var i = 0; i < pages.length - 1; i++) { 114 115 var addPage = { 116 src: getPhotoLink(slozka, i + 1), 117 w: 0, 118 h: 0 119 }; 120 121 objects.data.push(addPage); 122 } 123 124 return objects; 125} 126 127function uniqid(a, b) { 128 a = a || ""; 129 b = b && false; 130 131 var c = Date.now() / 1000; 132 var d = c.toString(16).split(".").join(""); 133 while (d.length < 14) { 134 d += "0"; 135 } 136 var e = ""; 137 if (b) { 138 e = "."; 139 e += Math.round(Math.random() * 100000000); 140 } 141 return a + d + e; 142} 143 144var highlightTimeout = 2000; 145 146function addActionHighlight(id) { 147 var highlighId = uniqid(); 148 149 $('.highlighted').removeClass('highlighted'); 150 $("#hotel" + id).addClass('action-highlight') 151 .addClass('action-highlight_' + highlighId); 152 153 removeAllOtherHighLights(highlighId); 154 155 return highlighId; 156} 157 158function removeAllOtherHighLights(exclusionId) { 159 var excludeClass = '.action-highlight_' + exclusionId; 160 $('.action-highlight:not(' + excludeClass + ')').removeClass('action-highlight'); 161 162} 163 164function removeActionHighlight(highlightId) { 165 var selector = typeof highlightId === "undefined" ? ".action-highlight" : ".action-highlight_" + highlightId; 166 167 setTimeout(function () { 168 $(selector).removeClass('action-highlight') 169 .removeClass('action-highlight_' + highlightId); 170 }, highlightTimeout); 171} 172 173function initializePhotoSwipe(items, highlightId) { 174 var containerElement = $('.pswp')[0]; 175 176 var options = { 177 history: false, 178 focus: false, 179 index: 0, 180 shareEl: false // schovánà share buttonu 181 }; 182 183 gallery = new PhotoSwipe(containerElement, PhotoSwipeUI_Default, items, options); 184 gallery.listen('close', function () { 185 if (window.location.hash.indexOf('galerie') !== -1) 186 window.history.back(); 187 188 removeActionHighlight(highlightId); 189 }); 190 // https://github.com/dimsemenov/PhotoSwipe/issues/796 191 gallery.listen('gettingData', function(index, item) { 192 if (item.w < 1 || item.h < 1) { // unknown size 193 var img = new Image(); 194 img.onload = function() { 195 item.w = this.width; 196 item.h = this.height; 197 gallery.invalidateCurrItems(); 198 gallery.updateSize(true); 199 }; 200 img.src = item.src; 201 } 202 }); 203 204 gallery.init(); 205 206} 207 208function showMorePhotos(slozka, foto_string, n, id) { 209 $('#fotoDialogContainer').show(); 210 211 var highlightId = addActionHighlight(id); 212 213 var photoObjects = createPhotoObjects(slozka, foto_string, n); 214 initializePhotoSwipe(photoObjects.data, highlightId); 215 216 if (window.location.hash.indexOf('galerie') === -1)
217 window.location.hash += 'galerie'; 218} 219 220var xmlHttp = new XMLHttpRequest(); 221 222function sendRequestCenikHR(id, route, mutace) { 223 const highlight = addActionHighlight(id); 224 225 fetch(route) 226 .then(response => response.text()) 227 .then(response => showPricesDialog(response, highlight)); 228} 229 230function sendRequestCenik(id, mutace, postfix) { 231 var highlightId = addActionHighlight(id); 232 233 if (xmlHttp) { 234 xmlHttp.open("GET", "/share/ajax/ajax_cenik_3R.php?id=" + id + "&mutace=" + mutace + "&postfix=" + postfix + '&highlightId=' + highlightId, true); 235 xmlHttp.onreadystatechange = function () { 236 showPrices(highlightId); 237 }; 238 xmlHttp.send(null); 239 } 240 241 242 if (window.location.hash.indexOf('cenik') === -1) 243 window.location.hash += 'cenik'; 244} 245 246function showPrices(highlightId) { 247 if (xmlHttp.readyState === 4) { 248 if (xmlHttp.status === 200) { 249 var ajaxReturn = xmlHttp.responseText; 250 showPricesDialog(ajaxReturn, highlightId); 251 } 252 253 else 254 $(".action-highlight_" + highlightId).removeClass('action-highlight action-highlight_' + highlightId); 255 } 256} 257 258function closeCenik(highlightId) { 259 removeActionHighlight(highlightId); 260 261 var toRemove = $("#simple-popup, #simple-popup-backdrop"); 262 toRemove.fadeOut('fast', function () { 263 toRemove.remove(); 264 }); 265 266 history.back(); 267} 268 269function showPricesDialog(text, highlightId) { 270 var options = { 271 type: "html", 272 htmlSelector: "#cenik-container", 273 afterClose: function () { 274 if (window.location.hash.indexOf('cenik') !== -1) 275 window.history.back(); 276 277 removeActionHighlight(highlightId); 278 } 279 }; 280 281 $("#cenik-container").html(text); 282 $(document).simplePopup(options); 283}
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.