Browse Source

update

master
windy 7 years ago
parent
commit
2e0a0cc6cc
  1. 22
      demo/js/widget/date/demo.datepane.js
  2. 383
      dist/bundle.js
  3. 22
      dist/demo.js
  4. 383
      dist/widget.js
  5. 2
      src/widget/date/calendar/popup.calendar.date.js
  6. 60
      src/widget/date/combo.date.js
  7. 317
      src/widget/date/trigger.date.js
  8. 2
      src/widget/datetimepane/card.static.datetimepane.js
  9. 4
      src/widget/datetimepane/datetimepane.js

22
demo/js/widget/date/demo.datepane.js

@ -35,17 +35,17 @@ Demo.DatePane = BI.inherit(BI.Widget, {
} }
}, { }, {
type: "bi.dynamic_date_time_pane", type: "bi.dynamic_date_time_pane",
value: { // value: {
type: 1, // type: 1,
value: { // value: {
year: 2017, // year: 2017,
month: 12, // month: 12,
day: 11, // day: 11,
hour: 12, // hour: 12,
minute: 12, // minute: 12,
second: 12 // second: 12
} // }
}, // },
ref: function (_ref) { ref: function (_ref) {
self.dateTimePane = _ref; self.dateTimePane = _ref;
}, },

383
dist/bundle.js vendored

@ -87998,7 +87998,7 @@ BI.DateCalendarPopup = BI.inherit(BI.Widget, {
o = this.options; o = this.options;
this.today = BI.getDate(); this.today = BI.getDate();
this._year = this.today.getFullYear(); this._year = this.today.getFullYear();
this._month = this.today.getMonth(); this._month = this.today.getMonth() + 1;
this._day = this.today.getDate(); this._day = this.today.getDate();
this.selectedTime = o.selectedTime || { this.selectedTime = o.selectedTime || {
@ -88235,381 +88235,6 @@ BI.DateTriangleTrigger = BI.inherit(BI.Trigger, {
} }
}); });
BI.shortcut("bi.date_triangle_trigger", BI.DateTriangleTrigger);/** BI.shortcut("bi.date_triangle_trigger", BI.DateTriangleTrigger);/**
* 日期下拉框
*
* Created by GUY on 2015/9/7.
* @class BI.DateCombo
* @extends BI.Widget
*/
BI.DateCombo = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.DateCombo.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-date-combo bi-border",
height: 25
});
},
_init: function () {
BI.DateCombo.superclass._init.apply(this, arguments);
var self = this,
o = this.options;
this.trigger = BI.createWidget({
type: "bi.date_trigger"
});
this.trigger.on(BI.DateTrigger.EVENT_TRIGGER_CLICK, function () {
self.combo.toggle();
});
this.popup = BI.createWidget({
type: "bi.date_calendar_popup"
});
this.popup.on(BI.DateCalendarPopup.EVENT_CHANGE, function () {
self.setValue(self.popup.getValue());
});
this.combo = BI.createWidget({
type: "bi.combo",
toggle: false,
element: this,
isNeedAdjustHeight: false,
isNeedAdjustWidth: false,
el: this.trigger,
popup: {
width: 270,
el: this.popup,
stopPropagation: false
}
});
},
setValue: function (v) {
this.trigger.setValue(v);
this.popup.setValue(v);
},
getValue: function () {
return this.popup.getValue();
}
});
BI.shortcut("bi.date_combo", BI.DateCombo);BI.DateTrigger = BI.inherit(BI.Trigger, {
_const: {
hgap: 4,
vgap: 2,
yearLength: 4,
yearMonthLength: 7
},
_defaultConfig: function () {
return BI.extend(BI.DateTrigger.superclass._defaultConfig.apply(this, arguments), {
extraCls: "bi-date-trigger",
min: "1900-01-01", // 最小日期
max: "2099-12-31", // 最大日期
height: 24
});
},
_init: function () {
BI.DateTrigger.superclass._init.apply(this, arguments);
var self = this, o = this.options, c = this._const;
this.editor = BI.createWidget({
type: "bi.sign_editor",
height: o.height,
validationChecker: function (v) {
var date = v.match(/\d+/g);
self._autoAppend(v, date);
return self._dateCheck(v) && BI.checkDateLegal(v) && self._checkVoid({
year: date[0],
month: date[1],
day: date[2]
});
},
quitChecker: function () {
return false;
},
hgap: c.hgap,
vgap: c.vgap,
allowBlank: true,
watermark: BI.i18nText("BI-Basic_Unrestricted"),
errorText: function () {
if (self.editor.isEditing()) {
return BI.i18nText("BI-Date_Trigger_Error_Text");
}
return BI.i18nText("BI-Year_Trigger_Invalid_Text");
}
});
this.editor.on(BI.SignEditor.EVENT_KEY_DOWN, function () {
self.fireEvent(BI.DateTrigger.EVENT_KEY_DOWN);
});
this.editor.on(BI.SignEditor.EVENT_FOCUS, function () {
self.fireEvent(BI.DateTrigger.EVENT_FOCUS);
});
this.editor.on(BI.SignEditor.EVENT_STOP, function () {
self.fireEvent(BI.DateTrigger.EVENT_STOP);
});
this.editor.on(BI.SignEditor.EVENT_VALID, function () {
self.fireEvent(BI.DateTrigger.EVENT_VALID);
});
this.editor.on(BI.SignEditor.EVENT_ERROR, function () {
self.fireEvent(BI.DateTrigger.EVENT_ERROR);
});
this.editor.on(BI.SignEditor.EVENT_CONFIRM, function () {
var value = self.editor.getValue();
if (BI.isNotNull(value)) {
self.editor.setState(value);
}
if (BI.isNotEmptyString(value)) {
var date = value.split("-");
self.store_value = {
type: BI.DateTrigger.MULTI_DATE_CALENDAR,
value: {
year: date[0] | 0,
month: date[1] - 1,
day: date[2] | 0
}
};
}
self.fireEvent(BI.DateTrigger.EVENT_CONFIRM);
});
this.editor.on(BI.SignEditor.EVENT_SPACE, function () {
if (self.editor.isValid()) {
self.editor.blur();
}
});
this.editor.on(BI.SignEditor.EVENT_START, function () {
self.fireEvent(BI.DateTrigger.EVENT_START);
});
this.editor.on(BI.SignEditor.EVENT_CHANGE, function () {
self.fireEvent(BI.DateTrigger.EVENT_CHANGE);
});
BI.createWidget({
type: "bi.htape",
element: this,
items: [{
el: BI.createWidget(),
width: 30
}, {
el: this.editor
}]
});
this.setValue(o.value);
},
_dateCheck: function (date) {
return BI.parseDateTime(date, "%Y-%x-%d").print("%Y-%x-%d") == date || BI.parseDateTime(date, "%Y-%X-%d").print("%Y-%X-%d") == date || BI.parseDateTime(date, "%Y-%x-%e").print("%Y-%x-%e") == date || BI.parseDateTime(date, "%Y-%X-%e").print("%Y-%X-%e") == date;
},
_checkVoid: function (obj) {
return !BI.checkDateVoid(obj.year, obj.month, obj.day, this.options.min, this.options.max)[0];
},
_autoAppend: function (v, dateObj) {
var self = this;
var date = BI.parseDateTime(v, "%Y-%X-%d").print("%Y-%X-%d");
var yearCheck = function (v) {
return BI.parseDateTime(v, "%Y").print("%Y") == v && date >= self.options.min && date <= self.options.max;
};
var monthCheck = function (v) {
return BI.parseDateTime(v, "%Y-%X").print("%Y-%X") == v && date >= self.options.min && date <= self.options.max;
};
if (BI.isNotNull(dateObj) && BI.checkDateLegal(v)) {
switch (v.length) {
case this._const.yearLength:
if (yearCheck(v)) {
this.editor.setValue(v + "-");
}
break;
case this._const.yearMonthLength:
if (monthCheck(v)) {
this.editor.setValue(v + "-");
}
break;
}
}
},
setValue: function (v) {
var type, value, self = this;
var date = BI.getDate();
this.store_value = v;
if (BI.isNotNull(v)) {
type = v.type || BI.DateTrigger.MULTI_DATE_CALENDAR; value = v.value;
if(BI.isNull(value)) {
value = v;
}
}
var _setInnerValue = function (date, text) {
var dateStr = date.print("%Y-%x-%e");
self.editor.setState(dateStr);
self.editor.setValue(dateStr);
self.setTitle(text + ":" + dateStr);
};
switch (type) {
case BI.DateTrigger.MULTI_DATE_YEAR_PREV:
var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_PREV];
date = BI.getDate((date.getFullYear() - 1 * value), date.getMonth(), date.getDate());
_setInnerValue(date, text);
break;
case BI.DateTrigger.MULTI_DATE_YEAR_AFTER:
var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_AFTER];
date = BI.getDate((date.getFullYear() + 1 * value), date.getMonth(), date.getDate());
_setInnerValue(date, text);
break;
case BI.DateTrigger.MULTI_DATE_YEAR_BEGIN:
var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_BEGIN];
date = BI.getDate(date.getFullYear(), 0, 1);
_setInnerValue(date, text);
break;
case BI.DateTrigger.MULTI_DATE_YEAR_END:
var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_END];
date = BI.getDate(date.getFullYear(), 11, 31);
_setInnerValue(date, text);
break;
case BI.DateTrigger.MULTI_DATE_QUARTER_PREV:
var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_PREV];
date = BI.getDate().getOffsetQuarter(-value);
_setInnerValue(date, text);
break;
case BI.DateTrigger.MULTI_DATE_QUARTER_AFTER:
var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_AFTER];
date = BI.getDate().getOffsetQuarter(value);
_setInnerValue(date, text);
break;
case BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN:
var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN];
date = BI.getDate().getQuarterStartDate();
_setInnerValue(date, text);
break;
case BI.DateTrigger.MULTI_DATE_QUARTER_END:
var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_END];
date = BI.getDate().getQuarterEndDate();
_setInnerValue(date, text);
break;
case BI.DateTrigger.MULTI_DATE_MONTH_PREV:
var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_PREV];
date = BI.getDate().getOffsetMonth(-value);
_setInnerValue(date, text);
break;
case BI.DateTrigger.MULTI_DATE_MONTH_AFTER:
var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_AFTER];
date = BI.getDate().getOffsetMonth(value);
_setInnerValue(date, text);
break;
case BI.DateTrigger.MULTI_DATE_MONTH_BEGIN:
var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_BEGIN];
date = BI.getDate(date.getFullYear(), date.getMonth(), 1);
_setInnerValue(date, text);
break;
case BI.DateTrigger.MULTI_DATE_MONTH_END:
var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_END];
date = BI.getDate(date.getFullYear(), date.getMonth(), (date.getLastDateOfMonth()).getDate());
_setInnerValue(date, text);
break;
case BI.DateTrigger.MULTI_DATE_WEEK_PREV:
var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_PREV];
date = date.getOffsetDate(-7 * value);
_setInnerValue(date, text);
break;
case BI.DateTrigger.MULTI_DATE_WEEK_AFTER:
var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_AFTER];
date = date.getOffsetDate(7 * value);
_setInnerValue(date, text);
break;
case BI.DateTrigger.MULTI_DATE_DAY_PREV:
var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_PREV];
date = date.getOffsetDate(-1 * value);
_setInnerValue(date, text);
break;
case BI.DateTrigger.MULTI_DATE_DAY_AFTER:
var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_AFTER];
date = date.getOffsetDate(1 * value);
_setInnerValue(date, text);
break;
case BI.DateTrigger.MULTI_DATE_DAY_TODAY:
var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_TODAY];
date = BI.getDate();
_setInnerValue(date, text);
break;
default:
if (BI.isNull(value) || BI.isNull(value.day)) {
this.editor.setState("");
this.editor.setValue("");
this.setTitle("");
} else {
var dateStr = value.year + "-" + (value.month + 1) + "-" + value.day;
this.editor.setState(dateStr);
this.editor.setValue(dateStr);
this.setTitle(dateStr);
}
break;
}
},
getKey: function () {
return this.editor.getValue();
},
getValue: function () {
return this.store_value;
}
});
BI.DateTrigger.MULTI_DATE_YEAR_PREV = 1;
BI.DateTrigger.MULTI_DATE_YEAR_AFTER = 2;
BI.DateTrigger.MULTI_DATE_YEAR_BEGIN = 3;
BI.DateTrigger.MULTI_DATE_YEAR_END = 4;
BI.DateTrigger.MULTI_DATE_MONTH_PREV = 5;
BI.DateTrigger.MULTI_DATE_MONTH_AFTER = 6;
BI.DateTrigger.MULTI_DATE_MONTH_BEGIN = 7;
BI.DateTrigger.MULTI_DATE_MONTH_END = 8;
BI.DateTrigger.MULTI_DATE_QUARTER_PREV = 9;
BI.DateTrigger.MULTI_DATE_QUARTER_AFTER = 10;
BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN = 11;
BI.DateTrigger.MULTI_DATE_QUARTER_END = 12;
BI.DateTrigger.MULTI_DATE_WEEK_PREV = 13;
BI.DateTrigger.MULTI_DATE_WEEK_AFTER = 14;
BI.DateTrigger.MULTI_DATE_DAY_PREV = 15;
BI.DateTrigger.MULTI_DATE_DAY_AFTER = 16;
BI.DateTrigger.MULTI_DATE_DAY_TODAY = 17;
BI.DateTrigger.MULTI_DATE_PARAM = 18;
BI.DateTrigger.MULTI_DATE_CALENDAR = 19;
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM = {};
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_PREV] = BI.i18nText("BI-Multi_Date_Year_Prev");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_AFTER] = BI.i18nText("BI-Multi_Date_Year_Next");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_BEGIN] = BI.i18nText("BI-Multi_Date_Year_Begin");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_END] = BI.i18nText("BI-Multi_Date_Year_End");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_PREV] = BI.i18nText("BI-Multi_Date_Quarter_Prev");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_AFTER] = BI.i18nText("BI-Multi_Date_Quarter_Next");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN] = BI.i18nText("BI-Multi_Date_Quarter_Begin");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_END] = BI.i18nText("BI-Multi_Date_Quarter_End");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_PREV] = BI.i18nText("BI-Multi_Date_Month_Prev");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_AFTER] = BI.i18nText("BI-Multi_Date_Month_Next");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_BEGIN] = BI.i18nText("BI-Multi_Date_Month_Begin");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_END] = BI.i18nText("BI-Multi_Date_Month_End");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_PREV] = BI.i18nText("BI-Multi_Date_Week_Prev");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_AFTER] = BI.i18nText("BI-Multi_Date_Week_Next");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_PREV] = BI.i18nText("BI-Multi_Date_Day_Prev");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_AFTER] = BI.i18nText("BI-Multi_Date_Day_Next");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_TODAY] = BI.i18nText("BI-Multi_Date_Today");
BI.DateTrigger.EVENT_FOCUS = "EVENT_FOCUS";
BI.DateTrigger.EVENT_START = "EVENT_START";
BI.DateTrigger.EVENT_STOP = "EVENT_STOP";
BI.DateTrigger.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.DateTrigger.EVENT_CHANGE = "EVENT_CHANGE";
BI.DateTrigger.EVENT_VALID = "EVENT_VALID";
BI.DateTrigger.EVENT_ERROR = "EVENT_ERROR";
BI.DateTrigger.EVENT_TRIGGER_CLICK = "EVENT_TRIGGER_CLICK";
BI.DateTrigger.EVENT_KEY_DOWN = "EVENT_KEY_DOWN";
BI.shortcut("bi.date_trigger", BI.DateTrigger);/**
* Created by zcf on 2017/2/20. * Created by zcf on 2017/2/20.
*/ */
BI.StaticDatePaneCard = BI.inherit(BI.Widget, { BI.StaticDatePaneCard = BI.inherit(BI.Widget, {
@ -89351,7 +88976,7 @@ BI.shortcut("bi.date_time_trigger", BI.DateTimeTrigger);BI.StaticDateTimePaneCar
this.today = BI.getDate(); this.today = BI.getDate();
this._year = this.today.getFullYear(); this._year = this.today.getFullYear();
this._month = this.today.getMonth(); this._month = this.today.getMonth() + 1;
this.selectedTime = o.selectedTime || { this.selectedTime = o.selectedTime || {
year: this._year, year: this._year,
@ -89498,7 +89123,7 @@ BI.shortcut("bi.static_date_time_pane_card", BI.StaticDateTimePaneCard);BI.Dynam
var date = BI.DynamicDateHelper.getCalculation(self.dynamicPane.getValue()); var date = BI.DynamicDateHelper.getCalculation(self.dynamicPane.getValue());
self.ymd.setValue({ self.ymd.setValue({
year: date.getFullYear(), year: date.getFullYear(),
month: date.getMonth(), month: date.getMonth() + 1,
day: date.getDate() day: date.getDate()
}); });
break; break;
@ -89582,7 +89207,7 @@ BI.shortcut("bi.static_date_time_pane_card", BI.StaticDateTimePaneCard);BI.Dynam
var date = BI.getDate(); var date = BI.getDate();
this.ymd.setValue({ this.ymd.setValue({
year: date.getFullYear(), year: date.getFullYear(),
month: date.getMonth() month: date.getMonth() + 1
}); });
} else { } else {
this.ymd.setValue(value); this.ymd.setValue(value);

22
dist/demo.js vendored

@ -12181,17 +12181,17 @@ BI.shortcut("demo.tips", Demo.Tips);Demo.DatePane = BI.inherit(BI.Widget, {
} }
}, { }, {
type: "bi.dynamic_date_time_pane", type: "bi.dynamic_date_time_pane",
value: { // value: {
type: 1, // type: 1,
value: { // value: {
year: 2017, // year: 2017,
month: 12, // month: 12,
day: 11, // day: 11,
hour: 12, // hour: 12,
minute: 12, // minute: 12,
second: 12 // second: 12
} // }
}, // },
ref: function (_ref) { ref: function (_ref) {
self.dateTimePane = _ref; self.dateTimePane = _ref;
}, },

383
dist/widget.js vendored

@ -844,7 +844,7 @@ BI.DateCalendarPopup = BI.inherit(BI.Widget, {
o = this.options; o = this.options;
this.today = BI.getDate(); this.today = BI.getDate();
this._year = this.today.getFullYear(); this._year = this.today.getFullYear();
this._month = this.today.getMonth(); this._month = this.today.getMonth() + 1;
this._day = this.today.getDate(); this._day = this.today.getDate();
this.selectedTime = o.selectedTime || { this.selectedTime = o.selectedTime || {
@ -1081,381 +1081,6 @@ BI.DateTriangleTrigger = BI.inherit(BI.Trigger, {
} }
}); });
BI.shortcut("bi.date_triangle_trigger", BI.DateTriangleTrigger);/** BI.shortcut("bi.date_triangle_trigger", BI.DateTriangleTrigger);/**
* 日期下拉框
*
* Created by GUY on 2015/9/7.
* @class BI.DateCombo
* @extends BI.Widget
*/
BI.DateCombo = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.DateCombo.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-date-combo bi-border",
height: 25
});
},
_init: function () {
BI.DateCombo.superclass._init.apply(this, arguments);
var self = this,
o = this.options;
this.trigger = BI.createWidget({
type: "bi.date_trigger"
});
this.trigger.on(BI.DateTrigger.EVENT_TRIGGER_CLICK, function () {
self.combo.toggle();
});
this.popup = BI.createWidget({
type: "bi.date_calendar_popup"
});
this.popup.on(BI.DateCalendarPopup.EVENT_CHANGE, function () {
self.setValue(self.popup.getValue());
});
this.combo = BI.createWidget({
type: "bi.combo",
toggle: false,
element: this,
isNeedAdjustHeight: false,
isNeedAdjustWidth: false,
el: this.trigger,
popup: {
width: 270,
el: this.popup,
stopPropagation: false
}
});
},
setValue: function (v) {
this.trigger.setValue(v);
this.popup.setValue(v);
},
getValue: function () {
return this.popup.getValue();
}
});
BI.shortcut("bi.date_combo", BI.DateCombo);BI.DateTrigger = BI.inherit(BI.Trigger, {
_const: {
hgap: 4,
vgap: 2,
yearLength: 4,
yearMonthLength: 7
},
_defaultConfig: function () {
return BI.extend(BI.DateTrigger.superclass._defaultConfig.apply(this, arguments), {
extraCls: "bi-date-trigger",
min: "1900-01-01", // 最小日期
max: "2099-12-31", // 最大日期
height: 24
});
},
_init: function () {
BI.DateTrigger.superclass._init.apply(this, arguments);
var self = this, o = this.options, c = this._const;
this.editor = BI.createWidget({
type: "bi.sign_editor",
height: o.height,
validationChecker: function (v) {
var date = v.match(/\d+/g);
self._autoAppend(v, date);
return self._dateCheck(v) && BI.checkDateLegal(v) && self._checkVoid({
year: date[0],
month: date[1],
day: date[2]
});
},
quitChecker: function () {
return false;
},
hgap: c.hgap,
vgap: c.vgap,
allowBlank: true,
watermark: BI.i18nText("BI-Basic_Unrestricted"),
errorText: function () {
if (self.editor.isEditing()) {
return BI.i18nText("BI-Date_Trigger_Error_Text");
}
return BI.i18nText("BI-Year_Trigger_Invalid_Text");
}
});
this.editor.on(BI.SignEditor.EVENT_KEY_DOWN, function () {
self.fireEvent(BI.DateTrigger.EVENT_KEY_DOWN);
});
this.editor.on(BI.SignEditor.EVENT_FOCUS, function () {
self.fireEvent(BI.DateTrigger.EVENT_FOCUS);
});
this.editor.on(BI.SignEditor.EVENT_STOP, function () {
self.fireEvent(BI.DateTrigger.EVENT_STOP);
});
this.editor.on(BI.SignEditor.EVENT_VALID, function () {
self.fireEvent(BI.DateTrigger.EVENT_VALID);
});
this.editor.on(BI.SignEditor.EVENT_ERROR, function () {
self.fireEvent(BI.DateTrigger.EVENT_ERROR);
});
this.editor.on(BI.SignEditor.EVENT_CONFIRM, function () {
var value = self.editor.getValue();
if (BI.isNotNull(value)) {
self.editor.setState(value);
}
if (BI.isNotEmptyString(value)) {
var date = value.split("-");
self.store_value = {
type: BI.DateTrigger.MULTI_DATE_CALENDAR,
value: {
year: date[0] | 0,
month: date[1] - 1,
day: date[2] | 0
}
};
}
self.fireEvent(BI.DateTrigger.EVENT_CONFIRM);
});
this.editor.on(BI.SignEditor.EVENT_SPACE, function () {
if (self.editor.isValid()) {
self.editor.blur();
}
});
this.editor.on(BI.SignEditor.EVENT_START, function () {
self.fireEvent(BI.DateTrigger.EVENT_START);
});
this.editor.on(BI.SignEditor.EVENT_CHANGE, function () {
self.fireEvent(BI.DateTrigger.EVENT_CHANGE);
});
BI.createWidget({
type: "bi.htape",
element: this,
items: [{
el: BI.createWidget(),
width: 30
}, {
el: this.editor
}]
});
this.setValue(o.value);
},
_dateCheck: function (date) {
return BI.parseDateTime(date, "%Y-%x-%d").print("%Y-%x-%d") == date || BI.parseDateTime(date, "%Y-%X-%d").print("%Y-%X-%d") == date || BI.parseDateTime(date, "%Y-%x-%e").print("%Y-%x-%e") == date || BI.parseDateTime(date, "%Y-%X-%e").print("%Y-%X-%e") == date;
},
_checkVoid: function (obj) {
return !BI.checkDateVoid(obj.year, obj.month, obj.day, this.options.min, this.options.max)[0];
},
_autoAppend: function (v, dateObj) {
var self = this;
var date = BI.parseDateTime(v, "%Y-%X-%d").print("%Y-%X-%d");
var yearCheck = function (v) {
return BI.parseDateTime(v, "%Y").print("%Y") == v && date >= self.options.min && date <= self.options.max;
};
var monthCheck = function (v) {
return BI.parseDateTime(v, "%Y-%X").print("%Y-%X") == v && date >= self.options.min && date <= self.options.max;
};
if (BI.isNotNull(dateObj) && BI.checkDateLegal(v)) {
switch (v.length) {
case this._const.yearLength:
if (yearCheck(v)) {
this.editor.setValue(v + "-");
}
break;
case this._const.yearMonthLength:
if (monthCheck(v)) {
this.editor.setValue(v + "-");
}
break;
}
}
},
setValue: function (v) {
var type, value, self = this;
var date = BI.getDate();
this.store_value = v;
if (BI.isNotNull(v)) {
type = v.type || BI.DateTrigger.MULTI_DATE_CALENDAR; value = v.value;
if(BI.isNull(value)) {
value = v;
}
}
var _setInnerValue = function (date, text) {
var dateStr = date.print("%Y-%x-%e");
self.editor.setState(dateStr);
self.editor.setValue(dateStr);
self.setTitle(text + ":" + dateStr);
};
switch (type) {
case BI.DateTrigger.MULTI_DATE_YEAR_PREV:
var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_PREV];
date = BI.getDate((date.getFullYear() - 1 * value), date.getMonth(), date.getDate());
_setInnerValue(date, text);
break;
case BI.DateTrigger.MULTI_DATE_YEAR_AFTER:
var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_AFTER];
date = BI.getDate((date.getFullYear() + 1 * value), date.getMonth(), date.getDate());
_setInnerValue(date, text);
break;
case BI.DateTrigger.MULTI_DATE_YEAR_BEGIN:
var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_BEGIN];
date = BI.getDate(date.getFullYear(), 0, 1);
_setInnerValue(date, text);
break;
case BI.DateTrigger.MULTI_DATE_YEAR_END:
var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_END];
date = BI.getDate(date.getFullYear(), 11, 31);
_setInnerValue(date, text);
break;
case BI.DateTrigger.MULTI_DATE_QUARTER_PREV:
var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_PREV];
date = BI.getDate().getOffsetQuarter(-value);
_setInnerValue(date, text);
break;
case BI.DateTrigger.MULTI_DATE_QUARTER_AFTER:
var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_AFTER];
date = BI.getDate().getOffsetQuarter(value);
_setInnerValue(date, text);
break;
case BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN:
var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN];
date = BI.getDate().getQuarterStartDate();
_setInnerValue(date, text);
break;
case BI.DateTrigger.MULTI_DATE_QUARTER_END:
var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_END];
date = BI.getDate().getQuarterEndDate();
_setInnerValue(date, text);
break;
case BI.DateTrigger.MULTI_DATE_MONTH_PREV:
var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_PREV];
date = BI.getDate().getOffsetMonth(-value);
_setInnerValue(date, text);
break;
case BI.DateTrigger.MULTI_DATE_MONTH_AFTER:
var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_AFTER];
date = BI.getDate().getOffsetMonth(value);
_setInnerValue(date, text);
break;
case BI.DateTrigger.MULTI_DATE_MONTH_BEGIN:
var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_BEGIN];
date = BI.getDate(date.getFullYear(), date.getMonth(), 1);
_setInnerValue(date, text);
break;
case BI.DateTrigger.MULTI_DATE_MONTH_END:
var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_END];
date = BI.getDate(date.getFullYear(), date.getMonth(), (date.getLastDateOfMonth()).getDate());
_setInnerValue(date, text);
break;
case BI.DateTrigger.MULTI_DATE_WEEK_PREV:
var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_PREV];
date = date.getOffsetDate(-7 * value);
_setInnerValue(date, text);
break;
case BI.DateTrigger.MULTI_DATE_WEEK_AFTER:
var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_AFTER];
date = date.getOffsetDate(7 * value);
_setInnerValue(date, text);
break;
case BI.DateTrigger.MULTI_DATE_DAY_PREV:
var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_PREV];
date = date.getOffsetDate(-1 * value);
_setInnerValue(date, text);
break;
case BI.DateTrigger.MULTI_DATE_DAY_AFTER:
var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_AFTER];
date = date.getOffsetDate(1 * value);
_setInnerValue(date, text);
break;
case BI.DateTrigger.MULTI_DATE_DAY_TODAY:
var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_TODAY];
date = BI.getDate();
_setInnerValue(date, text);
break;
default:
if (BI.isNull(value) || BI.isNull(value.day)) {
this.editor.setState("");
this.editor.setValue("");
this.setTitle("");
} else {
var dateStr = value.year + "-" + (value.month + 1) + "-" + value.day;
this.editor.setState(dateStr);
this.editor.setValue(dateStr);
this.setTitle(dateStr);
}
break;
}
},
getKey: function () {
return this.editor.getValue();
},
getValue: function () {
return this.store_value;
}
});
BI.DateTrigger.MULTI_DATE_YEAR_PREV = 1;
BI.DateTrigger.MULTI_DATE_YEAR_AFTER = 2;
BI.DateTrigger.MULTI_DATE_YEAR_BEGIN = 3;
BI.DateTrigger.MULTI_DATE_YEAR_END = 4;
BI.DateTrigger.MULTI_DATE_MONTH_PREV = 5;
BI.DateTrigger.MULTI_DATE_MONTH_AFTER = 6;
BI.DateTrigger.MULTI_DATE_MONTH_BEGIN = 7;
BI.DateTrigger.MULTI_DATE_MONTH_END = 8;
BI.DateTrigger.MULTI_DATE_QUARTER_PREV = 9;
BI.DateTrigger.MULTI_DATE_QUARTER_AFTER = 10;
BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN = 11;
BI.DateTrigger.MULTI_DATE_QUARTER_END = 12;
BI.DateTrigger.MULTI_DATE_WEEK_PREV = 13;
BI.DateTrigger.MULTI_DATE_WEEK_AFTER = 14;
BI.DateTrigger.MULTI_DATE_DAY_PREV = 15;
BI.DateTrigger.MULTI_DATE_DAY_AFTER = 16;
BI.DateTrigger.MULTI_DATE_DAY_TODAY = 17;
BI.DateTrigger.MULTI_DATE_PARAM = 18;
BI.DateTrigger.MULTI_DATE_CALENDAR = 19;
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM = {};
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_PREV] = BI.i18nText("BI-Multi_Date_Year_Prev");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_AFTER] = BI.i18nText("BI-Multi_Date_Year_Next");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_BEGIN] = BI.i18nText("BI-Multi_Date_Year_Begin");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_END] = BI.i18nText("BI-Multi_Date_Year_End");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_PREV] = BI.i18nText("BI-Multi_Date_Quarter_Prev");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_AFTER] = BI.i18nText("BI-Multi_Date_Quarter_Next");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN] = BI.i18nText("BI-Multi_Date_Quarter_Begin");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_END] = BI.i18nText("BI-Multi_Date_Quarter_End");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_PREV] = BI.i18nText("BI-Multi_Date_Month_Prev");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_AFTER] = BI.i18nText("BI-Multi_Date_Month_Next");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_BEGIN] = BI.i18nText("BI-Multi_Date_Month_Begin");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_END] = BI.i18nText("BI-Multi_Date_Month_End");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_PREV] = BI.i18nText("BI-Multi_Date_Week_Prev");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_AFTER] = BI.i18nText("BI-Multi_Date_Week_Next");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_PREV] = BI.i18nText("BI-Multi_Date_Day_Prev");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_AFTER] = BI.i18nText("BI-Multi_Date_Day_Next");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_TODAY] = BI.i18nText("BI-Multi_Date_Today");
BI.DateTrigger.EVENT_FOCUS = "EVENT_FOCUS";
BI.DateTrigger.EVENT_START = "EVENT_START";
BI.DateTrigger.EVENT_STOP = "EVENT_STOP";
BI.DateTrigger.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.DateTrigger.EVENT_CHANGE = "EVENT_CHANGE";
BI.DateTrigger.EVENT_VALID = "EVENT_VALID";
BI.DateTrigger.EVENT_ERROR = "EVENT_ERROR";
BI.DateTrigger.EVENT_TRIGGER_CLICK = "EVENT_TRIGGER_CLICK";
BI.DateTrigger.EVENT_KEY_DOWN = "EVENT_KEY_DOWN";
BI.shortcut("bi.date_trigger", BI.DateTrigger);/**
* Created by zcf on 2017/2/20. * Created by zcf on 2017/2/20.
*/ */
BI.StaticDatePaneCard = BI.inherit(BI.Widget, { BI.StaticDatePaneCard = BI.inherit(BI.Widget, {
@ -2197,7 +1822,7 @@ BI.shortcut("bi.date_time_trigger", BI.DateTimeTrigger);BI.StaticDateTimePaneCar
this.today = BI.getDate(); this.today = BI.getDate();
this._year = this.today.getFullYear(); this._year = this.today.getFullYear();
this._month = this.today.getMonth(); this._month = this.today.getMonth() + 1;
this.selectedTime = o.selectedTime || { this.selectedTime = o.selectedTime || {
year: this._year, year: this._year,
@ -2344,7 +1969,7 @@ BI.shortcut("bi.static_date_time_pane_card", BI.StaticDateTimePaneCard);BI.Dynam
var date = BI.DynamicDateHelper.getCalculation(self.dynamicPane.getValue()); var date = BI.DynamicDateHelper.getCalculation(self.dynamicPane.getValue());
self.ymd.setValue({ self.ymd.setValue({
year: date.getFullYear(), year: date.getFullYear(),
month: date.getMonth(), month: date.getMonth() + 1,
day: date.getDate() day: date.getDate()
}); });
break; break;
@ -2428,7 +2053,7 @@ BI.shortcut("bi.static_date_time_pane_card", BI.StaticDateTimePaneCard);BI.Dynam
var date = BI.getDate(); var date = BI.getDate();
this.ymd.setValue({ this.ymd.setValue({
year: date.getFullYear(), year: date.getFullYear(),
month: date.getMonth() month: date.getMonth() + 1
}); });
} else { } else {
this.ymd.setValue(value); this.ymd.setValue(value);

2
src/widget/date/calendar/popup.calendar.date.js

@ -36,7 +36,7 @@ BI.DateCalendarPopup = BI.inherit(BI.Widget, {
o = this.options; o = this.options;
this.today = BI.getDate(); this.today = BI.getDate();
this._year = this.today.getFullYear(); this._year = this.today.getFullYear();
this._month = this.today.getMonth(); this._month = this.today.getMonth() + 1;
this._day = this.today.getDate(); this._day = this.today.getDate();
this.selectedTime = o.selectedTime || { this.selectedTime = o.selectedTime || {

60
src/widget/date/combo.date.js

@ -1,60 +0,0 @@
/**
* 日期下拉框
*
* Created by GUY on 2015/9/7.
* @class BI.DateCombo
* @extends BI.Widget
*/
BI.DateCombo = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.DateCombo.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-date-combo bi-border",
height: 25
});
},
_init: function () {
BI.DateCombo.superclass._init.apply(this, arguments);
var self = this,
o = this.options;
this.trigger = BI.createWidget({
type: "bi.date_trigger"
});
this.trigger.on(BI.DateTrigger.EVENT_TRIGGER_CLICK, function () {
self.combo.toggle();
});
this.popup = BI.createWidget({
type: "bi.date_calendar_popup"
});
this.popup.on(BI.DateCalendarPopup.EVENT_CHANGE, function () {
self.setValue(self.popup.getValue());
});
this.combo = BI.createWidget({
type: "bi.combo",
toggle: false,
element: this,
isNeedAdjustHeight: false,
isNeedAdjustWidth: false,
el: this.trigger,
popup: {
width: 270,
el: this.popup,
stopPropagation: false
}
});
},
setValue: function (v) {
this.trigger.setValue(v);
this.popup.setValue(v);
},
getValue: function () {
return this.popup.getValue();
}
});
BI.shortcut("bi.date_combo", BI.DateCombo);

317
src/widget/date/trigger.date.js

@ -1,317 +0,0 @@
BI.DateTrigger = BI.inherit(BI.Trigger, {
_const: {
hgap: 4,
vgap: 2,
yearLength: 4,
yearMonthLength: 7
},
_defaultConfig: function () {
return BI.extend(BI.DateTrigger.superclass._defaultConfig.apply(this, arguments), {
extraCls: "bi-date-trigger",
min: "1900-01-01", // 最小日期
max: "2099-12-31", // 最大日期
height: 24
});
},
_init: function () {
BI.DateTrigger.superclass._init.apply(this, arguments);
var self = this, o = this.options, c = this._const;
this.editor = BI.createWidget({
type: "bi.sign_editor",
height: o.height,
validationChecker: function (v) {
var date = v.match(/\d+/g);
self._autoAppend(v, date);
return self._dateCheck(v) && BI.checkDateLegal(v) && self._checkVoid({
year: date[0],
month: date[1],
day: date[2]
});
},
quitChecker: function () {
return false;
},
hgap: c.hgap,
vgap: c.vgap,
allowBlank: true,
watermark: BI.i18nText("BI-Basic_Unrestricted"),
errorText: function () {
if (self.editor.isEditing()) {
return BI.i18nText("BI-Date_Trigger_Error_Text");
}
return BI.i18nText("BI-Year_Trigger_Invalid_Text");
}
});
this.editor.on(BI.SignEditor.EVENT_KEY_DOWN, function () {
self.fireEvent(BI.DateTrigger.EVENT_KEY_DOWN);
});
this.editor.on(BI.SignEditor.EVENT_FOCUS, function () {
self.fireEvent(BI.DateTrigger.EVENT_FOCUS);
});
this.editor.on(BI.SignEditor.EVENT_STOP, function () {
self.fireEvent(BI.DateTrigger.EVENT_STOP);
});
this.editor.on(BI.SignEditor.EVENT_VALID, function () {
self.fireEvent(BI.DateTrigger.EVENT_VALID);
});
this.editor.on(BI.SignEditor.EVENT_ERROR, function () {
self.fireEvent(BI.DateTrigger.EVENT_ERROR);
});
this.editor.on(BI.SignEditor.EVENT_CONFIRM, function () {
var value = self.editor.getValue();
if (BI.isNotNull(value)) {
self.editor.setState(value);
}
if (BI.isNotEmptyString(value)) {
var date = value.split("-");
self.store_value = {
type: BI.DateTrigger.MULTI_DATE_CALENDAR,
value: {
year: date[0] | 0,
month: date[1] - 1,
day: date[2] | 0
}
};
}
self.fireEvent(BI.DateTrigger.EVENT_CONFIRM);
});
this.editor.on(BI.SignEditor.EVENT_SPACE, function () {
if (self.editor.isValid()) {
self.editor.blur();
}
});
this.editor.on(BI.SignEditor.EVENT_START, function () {
self.fireEvent(BI.DateTrigger.EVENT_START);
});
this.editor.on(BI.SignEditor.EVENT_CHANGE, function () {
self.fireEvent(BI.DateTrigger.EVENT_CHANGE);
});
BI.createWidget({
type: "bi.htape",
element: this,
items: [{
el: BI.createWidget(),
width: 30
}, {
el: this.editor
}]
});
this.setValue(o.value);
},
_dateCheck: function (date) {
return BI.parseDateTime(date, "%Y-%x-%d").print("%Y-%x-%d") == date || BI.parseDateTime(date, "%Y-%X-%d").print("%Y-%X-%d") == date || BI.parseDateTime(date, "%Y-%x-%e").print("%Y-%x-%e") == date || BI.parseDateTime(date, "%Y-%X-%e").print("%Y-%X-%e") == date;
},
_checkVoid: function (obj) {
return !BI.checkDateVoid(obj.year, obj.month, obj.day, this.options.min, this.options.max)[0];
},
_autoAppend: function (v, dateObj) {
var self = this;
var date = BI.parseDateTime(v, "%Y-%X-%d").print("%Y-%X-%d");
var yearCheck = function (v) {
return BI.parseDateTime(v, "%Y").print("%Y") == v && date >= self.options.min && date <= self.options.max;
};
var monthCheck = function (v) {
return BI.parseDateTime(v, "%Y-%X").print("%Y-%X") == v && date >= self.options.min && date <= self.options.max;
};
if (BI.isNotNull(dateObj) && BI.checkDateLegal(v)) {
switch (v.length) {
case this._const.yearLength:
if (yearCheck(v)) {
this.editor.setValue(v + "-");
}
break;
case this._const.yearMonthLength:
if (monthCheck(v)) {
this.editor.setValue(v + "-");
}
break;
}
}
},
setValue: function (v) {
var type, value, self = this;
var date = BI.getDate();
this.store_value = v;
if (BI.isNotNull(v)) {
type = v.type || BI.DateTrigger.MULTI_DATE_CALENDAR; value = v.value;
if(BI.isNull(value)) {
value = v;
}
}
var _setInnerValue = function (date, text) {
var dateStr = date.print("%Y-%x-%e");
self.editor.setState(dateStr);
self.editor.setValue(dateStr);
self.setTitle(text + ":" + dateStr);
};
switch (type) {
case BI.DateTrigger.MULTI_DATE_YEAR_PREV:
var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_PREV];
date = BI.getDate((date.getFullYear() - 1 * value), date.getMonth(), date.getDate());
_setInnerValue(date, text);
break;
case BI.DateTrigger.MULTI_DATE_YEAR_AFTER:
var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_AFTER];
date = BI.getDate((date.getFullYear() + 1 * value), date.getMonth(), date.getDate());
_setInnerValue(date, text);
break;
case BI.DateTrigger.MULTI_DATE_YEAR_BEGIN:
var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_BEGIN];
date = BI.getDate(date.getFullYear(), 0, 1);
_setInnerValue(date, text);
break;
case BI.DateTrigger.MULTI_DATE_YEAR_END:
var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_END];
date = BI.getDate(date.getFullYear(), 11, 31);
_setInnerValue(date, text);
break;
case BI.DateTrigger.MULTI_DATE_QUARTER_PREV:
var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_PREV];
date = BI.getDate().getOffsetQuarter(-value);
_setInnerValue(date, text);
break;
case BI.DateTrigger.MULTI_DATE_QUARTER_AFTER:
var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_AFTER];
date = BI.getDate().getOffsetQuarter(value);
_setInnerValue(date, text);
break;
case BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN:
var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN];
date = BI.getDate().getQuarterStartDate();
_setInnerValue(date, text);
break;
case BI.DateTrigger.MULTI_DATE_QUARTER_END:
var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_END];
date = BI.getDate().getQuarterEndDate();
_setInnerValue(date, text);
break;
case BI.DateTrigger.MULTI_DATE_MONTH_PREV:
var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_PREV];
date = BI.getDate().getOffsetMonth(-value);
_setInnerValue(date, text);
break;
case BI.DateTrigger.MULTI_DATE_MONTH_AFTER:
var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_AFTER];
date = BI.getDate().getOffsetMonth(value);
_setInnerValue(date, text);
break;
case BI.DateTrigger.MULTI_DATE_MONTH_BEGIN:
var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_BEGIN];
date = BI.getDate(date.getFullYear(), date.getMonth(), 1);
_setInnerValue(date, text);
break;
case BI.DateTrigger.MULTI_DATE_MONTH_END:
var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_END];
date = BI.getDate(date.getFullYear(), date.getMonth(), (date.getLastDateOfMonth()).getDate());
_setInnerValue(date, text);
break;
case BI.DateTrigger.MULTI_DATE_WEEK_PREV:
var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_PREV];
date = date.getOffsetDate(-7 * value);
_setInnerValue(date, text);
break;
case BI.DateTrigger.MULTI_DATE_WEEK_AFTER:
var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_AFTER];
date = date.getOffsetDate(7 * value);
_setInnerValue(date, text);
break;
case BI.DateTrigger.MULTI_DATE_DAY_PREV:
var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_PREV];
date = date.getOffsetDate(-1 * value);
_setInnerValue(date, text);
break;
case BI.DateTrigger.MULTI_DATE_DAY_AFTER:
var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_AFTER];
date = date.getOffsetDate(1 * value);
_setInnerValue(date, text);
break;
case BI.DateTrigger.MULTI_DATE_DAY_TODAY:
var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_TODAY];
date = BI.getDate();
_setInnerValue(date, text);
break;
default:
if (BI.isNull(value) || BI.isNull(value.day)) {
this.editor.setState("");
this.editor.setValue("");
this.setTitle("");
} else {
var dateStr = value.year + "-" + (value.month + 1) + "-" + value.day;
this.editor.setState(dateStr);
this.editor.setValue(dateStr);
this.setTitle(dateStr);
}
break;
}
},
getKey: function () {
return this.editor.getValue();
},
getValue: function () {
return this.store_value;
}
});
BI.DateTrigger.MULTI_DATE_YEAR_PREV = 1;
BI.DateTrigger.MULTI_DATE_YEAR_AFTER = 2;
BI.DateTrigger.MULTI_DATE_YEAR_BEGIN = 3;
BI.DateTrigger.MULTI_DATE_YEAR_END = 4;
BI.DateTrigger.MULTI_DATE_MONTH_PREV = 5;
BI.DateTrigger.MULTI_DATE_MONTH_AFTER = 6;
BI.DateTrigger.MULTI_DATE_MONTH_BEGIN = 7;
BI.DateTrigger.MULTI_DATE_MONTH_END = 8;
BI.DateTrigger.MULTI_DATE_QUARTER_PREV = 9;
BI.DateTrigger.MULTI_DATE_QUARTER_AFTER = 10;
BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN = 11;
BI.DateTrigger.MULTI_DATE_QUARTER_END = 12;
BI.DateTrigger.MULTI_DATE_WEEK_PREV = 13;
BI.DateTrigger.MULTI_DATE_WEEK_AFTER = 14;
BI.DateTrigger.MULTI_DATE_DAY_PREV = 15;
BI.DateTrigger.MULTI_DATE_DAY_AFTER = 16;
BI.DateTrigger.MULTI_DATE_DAY_TODAY = 17;
BI.DateTrigger.MULTI_DATE_PARAM = 18;
BI.DateTrigger.MULTI_DATE_CALENDAR = 19;
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM = {};
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_PREV] = BI.i18nText("BI-Multi_Date_Year_Prev");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_AFTER] = BI.i18nText("BI-Multi_Date_Year_Next");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_BEGIN] = BI.i18nText("BI-Multi_Date_Year_Begin");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_END] = BI.i18nText("BI-Multi_Date_Year_End");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_PREV] = BI.i18nText("BI-Multi_Date_Quarter_Prev");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_AFTER] = BI.i18nText("BI-Multi_Date_Quarter_Next");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN] = BI.i18nText("BI-Multi_Date_Quarter_Begin");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_END] = BI.i18nText("BI-Multi_Date_Quarter_End");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_PREV] = BI.i18nText("BI-Multi_Date_Month_Prev");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_AFTER] = BI.i18nText("BI-Multi_Date_Month_Next");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_BEGIN] = BI.i18nText("BI-Multi_Date_Month_Begin");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_END] = BI.i18nText("BI-Multi_Date_Month_End");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_PREV] = BI.i18nText("BI-Multi_Date_Week_Prev");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_AFTER] = BI.i18nText("BI-Multi_Date_Week_Next");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_PREV] = BI.i18nText("BI-Multi_Date_Day_Prev");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_AFTER] = BI.i18nText("BI-Multi_Date_Day_Next");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_TODAY] = BI.i18nText("BI-Multi_Date_Today");
BI.DateTrigger.EVENT_FOCUS = "EVENT_FOCUS";
BI.DateTrigger.EVENT_START = "EVENT_START";
BI.DateTrigger.EVENT_STOP = "EVENT_STOP";
BI.DateTrigger.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.DateTrigger.EVENT_CHANGE = "EVENT_CHANGE";
BI.DateTrigger.EVENT_VALID = "EVENT_VALID";
BI.DateTrigger.EVENT_ERROR = "EVENT_ERROR";
BI.DateTrigger.EVENT_TRIGGER_CLICK = "EVENT_TRIGGER_CLICK";
BI.DateTrigger.EVENT_KEY_DOWN = "EVENT_KEY_DOWN";
BI.shortcut("bi.date_trigger", BI.DateTrigger);

