1// which site are we on? 2var siteType = false; 3 4var roomSearch = { 5 6 package_id : false, 7 8 wrapper : false, 9 10 // search parameters 11 time : false, 12 days : false, 13 weekdays : false, 14 order_by : false, 15 order_type : false, 16 language: "de", 17 18 detailpage_id : false, 19 20 init : function(package_id) { 21 this.package_id = package_id; 22 this.wrapper = jQuery("#ncm_packages_detail_wrapper_" + this.package_id); 23 this.detailpage_id = this.wrapper.attr("data-detailpage-id"); 24 25 if (jQuery("html").attr("lang")) { 26 this.language = jQuery("html").attr("lang"); 27 } 28 29 // click (for future elements also) 30 this.wrapper.on("click", ".selection_naechte span[data-index]", function(event) { 31 32 // active: do nothing 33 if (jQuery(this).hasClass("active")) { 34 return; 35 } 36 37 jQuery(this).siblings("span").removeClass("active"); 38 jQuery(this).addClass("active"); 39 jQuery(this).closest(".selection_naechte").attr("data-selected", jQuery(this).data("index")); 40 41 // refresh days 42 var $Wrapper = jQuery(this).closest(".ncm_packages_detail_wrapper"); 43 var day = $Wrapper.attr("data-selected"); 44 var selectedDay = jQuery(this).text(); 45 46 var possibleWeekDays = ncmPackageDetails.possibleDaysWeekdays[day][selectedDay]; 47 48 if (possibleWeekDays.length) { 49 $possibleWeekDaysWrapper = $Wrapper.find(".selection_tage").attr("data-selected", 0); 50 $possibleWeekDaysWrapper.attr("data-selected", "0").find("span[data-index]").remove(); 51 52 for (var i=0; i < possibleWeekDays.length; i++) { 53 var dayArray = []; 54 jQuery.each(possibleWeekDays[i], function(index, day) { 55 dayArray.push(CONTAO_LANGUAGE.msc.weekdays_short[(day==7?0:day)]); 56 }); 57 $possibleWeekDaysWrapper.append(jQuery("<span></span>").addClass(i==0?"active":"").attr("data-index", i).text(dayArray.join(", "))).append(" "); 58 } 59 } 60 61 62 // init search 63 roomSearch.search(); 64 }); 65 this.wrapper.on("click", ".selection_tage span[data-index]", function(event) { 66 67 // active: do nothing 68 if (jQuery(this).hasClass("active")) { 69 return; 70 } 71 72 jQuery(this).siblings("span").removeClass("active"); 73 jQuery(this).addClass("active"); 74 jQuery(this).closest(".selection_tage").attr("data-selected", jQuery(this).data("index")); 75 roomSearch.search(); 76 }); 77 78 this.wrapper.on("change", "select[name=order]", jQuery.proxy(function(event) { 79 // show all rooms on changing search criteria 80 this.wrapper.find(".show_all_rooms").attr("data-selected", "0"); 81 this.search(); 82 this.wrapper.find(".show_all_rooms").remove(); 83 }, this)); 84 85 this.wrapper.on("click", ".show_all_rooms a", function(event) { 86 event.stopPropagation(); 87 jQuery(this).closest(".show_all_rooms").attr("data-selected", "0"); 88 roomSearch.search({ message: CONTAO_LANGUAGE.ncmPackageDetails.room_all_ajax_text }); 89 jQuery(this).closest(".show_all_rooms").remove(); 90 return false; 91 }); 92 93 // this is not a search but also a live handler 94 this.wrapper.on("click", ".item_room .item_choose", function(event) { 95 // is this already selected? 96 if (jQuery(this).attr("data-selected") == 1) { 97 // unselect this 98 jQuery(this).attr("data-selected", "0").find("img").attr("src", jQuery(this).data("not-selected-img")); 99 jQuery(this).find("span.select-text").text(jQuery(this).find("span.select-text").data("not-selected-text")); 100 // hide the anfrage button 101 jQuery(this).closest(".item_room").find(".enquiry_text").slideUp(); 102 } else { 103 // select this 104 jQuery(this).attr("data-selected", "1").find("img").attr("src", jQuery(this).data("selected-img")); 105 jQuery(this).find("span.select-text").text(jQuery(this).find("span.select-text").data("selected-text")); 106 // show the anfrage button 107 jQuery(this).closest(".item_room").find(".enquiry_text").slideDown(); 108 } 109 110 // remove all other selecteds 111 //jQuery(this).closest(".selection_rooms").find(".item_room .item_cho
111ose").attr("data-selected", "0").find("img").attr("src", jQuery(this).data("not-selected-img")); 112 113 // update selected 114 var selected = []; 115 jQuery(this).closest(".selection_rooms").find(".item_room .item_choose").filter(function() { 116 return jQuery(this).attr("data-selected") == "1"; 117 }).each(function() { 118 selected.push(jQuery(this).closest(".item_room").attr("data-id")); 119 }); 120 jQuery(this).closest(".selection_rooms").attr("data-selected", selected.join(",")); 121 }); 122 123 // show all text 124 this.wrapper.find(".show_all_rooms a").text(jQuery("#room_result_count").attr("data-text")); 125 // hide when there's nothing more to show 126 if (jQuery("#room_result_count").attr("data-shown") >= jQuery("#room_result_count").val()) { 127 this.wrapper.find(".show_all_rooms a").hide(); 128 } else { 129 this.wrapper.find(".show_all_rooms a").show(); 130 } 131 132 // update selected rooms 133 this.wrapper.find(".selection_rooms").attr("data-selected", function() { 134 var selected = []; 135 jQuery(this).find(".item_choose").filter(function() { 136 return jQuery(this).attr("data-selected") == "1"; 137 }).each(function() { 138 selected.push(jQuery(this).closest(".item_room").attr("data-id")); 139 }); 140 return selected.join(","); 141 }); 142 }, 143 144 search : function(params) { 145 146 // default 147 if (typeof params == "undefined") { 148 params = {}; 149 } 150 151 // setup search parameters 152 this.time = this.wrapper.attr("data-selected"); 153 this.days = this.wrapper.find(".selection_naechte").attr("data-selected"); 154 this.weekdays = this.wrapper.find(".selection_tage").attr("data-selected"); 155 // order 156 var order = this.wrapper.find("select[name=order]:visible").val() || ""; 157 var matches; 158 if (matches = order.match(/sort_([a-z]+)_([a-z]+)/)) { 159 this.order_by = matches[1]; 160 this.order_type = matches[2]; 161 }else{ 162 this.order_by = ''; 163 this.order_type = '' 164 } 165 this.wrapper.find(".selection_rooms").addClass("loading"); 166 167 this.limit = this.wrapper.find(".show_all_rooms").attr("data-selected") || "0"; 168 169 // loading indicator 170 try { 171 var message = typeof params.message != "undefined" ? params.message : CONTAO_LANGUAGE.ncmPackageDetails.room_ajax_text; 172 173 jQuery.blockUI({ 174 message : '<div class="message"><div class="loader"></div><br /> ' + CONTAO_LANGUAGE.ncmRoomDetails.room_ajax_text + '</div>' 175 176 }); 177 } catch(e) { 178 } 179 180 //this.wrapper.find(".selection_rooms .item_room").remove(); 181 //debug("@TODO: ajax"); 182 jQuery.ajax({ 183 type: "GET", 184 url: "fe/packages?_action=search_rooms", 185 data: { 186 id : this.package_id, 187 time : this.time, 188 days : this.days, 189 weekdays : this.weekdays, 190 order_by : this.order_by, 191 order_type : this.order_type, 192 limit : this.limit, 193 selected: this.wrapper.find(".selection_rooms").attr("data-selected"), 194 detailpage_id : this.detailpage_id, 195 language : this.language 196 }, 197 cache: false, 198 // @TODO: error handling 199 success: jQuery.proxy(function(data){ 200 201 // check where to insert the new content 202 if (this.wrapper.find(".selection_rooms .sort").size()) { 203 var afterElement = this.wrapper.find(".selection_rooms .sort"); 204 } else if (this.wrapper.find(".selection_rooms > h2,.selection_rooms > h3,.selection_rooms > h4,.selection_rooms > .h4,.selection_rooms > .h3,.selection_rooms > .h2").size()) { 205 var afterElement = this.wrapper.find(".selection_rooms > h2,.selection_rooms > h3,.selection_rooms > h4,.selection_rooms > .h4,.selection_rooms > .h3,.selection_rooms > .h2").last(); 206 } 207 208 // update content 209 this.wrapper.find("#room_result_count").remove(); 210 this.wrapper.find(".selection_rooms .item_room").remove(); 211 212 // insert new content 213 if (typeof afterElement != "undefined" && afterElement) { 214 afterElement.after(data); 215 } else { 216 this.wrapper.prepend(data); 217 } 218 219 // update total button 220 this.wrapper.find(".show_all_rooms a").text(jQuery("#room_result_count").attr("data-text")); 221 222 // update selected rooms 223 this.wrapper.find(".selection_rooms").attr("data-selected", function() { 224 var selected = [];
225 jQuery(this).find(".item_choose").filter(function() { 226 return jQuery(this).attr("data-selected") == "1"; 227 }).each(function() { 228 selected.push(jQuery(this).closest(".item_room").attr("data-id")); 229 }); 230 return selected.join(","); 231 }); 232 233 // reset selected 234 //this.wrapper.find(".selection_rooms").attr("data-selected", ""); 235 236 // remove loading 237 this.wrapper.find(".selection_rooms").removeClass("loading"); 238 239 // loading 240 try { 241 jQuery.unblockUI(); 242 } catch (e) { 243 244 } 245 246 }, this) 247 }); 248 } 249}; 250 251jQuery(function() { 252 253 // init roomsearch //PerfOpt2017 254 if (typeof roomSearchInit != "undefined" && roomSearchInit) { 255 roomSearch.init(roomSearchInit); 256 } 257 258 // onclick on package links with closest-date-index to reset the cookie 259 jQuery("a[data-closest-date-index]").on("click", function(event) { 260 //event.stopPropagation(); 261 var dateIndex = parseInt(jQuery(this).attr("data-closest-date-index")); 262 // store the selected date index in a cookie 263 jQuery.cookie("package_date_index_" + parseInt(jQuery(this).attr("data-package-id")), dateIndex, { path: '/' }); 264 //return false; 265 }); 266 267 // set sitetype 268 switch (true) { 269 case (typeof ncmPackageListMinPrices != "undefined"): // packagelist 270 siteType = "packagelist"; 271 break; 272 273 case (typeof ncmPackageDetails != "undefined"): // packagelist 274 siteType = "packagedetails"; 275 break; 276 277 default: // don't contiunue 278 return false; 279 } 280 281 // store list url and breadrumb title in cookie 282 if (siteType == "packagelist") { 283 jQuery.cookie("package_list_url_" + jQuery("html").attr("lang"), window.location, {path:'/'}); 284 if (jQuery("ol.breadcrumb li.active span[itemprop=name]").size() && jQuery("ol.breadcrumb li.active span[itemprop=name]").text()) { 285 jQuery.cookie("package_list_name_" + jQuery("html").attr("lang"), jQuery("ol.breadcrumb li.active span[itemprop=name]").text(), {path:'/'}); 286 } 287 } 288 289 // replace list links with the link stored in cookie 290 if (siteType == "packagedetails") { 291 var list_url = jQuery.cookie("package_list_url_" + jQuery("html").attr("lang")); 292 if (list_url) { 293 jQuery("a.package-list-link").attr("href", list_url); 294 295 // try to fix the breadrcumb name 296 var list_name = jQuery.cookie("package_list_name_" + jQuery("html").attr("lang")); 297 var breadrcumbs_lenght = 0; 298 if (list_name && (breadrcumbs_lenght = jQuery("ol.breadcrumb li span[itemprop=name]").size())) { 299 //code 300 //alert(breadrcumbs_lenght); 301 if (breadrcumbs_lenght > 2) { 302 jQuery("ol.breadcrumb li span[itemprop=name]").eq(breadrcumbs_lenght-2).text(list_name).closest("a").attr("href", list_url); 303 } 304 } 305 306 } 307 } 308 309 // onclick 310 //jQuery("body") . 311 // on("click", "div[data-onclick] a", function(event) { 312 // //event.preventDefault(); 313 // event.stopPropagation(); 314 // }); 315 // 316 //jQuery("body") . 317 // on("click", "div[data-onclick]", function(event) { 318 // var link = window.location.protocol + '//' + window.location.hostname;// + '/'; 319 // var url = jQuery(this).attr('data-onclick'); 320 // if (url.substring(0, 1) != '/') { 321 // url = '/' + url; 322 // } 323 // window.location = link + url; 324 // }) . 325 // css('cursor','pointer'); 326 327// jQuery("div[data-onclick]").each(function() { 328// jQuery(this).css('cursor','pointer'); 329// var link = window.location.protocol + '//' + window.location.hostname;// + '/'; 330// jQuery(this).on('click', function(e) { 331// if (e.target == this) { 332// var url = jQuery(this).attr('data-onclick'); 333// if (url.substring(0, 1) != '/') { 334// url = '/' + url; 335// } 336// window.location = link + url; 337// } 338// }).on('click', '> *', function(e) { 339// if ((e.target.nodeName != 'A') && (e.target.parentNode.nodeName != 'A')) { 340// var url = jQuery(this).parents().attr('data-onclick'); 341// if (url.substring(0, 1) != '/') { 342// url = '/' + url; 343// } 344// window.location = link + url; 345// } else if (e.target.nodeName == 'A') { 346// var url = jQuery(e.target).attr('href'); 347// if (url.substring(0, 1) != '/') { 348// url = '/' + url; 349// } 350// window.location = link + url; 351// } 352// }); 353// }); 354 355 // ie8-9 workaround for image carousels
356 // @TODO: find the reason... 357 if (jQuery("body").hasClass("ie8") || jQuery("body").hasClass("ie9")) { 358 jQuery("#main").on("click", ".imgcarousel .carousel-control", function(event) { 359 event.stopPropagation(); 360 jQuery(this).closest(".imgcarousel").carousel(jQuery(this).data("slide")); 361 return false; 362 }); 363 jQuery("#main").on("click", ".pricecarousel .carousel-control", function(event) { 364 event.stopPropagation(); 365 jQuery(this).closest(".pricecarousel").carousel(jQuery(this).data("slide")); 366 return false; 367 }); 368 } 369 370 // event for all price carousels 371 jQuery(".pricecarousel").on("slide.bs.carousel", function(event) { 372 373 // actual package 374 var package_id = jQuery(this).data("package-id"); 375 376 // indexes 377 var slideFrom = jQuery(this).find('.active').index(); 378 var slideTo = jQuery(event.relatedTarget).index(); 379 380 // detail site functionality 381 if (siteType == "packagedetails") { 382 383 // shortcut 384 var $Wrapper = jQuery("#ncm_packages_detail_wrapper_" + package_id); 385 386 // loading 387 $Wrapper.find(".selection").addClass("loading"); 388 389 // update Nächte 390 $Wrapper.find(".selection_naechte span[data-index]").remove(); 391 392 // update Anreisetage 393 $Wrapper.find(".selection_tage span[data-index]").remove(); 394 395 // update index 396 $Wrapper.attr("data-selected", slideTo); 397 398 // store the selected date index in a cookie 399 jQuery.cookie("package_date_index_" + package_id, slideTo, {path:'/'}); 400 401 // add new Nächte 402 try { 403 404 // try to find the currently selected day in the new available days 405 var selectedNightsIndex = $Wrapper.find(".selection_naechte").attr("data-selected"); 406 if (selectedNightsIndex && ncmPackageDetails.possibleDays[slideTo][selectedNightsIndex] != ncmPackageDetails.possibleDays[slideFrom][selectedNightsIndex]) { 407 selectedNightsIndex = 0; 408 } 409 410 var possibleDays = ncmPackageDetails.possibleDays[slideTo]; 411 if (!possibleDays.length) { 412 throw 'NoPossibleDays'; 413 } 414 $possibleDaysWrapper = $Wrapper.find(".selection_naechte").attr("data-selected", selectedNightsIndex); 415 var selectedDay = -1; 416 for (var i=0; i < possibleDays.length; i++) { 417 $possibleDaysWrapper.append(jQuery("<span></span>").addClass(i==selectedNightsIndex?"active":"").attr("data-index", i).text(possibleDays[i])).append(" "); 418 if (selectedDay == -1) { 419 selectedDay = possibleDays[i]; 420 } 421 } 422 423 var possibleWeekDays = ncmPackageDetails.possibleDaysWeekdays[slideTo][selectedDay]; 424 if (!possibleWeekDays.length) { 425 throw 'NoPossibleWeekDays'; 426 } 427 428 $possibleWeekDaysWrapper = $Wrapper.find(".selection_tage").attr("data-selected", 0); 429 for (var i=0; i < possibleWeekDays.length; i++) { 430 var dayArray = []; 431 jQuery.each(possibleWeekDays[i], function(index, day) { 432 dayArray.push(CONTAO_LANGUAGE.msc.weekdays_short[(day==7?0:day)]); 433 }); 434 $possibleWeekDaysWrapper.append(jQuery("<span></span>").addClass(i==0?"active":"").attr("data-index", i).text(dayArray.join(", "))).append(" "); 435 } 436 437 // start search 438 roomSearch.search(); 439 } catch (e) { 440 // safety solution for errors: fill out with 1 value 441 $Wrapper.find(".selection_naechte span[data-index]").remove(); 442 $Wrapper.find(".selection_tage span[data-index]").remove(); 443 $Wrapper.find(".selection_naechte").attr("data-selected", 0).append('<span class="active">' + CONTAO_LANGUAGE.ncmPackageDetails.arbitrary + '</span>'); 444 $Wrapper.find(".selection_tage").attr("data-selected", 0).append( 445 '<span class="active">' + 446 CONTAO_LANGUAGE.msc.weekdays_short[1] + ", " + 447 CONTAO_LANGUAGE.msc.weekdays_short[2] + ", " + 448 CONTAO_LANGUAGE.msc.weekdays_short[3] + ", " + 449 CONTAO_LANGUAGE.msc.weekdays_short[4] + ", " + 450 CONTAO_LANGUAGE.msc.weekdays_short[5] + ", " + 451 CONTAO_LANGUAGE.msc.weekdays_short[6] + ", " + 452 CONTAO_LANGUAGE.msc.weekdays_short[0] + 453 '</span>' 454 ); 455 roomSearch.search(); 456 } 457 } 458 459 // list functionality 460 if (siteType == "packagelist") { 461 462 // turn on the loading class 463 jQuery("#package_preis_ab_" + package_id).find(".package_preis_indicator").show(); 464 jQuery("#package_preis_ab_" + package_id).find(".package_preis_wrapper").hide(); 465 // update the price 466 try { 467 468 jQuery("#package_preis_ab_value_" + package_id).text(ncmPackageListMinPrices[package_id][slideTo]); 469 470 // store the selected date index in a cookie 471 jQuery.cookie("package_date_index_" + package_id, slideTo, {path:'/'}); 472 473 } catch (e) { 474 debug(e); 475 } 476 } 477 }); 478 479 // event for all price carousels 480 jQuery(".pricecarousel").on("slid.bs.carousel", function(event) { 481 482 // actual package 483 var package_id = jQuery(this).data("package-id"); 484 485 // details functionality 486 if (siteType == "packagedetails") { 487 // shortcut 488 var $Wrapper = jQuery("#ncm_packages_detail_wrapper_" + package_id); 489 490 // remove loading class 491 jQuery("#ncm_packages_detail_wrapper_" + package_id + " .selection").removeClass("loading"); 492 } 493 494 // list functionality 495 if (siteType == "packagelist") { 496 // turn off the loading class 497 jQuery("#package_preis_ab_" + package_id).find(".package_preis_indicator").hide(); 498 jQuery("#package_preis_ab_" + package_id).find(".package_preis_wrapper").show(); 499 } 500 }); 501 502 // swipe 503 jQuery(".pricecarousel, .imgcarousel").swipe({ 504 //onSwipe:function(direction, data){ 505 swipe:function(event, direction, distance, duration, fingerCount) { 506 switch (direction) {
507 case "left": 508 jQuery(this).carousel("next"); 509 break; 510 case "right": 511 jQuery(this).carousel("prev"); 512 break; 513 //case "up": 514 //case "down": 515 //case "none": 516 // window.scrollBy(0,data.distY * -1); 517 // break; 518 } 519 }, 520 click:function(event) { 521 if (jQuery(this).hasClass("imgcarousel")) { 522 jQuery(this).find('.active a').trigger("click"); 523 } 524 }, 525 //threshold:50, 526 allowPageScroll:"vertical" 527 }); 528 529 530});
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.