base_url='https://www.triptoto.com/'; window.fbAsyncInit = function() { FB.init({ appId : '3938108099589652', cookie : true, xfbml : true, version : 'v10.0' }); FB.getLoginStatus(function(response) { if (response && response.status === "connected") { var payload={ type: 'GET', url: 'https://www.triptoto.com/facebookapp/autologin', async: true, success: function(response){ if(response.replace(/^\s+|\s+$/g, '')=='success'){ updateHeader(); } } }; webservice.ajax(payload); } }); }; jQuery(document).ready(function($){ $(document).bind('shrink-menu-init', function(e, status) { var topBarHeight = $('.navbar-extra-top').outerHeight(); // getting the height of the nabar-extra-top scrollMark = Math.max(topBarHeight, 30); // forced minimum of 30 style = ".menu-shrink {top : -"+topBarHeight+"px !important;}"; if ( !$('#ShrinkMenu').length ) { $( "" ).attr('id','ShrinkMenu').data('scrollMark',scrollMark).appendTo( "head" ); // add custom CSS for height offset } $('#ShrinkMenu').html(style); }); // navbar adjustments on scroll $(document).bind('shrink-menu', function(e, status){ scrollMark = $('#ShrinkMenu').data('scrollMark'); // when scroll hits height of navbar top, apply style changes if ( $(this).scrollTop() < scrollMark ) { $('#MainMenu').removeClass('scrolled menu-shrink'); } else { $('#MainMenu').addClass('scrolled menu-shrink'); } }); // trigger shrink-menu on scroll $(window).resize( function(){ $(document).trigger('shrink-menu-init'); }); $(window).scroll( function(){ $(document).trigger('shrink-menu'); }); if ($('#SubMenu').length) { $('#SubMenu').affix({ offset: { top: function () { return $('#SubMenu').parent().offset().top - $('#navbar-main-container').outerHeight(); }, } }).css('top',$('#navbar-main-container').outerHeight()); // Update values on window resize $(window).resize( function() { theTop = $('#SubMenu').parent().offset().top - $('#navbar-main-container').outerHeight(); $('#SubMenu').data('bs.affix').options.offset = { top: theTop }; }); } if ( $('.panel-heading').length ) { $('.panel-heading').on('click',function(e){ if($(this).parents('.panel').children('.panel-collapse').hasClass('in')){ e.preventDefault(); e.stopPropagation(); } }); } $('[data-toggle="tooltip"]').tooltip({ placement: function(tip, trigger) { // show above, unless no space. show bottom on affixed sub-nav return ( $(trigger).parents('#SubMenu.affix').length ) ? 'bottom' : 'auto top'; } }); if ( $('.featured-carousel').length ) { $(".featured-carousel").owlCarousel({ items: 1, loop: true, autoplay: true, autoplayHoverPause: true, autoplayTimeout: 3800, autoplaySpeed: 800, navSpeed: 1000, dots: true, nav: true, navText: [ '', '' ] }); } collapseSize = 1299; // 768; // hover sub-menu items $('.navbar-nav a').click( function(e) { $this = $(e.target); href = $this.attr('href'); // Link URL // Check link value if (href === undefined || !href.length || href === '#' || href === 'javascript:;') { href = false; } // Link behavior if ($this.hasClass('dropdown-toggle')) { // Parent menu items if ($(window).width() > collapseSize) { if (href) { // large screens, follow the parent menu link when clicked if (e.which !== 2) { window.location.href = href; } } } else if ( $this.parent().hasClass('open') && href !== false) { // small screens, 1st tap opens sub-menu & 2nd tap follows link $(document).trigger('collapse-menus'); window.location.href = href; } } else { // All other menu items, close menu on click $(document).trigger('collapse-menus'); } }); // Keep parent menus open on sub-menu expand $(document).on('show.bs.dropdown', function(obj) { if ($(window).width() <= collapseSize) { $(obj.target).parents('.show-on-hover').addClass('open'); } }); $('.navbar a:not(.dropdown-toggle)').click( function(e) { $this = $(e.target); href = $this.attr('href'); // Link URL // Check link value if (href === undefined || !href.length || href === '#' || href === 'javascript:;') { href = false; } // Link behavior if ($(window).width() > collapseSize) { if (href) { // large screens, follow the parent menu link when clicked if (e.which !== 2) { window.location.href = href; } } } else if ( $this.parent().hasClass('open') && href !== false) { // small screens, 1st tap opens sub-menu & 2nd tap follows link $(document).trigger('collapse-menus'); window.location.href = href; } }); // Close all menus $(document).on('collapse-menus', function () { $('.collapse.in').removeClass('in').children().removeClass('open'); }); // Hover styling helpers $('.navbar-nav > li.show-on-hover').hover(function() { if ($(window).width() > collapseSize) { $(this).addClass('open'); } }, function() { if ($(window).width() > collapseSize) { $(this).removeClass('open'); } }); $(document).trigger('shrink-menu-init'); $(document).trigger('shrink-menu'); }); jQuery(document).ready(function(){ $(".destination-image").height($(".destination-image").width()); $(".input").focusin( function() { $(this).addClass("textarea",1000); }); $(".input").focusout( function() { $(this).removeClass("textarea",1000); }); $('#loginlink').click(function() { var payload={ type: 'GET', url: 'https://www.triptoto.com/user/islogin', async: true, success: function(response){ updateHeader(); } }; webservice.ajax(payload); }); $('#header_search_input').typeahead({ name: 'q', valueKey: 'name', remote: { url: '/site/search?ajax=true&q=%QUERY', filter: function (parsedResponse) { return parsedResponse.data; } }, template: [ '
{{name}}
' ].join(''), engine: Hogan }).on('typeahead:selected', function (obj, data) { if(data.type=='country') location.href=base_url+data.type+'/'+data.name.replace(/ /g,'-'); else if(data.type=='city' || data.type=='region' || data.type=='park') location.href=base_url+data.type+'/'+data.name.replace(/ /g,'-').toLowerCase(); else location.href=base_url+data.type+'/'+data.id+'/'+data.name.replace(/ /g,'-').toLowerCase(); }); $("img").unveil(); $(".entry-thumbnail").unveil(); $.ajaxSetup({ error: function(XMLHttpRequest, textStatus, errorThrown) { switch (XMLHttpRequest.status) { case 400: var errorObj = JSON.parse(XMLHttpRequest.responseText); toast(errorObj.message); break; case 401: loginpanel(true); break; case 500: toast('System error, please try it again later.'); break; default: toast('System error, please try it again later.'); break; } } }); }); $( document ).on( "click", ".tripday", function() { type=$(this).attr("rtype"); vid=$(this).attr("rid"); url=base_url+'trip/remove/'+type+'/temp/'+vid; var payload={ type: 'GET', url: url, async: true, success: function(response){ $('#tripdetailDiv').html(response); $('#trip_btn').val('Add to trip'); $('#trip_btn').attr("action","add"); //size=$('#tripdetailDiv').find(".tripday").length; //$('#tripsize').html(size); } }; webservice.ajax(payload); }); $( document ).on( "click", ".add_tip_btn", function() { $("#add_tip_panel").modal('show'); }); $( document ).on( "click", "#readmore", function() { $('.expendable').slideToggle("slow"); if($(this).html()=='more'){ $(this).html('less'); }else{ $(this).html('more'); } }); $( document ).on( "click", '#trip_btn',function() { type=$(this).attr("rtype"); vid=$(this).attr("rid"); if ($(this).attr("action") == "add") { url=base_url+'trip/add/'+type+'/temp/'+vid; var payload={ type: 'GET', url: url, async: true, success: function(response){ $('#tripdetailDiv').html(response); $('#trip_btn').val('Remove from trip'); $('#trip_btn').attr("action","remove"); toast("The item is added into your itinerary."); //size=$('#tripdetailDiv').find(".tripday").length; //$('#tripsize').html(size); } }; webservice.ajax(payload); }else { url=base_url+'trip/remove/'+type+'/temp/'+vid; var payload={ type: 'GET', url: url, async: true, success: function(response){ $('#tripdetailDiv').html(response); $('#trip_btn').val('Add to trip'); $('#trip_btn').attr("action","add"); toast("The item is removed from your itinerary."); //size=$('#tripdetailDiv').find(".tripday").length; //$('#tripsize').html(size); } }; webservice.ajax(payload); } }); function updateHeader(){ var payload={ type: 'GET', url: '/site/header', async: false, success: function(response){ $('#usernav').html(response); } }; webservice.ajax(payload); } function updateTripplanPanel(){ var payload={ type: 'GET', url: '/trip/tripplanpanel', success: function(response){ $('#tripdetailDiv').html(response); } }; webservice.ajax(payload); } function beenthere(type,id){ functionName='beenthere'; var payload={ url: base_url+'user/beenthere/add/'+type+'/'+id, success: function(response){ toast("Your information is saved."); } }; webservice.ajax(payload); } function wantgothere(type,id){ functionName='beenthere'; var payload={ url: base_url+'user/wantgothere/add/'+type+'/'+id, success: function(response){ toast("Your information is saved."); } }; webservice.ajax(payload); } function previewtrip(){ location.href="/trip_planner/edit/temp"; } function deleteMedia(type,pid){ var strCheck = confirm('Are you sure you want to delete this?'); if (strCheck == true){ var payload={ type: 'GET', url: '/'+type+'/delete/'+pid, async: true, dataType: 'json', success: function(response){ if(response.status=='success') $('#'+pid).remove(); else{ toast(response.message); } } }; webservice.ajax(payload); } } $( document ).on( "click", ".join_tripgroup_btn", function() { ajaxFormData=[]; var extTemplate = $('#trip_partner_template').html(); var template = Hogan.compile(extTemplate); data=new Array(); data['email']=''; data['aboutme']=''; var rendered = template.render(data); $('#join_trip_panel').html(rendered); $('#join_trip_panel').modal({ opacity:70, overlayCss: {backgroundColor:"#000"}, onClose: function(){ $('#join_trip_panel').find(":input").each(function(i) { if(undefined != $(this).attr("name")){ value=$(this).val(); name=$(this).attr("name"); ajaxFormData.push({ "name": name, "value": value }); } }); $.modal.close(); } }); }); $( document ).on( "click", ".edit_tripgroup_btn", function() { ajaxFormData=[]; var iid=$(this).attr("iid"); var payload={ type: 'GET', url: base_url+'trip/group/detail/'+iid, async: true, dataType: 'json', success: function(response){ if(response.status=='success'){ var extTemplate = $('#trip_partner_template').html(); var template = Hogan.compile(extTemplate); data=response.data; var rendered = template.render(data); $('#join_trip_panel').html(rendered); $('#join_trip_panel').modal({ opacity:70, overlayCss: {backgroundColor:"#000"} }); $('.out_tripgroup_btn').show(); }else{ toast(response.message); } } }; webservice.ajax(payload); }); function joinTrip(iid){ functionName='joinTrip'; functionParameters.push(iid); if($('#join_trip_panel').find(":input[name='email']").val()==''){ toast("Email is invalid. please enter a valid email address."); return; } if(ajaxFormData.length==0){ $('#join_trip_panel').find(":input").each(function(i) { if(undefined != $(this).attr("name")){ value=$(this).val(); name=$(this).attr("name"); ajaxFormData.push({ "name": name, "value": value }); } }); } var payload={ url: base_url+'trip_planner/participant/participantjoin/'+iid, type: 'post', data: ajaxFormData, async: false, dataType: 'json', success: function(res){ $.modal.close(); if(res.status=='success'){ toast(res.message); $(".join_tripgroup_btn").hide(); $(".edit_tripgroup_btn").show(); }else{ toast(res.message); } } }; webservice.ajax(payload); } function removeFromTrip(iid){ functionName='removeFromTrip'; functionParameters.push(iid); var r = confirm("Are your sure you want to be removed from this trip?"); if(r==false) return; var payload={ url: base_url+'trip_planner/participant/participantdelete/'+iid, type: 'post', data: data, async: false, success: function(response){ res = JSON && JSON.parse(response) || $.parseJSON(response); if(res.status=='success'){ $("#trippartner_"+res.user_id).remove(); $(".remove_tripgroup_btn").hide(); $.modal.close(); }else{ toast(res.message); } } }; webservice.ajax(payload); } function manageTripPartner(action, iid, uid){ var payload={ url: base_url+'trip/group/'+action+'/'+iid+'?user_id='+uid, async: false, success: function(response){ res = JSON && JSON.parse(response) || $.parseJSON(response); if(res.status=='success'){ toast(res.message); $(".partnerstatus").hide(); $(".partnerstatus[status='"+action+"']").show(); }else{ toast(res.message); } } }; webservice.ajax(payload); } jQuery.fn.selectText = function(){ var doc = document; var element = this[0]; if (doc.body.createTextRange) { var range = document.body.createTextRange(); range.moveToElementText(element); range.select(); } else if (window.getSelection) { var selection = window.getSelection(); var range = document.createRange(); range.selectNodeContents(element); selection.removeAllRanges(); selection.addRange(range); } }; $( document ).on( "click", ".dropdown_btn", function() { $(this).next(".dropdown-menu").toggle(); }); $( document ).on( "click", ".dropdown_item", function() { $(this).closest(".dropdown-menu").toggle(); name=$(this).text(); val=$(this).attr("data-value"); target=$(this).closest( ".dropdown-menu" ).attr("for"); $("#"+target).html(name); $("#"+target).attr("data-value",val); $("#"+target).val(val); }); $( document ).on( "click", "#info_edit_btn", function() { var frm=$('#infoform'); for(var instanceName in CKEDITOR.instances){ CKEDITOR.instances[instanceName].updateElement(); } $.ajax({ type: frm.attr('method'), url: frm.attr('action'), data: frm.serialize(), success: function (data) { $('#thankyou_div').show(); $('#edit_div').hide(); } }); }); $(".calendar_icon").click(function() { $(this).prev("input").datepicker( "show" ); }); $(".trip_durationfilter_link").click(function() { link=$(this).attr("href"); month=$('#trip_datefilter_label').attr("data-value"); $(this).attr("href",link+"&month="+month); return true; }); $( document ).on( "click", ".trip_datefilter", function() { $(this).closest(".dropdown-menu").toggle(); val=$(this).attr("data-value"); window.location.href = replaceQueryString(window.location.href, 'month', val); }); $("#hotel_destination_input").typeahead({ name: 'destination', valueKey: 'name', remote: { url: '/destination/search?ajax=true&q=%QUERY' }, template: [ '{{name}}
' ].join(''), engine: Hogan }).on('typeahead:selected', function (obj, ret) { $("#hotel_availability_form").attr('destination',ret.english_name); }); var currentIndex=0; var reload=true; var loading=false; var functionName=""; var functionParameters=new Array(); var ajaxFormData=new Array(); (function(d){ var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0]; if (d.getElementById(id)) {return;} js = d.createElement('script'); js.id = id; js.async = true; js.src = "//connect.facebook.net/en_US/all.js"; ref.parentNode.insertBefore(js, ref); }(document)); var toast=function(msg){ $("