You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
259 lines
9.2 KiB
JavaScript
259 lines
9.2 KiB
JavaScript
//函数定义
|
|
var Daytrip = {Data:{},Fun:{}};
|
|
function changingOverTab(o) {
|
|
var a_current = o;
|
|
var a_parent = a_current.parent();
|
|
var a_current_name = a_current.attr("class");
|
|
a_parent.siblings().each(function(){
|
|
var sibling = $(this).find("a");
|
|
var sibling_name = sibling.attr("class");
|
|
if(testReg(/active/, sibling_name)){
|
|
sibling.removeClass('active');
|
|
}
|
|
});
|
|
|
|
if(testReg(/active/, a_current_name)){
|
|
}else{
|
|
a_current.addClass("active");
|
|
}
|
|
}
|
|
//正则测试
|
|
function testReg(reg,str){
|
|
return reg.test(str);
|
|
}
|
|
|
|
//翻页函数
|
|
//page 页码
|
|
//$search['city']
|
|
//.$search['code2'] 扩展类型
|
|
//.$search['order'] 排序
|
|
function goToPage(page,city,code2,order){
|
|
$.ajax({
|
|
type: "GET",
|
|
url: "/daytrip/search_" + city +'-'+ code2 +'-'+ order +'-'+ page,
|
|
success: function(msg){
|
|
$("#dataGrid").html(msg);
|
|
}
|
|
});
|
|
}
|
|
|
|
function geginSearch(){
|
|
if($('#city').val().length<2){
|
|
alert('Please Select a city from the drop-down.');
|
|
return;
|
|
}
|
|
window.location='/daytrip/list_'+$('#city').val().toLowerCase().replace(/(^\s*)|(\s*$)/g, '').replace(/\s+/g,'-')+'/' + ($('#code2').val()?'?code2='+$('#code2').val():'');
|
|
}
|
|
|
|
function setTourPrice(data,date){
|
|
var ExRate = data.ExRate;
|
|
var toUsd = function(rmb){rmb = Number(rmb);if(isNaN(rmb)){return 0;}return Math.ceil(rmb / ExRate);}
|
|
$(data.data).each(function(i){
|
|
var Item = this;
|
|
var T1 = new Date(Item.date_start);
|
|
var T2 = new Date(Item.date_end);
|
|
var Tnow = new Date();
|
|
if( T2.getTime() > Tnow.getTime() && Tnow.getTime() > T1.getTime()){
|
|
window.tripPrice = jQuery.parseJSON(Item.price);
|
|
if(Item.person_type == 0){
|
|
$("#priceTable tr:eq(0)").html("<th height=\"24\">1 person</th><th>2-3 persons</th>\
|
|
<th>4-5 persons</th><th>6-9 persons</th><th>> 10 persons</th>");
|
|
$("#priceTable tr:eq(1)").html('<td>' + toUsd(tripPrice[0]) + '</td><td>' + toUsd(tripPrice[1]) + '</td>\
|
|
<td>' + toUsd(tripPrice[2]) + '</td><td>' + toUsd(tripPrice[3]) + '</td>\
|
|
<td>' + toUsd(tripPrice[4]) + '</td>');
|
|
$(".bestPrice").text(toUsd(tripPrice[2]));
|
|
}else if(Item.person_type == 1){
|
|
$("#priceTable tr:eq(0)").html("<th height=\"24\">1 - 2 person</th><th>3 - 5 persons</th>\
|
|
<th>6 - 9 persons</th><th>> 10 persons</th>");
|
|
$("#priceTable tr:eq(1)").html('<td>' + toUsd(tripPrice[0]) + '</td><td>' + toUsd(tripPrice[1]) + '</td>\
|
|
<td>' + toUsd(tripPrice[2]) + '</td><td>' + toUsd(tripPrice[3]) + '</td>');
|
|
$(".bestPrice").text(toUsd(tripPrice[2]));
|
|
}
|
|
}
|
|
})
|
|
}
|
|
|
|
function clearSelectCity(){
|
|
$("#select_city").hide();$("#select_city>div").html('');
|
|
}
|
|
|
|
function setSelectCity(e){
|
|
if(e.target != $('#city').get(0)){
|
|
clearSelectCity();return;
|
|
}
|
|
$("#select_city>div").html('').append('<div class="close" align="right"><span style="float:left">Top City</span>X</div>');
|
|
$.each(Daytrip.Data.city,function(){
|
|
$("#select_city>div").append('<span><a href="##" onclick="$(\'#city\').val(\''+this.Name+'\');$(\'#triptype\').val(\'\')">'+this.Name+'</a></span>');
|
|
});
|
|
$("#select_city").fadeIn("fast");
|
|
}
|
|
function setCode2(code,Text){
|
|
$("#triptype").val(Text);
|
|
$("#code2").val(code);
|
|
}
|
|
function setSelectType(e){
|
|
if(e.target != $('#triptype').get(0)){
|
|
if($("#triptype").val().length<1){//If Extern Type was Empty
|
|
$("#code2").val('');
|
|
}
|
|
$("#select_type").hide().html('');return;
|
|
}
|
|
var types={};
|
|
$.each(Daytrip.Data.city,function(){
|
|
if(this.Name==$('#city').val()){
|
|
types=this;
|
|
return false;
|
|
}
|
|
});
|
|
if(typeof types.type =='undefined' || types.type.length<1){
|
|
$("#triptype").css("background-color","rgb(240, 240, 240)").val('');
|
|
}else{
|
|
$("#triptype").css("background-color","");
|
|
$("#select_type").html('<div></div>');
|
|
$("#select_type>div").html('').append('<div class="close" align="right"><span style="float:left">Trip Type</span>X</div>');
|
|
$.each(types.type,function(){
|
|
$("#select_type>div").append('<span><a href="javascript:setCode2(\''+this.c+'\',\''+this.n+'\');void(0)">'+this.n+'</a></span>');
|
|
});
|
|
$("#select_type").fadeIn("fast");
|
|
}
|
|
}
|
|
//-----split line-----------------------------------------------
|
|
//-----Data Segment-----
|
|
Daytrip.Data={"city":[{"Name":"Beijing","type":[
|
|
{"n":"Essence","c":"39010"},{"n":"Great Wall Tours","c":"39011"},{"n":"Night Tours","c":"39016"},{"n":"Hutong Tour","c":"39027"},{"n":"Beijing Forbidden City Tours","c":"39042"},{"n":"Beijing City Tours","c":"39043"},{"n":"Beijing Discovery Tours","c":"39045"},{"n":"Beijing Sightseeing Tours","c":"39046"},{"n":"Beijing Summer Palace Tours","c":"39050"},{"n":"Beijing Temple of Heaven Tours","c":"39052"},{"n":"Beijing Night Tours","c":"39058"},{"n":"Beijing Great Wall Tours","c":"39065"},{"n":"Beijing Hutong Tours","c":"39066"}
|
|
]},
|
|
{"Name":"Shanghai","type":[
|
|
{"n":"Culture Experience","c":"39001"},{"n":"Essence","c":"39010"},{"n":"Night Tours","c":"39016"},{"n":"Watertown Tours","c":"39017"},{"n":"Shanghai Night Tours","c":"39070"},{"n":"Shanghai City Tours","c":"39074"},{"n":"Shanghai Local Tours","c":"39076"},{"n":"Shanghai Hangzhou Tours","c":"39080"}
|
|
]},
|
|
{"Name":"Guangzhou","type":[
|
|
{"n":"Culture Experience","c":"39001"},{"n":"Essence","c":"39010"}
|
|
]},
|
|
{"Name":"Xian","type":[
|
|
{"n":"Essence","c":"39010"},{"n":"Xian Classic Tours","c":"39136"}
|
|
]},
|
|
{"Name":"Guilin","type":[
|
|
{"n":"Essence","c":"39010"},{"n":"Neighbor Tours","c":"39018"},{"n":"Guilin Li River Tours","c":"39127"},{"n":"Guilin Countryside Tours","c":"39132"}
|
|
]},
|
|
{"Name":"Chongqing","type":[
|
|
{"n":"Essence","c":"39010"}
|
|
]},
|
|
{"Name":"Dali","type":[
|
|
{"n":"Essence","c":"39010"}
|
|
]},
|
|
{"Name":"Hong Kong","type":[
|
|
{"n":"Essence","c":"39010"},{"n":"Countryside Tours","c":"39014"},{"n":"Night Tours","c":"39016"},{"n":"Hong Kong Island Tours","c":"39093"},{"n":"Hong Kong Night Tours","c":"39094"},{"n":"Hong Kong Big Bus Tours","c":"39098"},{"n":"Hong Kong Half Day Tours","c":"39109"}
|
|
]},
|
|
{"Name":"Hangzhou","type":[]},
|
|
{"Name":"Suzhou","type":[]},
|
|
{"Name":"Kunming","type":[
|
|
{"n":"Essence","c":"39010"}
|
|
]},
|
|
{"Name":"Lijiang","type":[]}
|
|
]};
|
|
|
|
|
|
//-----End Data Segment-----
|
|
|
|
// JavaScript Document
|
|
//首页的切换
|
|
$(function(){
|
|
//首页
|
|
if($(".otherCityList li").size()>0){
|
|
$(".otherCityList li").each(function(i){
|
|
$(this).bind("click",function(){
|
|
$(this).siblings().find('a').removeClass("active").end();
|
|
$(this).find('a').addClass("active");
|
|
$(".tourPro").filter(":not(:eq("+i+"))").hide().end().eq(i).show();
|
|
});
|
|
});
|
|
}
|
|
|
|
//详细页
|
|
//价格包括与不包括,切换
|
|
$(".priceIncl .title li").click(function(){
|
|
$(this).siblings('li').removeClass('active').end().addClass('active');
|
|
$(".priceIncl .priceList").hide();
|
|
$(".priceIncl .priceList").eq($(this).index()).show();
|
|
});
|
|
|
|
|
|
//图片切换播放效果
|
|
if(typeof $().orbit == 'function'){
|
|
$('#featured').orbit({animation: 'fade', bullets: true, 'bulletThumbs': false, captions: false});
|
|
}
|
|
//2012-10-23 trip advisoer show price action.
|
|
if($("#thighlights .highlights").size()>0){
|
|
$("#thighlights .highlights").after("<div class='persistentCR' style='display: none;'>"+$(".hide-persistentCR").html()+"</div>");
|
|
|
|
var sTags = $(".persistentCR");
|
|
|
|
sTags_top = sTags.offset().top;
|
|
$(window).unbind("scroll");
|
|
$(window).bind("scroll", function() {
|
|
try{
|
|
var self_top = $(this).scrollTop();
|
|
|
|
if(self_top > sTags_top && self_top > $("#thighlights .highlights").offset().top ){
|
|
$(".persistentCR").show()
|
|
.css({"position": "fixed", "top": 0, "width": 990, "z-index": 10, "background": "#FFFFFF", "border-bottom": "1px solid #fff"});
|
|
}else{
|
|
$(".persistentCR").hide()
|
|
.css({"position": "static", "background": "none"});
|
|
}
|
|
}catch(err){}
|
|
});
|
|
}
|
|
|
|
//左则漂浮,效果
|
|
var sTags = $(".smallCRight");
|
|
if(sTags.size()>0){
|
|
window.r_i = 0;
|
|
var ma_default = {anchortag: "href", anchorSmooth: true};
|
|
$(".tourType li").each(function(i){
|
|
r_i = i+1;
|
|
$(".at"+r_i).mAnchor(ma_default);
|
|
});
|
|
|
|
sTags_top = sTags.offset().top;
|
|
|
|
$(window).unbind("scroll");
|
|
$(window).bind("scroll", function() {
|
|
try{
|
|
var arr_t = [];
|
|
//console.log(r_i);
|
|
for(var i = 0; i < r_i; i++){
|
|
arr_t.push($("#t"+(i+1)).eq(0));
|
|
}
|
|
var self_top = $(this).scrollTop();
|
|
if( self_top > sTags_top ){
|
|
sTags.css({"position": "fixed", "top": 0, "z-index": 10});
|
|
|
|
for(var i = 0; i < r_i; i++){
|
|
if(self_top > arr_t[i].offset().top - 10 && arr_t[i].offset().top != 0){
|
|
//console.log(i);
|
|
changingOverTab($(".smallCRight .at"+(i+1)));
|
|
}
|
|
}
|
|
}else{
|
|
sTags.css({"position": "static", "background": "none"});
|
|
changingOverTab($("#smallCityLeft .at1"));
|
|
}
|
|
}catch(err){}
|
|
});
|
|
}
|
|
|
|
if(typeof $.datepicker =="object"){
|
|
$("#Starting_Date").datepicker(
|
|
{showAnim:"fadeIn",duration:0,minDate: "2d", numberOfMonths: 2,showButtonPanel: true}
|
|
);//detail page
|
|
}
|
|
|
|
//List page
|
|
if($("#city").size()>0){
|
|
$("body").click(function(e){setSelectCity(e);setSelectType(e);});
|
|
}
|
|
|
|
|
|
|
|
});
|