2
src/widget/datetimepane/card.static.datetimepane.js

@ -14,7 +14,7 @@ BI.StaticDateTimePaneCard = BI.inherit(BI.Widget, {
this.today = BI.getDate(); this.today = BI.getDate();
this._year = this.today.getFullYear(); this._year = this.today.getFullYear();
this._month = this.today.getMonth(); this._month = this.today.getMonth() + 1;
this.selectedTime = o.selectedTime || { this.selectedTime = o.selectedTime || {
year: this._year, year: this._year,

4
src/widget/datetimepane/datetimepane.js

@ -32,7 +32,7 @@ BI.DynamicDateTimePane = BI.inherit(BI.Widget, {
var date = BI.DynamicDateHelper.getCalculation(self.dynamicPane.getValue()); var date = BI.DynamicDateHelper.getCalculation(self.dynamicPane.getValue());
self.ymd.setValue({ self.ymd.setValue({
year: date.getFullYear(), year: date.getFullYear(),
month: date.getMonth(), month: date.getMonth() + 1,
day: date.getDate() day: date.getDate()
}); });
break; break;
@ -116,7 +116,7 @@ BI.DynamicDateTimePane = BI.inherit(BI.Widget, {
var date = BI.getDate(); var date = BI.getDate();
this.ymd.setValue({ this.ymd.setValue({
year: date.getFullYear(), year: date.getFullYear(),
month: date.getMonth() month: date.getMonth() + 1
}); });
} else { } else {
this.ymd.setValue(value); this.ymd.setValue(value);

Loading…
Cancel
Save