1(function($) { 2 'use strict'; 3 4 var hotelRoomCart = {}; 5 mkdf.modules.hotelRoomCart = hotelRoomCart; 6 7 hotelRoomCart.mkdfOnDocumentReady = mkdfOnDocumentReady; 8 hotelRoomCart.mkdfOnWindowLoad = mkdfOnWindowLoad; 9 hotelRoomCart.mkdfOnWindowResize = mkdfOnWindowResize; 10 hotelRoomCart.mkdfOnWindowScroll = mkdfOnWindowScroll; 11 12 hotelRoomCart.mkdfInitHotelRoomCartUpdateSession = mkdfInitHotelRoomCartUpdateSession ; 13 14 $(document).ready(mkdfOnDocumentReady); 15 $(window).load(mkdfOnWindowLoad); 16 $(window).resize(mkdfOnWindowResize); 17 $(window).scroll(mkdfOnWindowScroll); 18 19 /* 20 All functions to be called on $(document).ready() should be in this function 21 */ 22 function mkdfOnDocumentReady() { 23 mkdfInitHotelRoomCartUpdateSession(); 24 25 26 } 27 28 /* 29 All functions to be called on $(window).load() should be in this function 30 */ 31 function mkdfOnWindowLoad() { 32 } 33 34 /* 35 All functions to be called on $(window).resize() should be in this function 36 */ 37 function mkdfOnWindowResize() { 38 39 } 40 41 /* 42 All functions to be called on $(window).scroll() should be in this function 43 */ 44 function mkdfOnWindowScroll() { 45 46 } 47 48 function mkdfInitHotelRoomCartUpdateSession(){ 49 var wooCommerceCheckout = $('.woocommerce-checkout'); 50 51 function updateSessionTrigger() { 52 53 54 var ajaxData = { 55 action: 'check_hotel_room_session_update', 56 }; 57 58 $.ajax({ 59 type: 'POST', 60 data: ajaxData, 61 url: mkdfGlobalVars.vars.mkdfAjaxUrl, 62 63 success: function (data) { 64 return true; 65 } 66 }); 67 } 68 69 if(wooCommerceCheckout.length) { 70 updateSessionTrigger(); 71 } 72 73 } 74 75 76 77})(jQuery); 78(function($) { 79 'use strict'; 80 81 var hotelRoomSingle = {}; 82 mkdf.modules.hotelRoomSingle = hotelRoomSingle; 83 84 hotelRoomSingle.mkdfOnDocumentReady = mkdfOnDocumentReady; 85 hotelRoomSingle.mkdfOnWindowLoad = mkdfOnWindowLoad; 86 87 hotelRoomSingle.mkdfInitHotelRoomSingleTabs = mkdfInitHotelRoomSingleTabs; 88 hotelRoomSingle.mkdfHotelRoomTabsMapTrigger = mkdfHotelRoomTabsMapTrigger; 89 hotelRoomSingle.mkdfHotelRoomReviewsInit = mkdfHotelRoomReviewsInit; 90 hotelRoomSingle.mkdfInitHotelRoomSingleSlider = mkdfInitHotelRoomSingleSlider; 91 92 $(document).ready(mkdfOnDocumentReady); 93 $(window).load(mkdfOnWindowLoad); 94 95 /* 96 All functions to be called on $(document).ready() should be in this function 97 */ 98 function mkdfOnDocumentReady() { 99 if(typeof mkdf === 'undefined' || typeof mkdf === '' ){ 100 //if theme is not installed, generate single items manualy 101 mkdfInitHotelRoomSingleTabs(); 102 } 103 104 if(typeof mkdf !== 'undefined' ){ 105 //if theme is installed, trigger google map loading on location tab on single pages 106 mkdfHotelRoomTabsMapTrigger(); 107 108 } 109 110 // For now, regardless of whether the theme is installed, initiate reviews 111 mkdfHotelRoomReviewsInit(); 112 } 113 114 /* 115 All functions to be called on $(window).load() should be in this function 116 */ 117 function mkdfOnWindowLoad() { 118 mkdfInitHotelRoomSingleReservation(); 119 mkdfInitHotelRoomSingleSlider(); 120 } 121 122 function mkdfInitHotelRoomSingleTabs(){ 123 var holder = $('.mkdf-hotel-room-single-outer'); 124 var roomNavItems = holder.find('.mkdf-hr-item-wrapper ul li a'); 125 var roomSectionsItems = holder.find('.mkdf-hr-item-section'); 126 roomNavItems.first().addClass('mkdf-active-item'); 127 128 roomNavItems.on('click', function(e){ 129 130 e.preventDefault(); 131 132 roomNavItems.removeClass('mkdf-active-item'); 133 134 var thisNavItem = $(this); 135 136 var thisNavItemId = thisNavItem.attr('href'); 137 thisNavItem.addClass('mkdf-active-item'); 138 139 if( roomSectionsItems.length ){ 140 roomSectionsItems.each(function(){ 141 142 var thisSectionItem = $(this); 143 144 if('#'+thisSectionItem.attr('id') === thisNavItemId){ 145 thisSectionItem.show(); 146 if(thisNavItemId === '#mkdf_hotel_room_tab_id_location'){ 147 mkdfHotelRoomReInitGoogleMap(); 148 } 149 }else{ 150 thisSectionItem.hide(); 151 } 152 }); 153 } 154 }); 155 } 156 157 function mkdfHotelRoomTabsMapTrigger(){ 158 var holder = $('.mkdf-hotel-room-single-outer'); 159 var hotelRoomNavItems = holder.find('.mkdf-hr-item-wrapper ul li a'); 160 hotelRoomNavItems.on('click', function(e){ 161 162 e.preventDefault(); 163 164 var thisNavItem = $(this); 165 var thisNavItemId = thisNavItem.attr('href'); 166 167 if(thisNavItemId === '#mkdf_hotel_room_tab_id_location'){ 168 mkdfHotelRoomReInitGoogleMap(); 169 } 170 }); 171 } 172 173 function mkdfHotelRoomReInitGoogleMap(){ 174 175 if(typeof mkdf !== 'undefined'){ 176 mkdf.modules.googleMap.mkdfShowGoogleMap(); 177 } 178 } 179 180 function mkdfHotelRoomReviewsInit() { 181 var reviewWrappers = $('.mkdf-hr-item-reviews-input-wrapper'); 182 if (reviewWrappers.length) { 183 184 var emptyStarClass = 'icon_star_alt', 185 fullStarClass = 'icon_star'; 186 187 var setCriteriaCommands = function(criteriaHolder) { 188 criteriaHolder.find('.mkdf-hr-item-reviews-star-holder') 189 .mouseenter(function () { 190 $(this).add($(this).prevAll()).find('.mkdf-hr-item-reviews-star').removeClass(emptyStarClass).addClass(fullStarClass); 191 $(this).nextAll().find('.mkdf-hr-item-reviews-star').removeClass(fullStarClass).addClass(emptyStarClass); 192 }) 193 .on('click', function() { 194 criteriaHolder.find('.mkdf-hr-item-reviews-hidden-input').val($(this).index()+1); 195 }); 196 197 criteriaHolder.find('.mkdf-hr-item-reviews-rating-holder') 198 .mouseleave(function() { 199 var inputValue = criteriaHolder.find('.mkdf-hr-item-reviews-hidden-input').val(); 200 inputValue = inputValue === "" ? 0 : parseInt(inputValue,10); 201 $(this).find('.mkdf-hr-item-reviews-star-holder').each(function(i) { 202 $(this).find('.mkdf-hr-item-reviews-star').removeClass((i < inputValue) ? emptyStarClass : fullStarClass).addClass((i < inputValue) ? fullStarClass : emptyStarClass); 203 }); 204 }).trigger('mouseleave'); 205 }; 206 207 reviewWrappers.each(function() { 208 209 var reviewWrapper = $(this); 210 var criteriaHolders = reviewWrapper.find('.mkdf-hr-item-reviews-criteria-h
210older'); 211 212 criteriaHolders.each(function() { 213 setCriteriaCommands($(this)); 214 }); 215 }); 216 } 217 } 218 219 function mkdfInitHotelRoomSingleSlider() { 220 var sliders = $('.mkdf-hotel-room-single-holder .mkdf-owl-slider, .mkdf-hotel-room-single-holder .mkdf-slider-thumbnail'); 221 222 if(sliders.length) { 223 sliders.addClass('mkdf-hotel-single-slider-show'); 224 } 225 } 226 227 function mkdfInitHotelRoomSingleReservation() { 228 var reservation = $('.mkdf-hotel-room-reservation'); 229 230 if (reservation.length) { 231 reservation.each(function() { 232 var thisReservation = $(this), 233 allInputs = thisReservation.find('input, select'), 234 thisReservationHolder = thisReservation.parents('.mkdf-hotel-room-reservation-holder'), 235 finishForm = thisReservation.find('.mkdf-buy-item-form .mkdf-hotel-room-single-res-button'), // form that is enabled after validation 236 relocationButton = thisReservation.find('.mkdf-hotel-room-reservation-similar'), // button for relocation 237 form = thisReservation.find('#mkdf-hotel-room-form'), // initial form 238 initialPrice = thisReservation.find('.mkdf-res-initial-price .mkdf-res-price-number'), // initial price 239 endPrice = thisReservation.find('.mkdf-res-end-price .mkdf-res-price-number'), // end price after activated extra services 240 roomNumber = thisReservation.find('.mkdf-res-rooms-number'), 241 adults = thisReservation.find('.mkdf-res-adults'), 242 children = thisReservation.find('.mkdf-res-children'), 243 minDate = thisReservation.find('.mkdf-res-min-date'), 244 maxDate = thisReservation.find('.mkdf-res-max-date'), 245 formValidation = thisReservation.find('#reservation-validation-messages-holder'); 246 247 //INIT ROOMS FIELD 248 249 var selectRoomNumber = roomNumber; 250 if(selectRoomNumber.length) { 251 selectRoomNumber.select2({ 252 minimumResultsForSearch: -1 253 }); 254 } 255 256 //INIT ADULTS FIELD 257 258 var selectAdults = adults; 259 if(selectAdults.length) { 260 selectAdults.select2({ 261 minimumResultsForSearch: -1 262 }); 263 } 264 265 //INIT ADULTS FIELD 266 267 var selectChildren = children; 268 if(selectChildren.length) { 269 selectChildren.select2({ 270 minimumResultsForSearch: -1 271 }); 272 } 273 274 275 //INIT DATE CHECK-IN FIELD 276 if(minDate.length) { 277 minDate.datepicker({ 278 minDate : '0', 279 dateFormat: 'MM dd, yy' 280 }) 281 } 282 283 //INIT DATE CHECK-OUT FIELD 284 if(maxDate.length) { 285 maxDate.datepicker({ 286 minDate : '+1d', 287 dateFormat: 'MM dd, yy' 288 }) 289 } 290 291 allInputs.change(function() { 292 // reset buttons on reservation form when something is changed 293 finishForm.addClass('mkdf-disable-hotel-room-single-btn'); 294 relocationButton.addClass('mkdf-disable-hotel-room-single-btn'); 295 }); 296 297 form.on('submit', function(e) { 298 299 var thisForm = $(this); 300 301 e.preventDefault(); 302 e.stopPropagation(); 303 304 var ajaxData = { 305 action: 'check_hotel_room_booking' 306 }; 307 308 // get all inputs 309 ajaxData.fields = thisForm.serialize(); 310 311 $.ajax({ 312 type: 'POST', 313 data: ajaxData, 314 url: mkdfGlobalVars.vars.mkdfAjaxUrl, 315 success: function (data) { 316 var response = $.parseJSON(data); 317 318 if(!response.status) { 319 updateValidationTemplate(formValidation, response.messages); 320 321 finishForm.addClass('mkdf-disable-hotel-room-single-btn'); 322 323 if(response.relocation === 'hotel_search') { 324 // enable relocation 325 relocationButton.removeClass('mkdf-disable-hotel-room-single-btn'); 326 } else { 327 // leave only check reservation 328 relocationButton.addClass('mkdf-disable-hotel-room-single-btn'); 329 } 330 331 } else { 332 333 // reset all messages 334 updateValidationTemplate(formValidation, []); 335 336 // enable add to cart
337 relocationButton.addClass('mkdf-disable-hotel-room-single-btn'); 338 339 finishForm.removeClass('mkdf-disable-hotel-room-single-btn'); 340 341 if(response.newPrice !== '') { 342 // set new price 343 endPrice.html(response.newPrice); 344 } 345 } 346 347 // added to reservation holder data 348 setDataForBooking(thisReservationHolder, thisForm); 349 } 350 }); 351 }); 352 353 relocationButton.on('click', function (e) { 354 e.preventDefault(); 355 e.stopPropagation(); 356 357 var thisButton = $(this); 358 var data = thisReservationHolder.data(); 359 360 var searchLink = thisButton.attr('href'); 361 362 var i = 0; 363 // creating link and 'get' data 364 $.each(data, function(index, value) { 365 if(i++ === 0) { 366 searchLink+= '?'; 367 } else { 368 searchLink+= '&'; 369 } 370 searchLink += index + '=' + value; 371 }); 372 373 window.location = searchLink; 374 }); 375 }); 376 } 377 378 var updateValidationTemplate = function (formValidation, messages) { 379 var html = ''; 380 381 for(var i = 0; i < messages.length; i++) { 382 html += '<div class="mkdf-reservation-messages">' + messages[i] + '</div>'; 383 } 384 385 formValidation.html(html); 386 }; 387 388 var setDataForBooking = function (holder, form) { 389 holder.data('min_date', form.find('input[name="room_min_date"]').val()); 390 holder.data('max_date', form.find('input[name="room_max_date"]').val()); 391 holder.data('rooms_number', form.find('select[name="room_number"]').val()); 392 holder.data('adults', form.find('select[name="room_adults"]').val()); 393 holder.data('children', form.find('select[name="room_children"]').val()); 394 } 395 } 396 397})(jQuery); 398(function($) { 399 'use strict'; 400 401 var hotelRoomFilter = {}; 402 mkdf.modules.hotelRoomFilter = hotelRoomFilter; 403 404 hotelRoomFilter.mkdfOnDocumentReady = mkdfOnDocumentReady; 405 406 $(document).ready(mkdfOnDocumentReady); 407 408 /* 409 All functions to be called on $(document).ready() should be in this function 410 */ 411 function mkdfOnDocumentReady() { 412 mkdfInitHotelRoomFilter(); 413 } 414 415 function mkdfInitHotelRoomFilter() { 416 var filters = $('.mkdf-hotel-filters'); 417 418 if (filters.length) { 419 filters.each(function () { 420 var filter = $(this), 421 roomNumber = filter.find('.mkdf-filter-rooms-number'), 422 location = filter.find('.mkdf-filter-location'), 423 adults = filter.find('.mkdf-filter-adults'), 424 children = filter.find('.mkdf-filter-children'), 425 minDate = filter.find('.mkdf-filter-min-date'), 426 maxDate = filter.find('.mkdf-filter-max-date'); 427 428 //INIT ROOMS FIELD 429 430 var selectRoomNumber = roomNumber; 431 if (selectRoomNumber.length) { 432 selectRoomNumber.select2({ 433 minimumResultsForSearch: -1 434 }); 435 } 436 437 //INIT LOCATION FIELD 438 439 var selectLocation = location; 440 if (selectLocation.length) { 441 selectLocation.select2({ 442 minimumResultsForSearch: -1 443 }); 444 } 445 446 //INIT ADULTS FIELD 447 448 var selectAdults = adults; 449 if (selectAdults.length) { 450 selectAdults.select2({ 451 minimumResultsForSearch: -1 452 }); 453 } 454 455 //INIT ADULTS FIELD 456 457 var selectChildren = children; 458 if (selectChildren.length) { 459 selectChildren.select2({ 460 minimumResultsForSearch: -1 461 }); 462 } 463 464 //INIT DATE CHECK-IN FIELD 465 if (minDate.length) { 466 minDate.datepicker({ 467 minDate: '0', 468 dateFormat: 'MM dd, yy' 469 }); 470 } 471 472 //INIT DATE CHECK-OUT FIELD 473 if (maxDate.length) { 474 maxDate.datepicker({ 475 minDate: '+1d', 476 dateFormat: 'MM dd, yy' 477 }); 478 } 479 }); 480 } 481 } 482 483})(jQuery); 484(function($) { 485 'use strict'; 486 487 var hotelRoomList = {}; 488 mkdf.modules.hotelRoomList = hotelRoomList; 489 490 hotelRoomList.mkdfOnDocumentReady = mkdfOnDocumentReady; 491 hotelRoomList.mkdfOnWindowLoad = mkdfOnWindowLoad; 492 hotelRoomList.mkdfOnWindowScroll = mkdfOnWindowScroll; 493 494 $(document).ready(mkdfOnDocumentReady); 495 $(window).load(mkdfOnWindowLoad); 496 $(window).scroll(mkdfOnWindowScroll); 497 498 /* 499 All functions to be called on $(document).ready() should be in this function 500 */ 501 function mkdfOnDocumentReady() { 502 mkdfInitRangeSlider(); 503 504 } 505 506 /* 507 All functions to be called on $(window).load() should be in this function 508 */ 509 function mkdfOnWindowLoad() { 510 mkdfInitHotelRoomListFilter(); 511 mkdfInitHotelRoomListPagination().init(); 512 } 513 514 /* 515 All functions to be called on $(window).scroll() should be in this function 516 */ 517 function mkdfOnWindowScroll() { 518 mkdfInitHotelRoomListPagination().scroll(); 519 } 520 521 function mkdfInitHotelRoomListAnimation(thisHotelRoomListInner) { 522 setTimeout(function () {
523 thisHotelRoomListInner.find('article').addClass('mkdf-hrl-item-showed'); 524 }, 100); // fake animation 525 526 } 527 528 function mkdfInitRangeSlider(){ 529 530 var selectorHolder = $('.mkdf-hrl-filter-part .mkdf-filter-price-holder'); 531 var slider = selectorHolder.find('.mkdf-range-slider'); 532 var outputMin = selectorHolder.find('#mkdf-min-price-value'); 533 var valueMin = outputMin.data('min-price'); 534 var outputMax = selectorHolder.find('#mkdf-max-price-value'); 535 var valueMax = outputMax.data('max-price'); 536 var currency = selectorHolder.data('currency'); 537 538 var maxPriceSetting = selectorHolder.data('max-price-setting'); 539 540 // Basic rangeslider initialization 541 542 slider.slider({ 543 range: true, 544 animate: true, 545 min: 0, 546 max: maxPriceSetting, 547 step: 25, 548 values: [ valueMin, valueMax], 549 create: function() { 550 551 }, 552 slide: function( event, ui ) { 553 outputMin.html(currency + "" + ui.values[0] ); 554 outputMax.html(currency + "" + ui.values[1] ); 555 }, 556 change: function( event, ui ) { 557 outputMin.data('min-price', ui.values[0] ); 558 outputMax.data('max-price', ui.values[1] ); 559 } 560 }); 561 } 562 563 function mkdfInitHotelRoomListFilter() { 564 var hotelRoomListHolder = $('.mkdf-hrl-holder'); 565 if (hotelRoomListHolder.length) { 566 hotelRoomListHolder.each(function () { 567 var thisHotelRoomList = $(this), 568 thisFilter = $(this).find('.mkdf-hrl-filter-part'), 569 thisSorter = $(this).find('.mkdf-hrl-sort-part'), 570 button = '', // this will be used for filter 571 sortItems = ''; // this will be used for sorting 572 573 if (thisFilter.length) { 574 575 var location = thisFilter.find('.mkdf-filter-location-holder'), 576 numberOfRooms = thisFilter.find('.mkdf-filter-room-count-holder'), 577 minPrice = thisFilter.find('#mkdf-min-price-value'), 578 maxPrice = thisFilter.find('#mkdf-max-price-value'), 579 minDate = thisFilter.find('.mkdf-min-date'), 580 maxDate = thisFilter.find('.mkdf-max-date'), 581 adults = thisFilter.find('.mkdf-filter-adults-count-holder'), 582 children = thisFilter.find('.mkdf-filter-children-count-holder'); 583 584 button = thisFilter.find('.mkdf-hr-filter-button'); 585 586 //INIT LOCATION FIELD 587 var selectLocation = location.find('select'); 588 if (selectLocation.length) { 589 selectLocation.select2({ 590 minimumResultsForSearch: -1 591 }).on('select2:select', function (e) { 592 var selectedElement = $(e.currentTarget); 593 var selectVal = selectedElement.val(); 594 location.data('location', selectVal); 595 }); 596 } 597 598 //INIT NUMBER OF ROOMS FIELD 599 var selectNumberOfRooms = numberOfRooms.find('select'); 600 if (selectNumberOfRooms.length) { 601 selectNumberOfRooms.select2({ 602 minimumResultsForSearch: -1 603 }).on('select2:select', function (e) { 604 var selectedElement = $(e.currentTarget); 605 var selectVal = selectedElement.val(); 606 numberOfRooms.data('room-count', selectVal); 607 }); 608 } 609 610 //INIT ADULTS FIELD 611 var selectAdults = adults.find('select'); 612 if (selectAdults.length) { 613 selectAdults.select2({ 614 minimumResultsForSearch: -1 615 }).on('select2:select', function (e) { 616 var selectedElement = $(e.currentTarget); 617 var selectVal = selectedElement.val(); 618 adults.data('adults', selectVal); 619 }); 620 } 621 622 //INIT ADULTS FIELD 623 var selectChildren = children.find('select'); 624 if (selectChildren.length) { 625 selectChildren.select2({ 626 minimumResultsForSearch: -1 627 }).on('select2:select', function (e) { 628 var selectedElement = $(e.currentTarget); 629 var selectVal = selectedElement.val(); 630 children.data('children', selectVal); 631 }); 632 } 633 634 //INIT DATE CHECK-IN FIELD 635 if (minDate.length) { 636 minDate.datepicker({ 637 minDate: '0', 638 dateFormat: 'MM dd, yy' 639 }).change(function (e) { 640 var selectedElement = $(e.currentTarget); 641 var selectVal = selectedElement.val(); 642 minDate.data('min-date', selectVal); 643 }) 644 } 645 646 //INIT DATE CHECK-OUT FIELD 647 if (maxDate.length) { 648 maxDate.datepicker({ 649 minDate: '+1d', 650 dateFormat: 'MM dd, yy' 651 }).change(function (e) { 652 var selectedElement = $(e.currentTarget); 653 var selectVal = selectedElement.val(); 654 maxDate.data('max-date', selectVal); 655 }) 656 } 657 658 // call ajax in case if filter button is clicked 659 button.on('click', function () { 660 661 sortItems = thisHotelRoomList.find('.mkdf-hrl-sort-part-item');
662 sortItems.removeClass('mkdf-hrl-sort-part-item-active'); 663 thisHotelRoomList.find('.mkdf-hrl-sort-part-item:first-child').addClass('mkdf-hrl-sort-part-item-active'); 664 665 var locationValue = location.data('location'), 666 numberOfRoomsValue = numberOfRooms.data('room-count'), 667 minPriceValue = minPrice.data('min-price'), 668 maxPriceValue = maxPrice.data('max-price'), 669 minDateValue = minDate.val(), 670 maxDateValue = maxDate.val(), 671 adultsValue = adults.data('adults'), 672 childrenValue = children.data('children'), 673 amenities = [], 674 extraServices = [], 675 order = '', 676 orderBy = ''; 677 678 $("input[name='mkdf-amenities[]']:checked").each(function () { 679 amenities.push(parseInt($(this).data('id'))); 680 }); 681 amenities = amenities.join(','); 682 683 684 $("input[name='mkdf-extra-services[]']:checked").each(function () { 685 extraServices.push(parseInt($(this).data('id'))); 686 }); 687 extraServices = extraServices.join(','); 688 689 thisHotelRoomList.data('room-location', locationValue !== 'undefined' && locationValue !== false && locationValue !== '' ? locationValue : ''); 690 thisHotelRoomList.data('room-number-of-rooms', numberOfRoomsValue); 691 thisHotelRoomList.data('room-min-price', minPriceValue); 692 thisHotelRoomList.data('room-max-price', maxPriceValue); 693 thisHotelRoomList.data('room-min-date', minDateValue); 694 thisHotelRoomList.data('room-max-date', maxDateValue); 695 thisHotelRoomList.data('room-adults', adultsValue); 696 thisHotelRoomList.data('room-children', childrenValue); 697 thisHotelRoomList.data('room-amenities', amenities); 698 thisHotelRoomList.data('room-extra-services', extraServices); 699 thisHotelRoomList.data('order', order); 700 thisHotelRoomList.data('order-by', orderBy); 701 702 mkdfInitHotelRoomListPagination().getMainPagFunction(thisHotelRoomList, 1, true); 703 704 }); 705 } 706 707 if (thisSorter.length) { 708 sortItems = thisHotelRoomList.find('.mkdf-hrl-sort-part-item'); 709 710 var sortOption; 711 712 // call ajax in case if sort items is change 713 sortItems.on('click', function () { 714 sortItems.removeClass('mkdf-hrl-sort-part-item-active'); 715 $(this).addClass('mkdf-hrl-sort-part-item-active'); 716 717 sortOption = $(this).data('sort'); 718 719 thisHotelRoomList.data('sort-option', sortOption); 720 721 mkdfInitHotelRoomListPagination().getMainPagFunction(thisHotelRoomList, 1); 722 }); 723 } 724 }); 725 } 726 } 727 728 /** 729 * Initializes property list pagination functions 730 */ 731 function mkdfInitHotelRoomListPagination(){ 732 var hotelRoomList = $('.mkdf-hrl-holder'); 733 mkdfInitHotelRoomListAnimation( hotelRoomList.find('.mkdf-hrl-inner')); 734 735 var initStandardPagination = function(thisHotelRoomList) { 736 var standardLink = thisHotelRoomList.find('.mkdf-hrl-standard-pagination li'); 737 738 if(standardLink.length) { 739 standardLink.each(function(){ 740 var thisLink = $(this).children('a'), 741 pagedLink = 1; 742 743 thisLink.on('click', function(e) { 744 e.preventDefault(); 745 e.stopPropagation(); 746 747 if (typeof thisLink.data('paged') !== 'undefined' && thisLink.data('paged') !== false) { 748 pagedLink = thisLink.data('paged'); 749 } 750 751 initMainPagFunctionality(thisHotelRoomList, pagedLink); 752 }); 753 }); 754 } 755 }; 756 757 var initLoadMorePagination = function(thisHotelRoomList) { 758 var loadMoreButton = thisHotelRoomList.find('.mkdf-hrl-load-more a'); 759
760 loadMoreButton.on('click', function(e) { 761 e.preventDefault(); 762 e.stopPropagation(); 763 764 initMainPagFunctionality(thisHotelRoomList); 765 }); 766 }; 767 768 var initInifiteScrollPagination = function(thisHotelRoomList) { 769 770 var hotelRoomListHeight = thisHotelRoomList.outerHeight(), 771 hotelRoomListTopOffest = thisHotelRoomList.offset().top, 772 hotelRoomListPosition = hotelRoomListHeight + hotelRoomListTopOffest - mkdfGlobalVars.vars.mkdfAddForAdminBar, 773 hotelRoomListInfinityError = 200; 774 775 if(!thisHotelRoomList.hasClass('mkdf-hrl-infinite-scroll-started') && mkdf.scroll + mkdf.windowHeight > (hotelRoomListPosition - hotelRoomListInfinityError)) { 776 initMainPagFunctionality(thisHotelRoomList); 777 } 778 }; 779 780 var initMainPagFunctionality = function(thisHotelRoomList, pagedLink, newPagination) { 781 782 783 var thisHotelRoomListInner = thisHotelRoomList.find('.mkdf-hrl-inner'), 784 nextPage, 785 maxNumPages, 786 thisHotelRoomPagination = thisHotelRoomList.find('.mkdf-hrl-pagination-holder'); 787 if (typeof thisHotelRoomList.data('max-num-pages') !== 'undefined' && thisHotelRoomList.data('max-num-pages') !== false) { 788 maxNumPages = thisHotelRoomList.data('max-num-pages'); 789 } 790 791 if(thisHotelRoomList.hasClass('mkdf-hrl-pag-standard')) { 792 thisHotelRoomList.data('next-page', pagedLink); 793 } 794 795 if(thisHotelRoomList.hasClass('mkdf-hrl-pag-infinite-scroll')) { 796 thisHotelRoomList.addClass('mkdf-hrl-infinite-scroll-started'); 797 } 798 799 if(pagedLink == 1) { 800 thisHotelRoomList.data('next-page', pagedLink); 801 } 802 803 var loadMoreDatta = mkdf.modules.common.getLoadMoreData(thisHotelRoomList), 804 loadingItem = thisHotelRoomList.find('.mkdf-hrl-loading'); 805 806 nextPage = loadMoreDatta.nextPage; 807 808 if(nextPage <= maxNumPages || maxNumPages == 0){ 809 if(thisHotelRoomList.hasClass('mkdf-hrl-pag-standard')) { 810 loadingItem.addClass('mkdf-showing mkdf-standard-pag-trigger'); 811 thisHotelRoomList.addClass('mkdf-hrl-pag-standard-animate'); 812 } else { 813 loadingItem.addClass('mkdf-showing'); 814 } 815 816 var ajaxData = mkdf.modules.common.setLoadMoreAjaxData(loadMoreDatta, 'mkdf_hotel_room_hrl_ajax_load_more'); 817 818 if(newPagination === true) { 819 ajaxData['newPagination'] = 'yes'; 820 } 821 822 $.ajax({ 823 type: 'POST', 824 data: ajaxData, 825 url: mkdfGlobalVars.vars.mkdfAjaxUrl, 826 success: function (data) { 827 if(!thisHotelRoomList.hasClass('mkdf-hrl-pag-standard')) { 828 nextPage++; 829 } 830 831 thisHotelRoomList.data('next-page', nextPage); 832 833 var response = $.parseJSON(data), 834 responseHtml = response.html; 835 836 if(thisHotelRoomList.hasClass('mkdf-hrl-pag-standard') || pagedLink == 1) { 837 mkdfInitStandardPaginationLinkChanges(thisHotelRoomList, maxNumPages, nextPage); 838 839 thisHotelRoomList.waitForImages(function(){ 840 mkdfInitHtmlGalleryNewContent(thisHotelRoomList, thisHotelRoomListInner, loadingItem, responseHtml); 841 }); 842 } else { 843 thisHotelRoomList.waitForImages(function(){ 844 mkdfInitAppendGalleryNewContent(thisHotelRoomList, thisHotelRoomListInner, loadingItem, responseHtml); 845 }); 846 } 847 848 if(newPagination === true) { 849 if(thisHotelRoomPagination.length) { 850 mkdfInitAppendPaginationContent(thisHotelRoomList, thisHotelRoomPagination, response.pagination); 851 } 852 } 853
854 if(thisHotelRoomList.hasClass('mkdf-hrl-infinite-scroll-started')) { 855 thisHotelRoomList.removeClass('mkdf-hrl-infinite-scroll-started'); 856 } 857 } 858 }); 859 } 860 861 if(pagedLink === 1) { 862 thisHotelRoomList.find('.mkdf-hrl-load-more-holder').show(); 863 } 864 865 if(nextPage === maxNumPages){ 866 thisHotelRoomList.find('.mkdf-hrl-load-more-holder').hide(); 867 } 868 }; 869 870 var mkdfInitStandardPaginationLinkChanges = function(thisHotelRoomList, maxNumPages, nextPage) { 871 var standardPagHolder = thisHotelRoomList.find('.mkdf-hrl-standard-pagination'), 872 standardPagNumericItem = standardPagHolder.find('li.mkdf-hrl-pag-number'), 873 standardPagPrevItem = standardPagHolder.find('li.mkdf-hrl-pag-prev a'), 874 standardPagNextItem = standardPagHolder.find('li.mkdf-hrl-pag-next a'); 875 876 standardPagNumericItem.removeClass('mkdf-hrl-pag-active'); 877 standardPagNumericItem.eq(nextPage-1).addClass('mkdf-hrl-pag-active'); 878 879 standardPagPrevItem.data('paged', nextPage-1); 880 standardPagNextItem.data('paged', nextPage+1); 881 882 if(nextPage > 1) { 883 standardPagPrevItem.css({'opacity': '1'}); 884 } else { 885 standardPagPrevItem.css({'opacity': '0'}); 886 } 887 888 if(nextPage === maxNumPages) { 889 standardPagNextItem.css({'opacity': '0'}); 890 } else { 891 standardPagNextItem.css({'opacity': '1'}); 892 } 893 }; 894 895 var mkdfInitHtmlGalleryNewContent = function(thisHotelRoomList, thisHotelRoomListInner, loadingItem, responseHtml) { 896 loadingItem.removeClass('mkdf-showing mkdf-standard-pag-trigger'); 897 thisHotelRoomList.removeClass('mkdf-hrl-pag-standard-animate'); 898 thisHotelRoomListInner.html(responseHtml); 899 900 mkdfInitHotelRoomListAnimation(thisHotelRoomListInner); 901 mkdf.modules.common.mkdfInitParallax(); 902 }; 903 904 var mkdfInitAppendGalleryNewContent = function(thisHotelRoomList, thisHotelRoomListInner, loadingItem, responseHtml) { 905 loadingItem.removeClass('mkdf-showing'); 906 thisHotelRoomListInner.append(responseHtml); 907 908 mkdfInitHotelRoomListAnimation(thisHotelRoomListInner); 909 mkdf.modules.common.mkdfInitParallax(); 910 }; 911 912 var mkdfInitAppendPaginationContent = function(thisHotelRoomList, thisHotelRoomPagination, pagination) { 913 thisHotelRoomPagination.html(pagination.paginationHtml); 914 thisHotelRoomList.data('max-num-pages', pagination.maxNumPages) 915 916 mkdfInitHotelRoomListPagination().init(); 917 }; 918 919 return { 920 init: function() { 921 if(hotelRoomList.length) { 922 hotelRoomList.each(function() { 923 var thisHotelRoomList = $(this); 924 925 if(thisHotelRoomList.hasClass('mkdf-hrl-pag-standard')) { 926 initStandardPagination(thisHotelRoomList); 927 } 928 929 if(thisHotelRoomList.hasClass('mkdf-hrl-pag-load-more')) { 930 initLoadMorePagination(thisHotelRoomList); 931 } 932 933 if(thisHotelRoomList.hasClass('mkdf-hrl-pag-infinite-scroll')) { 934 initInifiteScrollPagination(thisHotelRoomList); 935 } 936 }); 937 } 938 }, 939 scroll: function() { 940 if(hotelRoomList.length) { 941 hotelRoomList.each(function() { 942 var thisHotelRoomList = $(this); 943 944 if(thisHotelRoomList.hasClass('mkdf-hrl-pag-infinite-scroll')) { 945 initInifiteScrollPagination(thisHotelRoomList); 946 } 947 }); 948 } 949 }, 950 getMainPagFunction: function(thisHotelRoomList, paged, newPagination) { 951 initMainPagFunctionality(thisHotelRoomList, paged, newPagination); 952 } 953 }; 954 } 955 956})(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.