$(function () { var ddls; if (!Array.prototype.filter) { Array.prototype.filter = function (fun /*, thisp */ ) { "use strict"; if (this === null) throw new TypeError(); var t = Object(this); var len = t.length >>> 0; if (typeof fun !== "function") throw new TypeError(); var res = []; var thisp = arguments[1]; for (var i = 0; i < len; i++) { if (i in t) { var val = t[i]; // in case fun mutates this if (fun.call(thisp, val, i, t)) res.push(val); } } return res; }; } //欄位名對應 var fields = { 'cOrder_SN': '訂單編號', 'cProduct_Type': '預購機型', 'Product_Size': '容量', 'cProductModel_ID': '顏色', 'cProduct_IMEI': '手機IMEI', 'cProduct_SN': '手機S/N', 'cChannel_ID': '購買通路', 'cBookStore_ID': '取貨門市', 'cUser_Identification_En': '身分證字號/居留證號碼', 'cUser_Nationality': '籍別', 'cUser_Name_En': '姓名', 'cUser_Sex': '性別', 'cUser_EMail_En': 'E-mail', 'cUser_Birthday': '出生日期', 'cUser_Phone_En': '手機號碼', 'cUsed_Brand': '手機品牌', 'cUsed_Model': '手機型號', 'cUsed_Other': '其他手機品牌/型號', 'cIsAppend': '您是否為預註冊活動消費者', 'cAppend1_SN': '限量加碼禮序號', 'county': '縣市', 'district': '鄉鎮區域', 'zipcode': '贈品寄送地址', 'cUser_Address': '贈品寄送地址', 'cIsExchange': '是否同意主辦單位得將本人之個人資料提供活動小組作為預購禮配送之用', 'cIsOK': '我同意本活動辦法及規定', 'cStoreAgree': '指定門市排隊禮數量有限,系統依照訂購完成時間(Setp.5)判斷是否符合排隊禮資格', 'cUser_CancelTxt': '取消原因', 'cReservation_SDate': '取機日期', 'cReservation_ID': '取機時段', 'cIsTradeIn': '是否參與舊機換新機活動', 'cIsCopyData': '是否需要舊機資料轉移至新機服務', 'cIsTransfer': '請問您是否參加iPhone轉入Galaxy 跨系統 LINE 線上轉移預約服務', 'validCode': '驗證碼' }; //回上一步 $(".btt-back:visible > a").click(function () { var url = $(this).attr("href"); var uo = $("input[name=uo]").val(); if (url.indexOf('#') > 0) { location.replace(url.replace(/#/, "?uo=" + encodeURIComponent(uo) + "#")); } else { location.replace(url + "?uo=" + encodeURIComponent(uo)); } return false; }); //step1 通路 if (id('aBtn')) { //if ($("input[name=cChannel_ID]:eq(0)").attr("disabled") === "disabled") { // $("#bBtn").hide(); //隱藏按鈕, 先不要 //} // 選擇通路若外連直接跳窗 $("ul.box a").click(function () { $("input[name=Channel_Type]").val($(this).attr("href")); if ($(this).data("t") !== 1) { window.open($(this).attr("href")); } else { $("#aBtn").trigger("click"); } return false; }); $("#aBtn").click(function () { var radio = $("input[name=Channel_Type]").val(); var url = $(this).attr("href"); if ($("input[name=Channel_Type]").val() === '') { alert("請先選擇通路商。"); } else { //console.log($(radio).data("t")); if ($("input[name=Channel_Type]").val().toLowerCase() !== $("input[name=cChannel_ID]").val()) { //外連 window.open($("input[name=Channel_Type]").val()); } else { $('html').addClass('loadingz'); $.post("api/ajax_preorder.ashx", $("#form1").serialize(), function (data) { if (data.status < 0) { alert(data.message); $('html').removeClass('loadingz'); } else { location.replace(url + "?uo=" + encodeURIComponent(data.objectz)); } }, "json"); } } return false; }); } //step2 產品與顏色 if (id('bBtn')) { //console.log('bbtn'); $('dt,dd').removeClass('select'); $("dt.pmodel[data-t='4']:eq(0)").css("width", "100%"); //watch第一個預設寬度 // $("dt.pmodel[data-t='4']:last-child").css("width", "100%"); //watch第一個預設寬度 $("input[name=Product_Type]").click(function () { $("input[name=Product_Model], input[name=Product_Size], input[name=Product_Color]").prop('checked', false); $("input[name=cProductModel_ID],input[name=cProductSeries_ID],input[name=cProductItem_ID]").val(''); var ptype = $("input[name=Product_Type]:checked").val(); $("dt.pmodel, dt.pcapa, dt.pcolor").removeClass('select').addClass("hide"); $("dt.pmodel[data-t='" + ptype + "']").removeClass("hide"); var pmodel = $("dt.pmodel[data-t='" + ptype + "']").find("input[name=Product_Model]:enabled:first").val(); //console.log(pmodel); $("dt.pcapa[data-t='" + ptype + "'][data-m='" + pmodel + "']").removeClass("hide"); var psize = $("dt.pcapa[data-t='" + ptype + "'][data-m='" + pmodel + "']").find("input[name=Product_Size]:enabled:first").val(); $("dd.pcolor").removeClass('select').addClass("hide"); $("dd.pcolor[data-t='" + ptype + "'][data-m='" + pmodel + "'][data-s='" + psize + "']").removeClass("hide"); var pimg = $("dd.pcolor[data-s='" + psize + "']").find("input[name=Product_Color]:enabled:first").data("img"); $(".productimg").attr("src", pimg); $('.precapa span').addClass('hide'); if (ptype == '4') {//, .btnbox a , .btnbox a:eq(1) $('.precapa span:eq(1)').removeClass('hide'); } else { $('.precapa span:eq(0)').removeClass('hide'); } pawidth(ptype); $('.main_phone').css({ "width": "90%", "transform": "translateX(0)", "padding-left": "10%" }); $("dt.ptype").removeClass('select'); $(this).parent().addClass('select'); }); $("input[name=Product_Model]").click(function () { $("input[name=Product_Size], input[name=Product_Color]").prop('checked', false); $("input[name=cProductModel_ID],input[name=cProductSeries_ID],input[name=cProductItem_ID]").val(''); var pmodel = $("input[name=Product_Model]:checked").val(); var ptype = $("input[name=Product_Model]:checked").parent().data('t'); //console.log('choose model...' + ptype + '--' + pmodel); if ($("input[name=Product_Type]:checked").val() === undefined) { $("input[name=Product_Type]").filter("[value='" + ptype + "']").prop('checked', true).parent().addClass('select'); } $("dt.pcapa").removeClass('select').addClass("hide"); $("dt.pcapa[data-t='" + ptype + "'][data-m='" + pmodel + "']").removeClass("hide"); var psize = $("dt.pcapa[data-t='" + ptype + "'][data-m='" + pmodel + "']").find("input[name=Product_Size]:enabled:first").val(); $("dd.pcolor").removeClass('select').addClass("hide"); $("dd.pcolor[data-s='" + psize + "']").removeClass("hide"); var pimg = $("dd.pcolor[data-s='" + psize + "']").find("input[name=Product_Color]:enabled:first").data("img"); $(".productimg").attr("src", pimg); $("dt.pmodel").removeClass('select'); $(this).parent().addClass('select'); }); $("input[name=Product_Size]").click(function () { var psize = $("input[name=Product_Size]:checked").val(); var ptype = $("input[name=Product_Size]:checked").parent().data('t'); var pmodel = $("input[name=Product_Size]:checked").parent().data('m'); //console.log('choose size...' + ptype + '--' + pmodel + '--' + psize); if ($("input[name=Product_Type]:checked").val() === undefined) { $("input[name=Product_Type]").filter("[value='" + ptype + "']").prop('checked', true).parent().addClass('select'); } if ($("input[name=Product_Model]:checked").val() === undefined) { $("input[name=Product_Model]").filter("[value='" + pmodel + "']").prop('checked', true).parent().addClass('select'); } $("input[name=Product_Color]").prop('checked', false); $("input[name=cProductItem_ID]").val(''); $("dd.pcolor").removeClass('select').addClass("hide"); $("dd.pcolor[data-s='" + psize + "']").removeClass("hide"); var pimg = $("dd.pcolor[data-s='" + psize + "']").find("input[name=Product_Color]:enabled:first").data("img"); $(".productimg").attr("src", pimg); $("dt.pcapa").removeClass('select'); $(this).parent().addClass('select'); }); $("input[name=Product_Color]").click(function () { var pcolor = $("input[name=Product_Color]:checked").val(); var ptype = $("input[name=Product_Color]:checked").parent().data('t'); var pmodel = $("input[name=Product_Color]:checked").parent().data('m'); var psize = $("input[name=Product_Color]:checked").parent().data('s'); var pseries = $("input[name=Product_Color]:checked").parent().data('e'); $("input[name=cProductItem_ID]").val(pcolor); $("input[name=cProductModel_ID]").val(psize); $("input[name=cProductSeries_ID]").val(pseries); $("input[name=cProduct_Type]").val(ptype); //console.log('choose color...' + ptype + '--' + pmodel + '--' + psize + '--' + pcolor); if ($("input[name=Product_Size]:checked").val() !== psize) { $("dt.pcapa").removeClass('select'); $("input[name=Product_Size]").filter("[value='" + psize + "']").prop('checked', true).parent().addClass('select'); } if ($("input[name=Product_Model]:checked").val() !== pmodel) { $("dt.pmodel").removeClass('select'); $("input[name=Product_Model]").filter("[value='" + pmodel + "']").prop('checked', true).parent().addClass('select'); } if ($("input[name=Product_Type]:checked").val() !== ptype) { $("dt.ptype").removeClass('select'); $("input[name=Product_Type]").filter("[value='" + ptype + "']").prop('checked', true).parent().addClass('select'); } //var pimg = $("input[name=Product_Color]:checked").data("img"); //console.log($("input[name=Product_Color]:checked").data("img")); $(".kv_product").addClass("hidekv"); $(".productimg").attr("src", $("input[name=Product_Color]:checked").data("img")); $("dd.pcolor").removeClass('select'); $(this).parent().addClass('select'); }); if ($("input[name=cProductItem_ID]").val() !== "") { $("input[name=Product_Color][value=" + $("input[name=cProductItem_ID]").val() + "]").prop("checked", true); $("dd.pcolor[data-s='" + $("input[name=Product_Color]:checked").parent().data('s') + "']").removeClass("hide"); $("dt.pcapa[data-m='" + $("input[name=Product_Color]:checked").parent().data('m') + "']").removeClass("hide"); $("dt.pmodel[data-t='" + $("input[name=Product_Color]:checked").parent().data('t') + "']").removeClass("hide"); $("input[name=Product_Color]:checked").trigger("click"); } else { //還沒選 var ptype = $("input[name=Product_Type]:enabled:first").val(); //console.log(window.location.hash); //if (window.location.hash != "") { //若有錨點則做預設 //if (window.location.hash == "#s22") { // $('input[name=Product_Type]:eq(0)').prop("checked", true).trigger("click"); //} else { // $('input[name=Product_Type]:eq(1)').prop("checked", true).trigger("click"); // ptype = "2"; //} // } else { $("dt.pmodel[data-t='" + ptype + "']").removeClass("hide"); var pmodel = $("input[name=Product_Model]:enabled:first").val(); if (pmodel === undefined) pmodel = $("input[name=Product_Model]:first").val(); $("dt.pcapa[data-t='" + ptype + "'][data-m='" + pmodel + "']").removeClass("hide"); var psize = $("input[name=Product_Size]:enabled:first").val(); if (psize === undefined) psize = $("input[name=Product_Size]:first").val(); $("dd.pcolor[data-s='" + psize + "']").removeClass("hide"); //var pimg = $("dd.pcolor[data-s='" + psize + "']").find("input[name=Product_Color]:enabled:first").data("img"); //console.log('first loading...' + ptype + '--' + pmodel + '--' + psize + '--' + pimg); //$(".step2phone").attr("src", pimg); pawidth(ptype); // } } // 容量寬度設定 function pawidth(ptype) { //本次補充 if (ptype == '4') { //手錶第一個寬百分百 // $("dt.pmodel[data-t='" + ptype + "']:eq(0)").css("width", "100%"); } else { } //pacount = $("dt.pmodel[data-t='" + ptype + "'][data-m='" + pmodel + "']").length; //console.log(pacount); //if (pacount == 2) { // $("dt.pcapa[data-t='" + ptype + "'][data-m='" + pmodel + "']").css('width', '47%'); //} else { // $("dt.pcapa[data-t='" + ptype + "'][data-m='" + pmodel + "']").css('width', '30%'); //} } $("#bBtn").click(function (e) { var url = $(this).data("href"); if ($("input[name=cProductModel_ID]").val() === "") { alert("請確實選擇產品(容量/顏色)"); e.preventDefault(); e.stopPropagation(); return false; } else { $('html').addClass('loadingz'); $.post("api/ajax_preorder.ashx", $("#form1").serialize(), function (data) { if (data.status < 0) { alert(data.message); $('html').removeClass('loadingz'); } else { location.replace(url + "?uo=" + encodeURIComponent(data.objectz)); } }, "json"); } return false; }); } //step3 資料 if (id('cBtn')) { $("input[name=cUser_Birthday]").attr('readonly', true).datepicker({ changeMonth: true, changeYear: true, showMonthAfterYear: true, clearBtn: true, yearRange: "-80:+0", monthRange: "-6:+6", format: "yyyy/mm/dd", defaultViewDate: "-18y", startDate: "-80y", endDate: "-6y" }); $('#twzipcode').twzipcode({ readonly: true }); $("select[name=cCity]").change(function () { //縣市 $("._no, ._yes, #c1Btn, #cBtn, .warning").addClass("hide"); $("#cBtn").removeClass("hide"); $("input[name=cStore_Address]").val(''); $("select[name=cDistrict],select[name=cBookStore_ID]").find('option:not(:eq(0))').remove(); if ($("select[name=cCity]").val() !== "") { //$('select[name=cDist_Temp] option[data-c=' + $("select[name=cCity]").val() + ']').clone().appendTo('select[name=cDistrict]'); $('select[name=cStore_Temp] option[data-c=' + $("select[name=cCity]").val() + ']').clone().appendTo('select[name=cBookStore_ID]'); } }); if ($("select[name=cCity]").val() !== "") { $("select[name=cCity]").trigger('change'); } $("select[name=cDistrict]").change(function () { //區域 $("._no, ._yes, #c1Btn, #cBtn, .warning").addClass("hide"); $("#cBtn").removeClass("hide"); $("input[name=cStore_Address]").val(''); $("select[name=cBookStore_ID]").find('option:not(:eq(0))').remove(); if ($("select[name=cDistrict]").val() !== "") { $('select[name=cStore_Temp] option[data-c=' + $("select[name=cCity]").val() + '][data-d=' + $("select[name=cDistrict]").val() + ']').clone().appendTo('select[name=cBookStore_ID]'); } }); if ($("select[name=cDistrict]").val() !== "") { $("select[name=cDistrict]").trigger('change'); } $("select[name=cBookStore_ID]").change(function () { //門市 //console.log('aaa'); $("._no, ._yes, #c1Btn, #cBtn, .warning").addClass("hide"); var act = $("select[name=cBookStore_ID] option:selected").data("a"); var seat = $("select[name=cBookStore_ID] option:selected").data("s"); var addr = $("select[name=cBookStore_ID] option:selected").data("r"); $("input[name=cStore_Address]").val(addr); if (act === 'Y') { if (seat === 'Y') { $("._yes, #cBtn, .warning").removeClass("hide"); $("._no, #c1Btn").addClass("hide"); } else { $("._no, #c1Btn").removeClass("hide"); $("._yes, #cBtn").addClass("hide"); } } else { $("#cBtn").removeClass("hide"); } }); if ($("select[name=cBookStore_ID]").val() !== "") { $("select[name=cBookStore_ID]").trigger('change'); } if ($("select[name=cCity]").attr("data-d") !== null) { $("select[name=cCity]").val($("select[name=cCity]").attr("data-d")).trigger('change'); } if ($("select[name=cDistrict]").attr("data-d") !== null) { $("select[name=cDistrict]").val($("select[name=cDistrict]").attr("data-d")).trigger('change'); } if ($("select[name=cBookStore_ID]").attr("data-d") !== null) { $("select[name=cBookStore_ID]").val($("select[name=cBookStore_ID]").attr("data-d")).trigger('change'); } //手機品牌 $("select[name=cUsed_Brand]").change(function () { if ($("select[name=cUsed_Brand]").val() !== "") { $("select[name=cUsed_Model]").attr('required', true); var t = $('select[name=cUsed_Brand] option:selected').data("t"); //console.log(t); if (t === "X") { $("input[name=cUsed_Other]").val($("input[name=cUsed_Other]").data("d")).removeClass('hide').attr('required', true); $("select[name=cUsed_Model]").val('').find('option:not(:eq(0))').remove().end().removeAttr('required').attr('disabled', true); } else { $("input[name=cUsed_Other]").val($("input[name=cUsed_Other]").data("d")).removeAttr("required").addClass('hide'); $("select[name=cUsed_Model]").find('option:not(:eq(0))').remove().end().removeAttr("disabled").attr('required', true); if ($("select[name=cUsed_Brand]").val() !== "") { $('select[name=cUsed_Temp] option[data-m=' + $("select[name=cUsed_Brand]").val() + ']').clone().appendTo('select[name=cUsed_Model]'); $("select[name=cUsed_Temp]").find('option:last').clone().appendTo('select[name=cUsed_Model]'); } } } else { $("select[name=cUsed_Model]").removeAttr('required'); } }); if ($("select[name=cUsed_Brand]").val() !== "") { $("select[name=cUsed_Brand]").trigger('change'); } $("select[name=cUsed_Model]").change(function () { //手機品牌 var t = $('select[name=cUsed_Model] option:selected').data("t"); if (t === "X") { $("input[name=cUsed_Other]").val($("input[name=cUsed_Other]").data("d")).removeClass('hide').attr('required', true); } else { $("input[name=cUsed_Other]").val($("input[name=cUsed_Other]").data("d")).addClass('hide').attr('required', false); } }); if ($("select[name=cUsed_Model]").val() !== "") { $("select[name=cUsed_Model]").trigger('change'); } //加碼禮確認 $("input[name=cIsAppend]").click(function () { //console.log($("input[name=cIsAppend]:checked").val()); if ($("input[name=cIsAppend]:checked").val() === "1") {//有 $(".adhbox").removeClass('hide'); $(".adhbox input, .adhbox select").attr('required', true); //$("input[name=cAppend1_SN],input[name=cUser_Address],select[name=district]").attr('required', true); } else { $(".adhbox input, .adhbox select").removeAttr('required'); // $("input[mame=cAppend1_SN],input[name=cUser_Address],select[name=district]").removeAttr('required'); $(".adhbox input, .adhbox select").val(''); $('#twzipcode').twzipcode('reset'); $(".adhbox").addClass('hide'); } }); if ($("input[name=cIsAppend]").is(':checked')) { $("input[name=cIsAppend]:checked").trigger('click'); } // $("#c3Btn").click(function (e) { e.preventDefault(); var lbCloseAni = new TimelineMax(); lbCloseAni.to($('.lb'), .3, { opacity: 0, ease: Linear.easeNone }) .to($('.lb'), .3, { css: { zIndex: -1 } }); $("select[name=cCity]").val(''); $('body').css({ 'overflow': '', 'position': '' }); return false; }); $("#c2Btn").click(function (e) { e.preventDefault(); $("#cBtn").trigger('click'); }); //原c1Btn跳提示換門市, 就不問了 $("#cBtn, #c1Btn").click(function (e) { var url = $(this).data("href"); if (!checkEmpty() || !checkFormat()) { e.preventDefault(); e.stopPropagation(); return false; } else { $('html').addClass('loadingz'); $.post("api/ajax_preorder.ashx", $("#form1").serialize(), function (data) { if (data.status < 0) { setTimeout(function () { alert(data.message); // 延遲一些顯示 }, 500); $('html').removeClass('loadingz'); } else { if ($("input[name=mode]").val() === "C") { if (url.indexOf('#') > 0) { location.replace(url.replace(/#/, "?uo=" + encodeURIComponent(data.objectz) + "#")); } else { location.replace(url + "?uo=" + encodeURIComponent(data.objectz)); } } else { location.replace("index.aspx"); } } }, "json"); } return false; }); } //step4 確認後送出 if (id('dBtn')) { $("#dBtn").click(function (e) { if (!checkEmpty() || !checkFormat()) { e.preventDefault(); e.stopPropagation(); return false; } else { $("#d1Btn").trigger('click'); //$('.libtn').trigger('click'); } return false; }); $("#eBtn").click(function (e) { var url = $(this).data("href"); $('html').addClass('loadingz'); $.post("api/ajax_preorder.ashx", $("#form1").serialize(), function (data) { if (data.status < 0) { if (data.status == -99) { location.replace("pay_cancel.aspx?uo=" + encodeURIComponent(data.objectz)); } else { alert(data.message); $('html').removeClass('loadingz'); } } else { location.replace(url + "?uo=" + encodeURIComponent(data.objectz)); } }, "json"); return false; }); } // step5 失敗重送 if (id('gBtn')) { $("#gBtn").click(function () { $('html').addClass('loadingz'); location.replace("pay_form.aspx?uo=" + encodeURIComponent($(this).attr('data-n'))); return false; }); } //查詢 if (id('sBtn')) { $("#iconV").click(function () { $("#imgV").attr("src", "api/ajax_captcha.ashx?r=" + Math.random()); return false; }); $("#sBtn").click(function (e) { if (!checkEmpty() || !checkFormat()) { e.preventDefault(); e.stopPropagation(); return false; } else { var url = $(this).data("href"); $('html').addClass('loadingz'); $.post("api/ajax_preorder.ashx", $("#form1").serialize(), function (data) { if (data.status < 0) { alert(data.message); $('html').removeClass('loadingz'); $("#imgV").attr("src", "api/ajax_captcha.ashx?r=" + Math.random()); } else { if (url.indexOf('#') > 0) { location.replace(url.replace(/#/, "?uo=" + encodeURIComponent(data.objectz) + "#")); } else { location.replace(url + "?uo=" + encodeURIComponent(data.objectz)); } } }, "json"); } return false; }); } //忘記密碼 if (id('fBtn')) { $("#fBtn").click(function (e) { if (!checkEmpty() || !checkFormat()) { e.preventDefault(); e.stopPropagation(); return false; } else { $('html').addClass('loadingz'); $.post("api/ajax_preorder.ashx", $("#form1").serialize(), function (data) { //console.log(data); alert(data.message); if (data.status < 0) { $('html').removeClass('loadingz'); } else { location.replace("check1.aspx"); } }, "json"); } return false; }); } //刪除或取消訂單 //預約取機時段 if (id('xBtn') || id('iBtn')) { //依日期換時段 $(document).on("change", "select[name=cReservation_SDate]", function () { //$("select[name=cReservation_SDate]").change(function (e) { //確定日期 if ($("select[name=cReservation_SDate]").val() == '') { $("dl.time dd").empty().append("請先選擇日期"); } else { var s = $('select[name=cReservation_SDate] option:selected').data("s"); //選擇狀態 //console.log(s); if (s === 'N') { //不可選 $(this).closest('.chooseday').nextUntil('.no_open').addClass('hide'); $('#lbResbox .no_open').removeClass('hide'); $('#lbResbox .btnbox ').addClass('hide'); } else { $(this).closest('.chooseday').nextUntil('.no_open').removeClass('hide'); $('#lbResbox .no_open').addClass('hide'); $('#lbResbox .btnbox ').removeClass('hide'); $("input[name=mode]").val('B'); $.post("/api/ajax_booking.ashx", $("#form1").serialize(), function (data) { if (data.status < 0) { //swalz.fire("", data.message, "error"); alert(data.message); } else { $("dl.time dd").empty().append(data.objectz); } $('html').removeClass('loadingz'); }, "json"); } } return false; }); //if ($("select[name=cReservation_SDate]").attr("data-o") !== null) { // $("select[name=cReservation_SDate]").val($("select[name=cReservation_SDate]").attr("data-o")).trigger('change'); //} $(document).on("click", "#iBtn", function () { //$("#iBtn").click(function (e) { //確定送出 if (!checkEmpty() || !checkFormat()) { e.preventDefault(); e.stopPropagation(); return false; } else { $("input[name=mode]").val('C'); $('html').addClass('loadingz'); $.post("api/ajax_booking.ashx", $("#form1").serialize(), function (data) { if (data.status < 0) { alert(data.message); $('html').removeClass('loadingz'); } else { $("span.rmsg").empty().append(data.message); $("#lbResbox .btn_x").addClass('hide'); $("#iBtn").closest('.form').addClass('hide'); $("#iBtn").closest('.form').next().removeClass('hide'); $('html').removeClass('loadingz'); } }, "json"); } return false; }); $(document).on("click", "#jBtn", function () { //$('#jBtn').click(function () { //重新預約 $(this).closest('.reserve_finish').addClass('hide'); $(this).closest('.reserve_finish').prev().removeClass('hide'); }); //詳情內容顯示 $('.information').find('.listtable').find('.more').each(function () { $(this).click(function () { var osn = $(this).data('o'); $("input[name=uo]").val($(this).data('u')); //使用者識別 $("input[name=cBookStore_ID]").val($(this).data('b')); //門市 $("input[name=cOriginal_ID]").val($(this).data('r')); //預約時段 $("input[name=mode]").val('L'); //載入取機 $.post("/api/ajax_booking.ashx", $("#form1").serialize(), function (data) { if (data.status <= 0) { swalz.fire(data.message, "", "error"); if (data.status === -9) { location.replace('check1.aspx'); } } else { $(".lreBox").empty().html(data.objectz); } }, "json"); $('.information .detailcontent').fadeOut(); $('.information').find('#' + osn).slideDown('slow'); }) }) //console.log("xBtn"); $("#xBtn").click(function () { if ($(this).data("n") === undefined) { // //console.log("刪除訂單"); if ($("select[name=cUser_CancelTxt]").val() === undefined) { alert('[訂單取消原因]請確實選擇'); e.preventDefault(); e.stopPropagation(); return false; } else { $("input[name=mode]").val('R'); $('html').addClass('loadingz'); $.post("api/ajax_preorder.ashx", $("#form1").serialize(), function (data) { if (data.status < 0) { alert("系統忙碌中,請稍後再刪除訂單。"); $('html').removeClass('loadingz'); } else { alert("您已成功刪除訂單。"); location.reload(); } }, "json"); } } else { var uo = $(this).data("n"); if (confirm('提醒您,若您取消本次交易,您的登錄資料將一同取消。')) { $('html').addClass('loadingz'); $.post("api/ajax_preorder.ashx", { mode: "X", uo: uo }, function (data) { if (data.status < 0) { alert("系統忙碌中,請稍後再取消本次交易。"); $('html').removeClass('loadingz'); } else { alert("您已成功取消本次交易。"); location.replace("index.aspx"); } }, "json"); } } return false; }); //登出 $(".oBtn").click(function () { var url = $(this).data("href"); $('html').addClass('loadingz'); $.post("api/ajax_preorder.ashx", { mode: "O", uo: $("input[name=uo]").val() }, function (data) { if (data.status < 0) { alert(data.message); $('html').removeClass('loadingz'); } else { location.replace(url); } }, "json"); return false; }); } //取消 pop if (id('pBtn')) { //$("#pBtn").click(function () { // $("#cancel-order").modal(); // return false; //}); } //取消(登出) if (id('oBtn')) { $("#oBtn").click(function () { var url = $(this).data("href"); $('html').addClass('loadingz'); $.post("api/ajax_preorder.ashx", { mode: "O", uo: $("input[name=uo]").val() }, function (data) { if (data.status < 0) { alert(data.message); $('html').removeClass('loadingz'); } else { location.replace(url); } }, "json"); return false; }); } //檢查格式 function checkFormat() { var message = ''; $('input[data-validate],textarea[data-validate]').each(function (index, element) { // new RegExp('ab+c', 'i'); var regexp = new RegExp($(element).data('validate'), 'i'); var value = $(element).val(); if (value != '') { if (!regexp.test(value)) { message = fields[element.name] + '的格式不正確,請重新輸入'; return false; } } }); if (message !== '') { alert(message); message = ''; return false; } else { return true; } } //檢查未填的欄位 function checkEmpty() { var flag = true; var obj = '', message = ''; $('input[required]:not([type=radio]):not([type=checkbox]),select[required],textarea[required]').each(function (index, element) { if ($(element).val() === '') { if (element.tagName.toLowerCase() === 'select') { if ($(element).data("f") !== undefined) { message = '請選擇' + $(element).data("f"); } else { message = '請選擇' + fields[element.name]; } } else { if (fields[element.name] === undefined) { message = '請填寫' + $(element).attr("placeholder"); } else { message = '請填寫' + fields[element.name]; } } obj = element.name; flag = false; return false; } }); if (flag) { $('[type=radio][required],[type=checkbox][required]').each(function (index, element) { var group = $(element).attr('name'); if ($('[name=' + group + ']:checked').length === 0) { message = '請確實選擇:' + fields[group]; obj = group; } }); } if (message !== '') { //console.log(message); alert(message); $("[name=" + obj + "]").focus(); message = ''; return false; } else { return true; } } }); // 更換圖檔名稱 function replacePhoto(newPath) { $(".slide .slide-move img").each(function () { var newSrc = $(this).attr('src').replace(/_[a-d]{1}_/, newPath); $(this).attr('src', newSrc); //console.log($(this).attr('src')); }); $('.preview img').attr('src', $('.preview img').attr('src').replace(/_[a-d]{1}_/, newPath)); } //----------------------------店家START--------------------------------------------------------------------- var putCityContrl = function (c, t, b) { $("input[name=cStore_Address]").val(''); $("select[name=cCity]").find('option:not(:eq(0))').remove(); $("select[name=cDistrict]").find('option:not(:eq(0))').remove(); $("select[name=cBookStore_ID]").find('option:not(:eq(0))').remove(); var p = $("input[name=cProduct_Type]").val(); $.post("api/ajax_preorder.ashx", { mode: "Z", channel: c, utype: t, prodType: p, bookStore: b }, function (data) { if (data.status < 0) { alert(data.message); } else { $("select[name=cCity]").find('option:not(:eq(0))').remove(); ddls = data.objectz; for (var ix = 0; ix < ddls.cCity.length; ix++) { $("select[name=cCity]")[0].options.add(new Option(ddls.cCity[ix].cCity, ddls.cCity[ix].cCity)); } $("select[name=cCity]").change(function () { var thisval = $("select[name=cCity]").val(); //set-default-value putDistContrl($(this).val(), ddls.cDistrict); if (thisval === "遠傳企業客戶" || thisval === "遠傳網路門市" || thisval === "台灣大哥大網路綁約門市") { //set-style $("select[name=cDistrict]").attr("style", "visibility: hidden"); $("select[name=cBookStore_ID]").attr("style", "visibility: hidden;height:0px"); $(".cBookStoreSector").attr("style", "margin-bottom:-26px;"); //set-default-value $("select[name=cDistrict]").val(thisval); } else { //reduce-style $("select[name=cDistrict]").attr("style", "visibility: visible"); $("select[name=cBookStore_ID]").attr("style", "visibility: visible;height:56px"); $(".cBookStoreSector").attr("style", "margin-bottom:10px"); //reset-value putDistContrl($(this).val(), ddls.cDistrict); } }); $("select[name=cDistrict]").change(function () { putStoreContrl($("select[name=cCity]").val(), $(this).val(), ddls.cStore); }); $("select[name=cBookStore_ID]").change(function () { putStoreInfo($(this).val(), ddls.cStore); }); if ($("select[name=cCity]").attr("data-d") !== null) { $("select[name=cCity]").val($("select[name=cCity]").attr("data-d")).trigger('change'); } if ($("select[name=cDistrict]").attr("data-d") !== null) { $("select[name=cDistrict]").val($("select[name=cDistrict]").attr("data-d")).trigger('change'); } if ($("select[name=cBookStore_ID]").attr("data-d") !== null) { $("select[name=cBookStore_ID]").val($("select[name=cBookStore_ID]").attr("data-d")).trigger('change'); } } }, "json"); }; var putDistContrl = function (c, d) { $("input[name=cStore_Address]").val(''); $("select[name=cDistrict]").find('option:not(:eq(0))').remove(); $("select[name=cBookStore_ID]").find('option:not(:eq(0))').remove(); if (c !== "") { var newd = d.filter(function (el) { return el.cCity === c; }); for (var ix = 0; ix < newd.length; ix++) { $("select[name=cDistrict]")[0].options.add(new Option(newd[ix].cDistrict, newd[ix].cDistrict)); } } }; var putStoreContrl = function (c1, c2, d) { $("input[name=cStore_Address]").val(''); $("select[name=cBookStore_ID]").find('option:not(:eq(0))').remove(); if (c1 !== "" && c2 !== "") { var newd = d.filter(function (el) { return el.cCity === c1 && el.cDistrict === c2; }); for (var ix = 0; ix < newd.length; ix++) { $("select[name=cBookStore_ID]")[0].options.add(new Option(newd[ix].txt, newd[ix].sno)); if (parseFloat(newd[ix].qty) <= 0) { $("select[name=cBookStore_ID] option:last").attr("disabled", true).text(newd[ix].txt + '(已額滿)'); } } } }; var putStoreInfo = function (c, d) { $("input[name=cStore_Address]").val(''); if (c !== "") { var newd = d.filter(function (el) { return el.sno === c; }); $("input[name=cStore_Address]").val(newd[0].addr); $("input[name=store_name]").val(newd[0].txt); } }; //----------------------------店家END--------------------------------------------------------------------- //----------------------------必備--------------------------------------------------------------------- function id(DOM) { return document.getElementById(DOM); } function className(DOM) { return document.getElementsByClassName(DOM); } function getParam(name, dvalue) { var AllVars = window.location.search.substring(1); var Vars = AllVars.split("&"); for (i = 0; i < Vars.length; i++) { var Var = Vars[i].split("="); if (Var[0] === name) return Var[1]; } return dvalue; } function trims(s) { return s.replace(/(^[\s]*)|([\s]*$)/g, ""); } //----------------------------驗證--------------------------------------------------------------------- function isChinese(s) { //var patrn = /^[\u4E00-\u9FA5\uF900-\uFA2D]{1,4}$/; //return patrn.test(s); if (s.length < 2) { return false; } else { return true; } } /*! * Datepicker for Bootstrap v1.8.0 (https://github.com/uxsolutions/bootstrap-datepicker) * * Licensed under the Apache License v2.0 (http://www.apache.org/licenses/LICENSE-2.0) */ ! function (a) { "function" == typeof define && define.amd ? define(["jquery"], a) : a("object" == typeof exports ? require("jquery") : jQuery) }(function (a, b) { function c() { return new Date(Date.UTC.apply(Date, arguments)) } function d() { var a = new Date; return c(a.getFullYear(), a.getMonth(), a.getDate()) } function e(a, b) { return a.getUTCFullYear() === b.getUTCFullYear() && a.getUTCMonth() === b.getUTCMonth() && a.getUTCDate() === b.getUTCDate() } function f(c, d) { return function () { return d !== b && a.fn.datepicker.deprecated(d), this[c].apply(this, arguments) } } function g(a) { return a && !isNaN(a.getTime()) } function h(b, c) { function d(a, b) { return b.toLowerCase() } var e, f = a(b).data(), g = {}, h = new RegExp("^" + c.toLowerCase() + "([A-Z])"); c = new RegExp("^" + c.toLowerCase()); for (var i in f) c.test(i) && (e = i.replace(h, d), g[e] = f[i]); return g } function i(b) { var c = {}; if (q[b] || (b = b.split("-")[0], q[b])) { var d = q[b]; return a.each(p, function (a, b) { b in d && (c[b] = d[b]) }), c } } var j = function () { var b = { get: function (a) { return this.slice(a)[0] }, contains: function (a) { for (var b = a && a.valueOf(), c = 0, d = this.length; c < d; c++) if (0 <= this[c].valueOf() - b && this[c].valueOf() - b < 864e5) return c; return -1 }, remove: function (a) { this.splice(a, 1) }, replace: function (b) { b && (a.isArray(b) || (b = [b]), this.clear(), this.push.apply(this, b)) }, clear: function () { this.length = 0 }, copy: function () { var a = new j; return a.replace(this), a } }; return function () { var c = []; return c.push.apply(c, arguments), a.extend(c, b), c } }(), k = function (b, c) { a.data(b, "datepicker", this), this._process_options(c), this.dates = new j, this.viewDate = this.o.defaultViewDate, this.focusDate = null, this.element = a(b), this.isInput = this.element.is("input"), this.inputField = this.isInput ? this.element : this.element.find("input"), this.component = !!this.element.hasClass("date") && this.element.find(".add-on, .input-group-addon, .btn"), this.component && 0 === this.component.length && (this.component = !1), this.isInline = !this.component && this.element.is("div"), this.picker = a(r.template), this._check_template(this.o.templates.leftArrow) && this.picker.find(".prev").html(this.o.templates.leftArrow), this._check_template(this.o.templates.rightArrow) && this.picker.find(".next").html(this.o.templates.rightArrow), this._buildEvents(), this._attachEvents(), this.isInline ? this.picker.addClass("datepicker-inline").appendTo(this.element) : this.picker.addClass("datepicker-dropdown dropdown-menu"), this.o.rtl && this.picker.addClass("datepicker-rtl"), this.o.calendarWeeks && this.picker.find(".datepicker-days .datepicker-switch, thead .datepicker-title, tfoot .today, tfoot .clear").attr("colspan", function (a, b) { return Number(b) + 1 }), this._process_options({ startDate: this._o.startDate, endDate: this._o.endDate, daysOfWeekDisabled: this.o.daysOfWeekDisabled, daysOfWeekHighlighted: this.o.daysOfWeekHighlighted, datesDisabled: this.o.datesDisabled }), this._allow_update = !1, this.setViewMode(this.o.startView), this._allow_update = !0, this.fillDow(), this.fillMonths(), this.update(), this.isInline && this.show() }; k.prototype = { constructor: k, _resolveViewName: function (b) { return a.each(r.viewModes, function (c, d) { if (b === c || a.inArray(b, d.names) !== -1) return b = c, !1 }), b }, _resolveDaysOfWeek: function (b) { return a.isArray(b) || (b = b.split(/[,\s]*/)), a.map(b, Number) }, _check_template: function (c) { try { if (c === b || "" === c) return !1; if ((c.match(/[<>]/g) || []).length <= 0) return !0; var d = a(c); return d.length > 0 } catch (a) { return !1 } }, _process_options: function (b) { this._o = a.extend({}, this._o, b); var e = this.o = a.extend({}, this._o), f = e.language; q[f] || (f = f.split("-")[0], q[f] || (f = o.language)), e.language = f, e.startView = this._resolveViewName(e.startView), e.minViewMode = this._resolveViewName(e.minViewMode), e.maxViewMode = this._resolveViewName(e.maxViewMode), e.startView = Math.max(this.o.minViewMode, Math.min(this.o.maxViewMode, e.startView)), e.multidate !== !0 && (e.multidate = Number(e.multidate) || !1, e.multidate !== !1 && (e.multidate = Math.max(0, e.multidate))), e.multidateSeparator = String(e.multidateSeparator), e.weekStart %= 7, e.weekEnd = (e.weekStart + 6) % 7; var g = r.parseFormat(e.format); e.startDate !== -(1 / 0) && (e.startDate ? e.startDate instanceof Date ? e.startDate = this._local_to_utc(this._zero_time(e.startDate)) : e.startDate = r.parseDate(e.startDate, g, e.language, e.assumeNearbyYear) : e.startDate = -(1 / 0)), e.endDate !== 1 / 0 && (e.endDate ? e.endDate instanceof Date ? e.endDate = this._local_to_utc(this._zero_time(e.endDate)) : e.endDate = r.parseDate(e.endDate, g, e.language, e.assumeNearbyYear) : e.endDate = 1 / 0), e.daysOfWeekDisabled = this._resolveDaysOfWeek(e.daysOfWeekDisabled || []), e.daysOfWeekHighlighted = this._resolveDaysOfWeek(e.daysOfWeekHighlighted || []), e.datesDisabled = e.datesDisabled || [], a.isArray(e.datesDisabled) || (e.datesDisabled = e.datesDisabled.split(",")), e.datesDisabled = a.map(e.datesDisabled, function (a) { return r.parseDate(a, g, e.language, e.assumeNearbyYear) }); var h = String(e.orientation).toLowerCase().split(/\s+/g), i = e.orientation.toLowerCase(); if (h = a.grep(h, function (a) { return /^auto|left|right|top|bottom$/.test(a) }), e.orientation = { x: "auto", y: "auto" }, i && "auto" !== i) if (1 === h.length) switch (h[0]) { case "top": case "bottom": e.orientation.y = h[0]; break; case "left": case "right": e.orientation.x = h[0] } else i = a.grep(h, function (a) { return /^left|right$/.test(a) }), e.orientation.x = i[0] || "auto", i = a.grep(h, function (a) { return /^top|bottom$/.test(a) }), e.orientation.y = i[0] || "auto"; else; if (e.defaultViewDate instanceof Date || "string" == typeof e.defaultViewDate) e.defaultViewDate = r.parseDate(e.defaultViewDate, g, e.language, e.assumeNearbyYear); else if (e.defaultViewDate) { var j = e.defaultViewDate.year || (new Date).getFullYear(), k = e.defaultViewDate.month || 0, l = e.defaultViewDate.day || 1; e.defaultViewDate = c(j, k, l) } else e.defaultViewDate = d() }, _events: [], _secondaryEvents: [], _applyEvents: function (a) { for (var c, d, e, f = 0; f < a.length; f++) c = a[f][0], 2 === a[f].length ? (d = b, e = a[f][1]) : 3 === a[f].length && (d = a[f][1], e = a[f][2]), c.on(e, d) }, _unapplyEvents: function (a) { for (var c, d, e, f = 0; f < a.length; f++) c = a[f][0], 2 === a[f].length ? (e = b, d = a[f][1]) : 3 === a[f].length && (e = a[f][1], d = a[f][2]), c.off(d, e) }, _buildEvents: function () { var b = { keyup: a.proxy(function (b) { a.inArray(b.keyCode, [27, 37, 39, 38, 40, 32, 13, 9]) === -1 && this.update() }, this), keydown: a.proxy(this.keydown, this), paste: a.proxy(this.paste, this) }; this.o.showOnFocus === !0 && (b.focus = a.proxy(this.show, this)), this.isInput ? this._events = [ [this.element, b] ] : this.component && this.inputField.length ? this._events = [ [this.inputField, b], [this.component, { click: a.proxy(this.show, this) }] ] : this._events = [ [this.element, { click: a.proxy(this.show, this), keydown: a.proxy(this.keydown, this) }] ], this._events.push([this.element, "*", { blur: a.proxy(function (a) { this._focused_from = a.target }, this) }], [this.element, { blur: a.proxy(function (a) { this._focused_from = a.target }, this) }]), this.o.immediateUpdates && this._events.push([this.element, { "changeYear changeMonth": a.proxy(function (a) { this.update(a.date) }, this) }]), this._secondaryEvents = [ [this.picker, { click: a.proxy(this.click, this) }], [this.picker, ".prev, .next", { click: a.proxy(this.navArrowsClick, this) }], [this.picker, ".day:not(.disabled)", { click: a.proxy(this.dayCellClick, this) }], [a(window), { resize: a.proxy(this.place, this) }], [a(document), { "mousedown touchstart": a.proxy(function (a) { this.element.is(a.target) || this.element.find(a.target).length || this.picker.is(a.target) || this.picker.find(a.target).length || this.isInline || this.hide() }, this) }] ] }, _attachEvents: function () { this._detachEvents(), this._applyEvents(this._events) }, _detachEvents: function () { this._unapplyEvents(this._events) }, _attachSecondaryEvents: function () { this._detachSecondaryEvents(), this._applyEvents(this._secondaryEvents) }, _detachSecondaryEvents: function () { this._unapplyEvents(this._secondaryEvents) }, _trigger: function (b, c) { var d = c || this.dates.get(-1), e = this._utc_to_local(d); this.element.trigger({ type: b, date: e, viewMode: this.viewMode, dates: a.map(this.dates, this._utc_to_local), format: a.proxy(function (a, b) { 0 === arguments.length ? (a = this.dates.length - 1, b = this.o.format) : "string" == typeof a && (b = a, a = this.dates.length - 1), b = b || this.o.format; var c = this.dates.get(a); return r.formatDate(c, b, this.o.language) }, this) }) }, show: function () { if (!(this.inputField.prop("disabled") || this.inputField.prop("readonly") && this.o.enableOnReadonly === !1)) return this.isInline || this.picker.appendTo(this.o.container), this.place(), this.picker.show(), this._attachSecondaryEvents(), this._trigger("show"), (window.navigator.msMaxTouchPoints || "ontouchstart" in document) && this.o.disableTouchKeyboard && a(this.element).blur(), this }, hide: function () { return this.isInline || !this.picker.is(":visible") ? this : (this.focusDate = null, this.picker.hide().detach(), this._detachSecondaryEvents(), this.setViewMode(this.o.startView), this.o.forceParse && this.inputField.val() && this.setValue(), this._trigger("hide"), this) }, destroy: function () { return this.hide(), this._detachEvents(), this._detachSecondaryEvents(), this.picker.remove(), delete this.element.data().datepicker, this.isInput || delete this.element.data().date, this }, paste: function (b) { var c; if (b.originalEvent.clipboardData && b.originalEvent.clipboardData.types && a.inArray("text/plain", b.originalEvent.clipboardData.types) !== -1) c = b.originalEvent.clipboardData.getData("text/plain"); else { if (!window.clipboardData) return; c = window.clipboardData.getData("Text") } this.setDate(c), this.update(), b.preventDefault() }, _utc_to_local: function (a) { if (!a) return a; var b = new Date(a.getTime() + 6e4 * a.getTimezoneOffset()); return b.getTimezoneOffset() !== a.getTimezoneOffset() && (b = new Date(a.getTime() + 6e4 * b.getTimezoneOffset())), b }, _local_to_utc: function (a) { return a && new Date(a.getTime() - 6e4 * a.getTimezoneOffset()) }, _zero_time: function (a) { return a && new Date(a.getFullYear(), a.getMonth(), a.getDate()) }, _zero_utc_time: function (a) { return a && c(a.getUTCFullYear(), a.getUTCMonth(), a.getUTCDate()) }, getDates: function () { return a.map(this.dates, this._utc_to_local) }, getUTCDates: function () { return a.map(this.dates, function (a) { return new Date(a) }) }, getDate: function () { return this._utc_to_local(this.getUTCDate()) }, getUTCDate: function () { var a = this.dates.get(-1); return a !== b ? new Date(a) : null }, clearDates: function () { this.inputField.val(""), this.update(), this._trigger("changeDate"), this.o.autoclose && this.hide() }, setDates: function () { var b = a.isArray(arguments[0]) ? arguments[0] : arguments; return this.update.apply(this, b), this._trigger("changeDate"), this.setValue(), this }, setUTCDates: function () { var b = a.isArray(arguments[0]) ? arguments[0] : arguments; return this.setDates.apply(this, a.map(b, this._utc_to_local)), this }, setDate: f("setDates"), setUTCDate: f("setUTCDates"), remove: f("destroy", "Method `remove` is deprecated and will be removed in version 2.0. Use `destroy` instead"), setValue: function () { var a = this.getFormattedDate(); return this.inputField.val(a), this }, getFormattedDate: function (c) { c === b && (c = this.o.format); var d = this.o.language; return a.map(this.dates, function (a) { return r.formatDate(a, c, d) }).join(this.o.multidateSeparator) }, getStartDate: function () { return this.o.startDate }, setStartDate: function (a) { return this._process_options({ startDate: a }), this.update(), this.updateNavArrows(), this }, getEndDate: function () { return this.o.endDate }, setEndDate: function (a) { return this._process_options({ endDate: a }), this.update(), this.updateNavArrows(), this }, setDaysOfWeekDisabled: function (a) { return this._process_options({ daysOfWeekDisabled: a }), this.update(), this }, setDaysOfWeekHighlighted: function (a) { return this._process_options({ daysOfWeekHighlighted: a }), this.update(), this }, setDatesDisabled: function (a) { return this._process_options({ datesDisabled: a }), this.update(), this }, place: function () { if (this.isInline) return this; var b = this.picker.outerWidth(), c = this.picker.outerHeight(), d = 10, e = a(this.o.container), f = e.width(), g = "body" === this.o.container ? a(document).scrollTop() : e.scrollTop(), h = e.offset(), i = [0]; this.element.parents().each(function () { var b = a(this).css("z-index"); "auto" !== b && 0 !== Number(b) && i.push(Number(b)) }); var j = Math.max.apply(Math, i) + this.o.zIndexOffset, k = this.component ? this.component.parent().offset() : this.element.offset(), l = this.component ? this.component.outerHeight(!0) : this.element.outerHeight(!1), m = this.component ? this.component.outerWidth(!0) : this.element.outerWidth(!1), n = k.left - h.left, o = k.top - h.top; "body" !== this.o.container && (o += g), this.picker.removeClass("datepicker-orient-top datepicker-orient-bottom datepicker-orient-right datepicker-orient-left"), "auto" !== this.o.orientation.x ? (this.picker.addClass("datepicker-orient-" + this.o.orientation.x), "right" === this.o.orientation.x && (n -= b - m)) : k.left < 0 ? (this.picker.addClass("datepicker-orient-left"), n -= k.left - d) : n + b > f ? (this.picker.addClass("datepicker-orient-right"), n += m - b) : this.o.rtl ? this.picker.addClass("datepicker-orient-right") : this.picker.addClass("datepicker-orient-left"); var p, q = this.o.orientation.y; if ("auto" === q && (p = -g + o - c, q = p < 0 ? "bottom" : "top"), this.picker.addClass("datepicker-orient-" + q), "top" === q ? o -= c + parseInt(this.picker.css("padding-top")) : o += l, this.o.rtl) { var r = f - (n + m); this.picker.css({ top: o, right: r, zIndex: j }) } else this.picker.css({ top: o, left: n, zIndex: j }); return this }, _allow_update: !0, update: function () { if (!this._allow_update) return this; var b = this.dates.copy(), c = [], d = !1; return arguments.length ? (a.each(arguments, a.proxy(function (a, b) { b instanceof Date && (b = this._local_to_utc(b)), c.push(b) }, this)), d = !0) : (c = this.isInput ? this.element.val() : this.element.data("date") || this.inputField.val(), c = c && this.o.multidate ? c.split(this.o.multidateSeparator) : [c], delete this.element.data().date), c = a.map(c, a.proxy(function (a) { return r.parseDate(a, this.o.format, this.o.language, this.o.assumeNearbyYear) }, this)), c = a.grep(c, a.proxy(function (a) { return !this.dateWithinRange(a) || !a }, this), !0), this.dates.replace(c), this.o.updateViewDate && (this.dates.length ? this.viewDate = new Date(this.dates.get(-1)) : this.viewDate < this.o.startDate ? this.viewDate = new Date(this.o.startDate) : this.viewDate > this.o.endDate ? this.viewDate = new Date(this.o.endDate) : this.viewDate = this.o.defaultViewDate), d ? (this.setValue(), this.element.change()) : this.dates.length && String(b) !== String(this.dates) && d && (this._trigger("changeDate"), this.element.change()), !this.dates.length && b.length && (this._trigger("clearDate"), this.element.change()), this.fill(), this }, fillDow: function () { if (this.o.showWeekDays) { var b = this.o.weekStart, c = ""; for (this.o.calendarWeeks && (c += ' '); b < this.o.weekStart + 7;) c += '"; c += "", this.picker.find(".datepicker-days thead").append(c) } }, fillMonths: function () { for (var a, b = this._utc_to_local(this.viewDate), c = "", d = 0; d < 12; d++) a = b && b.getMonth() === d ? " focused" : "", c += '' + q[this.o.language].monthsShort[d] + ""; this.picker.find(".datepicker-months td").html(c) }, setRange: function (b) { b && b.length ? this.range = a.map(b, function (a) { return a.valueOf() }) : delete this.range, this.fill() }, getClassNames: function (b) { var c = [], f = this.viewDate.getUTCFullYear(), g = this.viewDate.getUTCMonth(), h = d(); return b.getUTCFullYear() < f || b.getUTCFullYear() === f && b.getUTCMonth() < g ? c.push("old") : (b.getUTCFullYear() > f || b.getUTCFullYear() === f && b.getUTCMonth() > g) && c.push("new"), this.focusDate && b.valueOf() === this.focusDate.valueOf() && c.push("focused"), this.o.todayHighlight && e(b, h) && c.push("today"), this.dates.contains(b) !== -1 && c.push("active"), this.dateWithinRange(b) || c.push("disabled"), this.dateIsDisabled(b) && c.push("disabled", "disabled-date"), a.inArray(b.getUTCDay(), this.o.daysOfWeekHighlighted) !== -1 && c.push("highlighted"), this.range && (b > this.range[0] && b < this.range[this.range.length - 1] && c.push("range"), a.inArray(b.valueOf(), this.range) !== -1 && c.push("selected"), b.valueOf() === this.range[0] && c.push("range-start"), b.valueOf() === this.range[this.range.length - 1] && c.push("range-end")), c }, _fill_yearsView: function (c, d, e, f, g, h, i) { for (var j, k, l, m = "", n = e / 10, o = this.picker.find(c), p = Math.floor(f / e) * e, q = p + 9 * n, r = Math.floor(this.viewDate.getFullYear() / n) * n, s = a.map(this.dates, function (a) { return Math.floor(a.getUTCFullYear() / n) * n }), t = p - n; t <= q + n; t += n) j = [d], k = null, t === p - n ? j.push("old") : t === q + n && j.push("new"), a.inArray(t, s) !== -1 && j.push("active"), (t < g || t > h) && j.push("disabled"), t === r && j.push("focused"), i !== a.noop && (l = i(new Date(t, 0, 1)), l === b ? l = {} : "boolean" == typeof l ? l = { enabled: l } : "string" == typeof l && (l = { classes: l }), l.enabled === !1 && j.push("disabled"), l.classes && (j = j.concat(l.classes.split(/\s+/))), l.tooltip && (k = l.tooltip)), m += '" + t + ""; o.find(".datepicker-switch").text(p + "-" + q), o.find("td").html(m) }, fill: function () { var d, e, f = new Date(this.viewDate), g = f.getUTCFullYear(), h = f.getUTCMonth(), i = this.o.startDate !== -(1 / 0) ? this.o.startDate.getUTCFullYear() : -(1 / 0), j = this.o.startDate !== -(1 / 0) ? this.o.startDate.getUTCMonth() : -(1 / 0), k = this.o.endDate !== 1 / 0 ? this.o.endDate.getUTCFullYear() : 1 / 0, l = this.o.endDate !== 1 / 0 ? this.o.endDate.getUTCMonth() : 1 / 0, m = q[this.o.language].today || q.en.today || "", n = q[this.o.language].clear || q.en.clear || "", o = q[this.o.language].titleFormat || q.en.titleFormat; if (!isNaN(g) && !isNaN(h)) { this.picker.find(".datepicker-days .datepicker-switch").text(r.formatDate(f, o, this.o.language)), this.picker.find("tfoot .today").text(m).css("display", this.o.todayBtn === !0 || "linked" === this.o.todayBtn ? "table-cell" : "none"), this.picker.find("tfoot .clear").text(n).css("display", this.o.clearBtn === !0 ? "table-cell" : "none"), this.picker.find("thead .datepicker-title").text(this.o.title).css("display", "string" == typeof this.o.title && "" !== this.o.title ? "table-cell" : "none"), this.updateNavArrows(), this.fillMonths(); var p = c(g, h, 0), s = p.getUTCDate(); p.setUTCDate(s - (p.getUTCDay() - this.o.weekStart + 7) % 7); var t = new Date(p); p.getUTCFullYear() < 100 && t.setUTCFullYear(p.getUTCFullYear()), t.setUTCDate(t.getUTCDate() + 42), t = t.valueOf(); for (var u, v, w = []; p.valueOf() < t;) { if (u = p.getUTCDay(), u === this.o.weekStart && (w.push(""), this.o.calendarWeeks)) { var x = new Date(+p + (this.o.weekStart - u - 7) % 7 * 864e5), y = new Date(Number(x) + (11 - x.getUTCDay()) % 7 * 864e5), z = new Date(Number(z = c(y.getUTCFullYear(), 0, 1)) + (11 - z.getUTCDay()) % 7 * 864e5), A = (y - z) / 864e5 / 7 + 1; w.push('' + A + "") } v = this.getClassNames(p), v.push("day"); var B = p.getUTCDate(); this.o.beforeShowDay !== a.noop && (e = this.o.beforeShowDay(this._utc_to_local(p)), e === b ? e = {} : "boolean" == typeof e ? e = { enabled: e } : "string" == typeof e && (e = { classes: e }), e.enabled === !1 && v.push("disabled"), e.classes && (v = v.concat(e.classes.split(/\s+/))), e.tooltip && (d = e.tooltip), e.content && (B = e.content)), v = a.isFunction(a.uniqueSort) ? a.uniqueSort(v) : a.unique(v), w.push('' + B + ""), d = null, u === this.o.weekEnd && w.push(""), p.setUTCDate(p.getUTCDate() + 1) } this.picker.find(".datepicker-days tbody").html(w.join("")); var C = q[this.o.language].monthsTitle || q.en.monthsTitle || "Months", D = this.picker.find(".datepicker-months").find(".datepicker-switch").text(this.o.maxViewMode < 2 ? C : g).end().find("tbody span").removeClass("active"); if (a.each(this.dates, function (a, b) { b.getUTCFullYear() === g && D.eq(b.getUTCMonth()).addClass("active") }), (g < i || g > k) && D.addClass("disabled"), g === i && D.slice(0, j).addClass("disabled"), g === k && D.slice(l + 1).addClass("disabled"), this.o.beforeShowMonth !== a.noop) { var E = this; a.each(D, function (c, d) { var e = new Date(g, c, 1), f = E.o.beforeShowMonth(e); f === b ? f = {} : "boolean" == typeof f ? f = { enabled: f } : "string" == typeof f && (f = { classes: f }), f.enabled !== !1 || a(d).hasClass("disabled") || a(d).addClass("disabled"), f.classes && a(d).addClass(f.classes), f.tooltip && a(d).prop("title", f.tooltip) }) } this._fill_yearsView(".datepicker-years", "year", 10, g, i, k, this.o.beforeShowYear), this._fill_yearsView(".datepicker-decades", "decade", 100, g, i, k, this.o.beforeShowDecade), this._fill_yearsView(".datepicker-centuries", "century", 1e3, g, i, k, this.o.beforeShowCentury) } }, updateNavArrows: function () { if (this._allow_update) { var a, b, c = new Date(this.viewDate), d = c.getUTCFullYear(), e = c.getUTCMonth(), f = this.o.startDate !== -(1 / 0) ? this.o.startDate.getUTCFullYear() : -(1 / 0), g = this.o.startDate !== -(1 / 0) ? this.o.startDate.getUTCMonth() : -(1 / 0), h = this.o.endDate !== 1 / 0 ? this.o.endDate.getUTCFullYear() : 1 / 0, i = this.o.endDate !== 1 / 0 ? this.o.endDate.getUTCMonth() : 1 / 0, j = 1; switch (this.viewMode) { case 4: j *= 10; case 3: j *= 10; case 2: j *= 10; case 1: a = Math.floor(d / j) * j < f, b = Math.floor(d / j) * j + j > h; break; case 0: a = d <= f && e < g, b = d >= h && e > i } this.picker.find(".prev").toggleClass("disabled", a), this.picker.find(".next").toggleClass("disabled", b) } }, click: function (b) { b.preventDefault(), b.stopPropagation(); var e, f, g, h; e = a(b.target), e.hasClass("datepicker-switch") && this.viewMode !== this.o.maxViewMode && this.setViewMode(this.viewMode + 1), e.hasClass("today") && !e.hasClass("day") && (this.setViewMode(0), this._setDate(d(), "linked" === this.o.todayBtn ? null : "view")), e.hasClass("clear") && this.clearDates(), e.hasClass("disabled") || (e.hasClass("month") || e.hasClass("year") || e.hasClass("decade") || e.hasClass("century")) && (this.viewDate.setUTCDate(1), f = 1, 1 === this.viewMode ? (h = e.parent().find("span").index(e), g = this.viewDate.getUTCFullYear(), this.viewDate.setUTCMonth(h)) : (h = 0, g = Number(e.text()), this.viewDate.setUTCFullYear(g)), this._trigger(r.viewModes[this.viewMode - 1].e, this.viewDate), this.viewMode === this.o.minViewMode ? this._setDate(c(g, h, f)) : (this.setViewMode(this.viewMode - 1), this.fill())), this.picker.is(":visible") && this._focused_from && this._focused_from.focus(), delete this._focused_from }, dayCellClick: function (b) { var c = a(b.currentTarget), d = c.data("date"), e = new Date(d); this.o.updateViewDate && (e.getUTCFullYear() !== this.viewDate.getUTCFullYear() && this._trigger("changeYear", this.viewDate), e.getUTCMonth() !== this.viewDate.getUTCMonth() && this._trigger("changeMonth", this.viewDate)), this._setDate(e) }, navArrowsClick: function (b) { var c = a(b.currentTarget), d = c.hasClass("prev") ? -1 : 1; 0 !== this.viewMode && (d *= 12 * r.viewModes[this.viewMode].navStep), this.viewDate = this.moveMonth(this.viewDate, d), this._trigger(r.viewModes[this.viewMode].e, this.viewDate), this.fill() }, _toggle_multidate: function (a) { var b = this.dates.contains(a); if (a || this.dates.clear(), b !== -1 ? (this.o.multidate === !0 || this.o.multidate > 1 || this.o.toggleActive) && this.dates.remove(b) : this.o.multidate === !1 ? (this.dates.clear(), this.dates.push(a)) : this.dates.push(a), "number" == typeof this.o.multidate) for (; this.dates.length > this.o.multidate;) this.dates.remove(0) }, _setDate: function (a, b) { b && "date" !== b || this._toggle_multidate(a && new Date(a)), (!b && this.o.updateViewDate || "view" === b) && (this.viewDate = a && new Date(a)), this.fill(), this.setValue(), b && "view" === b || this._trigger("changeDate"), this.inputField.trigger("change"), !this.o.autoclose || b && "date" !== b || this.hide() }, moveDay: function (a, b) { var c = new Date(a); return c.setUTCDate(a.getUTCDate() + b), c }, moveWeek: function (a, b) { return this.moveDay(a, 7 * b) }, moveMonth: function (a, b) { if (!g(a)) return this.o.defaultViewDate; if (!b) return a; var c, d, e = new Date(a.valueOf()), f = e.getUTCDate(), h = e.getUTCMonth(), i = Math.abs(b); if (b = b > 0 ? 1 : -1, 1 === i) d = b === -1 ? function () { return e.getUTCMonth() === h } : function () { return e.getUTCMonth() !== c }, c = h + b, e.setUTCMonth(c), c = (c + 12) % 12; else { for (var j = 0; j < i; j++) e = this.moveMonth(e, b); c = e.getUTCMonth(), e.setUTCDate(f), d = function () { return c !== e.getUTCMonth() } } for (; d();) e.setUTCDate(--f), e.setUTCMonth(c); return e }, moveYear: function (a, b) { return this.moveMonth(a, 12 * b) }, moveAvailableDate: function (a, b, c) { do { if (a = this[c](a, b), !this.dateWithinRange(a)) return !1; c = "moveDay" } while (this.dateIsDisabled(a)); return a }, weekOfDateIsDisabled: function (b) { return a.inArray(b.getUTCDay(), this.o.daysOfWeekDisabled) !== -1 }, dateIsDisabled: function (b) { return this.weekOfDateIsDisabled(b) || a.grep(this.o.datesDisabled, function (a) { return e(b, a) }).length > 0 }, dateWithinRange: function (a) { return a >= this.o.startDate && a <= this.o.endDate }, keydown: function (a) { if (!this.picker.is(":visible")) return void(40 !== a.keyCode && 27 !== a.keyCode || (this.show(), a.stopPropagation())); var b, c, d = !1, e = this.focusDate || this.viewDate; switch (a.keyCode) { case 27: this.focusDate ? (this.focusDate = null, this.viewDate = this.dates.get(-1) || this.viewDate, this.fill()) : this.hide(), a.preventDefault(), a.stopPropagation(); break; case 37: case 38: case 39: case 40: if (!this.o.keyboardNavigation || 7 === this.o.daysOfWeekDisabled.length) break; b = 37 === a.keyCode || 38 === a.keyCode ? -1 : 1, 0 === this.viewMode ? a.ctrlKey ? (c = this.moveAvailableDate(e, b, "moveYear"), c && this._trigger("changeYear", this.viewDate)) : a.shiftKey ? (c = this.moveAvailableDate(e, b, "moveMonth"), c && this._trigger("changeMonth", this.viewDate)) : 37 === a.keyCode || 39 === a.keyCode ? c = this.moveAvailableDate(e, b, "moveDay") : this.weekOfDateIsDisabled(e) || (c = this.moveAvailableDate(e, b, "moveWeek")) : 1 === this.viewMode ? (38 !== a.keyCode && 40 !== a.keyCode || (b *= 4), c = this.moveAvailableDate(e, b, "moveMonth")) : 2 === this.viewMode && (38 !== a.keyCode && 40 !== a.keyCode || (b *= 4), c = this.moveAvailableDate(e, b, "moveYear")), c && (this.focusDate = this.viewDate = c, this.setValue(), this.fill(), a.preventDefault()); break; case 13: if (!this.o.forceParse) break; e = this.focusDate || this.dates.get(-1) || this.viewDate, this.o.keyboardNavigation && (this._toggle_multidate(e), d = !0), this.focusDate = null, this.viewDate = this.dates.get(-1) || this.viewDate, this.setValue(), this.fill(), this.picker.is(":visible") && (a.preventDefault(), a.stopPropagation(), this.o.autoclose && this.hide()); break; case 9: this.focusDate = null, this.viewDate = this.dates.get(-1) || this.viewDate, this.fill(), this.hide() } d && (this.dates.length ? this._trigger("changeDate") : this._trigger("clearDate"), this.inputField.trigger("change")) }, setViewMode: function (a) { this.viewMode = a, this.picker.children("div").hide().filter(".datepicker-" + r.viewModes[this.viewMode].clsName).show(), this.updateNavArrows(), this._trigger("changeViewMode", new Date(this.viewDate)) } }; var l = function (b, c) { a.data(b, "datepicker", this), this.element = a(b), this.inputs = a.map(c.inputs, function (a) { return a.jquery ? a[0] : a }), delete c.inputs, this.keepEmptyValues = c.keepEmptyValues, delete c.keepEmptyValues, n.call(a(this.inputs), c).on("changeDate", a.proxy(this.dateUpdated, this)), this.pickers = a.map(this.inputs, function (b) { return a.data(b, "datepicker") }), this.updateDates() }; l.prototype = { updateDates: function () { this.dates = a.map(this.pickers, function (a) { return a.getUTCDate() }), this.updateRanges() }, updateRanges: function () { var b = a.map(this.dates, function (a) { return a.valueOf() }); a.each(this.pickers, function (a, c) { c.setRange(b) }) }, clearDates: function () { a.each(this.pickers, function (a, b) { b.clearDates() }) }, dateUpdated: function (c) { if (!this.updating) { this.updating = !0; var d = a.data(c.target, "datepicker"); if (d !== b) { var e = d.getUTCDate(), f = this.keepEmptyValues, g = a.inArray(c.target, this.inputs), h = g - 1, i = g + 1, j = this.inputs.length; if (g !== -1) { if (a.each(this.pickers, function (a, b) { b.getUTCDate() || b !== d && f || b.setUTCDate(e) }), e < this.dates[h]) for (; h >= 0 && e < this.dates[h];) this.pickers[h--].setUTCDate(e); else if (e > this.dates[i]) for (; i < j && e > this.dates[i];) this.pickers[i++].setUTCDate(e); this.updateDates(), delete this.updating } } } }, destroy: function () { a.map(this.pickers, function (a) { a.destroy() }), a(this.inputs).off("changeDate", this.dateUpdated), delete this.element.data().datepicker }, remove: f("destroy", "Method `remove` is deprecated and will be removed in version 2.0. Use `destroy` instead") }; var m = a.fn.datepicker, n = function (c) { var d = Array.apply(null, arguments); d.shift(); var e; if (this.each(function () { var b = a(this), f = b.data("datepicker"), g = "object" == typeof c && c; if (!f) { var j = h(this, "date"), m = a.extend({}, o, j, g), n = i(m.language), p = a.extend({}, o, n, j, g); b.hasClass("input-daterange") || p.inputs ? (a.extend(p, { inputs: p.inputs || b.find("input").toArray() }), f = new l(this, p)) : f = new k(this, p), b.data("datepicker", f) } "string" == typeof c && "function" == typeof f[c] && (e = f[c].apply(f, d)) }), e === b || e instanceof k || e instanceof l) return this; if (this.length > 1) throw new Error("Using only allowed for the collection of a single element (" + c + " function)"); return e }; a.fn.datepicker = n; var o = a.fn.datepicker.defaults = { assumeNearbyYear: !1, autoclose: !1, beforeShowDay: a.noop, beforeShowMonth: a.noop, beforeShowYear: a.noop, beforeShowDecade: a.noop, beforeShowCentury: a.noop, calendarWeeks: !1, clearBtn: !1, toggleActive: !1, daysOfWeekDisabled: [], daysOfWeekHighlighted: [], datesDisabled: [], endDate: 1 / 0, forceParse: !0, format: "mm/dd/yyyy", keepEmptyValues: !1, keyboardNavigation: !0, language: "en", minViewMode: 0, maxViewMode: 4, multidate: !1, multidateSeparator: ",", orientation: "auto", rtl: !1, startDate: -(1 / 0), startView: 0, todayBtn: !1, todayHighlight: !1, updateViewDate: !0, weekStart: 0, disableTouchKeyboard: !1, enableOnReadonly: !0, showOnFocus: !0, zIndexOffset: 10, container: "body", immediateUpdates: !1, title: "", templates: { leftArrow: "«", rightArrow: "»" }, showWeekDays: !0 }, p = a.fn.datepicker.locale_opts = ["format", "rtl", "weekStart"]; a.fn.datepicker.Constructor = k; var q = a.fn.datepicker.dates = { en: { days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], today: "Today", clear: "Clear", titleFormat: "MM yyyy" } }, r = { viewModes: [{ names: ["days", "month"], clsName: "days", e: "changeMonth" }, { names: ["months", "year"], clsName: "months", e: "changeYear", navStep: 1 }, { names: ["years", "decade"], clsName: "years", e: "changeDecade", navStep: 10 }, { names: ["decades", "century"], clsName: "decades", e: "changeCentury", navStep: 100 }, { names: ["centuries", "millennium"], clsName: "centuries", e: "changeMillennium", navStep: 1e3 }], validParts: /dd?|DD?|mm?|MM?|yy(?:yy)?/g, nonpunctuation: /[^ -\/:-@\u5e74\u6708\u65e5\[-`{-~\t\n\r]+/g, parseFormat: function (a) { if ("function" == typeof a.toValue && "function" == typeof a.toDisplay) return a; var b = a.replace(this.validParts, "\0").split("\0"), c = a.match(this.validParts); if (!b || !b.length || !c || 0 === c.length) throw new Error("Invalid date format."); return { separators: b, parts: c } }, parseDate: function (c, e, f, g) { function h(a, b) { return b === !0 && (b = 10), a < 100 && (a += 2e3, a > (new Date).getFullYear() + b && (a -= 100)), a } function i() { var a = this.slice(0, j[n].length), b = j[n].slice(0, a.length); return a.toLowerCase() === b.toLowerCase() } if (!c) return b; if (c instanceof Date) return c; if ("string" == typeof e && (e = r.parseFormat(e)), e.toValue) return e.toValue(c, e, f); var j, l, m, n, o, p = { d: "moveDay", m: "moveMonth", w: "moveWeek", y: "moveYear" }, s = { yesterday: "-1d", today: "+0d", tomorrow: "+1d" }; if (c in s && (c = s[c]), /^[\-+]\d+[dmwy]([\s,]+[\-+]\d+[dmwy])*$/i.test(c)) { for (j = c.match(/([\-+]\d+)([dmwy])/gi), c = new Date, n = 0; n < j.length; n++) l = j[n].match(/([\-+]\d+)([dmwy])/i), m = Number(l[1]), o = p[l[2].toLowerCase()], c = k.prototype[o](c, m); return k.prototype._zero_utc_time(c) } j = c && c.match(this.nonpunctuation) || []; var t, u, v = {}, w = ["yyyy", "yy", "M", "MM", "m", "mm", "d", "dd"], x = { yyyy: function (a, b) { return a.setUTCFullYear(g ? h(b, g) : b) }, m: function (a, b) { if (isNaN(a)) return a; for (b -= 1; b < 0;) b += 12; for (b %= 12, a.setUTCMonth(b); a.getUTCMonth() !== b;) a.setUTCDate(a.getUTCDate() - 1); return a }, d: function (a, b) { return a.setUTCDate(b) } }; x.yy = x.yyyy, x.M = x.MM = x.mm = x.m, x.dd = x.d, c = d(); var y = e.parts.slice(); if (j.length !== y.length && (y = a(y).filter(function (b, c) { return a.inArray(c, w) !== -1 }).toArray()), j.length === y.length) { var z; for (n = 0, z = y.length; n < z; n++) { if (t = parseInt(j[n], 10), l = y[n], isNaN(t)) switch (l) { case "MM": u = a(q[f].months).filter(i), t = a.inArray(u[0], q[f].months) + 1; break; case "M": u = a(q[f].monthsShort).filter(i), t = a.inArray(u[0], q[f].monthsShort) + 1 } v[l] = t } var A, B; for (n = 0; n < w.length; n++) B = w[n], B in v && !isNaN(v[B]) && (A = new Date(c), x[B](A, v[B]), isNaN(A) || (c = A)) } return c }, formatDate: function (b, c, d) { if (!b) return ""; if ("string" == typeof c && (c = r.parseFormat(c)), c.toDisplay) return c.toDisplay(b, c, d); var e = { d: b.getUTCDate(), D: q[d].daysShort[b.getUTCDay()], DD: q[d].days[b.getUTCDay()], m: b.getUTCMonth() + 1, M: q[d].monthsShort[b.getUTCMonth()], MM: q[d].months[b.getUTCMonth()], yy: b.getUTCFullYear().toString().substring(2), yyyy: b.getUTCFullYear() }; e.dd = (e.d < 10 ? "0" : "") + e.d, e.mm = (e.m < 10 ? "0" : "") + e.m, b = []; for (var f = a.extend([], c.separators), g = 0, h = c.parts.length; g <= h; g++) f.length && b.push(f.shift()), b.push(e[c.parts[g]]); return b.join("") }, headTemplate: '' + o.templates.leftArrow + '' + o.templates.rightArrow + "", contTemplate: '', footTemplate: '' }; r.template = '
' + r.headTemplate + "" + r.footTemplate + '
' + r.headTemplate + r.contTemplate + r.footTemplate + '
' + r.headTemplate + r.contTemplate + r.footTemplate + '
' + r.headTemplate + r.contTemplate + r.footTemplate + '
' + r.headTemplate + r.contTemplate + r.footTemplate + "
", a.fn.datepicker.DPGlobal = r, a.fn.datepicker.noConflict = function () { return a.fn.datepicker = m, this }, a.fn.datepicker.version = "1.8.0", a.fn.datepicker.deprecated = function (a) { var b = window.console; b && b.warn && b.warn("DEPRECATED: " + a) }, a(document).on("focus.datepicker.data-api click.datepicker.data-api", '[data-provide="datepicker"]', function (b) { var c = a(this); c.data("datepicker") || (b.preventDefault(), n.call(c, "show")) }), a(function () { n.call(a('[data-provide="datepicker-inline"]')) }) }); ! function (a) { a.fn.datepicker.dates["zh-TW"] = { days: ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"], daysShort: ["週日", "週一", "週二", "週三", "週四", "週五", "週六"], daysMin: ["日", "一", "二", "三", "四", "五", "六"], months: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"], monthsShort: ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"], today: "今天", format: "yyyy年mm月dd日", weekStart: 1, clear: "清除" } }(jQuery); /** * jQuery TWzipcode plugin * https://code.essoduke.org/twzipcode/ * Copyright 2017 essoduke.org, Licensed MIT. * * Changelog * ------------------------------- * 修正新竹縣「峨嵋鄉」為「峨眉鄉」 * * @author essoduke.org * @license MIT License */ ; (function ($, window, document, undefined) { 'use strict'; // Zipcode JSON data var data = { '基隆市': { '仁愛區': '200', '信義區': '201', '中正區': '202', '中山區': '203', '安樂區': '204', '暖暖區': '205', '七堵區': '206' }, '臺北市': { '中正區': '100', '大同區': '103', '中山區': '104', '松山區': '105', '大安區': '106', '萬華區': '108', '信義區': '110', '士林區': '111', '北投區': '112', '內湖區': '114', '南港區': '115', '文山區': '116' }, '新北市': { '萬里區': '207', '金山區': '208', '板橋區': '220', '汐止區': '221', '深坑區': '222', '石碇區': '223', '瑞芳區': '224', '平溪區': '226', '雙溪區': '227', '貢寮區': '228', '新店區': '231', '坪林區': '232', '烏來區': '233', '永和區': '234', '中和區': '235', '土城區': '236', '三峽區': '237', '樹林區': '238', '鶯歌區': '239', '三重區': '241', '新莊區': '242', '泰山區': '243', '林口區': '244', '蘆洲區': '247', '五股區': '248', '八里區': '249', '淡水區': '251', '三芝區': '252', '石門區': '253' }, '宜蘭縣': { '宜蘭市': '260', '頭城鎮': '261', '礁溪鄉': '262', '壯圍鄉': '263', '員山鄉': '264', '羅東鎮': '265', '三星鄉': '266', '大同鄉': '267', '五結鄉': '268', '冬山鄉': '269', '蘇澳鎮': '270', '南澳鄉': '272', '釣魚臺列嶼': '290' }, '新竹市': { '東區': '300', '北區': '300', '香山區': '300' }, '新竹縣': { '竹北市': '302', '湖口鄉': '303', '新豐鄉': '304', '新埔鎮': '305', '關西鎮': '306', '芎林鄉': '307', '寶山鄉': '308', '竹東鎮': '310', '五峰鄉': '311', '橫山鄉': '312', '尖石鄉': '313', '北埔鄉': '314', '峨眉鄉': '315' }, '桃園市': { '中壢區': '320', '平鎮區': '324', '龍潭區': '325', '楊梅區': '326', '新屋區': '327', '觀音區': '328', '桃園區': '330', '龜山區': '333', '八德區': '334', '大溪區': '335', '復興區': '336', '大園區': '337', '蘆竹區': '338' }, '苗栗縣': { '竹南鎮': '350', '頭份市': '351', '三灣鄉': '352', '南庄鄉': '353', '獅潭鄉': '354', '後龍鎮': '356', '通霄鎮': '357', '苑裡鎮': '358', '苗栗市': '360', '造橋鄉': '361', '頭屋鄉': '362', '公館鄉': '363', '大湖鄉': '364', '泰安鄉': '365', '銅鑼鄉': '366', '三義鄉': '367', '西湖鄉': '368', '卓蘭鎮': '369' }, '臺中市': { '中區': '400', '東區': '401', '南區': '402', '西區': '403', '北區': '404', '北屯區': '406', '西屯區': '407', '南屯區': '408', '太平區': '411', '大里區': '412', '霧峰區': '413', '烏日區': '414', '豐原區': '420', '后里區': '421', '石岡區': '422', '東勢區': '423', '和平區': '424', '新社區': '426', '潭子區': '427', '大雅區': '428', '神岡區': '429', '大肚區': '432', '沙鹿區': '433', '龍井區': '434', '梧棲區': '435', '清水區': '436', '大甲區': '437', '外埔區': '438', '大安區': '439' }, '彰化縣': { '彰化市': '500', '芬園鄉': '502', '花壇鄉': '503', '秀水鄉': '504', '鹿港鎮': '505', '福興鄉': '506', '線西鄉': '507', '和美鎮': '508', '伸港鄉': '509', '員林市': '510', '社頭鄉': '511', '永靖鄉': '512', '埔心鄉': '513', '溪湖鎮': '514', '大村鄉': '515', '埔鹽鄉': '516', '田中鎮': '520', '北斗鎮': '521', '田尾鄉': '522', '埤頭鄉': '523', '溪州鄉': '524', '竹塘鄉': '525', '二林鎮': '526', '大城鄉': '527', '芳苑鄉': '528', '二水鄉': '530' }, '南投縣': { '南投市': '540', '中寮鄉': '541', '草屯鎮': '542', '國姓鄉': '544', '埔里鎮': '545', '仁愛鄉': '546', '名間鄉': '551', '集集鎮': '552', '水里鄉': '553', '魚池鄉': '555', '信義鄉': '556', '竹山鎮': '557', '鹿谷鄉': '558' }, '嘉義市': { '東區': '600', '西區': '600' }, '嘉義縣': { '番路鄉': '602', '梅山鄉': '603', '竹崎鄉': '604', '阿里山': '605', '中埔鄉': '606', '大埔鄉': '607', '水上鄉': '608', '鹿草鄉': '611', '太保市': '612', '朴子市': '613', '東石鄉': '614', '六腳鄉': '615', '新港鄉': '616', '民雄鄉': '621', '大林鎮': '622', '溪口鄉': '623', '義竹鄉': '624', '布袋鎮': '625' }, '雲林縣': { '斗南鎮': '630', '大埤鄉': '631', '虎尾鎮': '632', '土庫鎮': '633', '褒忠鄉': '634', '東勢鄉': '635', '臺西鄉': '636', '崙背鄉': '637', '麥寮鄉': '638', '斗六市': '640', '林內鄉': '643', '古坑鄉': '646', '莿桐鄉': '647', '西螺鎮': '648', '二崙鄉': '649', '北港鎮': '651', '水林鄉': '652', '口湖鄉': '653', '四湖鄉': '654', '元長鄉': '655' }, '臺南市': { '中西區': '700', '東區': '701', '南區': '702', '北區': '704', '安平區': '708', '安南區': '709', '永康區': '710', '歸仁區': '711', '新化區': '712', '左鎮區': '713', '玉井區': '714', '楠西區': '715', '南化區': '716', '仁德區': '717', '關廟區': '718', '龍崎區': '719', '官田區': '720', '麻豆區': '721', '佳里區': '722', '西港區': '723', '七股區': '724', '將軍區': '725', '學甲區': '726', '北門區': '727', '新營區': '730', '後壁區': '731', '白河區': '732', '東山區': '733', '六甲區': '734', '下營區': '735', '柳營區': '736', '鹽水區': '737', '善化區': '741', '大內區': '742', '山上區': '743', '新市區': '744', '安定區': '745' }, '高雄市': { '新興區': '800', '前金區': '801', '苓雅區': '802', '鹽埕區': '803', '鼓山區': '804', '旗津區': '805', '前鎮區': '806', '三民區': '807', '楠梓區': '811', '小港區': '812', '左營區': '813', '仁武區': '814', '大社區': '815', '東沙群島': '817', '南沙群島': '819', '岡山區': '820', '路竹區': '821', '阿蓮區': '822', '田寮區': '823', '燕巢區': '824', '橋頭區': '825', '梓官區': '826', '彌陀區': '827', '永安區': '828', '湖內區': '829', '鳳山區': '830', '大寮區': '831', '林園區': '832', '鳥松區': '833', '大樹區': '840', '旗山區': '842', '美濃區': '843', '六龜區': '844', '內門區': '845', '杉林區': '846', '甲仙區': '847', '桃源區': '848', '那瑪夏區': '849', '茂林區': '851', '茄萣區': '852' }, '屏東縣': { '屏東市': '900', '三地門鄉': '901', '霧臺鄉': '902', '瑪家鄉': '903', '九如鄉': '904', '里港鄉': '905', '高樹鄉': '906', '鹽埔鄉': '907', '長治鄉': '908', '麟洛鄉': '909', '竹田鄉': '911', '內埔鄉': '912', '萬丹鄉': '913', '潮州鎮': '920', '泰武鄉': '921', '來義鄉': '922', '萬巒鄉': '923', '崁頂鄉': '924', '新埤鄉': '925', '南州鄉': '926', '林邊鄉': '927', '東港鎮': '928', '琉球鄉': '929', '佳冬鄉': '931', '新園鄉': '932', '枋寮鄉': '940', '枋山鄉': '941', '春日鄉': '942', '獅子鄉': '943', '車城鄉': '944', '牡丹鄉': '945', '恆春鎮': '946', '滿州鄉': '947' }, '臺東縣': { '臺東市': '950', '綠島鄉': '951', '蘭嶼鄉': '952', '延平鄉': '953', '卑南鄉': '954', '鹿野鄉': '955', '關山鎮': '956', '海端鄉': '957', '池上鄉': '958', '東河鄉': '959', '成功鎮': '961', '長濱鄉': '962', '太麻里鄉': '963', '金峰鄉': '964', '大武鄉': '965', '達仁鄉': '966' }, '花蓮縣': { '花蓮市': '970', '新城鄉': '971', '秀林鄉': '972', '吉安鄉': '973', '壽豐鄉': '974', '鳳林鎮': '975', '光復鄉': '976', '豐濱鄉': '977', '瑞穗鄉': '978', '萬榮鄉': '979', '玉里鎮': '981', '卓溪鄉': '982', '富里鄉': '983' }, '金門縣': { '金沙鎮': '890', '金湖鎮': '891', '金寧鄉': '892', '金城鎮': '893', '烈嶼鄉': '894', '烏坵鄉': '896' }, '連江縣': { '南竿鄉': '209', '北竿鄉': '210', '莒光鄉': '211', '東引鄉': '212' }, '澎湖縣': { '馬公市': '880', '西嶼鄉': '881', '望安鄉': '882', '七美鄉': '883', '白沙鄉': '884', '湖西鄉': '885' } }; /** * twzipcode Constructor * @param {Object} container HTML element * @param {(Object|string)} options User settings * @constructor */ function TWzipcode(container, options) { /** * Default settings * @type {Object} */ var defaults = { 'countyName': 'county', 'css': [], 'detect': false, // v1.6.7 'districtName': 'district', 'googleMapsKey': '', // v1.6.9 'hideCounty': [], // v1.7.9 'hideDistrict': [], // v1.7.9 'onCountySelect': null, // v1.5 'onDistrictSelect': null, // v1.5 'onZipcodeKeyUp': null, // v1.5 'readonly': false, 'zipcodeName': 'zipcode', 'zipcodePlaceholder': '郵遞區號', 'zipcodeIntoDistrict': false, // v1.6.6 }; /** * DOM of selector * @type {Object} */ this.container = $(container); /** * Merge the options * @type {Object} */ this.options = $.extend({}, defaults, options); // initialize this.init(); } /** * TWzipcode prototype */ TWzipcode.prototype = { VERSION: '1.7.14', /** * Method: Get all post data * @return {Object} */ data: function () { var wrap = this.wrap; return 'undefined' !== typeof data[wrap.county.val()] ? data[wrap.county.val()] : data; }, /** * Method: Serialize the data * @return {string} */ serialize: function () { var result = [], obj = {}, ele = {}, s = {}; obj = this.container.find('select,input'); if (obj.length) { obj.each(function () { ele = $(this); result.push(ele.attr('name') + '=' + ele.val()); }); } else { $(this).children().each(function () { s = $(this); result.push(s.attr('name') + '=' + s.val()); }); } return result.join('&'); }, /** * Method: Destroy the container. * @this {TWzipcode} */ destroy: function () { $.data(this.container.get(0), 'twzipcode', null); if (this.container.length) { return this.container.empty().off('change.twzipcode keyup.twzipcode blur.twzipcode'); } }, /** * Method: Get elements of instance * @param {(string|Array)} opts Type name * @param {Function} callback Function callback */ get: function (callback) { var self = this, result = [], n; function putin(o) { if ('undefined' !== typeof self.wrap[o]) { result.push(self.wrap[o].val()); } } if ('function' === typeof callback) { callback.call(this, this.wrap.county.val(), this.wrap.district.val(), this.wrap.zipcode.val()); } else if ('string' === typeof callback) { callback.split(',').forEach(putin); } else if (Array.isArray(callback)) { callback.forEach(putin); } else { result = this.wrap; } return result; }, /** * Method: Set value for elements. * @param {(string|number|Object)} opts Input value */ set: function (opts) { var self = this, def = { 'county': '', 'district': '', 'zipcode': '' }, opt = $.extend({}, def, opts); try { if ('string' === typeof opts || 'number' === typeof opts) { self.wrap.zipcode.val(opts).trigger('blur.twzipcode'); } else { if (opt.zipcode) { self.wrap.zipcode.val(opt.zipcode).trigger('blur.twzipcode'); } if (opt.county) { self.wrap.county.val(opt.county).trigger('change.twzipcode'); } if (opt.district) { self.wrap.district.val(opt.district).trigger('change.twzipcode'); } } } catch (ignore) { console.warn(ignore.message); } finally { return self.container; } }, /** * Method: Reset the selected items to default. * @this {TWzipcode} */ reset: function (container, obj) { var self = this, wrap = self.wrap, opts = self.options, county = '', list = { 'county': '', 'district': '' }, tpl = []; switch (obj) { case 'district': wrap.district.html(list.district); break; default: wrap.county.html(list.county); wrap.district.html(list.district); for (county in data) { if ('undefined' !== typeof data[county] && -1 === opts.hideCounty.indexOf(county)) { tpl.push(''); } } $(tpl.join('')).appendTo(wrap.county); break; } wrap.zipcode.val(''); }, /** * Binding the event of the elements * @this {TWzipcode} */ bindings: function () { var self = this, opts = self.options, wrap = self.wrap, dz = '', dc = '', dd = ''; // county wrap.county.on('change.twzipcode', function () { var val = $(this).val(), district = '', tpl = []; wrap.district.empty(); if (val) { if (true === opts.zipcodeIntoDistrict) { for (district in data[val]) { if ('undefined' !== typeof data[val][district] && (-1 === opts.hideDistrict.indexOf(district) && -1 === opts.hideDistrict.indexOf(data[val][district])) ) { tpl.push(''); } } } else { for (district in data[val]) { if ('undefined' !== typeof data[val][district] && (-1 === opts.hideDistrict.indexOf(district) && -1 === opts.hideDistrict.indexOf(data[val][district])) ) { tpl.push(''); } } } wrap.district.append(tpl.join('')).trigger('change.twzipcode'); } else { wrap.county.find('option:first').prop('selected', true); self.reset('district'); } // County callback binding if ('function' === typeof opts.onCountySelect) { opts.onCountySelect.call(this); } }); // District wrap.district.on('change.twzipcode', function () { var val = $(this).val(); if (wrap.county.val()) { wrap.zipcode.val(data[wrap.county.val()][val]); } // District callback binding if ('function' === typeof opts.onDistrictSelect) { opts.onDistrictSelect.call(this); } }); // Zipcode wrap.zipcode.on('keyup.twzipcode blur.twzipcode', function () { var obj = $(this), val = '', i = '', j = ''; obj.val(obj.val().replace(/[^0-9]/g, '')); val = obj.val().toString(); if (3 === val.length) { for (i in data) { if ('undefined' !== typeof data[i]) { for (j in data[i]) { if ('undefined' !== typeof data[i][j] && val === data[i][j] ) { wrap.county.val(i).trigger('change.twzipcode'); wrap.district.val(j).trigger('change.twzipcode'); break; } } } } } // Zipcode callback binding if ('function' === typeof opts.onZipcodeKeyUp) { opts.onZipcodeKeyUp.call(this); } }); // Put [data-*] into attributes of element (function () { var zip = self.role.zipcode.data(), county = self.role.county.data(), district = self.role.district.data(), n; for (n in zip) { if ('role' !== n) { self.role.zipcode.find(':input').attr(n, zip[n]); } } for (n in county) { if ('role' !== n) { self.role.county.find('select').attr(n, county[n]); } } for (n in district) { if ('role' !== n) { self.role.district.find('select').attr(n, district[n]); } } }()); dz = 'undefined' !== typeof opts.zipcodeSel ? opts.zipcodeSel : ( 'undefined' !== typeof self.role.zipcode.data('value') ? self.role.zipcode.data('value') : opts.zipcodeSel ); dc = 'undefined' !== typeof opts.countySel ? opts.countySel : ( 'undefined' !== typeof self.role.county.data('value') ? self.role.county.data('value') : opts.countySel ); dd = 'undefined' !== typeof opts.districtSel ? opts.districtSel : ( 'undefined' !== typeof self.role.district.data('value') ? self.role.district.data('value') : opts.districtSel ); // Default value if (dc) { self.wrap.county.val(dc).trigger('change.twzipcode'); if ('undefined' !== typeof data[dc][dd]) { self.wrap.district.val(dd).trigger('change.twzipcode'); } } if (dz && 3 === dz.toString().length) { self.wrap.zipcode.val(dz).trigger('blur.twzipcode'); } }, /** * Geolocation detect * @this {TWzipcode} */ geoLocation: function (callback) { var self = this, geolocation = navigator.geolocation, options = { 'maximumAge': 600000, 'timeout': 3000, 'enableHighAccuracy': false }, opts = self.options; if (!geolocation || !callback) { return; } geolocation.getCurrentPosition( function (loc) { var latlng = {}; if (('coords' in loc) && ('latitude' in loc.coords) && ('longitude' in loc.coords) ) { latlng = [loc.coords.latitude, loc.coords.longitude]; $.getJSON( 'https://maps.googleapis.com/maps/api/geocode/json', { 'key': opts.googleMapsKey, 'sensor': false, 'latlng': latlng.join(',') }, function (data) { var postal = ''; if (data && 'undefined' !== typeof data.results && 'undefined' !== typeof data.results[0].address_components && 'undefined' !== typeof data.results[0].address_components[0] ) { postal = data.results[0] .address_components[data.results[0].address_components.length - 1] .long_name; if (postal) { self.wrap.zipcode.val(postal.toString()).trigger('blur.twzipcode'); } } if ('function' === typeof callback) { callback.call(self, loc); } }); } }, function (error) { console.error(error); }, options ); }, /** * twzipcode Initialize * @this {TWzipcode} */ init: function () { var self = this, container = self.container, opts = self.options, role = { county: container.find('[data-role=county]:first'), district: container.find('[data-role=district]:first'), zipcode: container.find('[data-role=zipcode]:first') }, countyName = role.county.data('name') || opts.countyName, districtName = role.district.data('name') || opts.districtName, zipcodeName = role.zipcode.data('name') || opts.zipcodeName, zipcodePlaceholder = role.zipcode.data('placeholder') || opts.zipcodePlaceholder, readonly = role.zipcode.data('readonly') || opts.readonly; // Elements create $('') .attr('name', districtName)//.prop({ 'required': true }) .addClass(role.district.data('style') || ('undefined' !== typeof opts.css[1] ? opts.css[1] : '')) .appendTo(role.district.length ? role.district : container); $('') .attr({ 'type': 'text', 'name': zipcodeName, 'placeholder': zipcodePlaceholder }) .prop({ 'readonly': readonly }) .addClass(role.zipcode.data('style') || ('undefined' !== typeof opts.css[2] ? opts.css[2] : '')) .appendTo(role.zipcode.length ? role.zipcode : container); self.wrap = { 'county': container.find('select[name="' + countyName + '"]:first'), 'district': container.find('select[name="' + districtName + '"]:first'), 'zipcode': container.find('input[type=text][name="' + zipcodeName + '"]:first') }; if (true === opts.zipcodeIntoDistrict) { self.wrap.zipcode.hide(); } self.role = role; // Reset the elements self.reset(); // Elements events binding self.bindings(); // Geolocation self.geoLocation(opts.detect); } }; /** * jQuery twzipcode instance * @param {Object} options Plugin settings * @public */ $.fn.twzipcode = function (options) { var instance = {}, result = [], args = arguments, id = 'twzipcode'; if ('string' === typeof options) { this.each(function () { instance = $.data(this, id); if (instance instanceof TWzipcode && 'function' === typeof instance[options]) { result = instance[options].apply(instance, Array.prototype.slice.call(args, 1)); } }); return 'undefined' !== typeof result ? result : this; } else { return this.each(function () { if (!$.data(this, id)) { $.data(this, id, new TWzipcode(this, options)); } }); } }; })(window.jQuery || {}, window, document); //#EOF