正在載入此比較的其餘部分。

mphb.js diff for global locked date

建立於 差異永不過期
0 刪除
885 行
0 新增
885 行
"use strict";
"use strict";


(function ($) {
(function ($) {
$(function () {
$(function () {
MPHB.DateRules = can.Construct.extend({}, {
MPHB.DateRules = can.Construct.extend({}, {
dates: {},
dates: {},
init: function init(dates) {
init: function init(dates) {
this.dates = dates;
this.dates = dates;
},
},


/**
/**
*
*
* @param {Date} date
* @param {Date} date
* @returns {Boolean}
* @returns {Boolean}
*/
*/
canCheckIn: function canCheckIn(date) {
canCheckIn: function canCheckIn(date) {
var formattedDate = this.formatDate(date);
var formattedDate = this.formatDate(date);


if (!this.dates.hasOwnProperty(formattedDate)) {
if (!this.dates.hasOwnProperty(formattedDate)) {
return true;
return true;
}
}


return !this.dates[formattedDate].not_check_in && !this.dates[formattedDate].not_stay_in;
return !this.dates[formattedDate].not_check_in && !this.dates[formattedDate].not_stay_in;
},
},


/**
/**
*
*
* @param {Date} date
* @param {Date} date
* @returns {Boolean}
* @returns {Boolean}
*/
*/
canCheckOut: function canCheckOut(date) {
canCheckOut: function canCheckOut(date) {
var formattedDate = this.formatDate(date);
var formattedDate = this.formatDate(date);


if (!this.dates.hasOwnProperty(formattedDate)) {
if (!this.dates.hasOwnProperty(formattedDate)) {
return true;
return true;
}
}


return !this.dates[formattedDate].not_check_out;
return !this.dates[formattedDate].not_check_out;
},
},


/**
/**
*
*
* @param {Date} date
* @param {Date} date
* @returns {Boolean}
* @returns {Boolean}
*/
*/
canStayIn: function canStayIn(date) {
canStayIn: function canStayIn(date) {
var formattedDate = this.formatDate(date);
var formattedDate = this.formatDate(date);


if (!this.dates.hasOwnProperty(formattedDate)) {
if (!this.dates.hasOwnProperty(formattedDate)) {
return true;
return true;
}
}


return !this.dates[formattedDate].not_stay_in;
return !this.dates[formattedDate].not_stay_in;
},
},


/**
/**
*
*
* @param {Date} dateFrom
* @param {Date} dateFrom
* @param {Date} stopDate
* @param {Date} stopDate
* @returns {Date}
* @returns {Date}
*/
*/
getNearestNotStayInDate: function getNearestNotStayInDate(dateFrom, stopDate) {
getNearestNotStayInDate: function getNearestNotStayInDate(dateFrom, stopDate) {
var nearestDate = MPHB.Utils.cloneDate(stopDate);
var nearestDate = MPHB.Utils.cloneDate(stopDate);
var dateFromFormatted = $.datepick.formatDate('yyyy-mm-dd', dateFrom);
var dateFromFormatted = $.datepick.formatDate('yyyy-mm-dd', dateFrom);
var stopDateFormatted = $.datepick.formatDate('yyyy-mm-dd', stopDate);
var stopDateFormatted = $.datepick.formatDate('yyyy-mm-dd', stopDate);
$.each(this.dates, function (ruleDate, rule) {
$.each(this.dates, function (ruleDate, rule) {
if (ruleDate > stopDateFormatted) {
if (ruleDate > stopDateFormatted) {
return false;
return false;
}
}


if (dateFromFormatted > ruleDate) {
if (dateFromFormatted > ruleDate) {
return true;
return true;
}
}


if (rule.not_stay_in) {
if (rule.not_stay_in) {
nearestDate = $.datepick.parseDate('yyyy-mm-dd', ruleDate);
nearestDate = $.datepick.parseDate('yyyy-mm-dd', ruleDate);
return false;
return false;
}
}
});
});
return nearestDate;
return nearestDate;
},
},


/**
/**
*
*
* @param {Date} date
* @param {Date} date
* @returns {string}
* @returns {string}
*/
*/
formatDate: function formatDate(date) {
formatDate: function formatDate(date) {
return $.datepick.formatDate('yyyy-mm-dd', date);
return $.datepick.formatDate('yyyy-mm-dd', date);
}
}
});
});
/**
/**
* @class MPHB.Datepicker
* @class MPHB.Datepicker
*/
*/


can.Control('MPHB.Datepicker', {}, {
can.Control('MPHB.Datepicker', {}, {
form: null,
form: null,
hiddenElement: null,
hiddenElement: null,
roomTypeId: null,
roomTypeId: null,
init: function init(el, args) {
init: function init(el, args) {