var base64; var ddls; $(function () { 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; }; } const swalz = Swal.mixin({ showClass: { popup: 'animated fadeInDown faster' }, hideClass: { popup: 'animated fadeOutUp faster' } }); //欄位名對應 var fields = { 'cOrder_SN': '訂單編號', 'cUser_Birthday': '生日', 'cUser_Identification': '身分證字號', 'cUser_Name': '姓名', 'cUser_EMail': 'E-mail', 'cUser_Phone': '聯絡電話', 'cUsed_Brand': '手機品牌', 'cUsed_Model': '手機型號', 'cUsed_Other': '其他手機品牌/型號', 'cIsTradeIn': '舊換新活動', 'cRecycle_Model': '舊機品牌/型號', 'cBookStore_ID': '預約門市', 'cBackStore_ID': '歸還門市', 'cBackStore_ID2': '歸還門市', 'cReservation_Type': '預約類型', 'cReservation_SDate': '預約日期', 'cReservation_ID': '預約時段', 'cStore_ID': '門市代碼', 'cStore_Pass': '登入密碼', 'cDisplaceCode': '驗證碼(手機後3碼)', 'cCloud_Link': '雲端下載連結網址', 'cIsAgree': '我同意本活動相關規定及辦法', 'cIsAgree1': '同意下述活動辦法', 'cIsAgree2': '同意授權影片給台灣三星電子使用' }; //回上一步或去其它頁 $("button.gonext").click(function () { if ($(this).data("u") !== undefined) { if ($(this).data("g") == '_blank') { //是否另開 window.open($(this).data("u"), '_blank') } else { location.replace($(this).data("u")); } } else { location.replace('index.aspx'); } return false; }); //關閉視窗 $('button.closeme').click(function () { window.top.keyEsc(); return false; }); if (id('aBtn')) { //step1.基本資料 $("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: "-25y", startDate: "-80y", endDate: "-18y" }); //手機品牌 $("select[name=cUsed_Brand]").change(function () { if ($("select[name=cUsed_Brand]").val() !== "") { $("select[name=cUsed_Model]").attr('required', true); var o = $('select[name=cUsed_Brand] option:selected').data("o"); if (o === "X") { $("input[name=cUsed_Other]").val('').removeClass('hide').attr('required', true); $("select[name=cUsed_Model]").val('').find('option:not(:eq(0))').remove().end().removeAttr('required').attr('disabled', true); } else { console.log($("select[name=cUsed_Brand]").val()); $("input[name=cUsed_Other]").val('').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_Model_Temp] option[data-m=' + $("select[name=cUsed_Brand]").val() + ']').clone().appendTo('select[name=cUsed_Model]'); $("select[name=cUsed_Model_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 o = $('select[name=cUsed_Model] option:selected').data("o"); if (o === "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=cIsTradeIn]").click(function () { //舊換新 if ($("input[name=cIsTradeIn]:checked").val() == 'no') { console.log($("input[name=cIsTradeIn]:checked").val()); $("input[name=cRecycle_Model]").val('').attr('disabled', true).removeAttr('required'); } else { $("input[name=cRecycle_Model]").removeAttr('disabled').attr('required', true); } }); $("#aBtn").click(function (e) { $("input[name=mode]").val('A'); if (!checkEmpty() || !checkFormat()) { e.preventDefault(); e.stopPropagation(); return false; } else { $('html').addClass('loadingz'); $.post("/api/ajax_booking.ashx", $("#form1").serialize(), function (data) { if (data.status < 0) { swalz.fire("", data.message, "error"); } else { //$("select[name=cReservation_SDate]").find('option:not(:eq(0))').remove(); //ddls = data.objectz; //for (var ix = 0; ix < ddls.length; ix++) { // $("select[name=cReservation_SDate]")[0].options.add(new Option(ddls[ix].sno, ddls[ix].sno)); // if (parseFloat(ddls[ix].quota) <= 0) { // $("select[name=cReservation_SDate] option:last").attr("disabled", true).text(ddls[ix].sno + '(已額滿)'); // } //} if ($("input[name=cOrder_SN]").val() !== undefined && data.message !== '') { //預購 $("select[name=cBookStore_ID]").removeAttr('disabled'); $("select[name=cBookStore_ID]").val(data.message).trigger('change'); $("select[name=cBookStore_ID] option:not(:selected)").attr('disabled', true); $("input[name=cBookStore_Name]").val($("select[name=cBookStore_ID] option:selected").text()); } $("section.secstep").removeClass("step1").addClass("step2"); $(".stepbar li").removeClass("select").eq(1).addClass("select"); $("#step1Box").addClass("hide"); $("#step2Box").removeClass("hide"); $("html, body").animate({ scrollTop: $("#content").offset().top }, "show"); } $('html').removeClass('loadingz'); }, "json"); } return false; }); //cProduct_Type $("select[name=cProduct_Type]").change(function () { //產品類型 console.log('cProduct_Type'); $("select[name=cReservation_Type],select[name=cChannel_ID],select[name=cBookStore_ID],select[name=cBackStore_ID],select[name=cReservation_SDate]").find('option:not(:eq(0))').remove(); $(".address p").empty(); if ($("select[name=cProduct_Type]").val() !== "") { $('select[name=cReserv_Temp] option[data-t=' + $("select[name=cProduct_Type]").val() + ']').clone().appendTo('select[name=cReservation_Type]'); if ($("select[name=cReservation_Type]").find("option").length == 2) { //預設跟唯一選項 $("select[name=cReservation_Type] option:last").attr("selected", "selected").trigger('change'); } } }); //如果只有一種類型直接觸發 if ($("select[name=cProduct_Type]").val() !== "") { $("select[name=cProduct_Type]").trigger('change'); } //cReservation_Type $("select[name=cReservation_Type]").change(function () { //預約類型 console.log('cReservation_Type'); $("select[name=cChannel_ID],select[name=cBookStore_ID],select[name=cBackStore_ID],select[name=cReservation_SDate]").find('option:not(:eq(0))').remove(); $(".address p").empty(); if ($("select[name=cReservation_Type]").val() !== "") { $('select[name=cChannel_Temp] option[data-t=' + $("select[name=cProduct_Type]").val() + '][data-r=' + $("select[name=cReservation_Type]").val() + ']').clone().appendTo('select[name=cChannel_ID]'); if ($("select[name=cReservation_Type]").val() !== '3') { if ($("select[name=cChannel_ID]").find("option").length == 2) { //預設跟唯一選項 $("select[name=cChannel_ID] option:last").attr("selected", "selected").trigger('change'); } } } }); if ($("select[name=cReservation_Type]").val() !== "") { $("select[name=cReservation_Type]").trigger('change'); } $("select[name=cLive_Type]").change(function () { //現場預約類型 $("select[name=cBackStore_ID]").find('option:not(:eq(0))').remove(); $(".address.backbox p").empty(); if ($("select[name=cLive_Type]").val() !== "") { console.log('cLive_Type' + $("select[name=cLive_Type]").val()); $('select[name=cBackStore_Temp] option[data-t=' + $("select[name=cProduct_Type]").val() + '][data-r=' + $("select[name=cLive_Type]").val() + ']').clone().appendTo('select[name=cBackStore_ID]'); $("select[name=cBackStore_ID]").attr('required', true); if ($("select[name=cReservation_Type]").val() !== '3') { if ($("select[name=cBackStore_ID]").find("option").length == 2) { //預設跟唯一選項 $("select[name=cBackStore_ID] option:last").attr("selected", "selected").trigger('change'); } } } }); $("select[name=cChannel_ID]").change(function () { //通路店別 //console.log('cChannel_ID'); //console.log('cChannel_ID');printBtn $("select[name=cBookStore_ID],select[name=cBackStore_ID],select[name=cReservation_SDate]").find('option:not(:eq(0))').remove(); $(".address p, .steplist").empty(); if ($("select[name=cChannel_ID]").val() !== "") { var ptype = $('select[name=cChannel_ID] option:selected').data("t"); var ctype = $('select[name=cChannel_ID] option:selected').data("c"); $('select[name=cBookStore_Temp] option[data-t=' + ptype + '][data-c=' + $("select[name=cChannel_ID]").val() + '][data-r=' + $("select[name=cReservation_Type]").val() + ']').clone().appendTo('select[name=cBookStore_ID]'); if ($("select[name=cBookStore_ID]").find("option").length == 2) { //預設跟唯一選項 $("select[name=cBookStore_ID] option:last").attr("selected", "selected").trigger('change'); } if (ctype != '5' && $("select[name=cReservation_Type]").val() == '1') { //非活動(球賽&音樂祭)且為七日試用, 不需歸還門市 $(".backbox").addClass('hide'); $("select[name=cBackStore_ID],select[name=cBackStore_ID2]").removeAttr('required'); } else { console.log('back'); $(".backbox").removeClass('hide'); if ($("select[name=cReservation_Type]").val() == '3') { //現場預約 $('select[name=cBackStore_Temp] option[data-t=' + $("select[name=cProduct_Type]").val() + '][data-r=' + $("select[name=cLive_Type]").val() + ']').clone().appendTo('select[name=cBackStore_ID]'); $("select[name=cBackStore_ID]").attr('required', true); //$("select[name=cBackStore_ID2]").val($("select[name=cBookStore_ID]").val()); //$("select[name=cBackStore_ID2]").attr('required', true); } else { $('select[name=cBackStore_Temp] option[data-t=' + $("select[name=cProduct_Type]").val() + '][data-r=' + $("select[name=cReservation_Type]").val() + ']').clone().appendTo('select[name=cBackStore_ID]'); $("select[name=cBackStore_ID]").attr('required', true); if ($("select[name=cBackStore_ID]").find("option").length == 2) { //預設跟唯一選項 $("select[name=cBackStore_ID] option:last").attr("selected", "selected").trigger('change'); } } } } }); if ($("select[name=cChannel_ID]").val() !== "") { $("select[name=cChannel_ID]").trigger('change'); } $("select[name=cBackStore_ID],select[name=cBackStore_ID2]").change(function () { //還機門市 $(".address.backbox p").empty(); if ($("select[name=cBackStore_ID]").val() !== "") { $(".address.backbox p").text($("select[name=cBackStore_ID]").children('option:selected').data('d')); } if ($("select[name=cBackStore_ID2]").val() !== "") { $(".address.backbox p").text($("select[name=cBackStore_ID2]").children('option:selected').data('d')); } }); if ($("select[name=cBackStore_ID]").val() !== "") { $("select[name=cBackStore_ID]").trigger('change'); } if ($("select[name=cBackStore_ID2]").val() !== "") { $("select[name=cBackStore_ID2]").trigger('change'); } $("select[name=cBookStore_ID]").change(function () { //門市 //console.log('cBookStore_ID'); $("select[name=cReservation_SDate]").find('option:not(:eq(0))').remove(); $(".steplist").empty(); $(".address.bookbox p").empty(); if ($("select[name=cBookStore_ID]").val() !== "") { var ptype = $('select[name=cChannel_ID] option:selected').data("t"); $(".address.bookbox p").text($("select[name=cBookStore_ID]").children('option:selected').data('d')); $('select[name=cReservation_Temp] option[data-t=' + ptype + '][data-r=' + $("select[name=cReservation_Type]").val() + '][data-s=' + $("select[name=cBookStore_ID]").val() + ']').clone().appendTo('select[name=cReservation_SDate]'); if ($("select[name=cReservation_SDate]").find("option").length == 2) { //預設跟唯一選項 $("select[name=cReservation_SDate] option:last").attr("selected", "selected").trigger('change'); } } }); if ($("select[name=cBookStore_ID]").val() !== "") { $("select[name=cBookStore_ID]").trigger('change'); } $("select[name=cReservation_SDate]").change(function (e) { //確定日期 $(".steplist").empty(); console.log("steplist"); console.log($("select[name=cReservation_SDate]").val()); if ($("select[name=cReservation_SDate]").val() == '') { $(".timeBox").addClass("hide"); } else { $("input[name=mode]").val('B'); $.post("/api/ajax_booking.ashx", $("#form1").serialize(), function (data) { if (data.status < 0) { swalz.fire("", data.message, "error"); } else { //if ($("select[name=cReservation_SDate]").val() == '2020/08/26') { // $(".steplist li:eq(0)").removeClass("hide"); //} else { // $(".steplist li:eq(0)").addClass("hide"); //} $(".steplist").append(data.objectz); $(".timeBox").removeClass("hide"); } $('html').removeClass('loadingz'); }, "json"); } return false; }); if ($("select[name=cReservation_SDate]").val() !== "") { console.log($("select[name=cReservation_SDate]").val()); $("select[name=cReservation_SDate]").trigger('change'); } $("#rBtn").click(function (e) { //回上一步 $("section.secstep").removeClass("step2").addClass("step1"); $(".stepbar li").removeClass("select").eq(0).addClass("select"); $("#step1Box").removeClass("hide"); $("#step2Box").addClass("hide"); $("select[name=cReservation_SDate]").val(''); $(".steplist").empty(); //$(".steplist").find('li:not(:eq(0))').remove(); $("html, body").animate({ scrollTop: $("#content").offset().top }, "show"); return false; }); $("#nBtn").click(function (e) { //送出了 var uri = $(this).data('href'); if ($("input[name=cReservation_ID]:checked").val() === undefined) { swalz.fire("", "請確實選擇預約時段", "error"); } else { $("input[name=mode]").val('C'); $('html').addClass('loadingz'); $.post("/api/ajax_booking.ashx", $("#form1").serialize(), function (data) { if (data.status < 0) { swalz.fire("", data.message, "error"); $('html').removeClass('loadingz'); } else { location.replace(uri + "?uo=" + encodeURIComponent(data.objectz) + "#content"); } }, "json"); } return false; }); //付款 $("#r2Btn").click(function (e) { //回上一步 $(".preorder_con:eq(2)").addClass("hide").prev().removeClass("hide"); var xsd = $("select[name=cReservation_SDate]").val(); $("select[name=cReservation_SDate]").val(xsd); $("select[name=cReservation_SDate]").trigger('change'); $("html, body").animate({ scrollTop: $("#content").offset().top }, "show"); return false; }); $("#n2Btn").click(function (e) { //轉至付款頁面 var cflag = true; //console.log($("select[name=cBackStore_ID]").val()); if (($("select[name=cBackStore_ID]").attr('required') == 'required' && $("select[name=cBackStore_ID]").val() === '') || ($("select[name=cBackStore_ID2]").attr('required') == 'required' && $("select[name=cBackStore_ID2]").val() === '')) { swalz.fire("", "請確實選擇還機門市", "error"); cflag = false; } if ($("input[name=cReservation_ID]:checked").val() === undefined) { swalz.fire("", "請確實選擇預約時段", "error"); cflag = false; } if (cflag == true) { var st = $("input[name=cReservation_ID]:checked").data('s'); $("input[name=st]").val(st); if (st == 'S') { //正取才要付款 $('.pmodel').text($("input[name=cReservation_ID]:checked").data('p')); $('.pmoney').text($("input[name=cReservation_ID]:checked").data('d')); $('.ptryout').text($("input[name=cReservation_ID]:checked").data('y')); console.log($("input[name=cReservation_ID]:checked").data('y')); if ($("input[name=cReservation_ID]:checked").data('o') == 'b') { //當日歸還 $(".a_box1").addClass("hide"); $(".b_box1").removeClass("hide"); } else { $(".a_box1").removeClass("hide"); $(".b_box1").addClass("hide"); } $(".preorder_con:eq(2)").removeClass("hide").prev().addClass("hide"); $("html, body").animate({ scrollTop: $("#content").offset().top }, "show"); } else { $("#nBtn").trigger('click'); } } return false; }); $("#n3Btn").click(function (e) { var url = $(this).data("href"); $("input[name=mode]").val('C'); if (!$("input[name=cIsAgree]").is(':checked')) { swalz.fire("", "請勾選[我同意本活動相關規定及辦法]", "warning"); } else { $('html').addClass('loadingz'); $.post("/api/ajax_booking.ashx", $("#form1").serialize(), function (data) { if (data.status < 0) { alert(data.message); $('html').removeClass('loadingz'); } else { location.replace(url); } }, "json"); return false; } }); } //付款失敗取消 if (id('xBtn')) { $("#xBtn").click(function (e) { if (confirm('提醒您,若您取消本次交易,您的預約資料將一同取消。')) { $('html').addClass('loadingz'); $.post("/api/ajax_booking.ashx", $("#form1").serialize(), function (data) { if (data.status < 0) { alert("系統忙碌中,請稍後再取消本次交易。"); $('html').removeClass('loadingz'); } else { alert("您已成功取消本次交易。"); location.replace("index.aspx"); } }, "json"); } return false; }); // 失敗重送 if (id('gBtn')) { $("#gBtn").click(function () { $('html').addClass('loadingz'); location.replace("pay_form.aspx?uo=" + encodeURIComponent($(this).attr('data-n'))); return false; }); } } if (id('dBtn')) { //重新選擇時段 $("html, body").animate({ scrollTop: $("#content").offset().top }, "show"); $("select[name=cBookStore_ID]").change(function () { //門市 $("select[name=cReservation_SDate]").find('option:not(:eq(0))').remove(); if ($("select[name=cBookStore_ID]").val() !== "") { $('select[name=cReservation_Temp] option[data-s=' + $("select[name=cBookStore_ID]").val() + ']').clone().appendTo('select[name=cReservation_SDate]'); $("select[name=cReservation_SDate]").trigger('change'); } }); if ($("select[name=cBookStore_ID]").val() !== "") { $("select[name=cBookStore_ID]").trigger('change'); } $("#dBtn").click(function (e) { // 編輯 $(".btn_check, .bbox2").removeClass("hide"); $(".btn_edit, .bbox1").addClass("hide"); $("input[name=cUser_Phone],input[name=cUser_EMail]").removeAttr("disabled"); $("input[name=cProduct_IMEI],input[name=cProduct_SN]").attr("disabled", true); return false; }); $("#iBtn").click(function (e) { // 預約IMEI/SN var chkFlag = true; if ($("input[name=cProduct_Type]").val() == "1") { if ($("input[name=cProduct_IMEI]").val() == "" || $("input[name=cProduct_SN]").val() == "") { chkFlag = false; swalz.fire("[ 手機IMEI / 手錶IMEI ] 請確實輸入", "", "warning"); } } else { if ($("input[name=cProduct_SN]").val() == "") { hkFlag = false; swalz.fire("[ SN ] 請確實輸入", "", "warning"); } } if (chkFlag === true) { $('html').addClass('loadingz'); $("input[name=mode]").val('I'); $.post("/api/ajax_booking.ashx", $("#form1").serialize(), function (data) { if (data.status < 0) { swalz.fire("", data.message, "error"); } else { $("#iBtn").parent().addClass("hide").next('.btn_edit').removeClass('hide'); } $('html').removeClass('loadingz'); }, "json"); } return false; }); $("#jBtn").click(function (e) { // 清空重來 $("input[name=cProduct_IMEI],input[name=cProduct_SN]").val(''); $("input[name=cProduct_IMEI]").focus(); $("#jBtn").parent().addClass("hide").prev('.btn_edit').removeClass('hide'); return false; }); $("#eBtn").click(function (e) { //重選時段 $("select[name=cBookStore_ID],select[name=cReservation_SDate]").removeAttr("disabled"); if ($("input[name=cOrder_SN]").val() !== undefined) { $("select[name=cBookStore_ID] option:not(:selected)").attr('disabled', true);//先綁死門市 } else { } $("select[name=cReservation_SDate]").trigger('change'); $(".rdo1Box, .btn_check").addClass("hide"); return false; }); $("#fBtn").click(function (e) { //取消編輯 $("select[name=cBookStore_ID]").val($("select[name=cBookStore_ID]").data('o')); $("select[name=cReservation_SDate]").val($("select[name=cReservation_SDate]").data('o')); $(".rdo2Box").empty(); $("input[name=cReservation_ID]").val($("input[name=cOriginal_ID]:checked").val()); $("input[name=cUser_Phone],input[name=cUser_EMail], select[name=cBookStore_ID],select[name=cReservation_SDate]").attr("disabled", true); $("input[name=cProduct_IMEI],input[name=cProduct_SN]").removeAttr("disabled"); $(".rdo1Box, .btn_edit, .bbox1").removeClass("hide"); $(".btn_check, .bbox2").addClass("hide"); $("html, body").animate({ scrollTop: $("#content").offset().top }, "show"); return false; }); $("#vBtn").click(function (e) { //取消預約 var url = $(this).attr("href"); if (confirm('是否確定取消預約資格?')) { $('html').addClass('loadingz'); $("input[name=mode]").val('U'); $.post("/api/ajax_booking.ashx", $("#form1").serialize(), function (data) { if (data.status < 0) { swalz.fire("", data.message, "error"); } else { window.location.replace(url); //swalz.fire({ // title: "", // html: "您已取消此筆預約紀錄。", // icon: "info", // confirmButtonText: "闗閉" //}).then(function (result) { // //導頁寫在此 // if (result.value) { // window.location.replace(url); // } //}); } $('html').removeClass('loadingz'); }, "json"); } return false; }); $("#hBtn").click(function (e) { var url = $(this).attr("href"); if (!checkEmpty() || !checkFormat()) { e.preventDefault(); e.stopPropagation(); return false; } else { $('html').addClass('loadingz'); $("input[name=mode]").val('H'); if ($("select[name=cBookStore_ID]").length) { $("input[name=changeStore]").val($("select[name=cBookStore_ID] option:selected").text()); } $("input[name=cStatus]").val($("input[name=cReservation_ID]:checked").data("s")); $.post("/api/ajax_booking.ashx", $("#form1").serialize(), function (data) { if (data.status < 0) { swalz.fire("", data.message, "error"); } else { //console.log(url); location.replace(url); } $('html').removeClass('loadingz'); }, "json"); } return false; }); $("select[name=cReservation_SDate]").change(function (e) { //確定日期 $(".rdo2Box").empty(); if ($('select[name=cReservation_SDate] option:selected').is(':disabled')) { var nday = $('select[name=cReservation_SDate] option:not([disabled]):eq(1)').val(); $("select[name=cReservation_SDate]").val(nday); } if ($("select[name=cReservation_SDate]").val() != '') { $("input[name=mode]").val('B'); //console.log($("select[name=cReservation_SDate]").val()); $.post("/api/ajax_booking.ashx", $("#form1").serialize(), function (data) { if (data.status < 0) { swalz.fire("", data.message, "error"); } else { $(".rdo2Box").append(data.objectz).removeClass("hide"); } $('html').removeClass('loadingz'); }, "json"); } return false; }); } //查詢 if (id('sBtn')) { $("#iconV").click(function () { $("#imgV").attr("src", "/api/ajax_captcha.ashx?r=" + Math.random()); return false; }); $("#sBtn").click(function (e) { var url = $(this).attr("href"); if (!checkEmpty() || !checkFormat()) { e.preventDefault(); e.stopPropagation(); return false; } else { $('html').addClass('loadingz'); $.post("/api/ajax_booking.ashx", $("#form1").serialize(), function (data) { if (data.status < 0) { swalz.fire("", data.message, "error"); $('html').removeClass('loadingz'); $("#imgV").attr("src", "/api/ajax_captcha.ashx?r=" + Math.random()); } else { location.replace(url); } }, "json"); } return false; }); } if (id('qBtn')) { //列表查詢 $(".mainkv").hide(); $("select[name=qst]").change(function () { //門市 $("select[name=qsd],select[name=qtime]").find('option:not(:eq(0))').remove(); // console.log($("select[name=qst]").val()); if ($("select[name=qst]").val() !== "") { $('select[name=qTempD] option[data-b=' + $("select[name=qst]").val() + ']').clone().appendTo('select[name=qsd]'); $('select[name=qTemp] option[data-s=' + $("select[name=qsd]").val() + '][data-b=' + $("select[name=qst]").val() + ']').clone().appendTo('select[name=qtime]'); } }); if ($("select[name=qst]").val() !== "") { $("select[name=qst]").trigger('change'); } $("select[name=qsd]").change(function () { //日期 $("select[name=qtime]").find('option:not(:eq(0))').remove(); var st = $("select[name=qst]").val() ?? $("input[name=qst]").val(); // console.log($("select[name=qsd]").val()); if ($("select[name=qsd]").val() !== "") { $('select[name=qTemp] option[data-s=' + $("select[name=qsd]").val() + '][data-b=' + st + ']').clone().appendTo('select[name=qtime]'); } }); if ($("select[name=qsd]").val() !== "") { $("select[name=qsd]").trigger('change'); } $("#qBtn").click(function () { if ($("select[name=qsd]").val() === "") { alert("請先選擇日期"); } else { $('html').addClass('loading'); $.post("/api/ajax_list.ashx", $("#form1").serialize(), function (data) { $('html').removeClass('loading'); if (data.status <= 0) { swalz.fire(data.message, "", "error"); if (data.status === -99) { location.replace('c1696e35-e580-4cd0-838b-a13cc3e0dcda.aspx'); } } else { $(".lstBox").empty().html(data.objectz); } }, "json"); } return false; }); $(document).on("click", "a.cancelBtn", function () { var $btn = $(this); $("input[name=uo]").val($btn.data('v')); $("input[name=st]").val($btn.data('s')); if (confirm('是否確定取消? 提醒您, 取消後無法還原')) { $('html').addClass('loadingz'); $.post("/api/ajax_booking.ashx", $("#form1").serialize(), function (data) { if (data.status < 0) { swalz.fire(data.message, "", "error"); } else { //location.replace(url); //$btn.parent().remove(); //$btn.addClass('hide'); //$btn.parent().find('.btn-info').addClass('hide'); //$btn.parent().find('.btn-default').text('無效'); $("#qBtn").trigger('click'); } $('html').removeClass('loadingz'); }, "json"); } return false; }); //頁面tab $(document).on("click", "a.navs", function () { var i = $(this).data('i'); $(".tabBox").addClass('hide'); $(".nav-tabs li").removeClass('active'); $(".box" + i).removeClass('hide'); $(this).parent().addClass('active'); return false; }); //export $("#printBtn").click(function () { post_to_url('/api/export_list.ashx', '#form1'); return false; }); //export還機 $("#print2Btn").click(function () { post_to_url('/api/export_back.ashx', '#form1'); return false; }); function post_to_url(path, thisfrm, method) { method = method || "post"; var form = document.createElement("form"); form.setAttribute("method", method); form.setAttribute("action", path); $(thisfrm).serializeArray().map(function (field, i) { var input = document.createElement('input'); input.type = 'hidden'; input.name = field.name; input.value = field.value; form.appendChild(input); }); document.body.appendChild(form); form.submit(); document.body.removeChild(form); } } //約定信用卡付款 if (id('pBtn')) { $("#pBtn").on('click', function (e) { if (!checkEmpty() || !checkFormat()) { e.preventDefault(); e.stopPropagation(); return false; } else { $('html').addClass('loadingz'); $.post("/api/ajax_booking.ashx", $("#form1").serialize(), function (data) { if (data.status < 0) { swalz.fire("", data.message, "error"); $('html').removeClass('loadingz'); } else { location.reload(); } }, "json"); } return false; }); } //遞補 if (id('kBtn')) { $("#gBtn").click(function (e) { //取消預約 var url = $(this).attr("href"); if (confirm('是否確定放棄遞補資格?')) { if (!checkEmpty() || !checkFormat()) { e.preventDefault(); e.stopPropagation(); return false; } else { $('html').addClass('loadingz'); $("input[name=mode]").val('G'); $.post("/api/ajax_booking.ashx", $("#form1").serialize(), function (data) { if (data.status < 0) { swalz.fire("", data.message, "error"); $('html').removeClass('loadingz'); } else { location.reload(); } }, "json"); } } return false; }); //驗證並導至刷卡頁 $("#kBtn").click(function (e) { $("input[name=mode]").val('K'); if (!checkEmpty() || !checkFormat()) { e.preventDefault(); e.stopPropagation(); return false; } else { $('html').addClass('loadingz'); $.post("/api/ajax_booking.ashx", $("#form1").serialize(), function (data) { $('html').removeClass('loadingz'); if (data.status < 0) { swalz.fire("", data.message, "error"); } else { $(".stepbox li").removeClass("select"); $(".stepbox li:eq(1)").addClass("select"); $("#step1Box").addClass("hide"); $("#step2Box").removeClass("hide"); $("html, body").animate({ scrollTop: $("#content").offset().top }, "show"); } }, "json"); } return false; }); //送出 $("#k3Btn").click(function (e) { var url = $(this).data("href"); if (!$("input[name=cIsAgree]").is(':checked')) { swalz.fire("", "請勾選[我同意本活動相關規定及辦法]", "warning"); } else { location.replace(url); return false; } }); //回上步 $("#k2Btn").click(function (e) { $("#stepbox li").removeClass("select").end().eq(0).addClass("select"); $("#step2Box").addClass("hide"); $("#step1Box").removeClass("hide"); $("html, body").animate({ scrollTop: $("#content").offset().top }, "show"); return false; }); } //fancam星任務 if (id('w1Btn')) { //步驟1 $("#w1Btn").click(function (e) { $("input[name=mode]").val('A'); if (!checkEmpty() || !checkFormat()) { e.preventDefault(); e.stopPropagation(); return false; } else { $('html').addClass('loadingz'); $.post("/api/ajax_fancam.ashx", $("#form1").serialize(), function (data) { $('html').removeClass('loadingz'); if (data.status < 0) { swalz.fire("", data.message, "error"); } else { $("#step1Box").addClass("hide"); $("#step2Box").removeClass("hide"); $("input[type=checkbox],input[name=cCloud_Link]").attr('required', true); $("html, body").animate({ scrollTop: $("#content").offset().top }, "show"); } }, "json"); } return false; }); //步驟2 $("#w2Btn").click(function (e) { var url = $(this).attr("href"); if (!checkEmpty() || !checkFormat()) { e.preventDefault(); e.stopPropagation(); return false; } else { $("input[name=mode]").val('B'); $.post("/api/ajax_fancam.ashx", $("#form1").serialize(), function (data) { $('html').removeClass('loadingz'); if (data.status < 0) { swalz.fire("", data.message, "error"); } else { location.replace(url); } }, "json"); } return false; }); } //取消(登出) if (id('oBtn')) { $("#oBtn, #oBtn2").on('click', function (e) { var url = $(this).attr("href"); $('html').addClass('loadingz'); $.post("/api/ajax_booking.ashx", { mode: "O" }, function (data) { if (data.status < 0) { swalz.fire(data.message, "", "error"); $('html').removeClass('loadingz'); } else { location.replace(url); } }, "json"); // return false; }); } //檢查格式 function checkFormat() { var message = ''; obj = ''; $('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] + '的格式不正確,請重新輸入'; obj = element.name; return false; } } }); if (message !== '') { $("[name=" + obj + "]").focus(); swalz.fire(message, "", "error"); 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') { 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) { $('[type=checkbox][required]').each(function (index, element) { var iptn = $(element).attr('type') === 'checkbox' ? '請勾選' : '請選擇'; var group = $(element).attr('name'); //console.log(ipt); if ($('[name=' + group + ']:checked').length === 0) { if (fields[group] === undefined) { message = iptn + ' [' + $(element).next().text() + ' ]'; } else { message = iptn + fields[group]; } obj = group; } }); } if (message !== '') { $("[name=" + obj + "]").focus(); swalz.fire(message, "", "warning"); message = ''; return false; } else { return true; } } function readUrl(input) { if (input.files && input.files[0]) { var reader = new FileReader(); reader.onload = function (e) { //var imgData = e.target.result; var imgName = input.files[0].name; input.setAttribute("data-title", imgName); // console.log(e.target.result); var image = new Image(); //image.src = e.target.result; getImgData(e.target.result, function (data) { //这里可以使用校正后的图片data了 $('input[name=cUser_Base64]').val(data); image.src = data; image.onload = function () { // access image size here if (id('mBtn')) { //手機版 $('#mBtn').trigger('click'); } else { $(".upload-zone").removeClass('uploaded').addClass('uploaded'); $('.preview-image').attr("src", data); } //$(image).appendTo($('.inputDnD')); //$('.inputDnD').height(image.height); }; }); }; reader.readAsDataURL(input.files[0]); } } window.readUrl = readUrl; function getImgData(img, next) { var image = new Image(); image.onload = function () { var degree = 0, drawWidth, drawHeight; var maxWidth = 2000; drawWidth = this.naturalWidth; drawHeight = this.naturalHeight; //以下改变一下图片大小 var maxSide = Math.max(drawWidth, drawHeight); if (maxSide > maxWidth) { var minSide = Math.min(drawWidth, drawHeight); minSide = minSide / maxSide * maxWidth; maxSide = maxWidth; if (drawWidth > drawHeight) { drawWidth = maxSide; drawHeight = minSide; } else { drawWidth = minSide; drawHeight = maxSide; } } var canvas = document.createElement('canvas'); canvas.width = drawWidth; canvas.height = drawHeight; var context = canvas.getContext('2d'); //context.rotate(degree * Math.PI / 180); context.drawImage(this, 0, 0, drawWidth, drawHeight); //返回校正图片 next(canvas.toDataURL("image/jpeg", .8)); } image.src = img; } }); //----------------------------其它--------------------------------------------------------------------- var putVoucher = function (img) { var image = new Image(); image.src = img; image.onload = function () { // access image size here $(".upload-zone").removeClass('uploaded').addClass('uploaded'); $('.preview-image').attr("src", img); }; } //----------------------------必備--------------------------------------------------------------------- function keyEsc() { var esc = $.Event("keydown", { keyCode: 27 }); $("body").trigger(esc); }; function keyResend() { if (id('qBtn')) { $("#qBtn").trigger('click'); } var esc = $.Event("keydown", { keyCode: 27 }); $("body").trigger(esc); }; function id(DOM) { return document.getElementById(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, ""); return s.replace(/\s+/g, ""); } /*! * 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 = "