logo-img
logo-img
'); $sub.append($class); $cont.append($sub); $parent.append($cont); count++; } $('.cont input').change(function() { $(this).closest('.cont-parent').find('.dest input').prop('checked', this.checked); loadTours(); }); $('.dest input').change(loadTours); if (destination_filter.length) { $("#destinations").find(destination_filter).prop('checked', true).trigger('change'); } var $priceRange = $('#price--range'); $priceRange.slider({ range: true, min: info.price.min, max: info.price.max, step: 100, values: [info.price.min, info.price.max], slide: function(event, ui) { if (ui.values[0] == info.price.max) { $('#price-ammount span').html(ui.values[0] + '+'); } else { $('#price-ammount span').html(ui.values[0] + ' - ' + ui.values[1]); } loadTours(); } }); $('#price-ammount span').html(info.price.min + ' - ' + info.price.max); if (price_range.length) { price_range = price_range.split('-'); if (price_range[1] === "0") { price_range[1] = info.price.max; } $priceRange.slider('values', 0, price_range[0]); $priceRange.slider('values', 1, price_range[1]); $priceRange.slider('option', 'slide').call($dateRange, null, { value: price_range[0], values: price_range }); } var $dateRange = $('#date-range'); $dateRange.slider({ range: true, min: 0, max: info.dates.delta, values: [0, info.dates.delta], slide: function(event, ui) { var sd = new Date(info.dates.min); var dte1 = new Date(sd.getFullYear(), sd.getMonth() + parseInt(ui.values[0]), 1); var dte2 = new Date(sd.getFullYear(), sd.getMonth() + parseInt(ui.values[1]), 1); $('#date-ammount span').html(months[dte1.getMonth()] + ' ' + dte1.getFullYear() + ' - ' + months[dte2.getMonth()] + ' ' + dte2.getFullYear()); loadTours(); } }); var sd = new Date(info.dates.min); var dte1 = new Date(sd.getFullYear(), sd.getMonth(), 1); var dte2 = new Date(sd.getFullYear(), sd.getMonth() + info.dates.delta, 1); $('#date-ammount span').html(months[dte1.getMonth()] + ' ' + dte1.getFullYear() + ' - ' + months[dte2.getMonth()] + ' ' + dte2.getFullYear()); if (date_range.length) { date_range = date_range.split('-'); $dateRange.slider('values', 0, date_range[0]); $dateRange.slider('values', 1, date_range[1]); $dateRange.slider('option', 'slide').call($dateRange, null, { value: date_range[0], values: date_range }); } $('#duration-range').slider({ range: true, min: info.duration.min, max: info.duration.max, values: [info.duration.min, info.duration.max], slide: function(event, ui) { $('#duration-ammount span').html(ui.values[0] + ' - ' + ui.values[1]); loadTours(); } }); $('#duration-ammount span').html(info.duration.min + ' - ' + info.duration.max); var $lead = $('#leaders'); $lead.append(''); for (let i in info.leaders) { var lead = info.leaders[i]; $lead.append(''); } //$('#group-range').slider({ // range: true, // min: info.group.min, // max: info.group.max, // values: [info.group.min, info.group.max], // slide: function(event, ui) { // if (ui.values[0] == info.group.max){ // $('#group-ammount span').html(ui.values[0]+'+'); // } else { // $('#group-ammount span').html(ui.values[0]+' - '+ui.values[1]); // } // // loadTours(); // } //}); //$('#group-ammount span').html(info.group.min+' - '+info.group.max); var $cat = $('#categories'); var category = ""; for (let i in info.categories) { var cat = info.categories[i]; $cat.append('
'); if (category == cat.id) { $(`#cat${i}`).prop('checked', true); } } // one type --> many options var $type_options = { 65: [4, 5, 6], '#': [1, 3, 7, 2] }; var $opt = $('#options'); for (let i in info.options) { var opt = info.options[i]; var show_option = true; for (var k in $type_options) { for (var idx = 0; idx < $type_options[k].length; idx++) { if ($type_options[k][idx] === opt.id) { show_option = false; if (k === '#') { info.options[i].show_in_filter = '1'; info.options[i].is_option = '1'; info.type.push(info.options[i]); } } } } if (show_option) { var checked = ''; if (options_filter === "" + opt.id) { checked = 'checked'; } $opt.append('
'); } } info.type.sort(function(a, b) { var tA = a.title.toUpperCase(); var tB = b.title.toUpperCase(); return (tA < tB) ? -1 : (tA > tB) ? 1 : 0; }); var $type = $('#types'); for (let i in info.type) { var type = info.type[i]; if (type.show_in_filter === "1") { var checked = ''; if (type_filter === "" + type.id) { checked = 'checked'; } var is_option = ''; if (type.is_option) { is_option = 'data-type="option"'; if (options_filter === "" + type.id) { checked = 'checked'; } } $type.append('
'); for (var type_id in $type_options) { if (type.id === type_id) { for (var idx in info.options) { var opt = info.options[idx]; if ($type_options[type_id].indexOf(opt.id) !== -1) { $(document).find('.type_cont:last-child').append('
'); } } } } if (checked === "checked") { $('#types .type_cont:last-child').find('.type_sub input').prop('checked', true); } } } $('#types > .type_cont > input').change(function() { $(this).parent().find('.type_sub input').prop('checked', this.checked); loadTours(); }); $('#categories input, #options input, #types > .type_cont > .type_sub > input').click(loadTours); // getTours(); if (current_destination_id != "") { // Change the value of the custom variable $('#sort').val('website_rank_order'); $('#order').val('asc'); getTours(); } else { getTours(); } }); $('#leaders').change(function() { var $this = $(this); if ($this.val()) { var $opt = $this.find('option:selected'); var $row = $('
' + '
'); $('#selected-leaders').append($row); $row.find('input').click(function() { if (!this.checked) { $(this).closest('div').remove(); loadTours(); } }); $this.val(''); loadTours(); } }); $('#sort, #order').change(loadTours); $('#content .loader-here').append('
'); $('#btn-filters').click(function() { $('#sidebar').removeClass('shid').addClass('sshw'); $('#content').removeClass('sshw').addClass('shid'); }); $('#btn-apply').click(function() { $('#sidebar').removeClass('sshw').addClass('shid'); $('#content').removeClass('shid').addClass('sshw'); }); var $win = $(window); $win.scroll(function() { var $result = $('.tours_list').find('.results'); if ($result.length) { if ($win.scrollTop() > ($result.offset().top + $result.height()) - 300) { showTours(); } } }); //showTours(); }); }); function loadTours() { if (loader) { clearTimeout(loader); } loader = setTimeout(getTours, 2000); } function getTours() { var $list = $(".tours_list"); $list.html('
'); if (view === 'grid') { $list.append('
'); } else { $list.append('
'); } var sd = new Date(info.dates.min); var dte1 = new Date(sd.getFullYear(), sd.getMonth() + $('#date-range').slider('values', 0), 1); var dte2 = new Date(sd.getFullYear(), sd.getMonth() + $('#date-range').slider('values', 1), 1); data = { sort: $('#sort').val(), order: $('#order').val(), destinations: [], company:2, price: { min: $('#price--range').slider('values', 0), max: $('#price--range').slider('values', 1) }, date: { min: dte1.getTime(), max: dte2.getTime() }, duration: { min: $('#duration-range').slider('values', 0), max: $('#duration-range').slider('values', 1) }, leaders: [], //group: { // min: $('#group-range').slider('values', 0), // max: $('#group-range').slider('values', 1) //}, categories: [], options: [], type: [], merge: true }; $('#destinations .dest input:checked').each(function() { if (this.checked) { data.destinations[data.destinations.length] = $(this).val(); } }); $('#selected-leaders input').each(function() { if (this.checked) { data.leaders[data.leaders.length] = $(this).val(); } }); $('#categories input').each(function() { if (this.checked) { data.categories[data.categories.length] = $(this).val(); } }); $('#options input').each(function() { if (this.checked) { data.options[data.options.length] = $(this).val(); } }); $('#types .type_sub > input, #types > .type_cont > input[data-type="option"]').each(function() { if (this.checked) { data.options[data.options.length] = $(this).val(); } }); $('#types > .type_cont > input').each(function() { if (this.checked && $(this).attr('data-type') !== 'option') { data.type[data.type.length] = $(this).val(); } }); $('#loader').show(); $.ajax({ 'url': 'https://app.rockjumperbirding.com/' + 'tour-filter_list/rawpost/1/', 'method': 'POST', 'data': data, beforeSend: function() { $('.pagination-page').hide(); }, 'success': function(tours) { $('.tours_list').find('.results .tour-itm').remove(); tourList = tours; tourPos = 0; showTours(); $('.pagination-page').show(); $('#loader').hide(); }, complete: function() { // $(".tours_list").pagify(5, " div.results > article"); } }); } $(document).on('rj.get.tours', function(e) { if ($(e.target.activeElement).hasClass('link-grid')) { view = 'grid'; } else { view = 'list'; } getTours(); }); $('.listViewIcon .link').click(function(e) { e.preventDefault(); if ($(this).hasClass('link-grid')) { view = 'grid'; } else { view = 'list'; } $('.listViewIcon .link').removeClass('active'); $('.listViewIcon .link-' + view).addClass('active'); getTours(); }); function showTours() { $('.popupLoader').remove(); if (!tourList) { return; } var $list = $('.tours_list').find('.results'); var end = tourList.length < tourPos + 9 ? tourList.length : tourPos + 9; //var end = tourList.length; for (tourPos; tourPos < end; tourPos++) { var t = tourList[tourPos]; if (view === 'grid') { $list.append(TourView(t, 'https://www.rockjumperbirding.com', wishList, wishHref)); } else { $list.append(TourView(t, 'https://www.rockjumperbirding.com', wishList, wishHref)); } } if (!tourList.length) { if (view === 'grid') { $list.html(getNoToursView(info, data)); var items = $(".tours_list > div.grid > div.results > div.pageload"); } else { $list.html(getNoToursView(info, data)); var items = $(".tours_list > div.list-view > div.results > div.pageload"); } } // if (view === 'grid') { // var itemDiv = $(".tours_list > div.grid > div.results > div.pageload"); // } else { // var itemDiv = $(".tours_list > div.list-view > div.results > div.pageload"); // } $('.result-info span').text(tourList.length); /* var items = itemDiv; var numItems = items.length; //total items var perPage = 9; //per page var startindex = 0; totalPages = Math.floor(numItems / perPage); currentPage = Math.ceil(startindex / perPage); if(numItems < perPage){ $('.pagination-page').css('visibility', 'hidden'); }else{ items.slice(perPage).hide(); $(".pagination-page").pagination({ items: numItems, itemsOnPage: perPage, cssStyle: "light-theme", onPageClick: function(pageNumber) { var showFrom = ((pageNumber-1) * perPage); var showTo = (showFrom + perPage) ; items.hide().slice(showFrom, showTo).show(); $('html, body').animate({ scrollTop: $(".tours_list").offset().top - 250 }, 500); } }); }*/ // $(".tours_list").pagify(9, " div.results > article"); window.history.replaceState(null, '', window.location.pathname); } })(jQuery);

Get Special Offers From Rockjumper Birding

Sign up now and get the best deals straight in your inbox!

shape shape