Browse Source

Merge pull request #301 in FUI/fineui from ~WINDY/fui:master to master

* commit '086cf229bb7de76df0f614141aefcc1342d4d9b1':
  控件部分月份取值为1-12
  删除与整理
  clear_editor的默认值
es6
guy 7 years ago
parent
commit
e07f8a70b0
  1. 3
      demo/js/case/editor/demo.clear_editor.js
  2. 6
      demo/js/widget/date/demo.datepane.js
  3. 4
      demo/js/widget/date/demo.multidate_combo.js
  4. 6
      demo/js/widget/yearmonth/demo.year_month_combo.js
  5. 2
      demo/js/widget/yearmonthinterval/demo.year_month_interval.js
  6. 28910
      dist/bundle.js
  7. 18
      dist/case.js
  8. 21
      dist/demo.js
  9. 25694
      dist/widget.js
  10. 9
      src/case/calendar/calendar.js
  11. 9
      src/case/editor/editor.clear.js
  12. 2
      src/widget/date/calendar/combo.month.date.js
  13. 6
      src/widget/date/calendar/picker.date.js
  14. 110
      src/widget/date/calendar/popup.year.js
  15. 0
      src/widget/datepane/card.static.datepane.js
  16. 220
      src/widget/datepane/datepane.js
  17. 0
      src/widget/datetimepane/card.static.datetimepane.js
  18. 0
      src/widget/datetimepane/datetimepane.js
  19. 140
      src/widget/dynamic/datepane/datepane.js
  20. 161
      src/widget/dynamic/year/combo.year.js
  21. 206
      src/widget/dynamic/year/popup.year.js
  22. 146
      src/widget/dynamic/year/trigger.year.js
  23. 170
      src/widget/dynamic/yearmonth/combo.yearmonth.js
  24. 152
      src/widget/dynamic/yearquarter/combo.yearquarter.js
  25. 2
      src/widget/dynamicdate/dynamicdate.popup.js
  26. 4
      src/widget/dynamicdate/dynamicdate.trigger.js
  27. 2
      src/widget/dynamicdatetime/dynamicdatetime.popup.js
  28. 4
      src/widget/dynamicdatetime/dynamicdatetime.trigger.js
  29. 4
      src/widget/month/popup.month.js
  30. 151
      src/widget/multidate/abstract.multidate.datepane.js
  31. 283
      src/widget/multidate/multidate.combo.js
  32. 43
      src/widget/multidate/multidate.day.js
  33. 47
      src/widget/multidate/multidate.month.js
  34. 317
      src/widget/multidate/multidate.popup.js
  35. 48
      src/widget/multidate/multidate.quarter.js
  36. 127
      src/widget/multidate/multidate.segment.js
  37. 37
      src/widget/multidate/multidate.week.js
  38. 47
      src/widget/multidate/multidate.year.js
  39. 0
      src/widget/year/card.dynamic.year.js
  40. 0
      src/widget/year/card.year.js
  41. 154
      src/widget/year/combo.year.js
  42. 270
      src/widget/year/popup.year.js
  43. 132
      src/widget/year/trigger.year.js
  44. 0
      src/widget/yearmonth/card.dynamic.yearmonth.js
  45. 4
      src/widget/yearmonth/card.static.yearmonth.js
  46. 197
      src/widget/yearmonth/combo.yearmonth.js
  47. 2
      src/widget/yearmonth/popup.yearmonth.js
  48. 2
      src/widget/yearmonth/trigger.yearmonth.js
  49. 0
      src/widget/yearquarter/card.dynamic.yearquarter.js
  50. 0
      src/widget/yearquarter/card.static.yearquarter.js
  51. 178
      src/widget/yearquarter/combo.yearquarter.js
  52. 2
      src/widget/yearquarter/popup.yearquarter.js
  53. 0
      src/widget/yearquarter/trigger.yearquarter.js

3
demo/js/case/editor/demo.clear_editor.js

@ -12,7 +12,8 @@ Demo.ClearEditor = BI.inherit(BI.Widget, {
type: "bi.clear_editor",
cls: "bi-border",
width: 300,
watermark: "这个是带清除按钮的"
watermark: "这个是带清除按钮的",
value: 123
}],
vgap: 20
};

6
demo/js/widget/date/demo.datepane.js

@ -19,7 +19,7 @@ Demo.DatePane = BI.inherit(BI.Widget, {
type: 1,
value: {
year: 2017,
month: 11,
month: 12,
day: 11
}
},
@ -39,7 +39,7 @@ Demo.DatePane = BI.inherit(BI.Widget, {
type: 1,
value: {
year: 2017,
month: 11,
month: 12,
day: 11,
hour: 12,
minute: 12,
@ -62,7 +62,7 @@ Demo.DatePane = BI.inherit(BI.Widget, {
handler: function () {
self.datepane.setValue({
year: 2017,
month: 11,
month: 12,
day: 31
});
}

4
demo/js/widget/date/demo.multidate_combo.js

@ -25,7 +25,7 @@ Demo.Date = BI.inherit(BI.Widget, {
type: 1,
value: {
year: 2018,
month: 1,
month: 2,
day: 23
}
}
@ -46,7 +46,7 @@ Demo.Date = BI.inherit(BI.Widget, {
type: 1,
value: {
year: 2018,
month: 1,
month: 2,
day: 23
}
}

6
demo/js/widget/yearmonth/demo.year_month_combo.js

@ -20,7 +20,7 @@ Demo.YearMonthCombo = BI.inherit(BI.Widget, {
type: 1,
value: {
year: 2018,
month: 0
month: 1
}
}
}, {
@ -32,12 +32,12 @@ Demo.YearMonthCombo = BI.inherit(BI.Widget, {
width: 300
}, {
type: "bi.button",
text: "setVlaue '2017-12'",
text: "setValue '2017-12'",
width: 300,
handler: function () {
self.widget.setValue({
year: 2017,
month: 11
month: 12
});
}
}],

2
demo/js/widget/yearmonthinterval/demo.year_month_interval.js

@ -24,7 +24,7 @@ Demo.YearMonthInterval = BI.inherit(BI.Widget, {
type: 1,
value: {
year: 2018,
month: 0
month: 1
}
}
},

28910
dist/bundle.js vendored

File diff suppressed because it is too large Load Diff

18
dist/case.js vendored

@ -1605,7 +1605,7 @@ BI.Calendar = BI.inherit(BI.Widget, {
min: "1900-01-01", // 最小日期
max: "2099-12-31", // 最大日期
year: 2015,
month: 7, // 7表示八月
month: 8,
day: 25
});
},
@ -1623,18 +1623,23 @@ BI.Calendar = BI.inherit(BI.Widget, {
var MD = Date._MD.slice(0);
MD[1] = BI.isLeapYear(log.ymd[0]) ? 29 : 28;
// 日期所在月第一天
De.setFullYear(log.ymd[0], log.ymd[1], 1);
// 是周几
log.FDay = De.getDay();
// 当前月页第一天是几号
log.PDay = MD[M === 0 ? 11 : M - 1] - log.FDay + 1;
log.NDay = 1;
var items = [];
BI.each(BI.range(42), function (i) {
var td = {}, YY = log.ymd[0], MM = log.ymd[1] + 1, DD;
// 上个月的日期
if (i < log.FDay) {
td.lastMonth = true;
DD = i + log.PDay;
// 上一年
MM === 1 && (YY -= 1);
MM = MM === 1 ? 12 : MM - 1;
} else if (i >= log.FDay && i < log.FDay + MD[log.ymd[1]]) {
@ -1677,7 +1682,7 @@ BI.Calendar = BI.inherit(BI.Widget, {
vgap: 10
}]
});
var days = this._dateCreator(o.year, o.month, o.day);
var days = this._dateCreator(o.year, o.month - 1, o.day);
items = [];
items.push(days.slice(0, 7));
items.push(days.slice(7, 14));
@ -6581,7 +6586,8 @@ BI.ClearEditor = BI.inherit(BI.Widget, {
allowBlank: true,
errorText: o.errorText,
validationChecker: o.validationChecker,
quitChecker: o.quitChecker
quitChecker: o.quitChecker,
value: o.value
});
this.clear = BI.createWidget({
type: "bi.icon_button",
@ -6665,7 +6671,11 @@ BI.ClearEditor = BI.inherit(BI.Widget, {
self.fireEvent(BI.ClearEditor.EVENT_STOP);
});
this.clear.invisible();
if (BI.isKey(o.value)) {
this.clear.visible();
} else {
this.clear.invisible();
}
},
_checkClear: function () {

21
dist/demo.js vendored

@ -2471,7 +2471,8 @@ Demo.ClearEditor = BI.inherit(BI.Widget, {
type: "bi.clear_editor",
cls: "bi-border",
width: 300,
watermark: "这个是带清除按钮的"
watermark: "这个是带清除按钮的",
value: 123
}],
vgap: 20
};
@ -12096,7 +12097,7 @@ BI.shortcut("demo.tips", Demo.Tips);Demo.DatePane = BI.inherit(BI.Widget, {
type: 1,
value: {
year: 2017,
month: 11,
month: 12,
day: 11
}
},
@ -12116,7 +12117,7 @@ BI.shortcut("demo.tips", Demo.Tips);Demo.DatePane = BI.inherit(BI.Widget, {
type: 1,
value: {
year: 2017,
month: 11,
month: 12,
day: 11,
hour: 12,
minute: 12,
@ -12139,7 +12140,7 @@ BI.shortcut("demo.tips", Demo.Tips);Demo.DatePane = BI.inherit(BI.Widget, {
handler: function () {
self.datepane.setValue({
year: 2017,
month: 11,
month: 12,
day: 31
});
}
@ -12182,7 +12183,7 @@ Demo.Date = BI.inherit(BI.Widget, {
type: 1,
value: {
year: 2018,
month: 1,
month: 2,
day: 23
}
}
@ -12203,7 +12204,7 @@ Demo.Date = BI.inherit(BI.Widget, {
type: 1,
value: {
year: 2018,
month: 1,
month: 2,
day: 23
}
}
@ -14556,7 +14557,7 @@ Demo.YearMonthCombo = BI.inherit(BI.Widget, {
type: 1,
value: {
year: 2018,
month: 0
month: 1
}
}
}, {
@ -14568,12 +14569,12 @@ Demo.YearMonthCombo = BI.inherit(BI.Widget, {
width: 300
}, {
type: "bi.button",
text: "setVlaue '2017-12'",
text: "setValue '2017-12'",
width: 300,
handler: function () {
self.widget.setValue({
year: 2017,
month: 11
month: 12
});
}
}],
@ -14608,7 +14609,7 @@ BI.shortcut("demo.year_month_combo", Demo.YearMonthCombo);Demo.YearMonthInterval
type: 1,
value: {
year: 2018,
month: 0
month: 1
}
}
},

25694
dist/widget.js vendored

File diff suppressed because it is too large Load Diff

9
src/case/calendar/calendar.js

@ -14,7 +14,7 @@ BI.Calendar = BI.inherit(BI.Widget, {
min: "1900-01-01", // 最小日期
max: "2099-12-31", // 最大日期
year: 2015,
month: 7, // 7表示八月
month: 8,
day: 25
});
},
@ -32,18 +32,23 @@ BI.Calendar = BI.inherit(BI.Widget, {
var MD = Date._MD.slice(0);
MD[1] = BI.isLeapYear(log.ymd[0]) ? 29 : 28;
// 日期所在月第一天
De.setFullYear(log.ymd[0], log.ymd[1], 1);
// 是周几
log.FDay = De.getDay();
// 当前月页第一天是几号
log.PDay = MD[M === 0 ? 11 : M - 1] - log.FDay + 1;
log.NDay = 1;
var items = [];
BI.each(BI.range(42), function (i) {
var td = {}, YY = log.ymd[0], MM = log.ymd[1] + 1, DD;
// 上个月的日期
if (i < log.FDay) {
td.lastMonth = true;
DD = i + log.PDay;
// 上一年
MM === 1 && (YY -= 1);
MM = MM === 1 ? 12 : MM - 1;
} else if (i >= log.FDay && i < log.FDay + MD[log.ymd[1]]) {
@ -86,7 +91,7 @@ BI.Calendar = BI.inherit(BI.Widget, {
vgap: 10
}]
});
var days = this._dateCreator(o.year, o.month, o.day);
var days = this._dateCreator(o.year, o.month - 1, o.day);
items = [];
items.push(days.slice(0, 7));
items.push(days.slice(7, 14));

9
src/case/editor/editor.clear.js

@ -26,7 +26,8 @@ BI.ClearEditor = BI.inherit(BI.Widget, {
allowBlank: true,
errorText: o.errorText,
validationChecker: o.validationChecker,
quitChecker: o.quitChecker
quitChecker: o.quitChecker,
value: o.value
});
this.clear = BI.createWidget({
type: "bi.icon_button",
@ -110,7 +111,11 @@ BI.ClearEditor = BI.inherit(BI.Widget, {
self.fireEvent(BI.ClearEditor.EVENT_STOP);
});
this.clear.invisible();
if (BI.isKey(o.value)) {
this.clear.visible();
} else {
this.clear.invisible();
}
},
_checkClear: function () {

2
src/widget/date/calendar/combo.month.date.js

@ -49,7 +49,7 @@ BI.MonthDateCombo = BI.inherit(BI.Trigger, {
},
setValue: function (v) {
this.trigger.setValue(v + 1);
this.trigger.setValue(v);
this.popup.setValue(v);
},

6
src/widget/date/calendar/picker.date.js

@ -29,7 +29,7 @@ BI.DatePicker = BI.inherit(BI.Widget, {
if (self._month === 0) {
self.setValue({
year: self.year.getValue() - 1,
month: 11
month: 12
});
} else {
self.setValue({
@ -121,14 +121,14 @@ BI.DatePicker = BI.inherit(BI.Widget, {
_checkLeftValid: function () {
var o = this.options;
var valid = !(this._month === 0 && this._year === BI.parseDateTime(o.min, "%Y-%X-%d").getFullYear());
var valid = !(this._month === 1 && this._year === BI.parseDateTime(o.min, "%Y-%X-%d").getFullYear());
this.left.setEnable(valid);
return valid;
},
_checkRightValid: function () {
var o = this.options;
var valid = !(this._month === 11 && this._year === BI.parseDateTime(o.max, "%Y-%X-%d").getFullYear());
var valid = !(this._month === 12 && this._year === BI.parseDateTime(o.max, "%Y-%X-%d").getFullYear());
this.right.setEnable(valid);
return valid;
},

110
src/widget/date/calendar/popup.year.js

@ -0,0 +1,110 @@
/**
* 年份展示面板
*
* Created by GUY on 2015/9/2.
* @class BI.YearPopup
* @extends BI.Trigger
*/
BI.YearPopup = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.YearPopup.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-year-popup",
behaviors: {},
min: "1900-01-01", // 最小日期
max: "2099-12-31" // 最大日期
});
},
_createYearCalendar: function (v) {
var o = this.options, y = this._year;
var calendar = BI.createWidget({
type: "bi.year_calendar",
behaviors: o.behaviors,
min: o.min,
max: o.max,
logic: {
dynamic: true
},
year: y + v * 12
});
calendar.setValue(this._year);
return calendar;
},
_init: function () {
BI.YearPopup.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.selectedYear = this._year = BI.getDate().getFullYear();
var backBtn = BI.createWidget({
type: "bi.icon_button",
cls: "pre-page-h-font",
width: 25,
height: 25,
value: -1
});
var preBtn = BI.createWidget({
type: "bi.icon_button",
cls: "next-page-h-font",
width: 25,
height: 25,
value: 1
});
this.navigation = BI.createWidget({
type: "bi.navigation",
element: this,
single: true,
logic: {
dynamic: true
},
tab: {
cls: "year-popup-navigation bi-high-light bi-border-top",
height: 25,
items: [backBtn, preBtn]
},
cardCreator: BI.bind(this._createYearCalendar, this),
afterCardShow: function () {
this.setValue(self.selectedYear);
var calendar = this.getSelectedCard();
backBtn.setEnable(!calendar.isFrontYear());
preBtn.setEnable(!calendar.isFinalYear());
}
});
this.navigation.on(BI.Navigation.EVENT_CHANGE, function () {
self.selectedYear = this.getValue();
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
self.fireEvent(BI.YearPopup.EVENT_CHANGE, self.selectedYear);
});
if(BI.isKey(o.value)){
this.setValue(o.value);
}
},
getValue: function () {
return this.selectedYear;
},
setValue: function (v) {
var o = this.options;
if (BI.checkDateVoid(v, 1, 1, o.min, o.max)[0]) {
v = BI.getDate().getFullYear();
this.selectedYear = "";
this.navigation.setSelect(BI.YearCalendar.getPageByYear(v));
this.navigation.setValue("");
} else {
this.selectedYear = v;
this.navigation.setSelect(BI.YearCalendar.getPageByYear(v));
this.navigation.setValue(v);
}
}
});
BI.YearPopup.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.year_popup", BI.YearPopup);

0
src/widget/dynamic/datepane/card.static.datepane.js → src/widget/datepane/card.static.datepane.js

220
src/widget/datepane/datepane.js

@ -1,114 +1,140 @@
/**
* Created by zcf on 2017/2/20.
*/
BI.DatePaneWidget = BI.inherit(BI.Widget, {
_defaultConfig: function () {
var conf = BI.DatePaneWidget.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
baseCls: "bi-date-pane",
min: "1900-01-01", // 最小日期
max: "2099-12-31", // 最大日期
selectedTime: null
});
},
_init: function () {
BI.DatePaneWidget.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.today = BI.getDate();
this._year = this.today.getFullYear();
this._month = this.today.getMonth();
this.selectedTime = o.selectedTime || {
year: this._year,
month: this._month
};
this.datePicker = BI.createWidget({
type: "bi.date_picker",
min: o.min,
max: o.max
});
this.datePicker.on(BI.DatePicker.EVENT_CHANGE, function () {
self.selectedTime = self.datePicker.getValue();
self.calendar.setSelect(BI.Calendar.getPageByDateJSON(self.selectedTime));
});
this.calendar = BI.createWidget({
direction: "top",
element: this,
logic: {
dynamic: false
},
type: "bi.navigation",
tab: this.datePicker,
cardCreator: BI.bind(this._createNav, this)
});
this.calendar.on(BI.Navigation.EVENT_CHANGE, function () {
self.selectedTime = self.calendar.getValue();
self.calendar.empty();
self.setValue(self.selectedTime);
self.fireEvent(BI.DateCalendarPopup.EVENT_CHANGE);
});
this.setValue(o.selectedTime);
},
BI.DynamicDatePane = BI.inherit(BI.Widget, {
_createNav: function (v) {
var date = BI.Calendar.getDateJSONByPage(v);
var calendar = BI.createWidget({
type: "bi.calendar",
logic: {
dynamic: false
},
min: this.options.min,
max: this.options.max,
year: date.year,
month: date.month,
day: this.selectedTime.day
});
return calendar;
props: {
baseCls: "bi-dynamic-date-pane"
},
_getNewCurrentDate: function () {
var today = BI.getDate();
render: function () {
var self = this;
return {
year: today.getFullYear(),
month: today.getMonth()
type: "bi.vtape",
items: [{
el: {
type: "bi.linear_segment",
cls: "bi-border-bottom",
height: 30,
items: BI.createItems([{
text: BI.i18nText("BI-Multi_Date_YMD"),
value: BI.DynamicDatePane.Static
}, {
text: BI.i18nText("BI-Basic_Dynamic_Title"),
value: BI.DynamicDatePane.Dynamic
}], {
textAlign: "center"
}),
listeners: [{
eventName: BI.ButtonGroup.EVENT_CHANGE,
action: function () {
var value = this.getValue()[0];
self.dateTab.setSelect(value);
switch (value) {
case BI.DynamicDatePane.Static:
var date = BI.DynamicDateHelper.getCalculation(self.dynamicPane.getValue());
self.ymd.setValue({
year: date.getFullYear(),
month: date.getMonth(),
day: date.getDate()
});
break;
case BI.DynamicDatePane.Dynamic:
self.dynamicPane.setValue({
year: 0
});
break;
default:
break;
}
}
}],
ref: function () {
self.switch = this;
}
},
height: 30
}, {
type: "bi.tab",
ref: function () {
self.dateTab = this;
},
showIndex: BI.DynamicDatePane.Static,
cardCreator: function (v) {
switch (v) {
case BI.DynamicDatePane.Static:
return {
type: "bi.static_date_pane_card",
listeners: [{
eventName: "EVENT_CHANGE",
action: function () {
self.fireEvent("EVENT_CHANGE");
}
}],
ref: function () {
self.ymd = this;
}
};
case BI.DynamicDatePane.Dynamic:
default:
return {
type: "bi.dynamic_date_card",
listeners: [{
eventName: "EVENT_CHANGE",
action: function () {
self.fireEvent("EVENT_CHANGE");
}
}],
ref: function () {
self.dynamicPane = this;
}
};
}
}
}]
};
},
_setCalenderValue: function (date) {
this.calendar.setSelect(BI.Calendar.getPageByDateJSON(date));
this.calendar.setValue(date);
this.selectedTime = date;
mounted: function () {
this.setValue(this.options.value);
},
_setDatePicker: function (timeOb) {
if (BI.isNull(timeOb) || BI.isNull(timeOb.year) || BI.isNull(timeOb.month)) {
this.datePicker.setValue(this._getNewCurrentDate());
} else {
this.datePicker.setValue(timeOb);
}
_checkValueValid: function (value) {
return BI.isNull(value) || BI.isEmptyObject(value) || BI.isEmptyString(value);
},
_setCalendar: function (timeOb) {
if (BI.isNull(timeOb) || BI.isNull(timeOb.day)) {
this.calendar.empty();
this._setCalenderValue(this._getNewCurrentDate());
} else {
this._setCalenderValue(timeOb);
setValue: function (v) {
v = v || {};
var type = v.type || BI.DynamicDateCombo.Static;
var value = v.value || v;
this.switch.setValue(type);
this.dateTab.setSelect(type);
switch (type) {
case BI.DynamicDateCombo.Dynamic:
this.dynamicPane.setValue(value);
break;
case BI.DynamicDateCombo.Static:
default:
if (this._checkValueValid(value)) {
var date = BI.getDate();
this.ymd.setValue({
year: date.getFullYear(),
month: date.getMonth()
});
} else {
this.ymd.setValue(value);
}
break;
}
},
setValue: function (timeOb) {
this._setDatePicker(timeOb);
this._setCalendar(timeOb);
},
getValue: function () {
return this.selectedTime;
return {
type: this.dateTab.getSelect(),
value: this.dateTab.getValue()
};
}
});
BI.shortcut("bi.date_pane", BI.DatePaneWidget);
BI.shortcut("bi.dynamic_date_pane", BI.DynamicDatePane);
BI.extend(BI.DynamicDatePane, {
Static: 1,
Dynamic: 2
});

0
src/widget/dynamic/datetimepane/card.static.datetimepane.js → src/widget/datetimepane/card.static.datetimepane.js

0
src/widget/dynamic/datetimepane/datetimepane.js → src/widget/datetimepane/datetimepane.js

140
src/widget/dynamic/datepane/datepane.js

@ -1,140 +0,0 @@
BI.DynamicDatePane = BI.inherit(BI.Widget, {
props: {
baseCls: "bi-dynamic-date-pane"
},
render: function () {
var self = this;
return {
type: "bi.vtape",
items: [{
el: {
type: "bi.linear_segment",
cls: "bi-border-bottom",
height: 30,
items: BI.createItems([{
text: BI.i18nText("BI-Multi_Date_YMD"),
value: BI.DynamicDatePane.Static
}, {
text: BI.i18nText("BI-Basic_Dynamic_Title"),
value: BI.DynamicDatePane.Dynamic
}], {
textAlign: "center"
}),
listeners: [{
eventName: BI.ButtonGroup.EVENT_CHANGE,
action: function () {
var value = this.getValue()[0];
self.dateTab.setSelect(value);
switch (value) {
case BI.DynamicDatePane.Static:
var date = BI.DynamicDateHelper.getCalculation(self.dynamicPane.getValue());
self.ymd.setValue({
year: date.getFullYear(),
month: date.getMonth(),
day: date.getDate()
});
break;
case BI.DynamicDatePane.Dynamic:
self.dynamicPane.setValue({
year: 0
});
break;
default:
break;
}
}
}],
ref: function () {
self.switch = this;
}
},
height: 30
}, {
type: "bi.tab",
ref: function () {
self.dateTab = this;
},
showIndex: BI.DynamicDatePane.Static,
cardCreator: function (v) {
switch (v) {
case BI.DynamicDatePane.Static:
return {
type: "bi.static_date_pane_card",
listeners: [{
eventName: "EVENT_CHANGE",
action: function () {
self.fireEvent("EVENT_CHANGE");
}
}],
ref: function () {
self.ymd = this;
}
};
case BI.DynamicDatePane.Dynamic:
default:
return {
type: "bi.dynamic_date_card",
listeners: [{
eventName: "EVENT_CHANGE",
action: function () {
self.fireEvent("EVENT_CHANGE");
}
}],
ref: function () {
self.dynamicPane = this;
}
};
}
}
}]
};
},
mounted: function () {
this.setValue(this.options.value);
},
_checkValueValid: function (value) {
return BI.isNull(value) || BI.isEmptyObject(value) || BI.isEmptyString(value);
},
setValue: function (v) {
v = v || {};
var type = v.type || BI.DynamicDateCombo.Static;
var value = v.value || v;
this.switch.setValue(type);
this.dateTab.setSelect(type);
switch (type) {
case BI.DynamicDateCombo.Dynamic:
this.dynamicPane.setValue(value);
break;
case BI.DynamicDateCombo.Static:
default:
if (this._checkValueValid(value)) {
var date = BI.getDate();
this.ymd.setValue({
year: date.getFullYear(),
month: date.getMonth()
});
} else {
this.ymd.setValue(value);
}
break;
}
},
getValue: function () {
return {
type: this.dateTab.getSelect(),
value: this.dateTab.getValue()
};
}
});
BI.shortcut("bi.dynamic_date_pane", BI.DynamicDatePane);
BI.extend(BI.DynamicDatePane, {
Static: 1,
Dynamic: 2
});

161
src/widget/dynamic/year/combo.year.js

@ -1,161 +0,0 @@
BI.DynamicYearCombo = BI.inherit(BI.Widget, {
props: {
baseCls: "bi-year-combo bi-border",
behaviors: {},
min: "1900-01-01", // 最小日期
max: "2099-12-31", // 最大日期
height: 24
},
_init: function () {
BI.DynamicYearCombo.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.storeValue = o.value;
this.trigger = BI.createWidget({
type: "bi.dynamic_year_trigger",
min: o.min,
max: o.max,
value: o.value || ""
});
this.trigger.on(BI.DynamicYearTrigger.EVENT_FOCUS, function () {
self.storeTriggerValue = this.getKey();
});
this.trigger.on(BI.DynamicYearTrigger.EVENT_START, function () {
self.combo.isViewVisible() && self.combo.hideView();
});
this.trigger.on(BI.DynamicYearTrigger.EVENT_STOP, function () {
self.combo.showView();
});
this.trigger.on(BI.DynamicYearTrigger.EVENT_ERROR, function () {
self.combo.isViewVisible() && self.combo.hideView();
});
this.trigger.on(BI.DynamicYearTrigger.EVENT_CONFIRM, function () {
if (self.combo.isViewVisible()) {
return;
}
if (this.getKey() && this.getKey() !== self.storeTriggerValue) {
self.storeValue = self.trigger.getValue();
self.setValue(self.storeValue);
} else if (!this.getKey()) {
self.storeValue = null;
self.setValue();
}
self.fireEvent(BI.DynamicYearCombo.EVENT_CONFIRM);
});
this.combo = BI.createWidget({
type: "bi.combo",
isNeedAdjustHeight: false,
isNeedAdjustWidth: false,
el: this.trigger,
popup: {
minWidth: 85,
stopPropagation: false,
el: {
type: "bi.dynamic_year_popup",
ref: function () {
self.popup = this;
},
listeners: [{
eventName: BI.DynamicYearPopup.EVENT_CHANGE,
action: function () {
self.setValue(self.popup.getValue());
self.combo.hideView();
self.fireEvent(BI.DynamicYearCombo.EVENT_CONFIRM);
}
}, {
eventName: BI.DynamicYearPopup.BUTTON_CLEAR_EVENT_CHANGE,
action: function () {
self.setValue();
self.combo.hideView();
self.fireEvent(BI.DynamicYearCombo.EVENT_CONFIRM);
}
}, {
eventName: BI.DynamicYearPopup.BUTTON_lABEL_EVENT_CHANGE,
action: function () {
var date = BI.getDate();
self.setValue({year: date.getFullYear()});
self.combo.hideView();
self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM);
}
}, {
eventName: BI.DynamicYearPopup.BUTTON_OK_EVENT_CHANGE,
action: function () {
self.setValue(self.popup.getValue());
self.combo.hideView();
self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM);
}
}],
behaviors: o.behaviors,
min: o.min,
max: o.max
},
value: o.value || ""
}
});
this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
self.popup.setValue(self.storeValue);
self.fireEvent(BI.DynamicYearCombo.EVENT_BEFORE_POPUPVIEW);
});
BI.createWidget({
type: "bi.htape",
element: this,
ref: function () {
self.comboWrapper = this;
},
items: [{
el: {
type: "bi.icon_button",
cls: "bi-trigger-icon-button date-change-h-font",
width: 24,
height: 24,
ref: function () {
self.changeIcon = this;
}
},
width: 24
}, this.combo]
});
this._checkDynamicValue(o.value);
},
_checkDynamicValue: function (v) {
var type = null;
if (BI.isNotNull(v)) {
type = v.type;
}
switch (type) {
case BI.DynamicYearCombo.Dynamic:
this.changeIcon.setVisible(true);
this.comboWrapper.attr("items")[0].width = 24;
this.comboWrapper.resize();
break;
default:
this.comboWrapper.attr("items")[0].width = 0;
this.comboWrapper.resize();
this.changeIcon.setVisible(false);
break;
}
},
setValue: function (v) {
this.storeValue = v;
this.trigger.setValue(v);
this._checkDynamicValue(v);
},
getValue: function () {
return this.storeValue;
}
});
BI.DynamicYearCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.DynamicYearCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
BI.shortcut("bi.dynamic_year_combo", BI.DynamicYearCombo);
BI.extend(BI.DynamicYearCombo, {
Static: 1,
Dynamic: 2
});

206
src/widget/dynamic/year/popup.year.js

@ -1,206 +0,0 @@
/**
* 年份展示面板
*
* Created by GUY on 2015/9/2.
* @class BI.DynamicYearPopup
* @extends BI.Trigger
*/
BI.DynamicYearPopup = BI.inherit(BI.Widget, {
constants: {
tabHeight: 30
},
props: {
baseCls: "bi-year-popup",
behaviors: {},
min: "1900-01-01", // 最小日期
max: "2099-12-31", // 最大日期,
width: 180,
height: 240
},
render: function () {
var self = this, opts = this.options;
this.storeValue = {type: BI.DynamicYearCombo.Static};
return {
type: "bi.vtape",
items: [{
el: this._getTabJson()
}, {
el: {
type: "bi.grid",
items: [[{
type: "bi.text_button",
forceCenter: true,
cls: "bi-border-top bi-high-light",
shadow: true,
text: BI.i18nText("BI-Basic_Clear"),
listeners: [{
eventName: BI.TextButton.EVENT_CHANGE,
action: function () {
self.fireEvent(BI.DynamicYearPopup.BUTTON_CLEAR_EVENT_CHANGE);
}
}]
}, {
type: "bi.text_button",
forceCenter: true,
cls: "bi-border-left bi-border-right bi-border-top",
shadow: true,
text: BI.i18nText("BI-Basic_Current_Year"),
ref: function () {
self.textButton = this;
},
listeners: [{
eventName: BI.TextButton.EVENT_CHANGE,
action: function () {
self.fireEvent(BI.DynamicYearPopup.BUTTON_lABEL_EVENT_CHANGE);
}
}]
}, {
type: "bi.text_button",
forceCenter: true,
cls: "bi-border-top bi-high-light",
shadow: true,
text: BI.i18nText("BI-Basic_OK"),
listeners: [{
eventName: BI.TextButton.EVENT_CHANGE,
action: function () {
self.fireEvent(BI.DynamicYearPopup.BUTTON_OK_EVENT_CHANGE);
}
}]
}]]
},
height: 24
}]
};
},
_setInnerValue: function () {
if (this.dateTab.getSelect() === BI.DynamicDateCombo.Static) {
this.textButton.setValue(BI.i18nText("BI-Basic_Current_Year"));
this.textButton.setEnable(true);
} else {
var date = BI.DynamicDateHelper.getCalculation(this.dynamicPane.getValue());
date = date.print("%Y");
this.textButton.setValue(date);
this.textButton.setEnable(false);
}
},
_getTabJson: function () {
var self = this, o = this.options;
return {
type: "bi.tab",
ref: function () {
self.dateTab = this;
},
tab: {
type: "bi.linear_segment",
cls: "bi-border-bottom",
height: this.constants.tabHeight,
items: BI.createItems([{
text: BI.i18nText("BI-Basic_Year_Fen"),
value: BI.DynamicYearCombo.Static
}, {
text: BI.i18nText("BI-Basic_Dynamic_Title"),
value: BI.DynamicYearCombo.Dynamic
}], {
textAlign: "center"
})
},
cardCreator: function (v) {
switch (v) {
case BI.DynamicYearCombo.Dynamic:
return {
type: "bi.dynamic_year_card",
listeners: [{
eventName: "EVENT_CHANGE",
action: function () {
self._setInnerValue(self.year, v);
}
}],
ref: function () {
self.dynamicPane = this;
}
};
case BI.DynamicYearCombo.Static:
default:
return {
type: "bi.static_year_card",
behaviors: o.behaviors,
min: self.options.min,
max: self.options.max,
listeners: [{
eventName: BI.YearCard.EVENT_CHANGE,
action: function () {
self.fireEvent(BI.DynamicYearPopup.EVENT_CHANGE);
}
}],
ref: function () {
self.year = this;
}
};
}
},
listeners: [{
eventName: BI.Tab.EVENT_CHANGE,
action: function () {
var v = self.dateTab.getSelect();
switch (v) {
case BI.DynamicYearCombo.Static:
var date = BI.DynamicDateHelper.getCalculation(self.dynamicPane.getValue());
self.year.setValue({year: date.getFullYear()});
self._setInnerValue();
break;
case BI.DynamicYearCombo.Dynamic:
default:
if(self.storeValue && self.storeValue.type === BI.DynamicYearCombo.Dynamic) {
self.dynamicPane.setValue(self.storeValue.value);
}else{
self.dynamicPane.setValue({
year: 0
});
}
self._setInnerValue();
break;
}
}
}]
};
},
setValue: function (v) {
this.storeValue = v;
var self = this;
var type, value;
v = v || {};
type = v.type || BI.DynamicDateCombo.Static;
value = v.value || v;
this.dateTab.setSelect(type);
switch (type) {
case BI.DynamicDateCombo.Dynamic:
this.dynamicPane.setValue(value);
self._setInnerValue();
break;
case BI.DynamicDateCombo.Static:
default:
this.year.setValue(value);
this.textButton.setValue(BI.i18nText("BI-Basic_Current_Year"));
this.textButton.setEnable(true);
break;
}
},
getValue: function () {
return {
type: this.dateTab.getSelect(),
value: this.dateTab.getValue()
};
}
});
BI.DynamicYearPopup.BUTTON_CLEAR_EVENT_CHANGE = "BUTTON_CLEAR_EVENT_CHANGE";
BI.DynamicYearPopup.BUTTON_lABEL_EVENT_CHANGE = "BUTTON_lABEL_EVENT_CHANGE";
BI.DynamicYearPopup.BUTTON_OK_EVENT_CHANGE = "BUTTON_OK_EVENT_CHANGE";
BI.DynamicYearPopup.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.dynamic_year_popup", BI.DynamicYearPopup);

146
src/widget/dynamic/year/trigger.year.js

@ -1,146 +0,0 @@
BI.DynamicYearTrigger = BI.inherit(BI.Trigger, {
_const: {
hgap: 4,
vgap: 2,
errorText: BI.i18nText("BI-Please_Input_Positive_Integer"),
errorTextInvalid: BI.i18nText("BI-Year_Trigger_Invalid_Text")
},
_defaultConfig: function () {
return BI.extend(BI.DynamicYearTrigger.superclass._defaultConfig.apply(this, arguments), {
extraCls: "bi-year-trigger",
min: "1900-01-01", // 最小日期
max: "2099-12-31", // 最大日期
height: 24
});
},
_init: function () {
BI.DynamicYearTrigger.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) {
return v === "" || (BI.isPositiveInteger(v) && !BI.checkDateVoid(v, 1, 1, o.min, o.max)[0]);
},
quitChecker: function (v) {
return false;
},
hgap: c.hgap,
vgap: c.vgap,
watermark: BI.i18nText("BI-Basic_Unrestricted"),
allowBlank: true,
errorText: function (v) {
return !BI.isPositiveInteger(v) ? c.errorText : c.errorTextInvalid;
}
});
this.editor.on(BI.SignEditor.EVENT_FOCUS, function () {
self.fireEvent(BI.DynamicYearTrigger.EVENT_FOCUS);
});
this.editor.on(BI.SignEditor.EVENT_STOP, function () {
self.fireEvent(BI.DynamicYearTrigger.EVENT_STOP);
});
this.editor.on(BI.SignEditor.EVENT_CONFIRM, function () {
var value = self.editor.getValue();
if (BI.isNotNull(value)) {
self.editor.setValue(value);
}
if (BI.isNotEmptyString(value)) {
self.storeValue = {
type: BI.DynamicDateCombo.Static,
value: {
year: value
}
};
}
self.fireEvent(BI.DynamicYearTrigger.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.DynamicYearTrigger.EVENT_START);
});
this.editor.on(BI.SignEditor.EVENT_ERROR, function () {
self.fireEvent(BI.DynamicYearTrigger.EVENT_ERROR);
});
BI.createWidget({
element: this,
type: "bi.htape",
items: [{
el: this.editor
}, {
el: {
type: "bi.text_button",
baseCls: "bi-trigger-year-text",
text: BI.i18nText("BI-Multi_Date_Year"),
width: o.height
},
width: o.height
}, {
el: {
type: "bi.trigger_icon_button",
width: o.height
},
width: o.height
}]
});
this.setValue(o.value);
},
_getText: function (obj) {
var value = "";
if(BI.isNotNull(obj.year) && obj.year !== 0) {
value += Math.abs(obj.year) + BI.i18nText("BI-Basic_Year") + (obj.year < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind"));
}
return value;
},
_setInnerValue: function (date, text) {
var dateStr = date.print("%Y");
this.editor.setState(dateStr);
this.editor.setValue(dateStr);
this.setTitle(BI.isEmptyString(text) ? dateStr : (text + ":" + dateStr));
},
setValue: function (v) {
var type, value;
var date = BI.getDate();
this.storeValue = v;
if (BI.isNotNull(v)) {
type = v.type || BI.DynamicDateCombo.Static;
value = v.value || v;
}
switch (type) {
case BI.DynamicDateCombo.Dynamic:
var text = this._getText(value);
date = BI.DynamicDateHelper.getCalculation(value);
this._setInnerValue(date, text);
break;
case BI.DynamicDateCombo.Static:
default:
value = value || {};
this.editor.setState(value.year);
this.editor.setValue(value.year);
this.editor.setTitle(value.year);
break;
}
},
getValue: function () {
return this.storeValue;
},
getKey: function () {
return this.editor.getValue() | 0;
}
});
BI.DynamicYearTrigger.EVENT_FOCUS = "EVENT_FOCUS";
BI.DynamicYearTrigger.EVENT_ERROR = "EVENT_ERROR";
BI.DynamicYearTrigger.EVENT_START = "EVENT_START";
BI.DynamicYearTrigger.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.DynamicYearTrigger.EVENT_STOP = "EVENT_STOP";
BI.shortcut("bi.dynamic_year_trigger", BI.DynamicYearTrigger);

170
src/widget/dynamic/yearmonth/combo.yearmonth.js

@ -1,170 +0,0 @@
BI.DynamicYearMonthCombo = BI.inherit(BI.Single, {
props: {
baseCls: "bi-year-month-combo bi-border",
behaviors: {},
min: "1900-01-01", // 最小日期
max: "2099-12-31", // 最大日期
height: 24
},
_init: function () {
BI.DynamicYearMonthCombo.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.storeValue = o.value;
this.trigger = BI.createWidget({
type: "bi.dynamic_year_month_trigger",
min: o.min,
max: o.max,
value: o.value || ""
});
this.trigger.on(BI.DynamicYearMonthTrigger.EVENT_START, function () {
self.combo.isViewVisible() && self.combo.hideView();
});
this.trigger.on(BI.DynamicYearMonthTrigger.EVENT_STOP, function () {
self.combo.showView();
});
this.trigger.on(BI.DynamicYearMonthTrigger.EVENT_ERROR, function () {
self.combo.isViewVisible() && self.combo.hideView();
self.fireEvent(BI.DynamicYearMonthCombo.EVENT_ERROR);
});
this.trigger.on(BI.DynamicYearMonthTrigger.EVENT_VALID, function () {
self.fireEvent(BI.DynamicYearMonthCombo.EVENT_VALID);
});
this.trigger.on(BI.DynamicYearMonthTrigger.EVENT_CONFIRM, function () {
if (self.combo.isViewVisible()) {
return;
}
self.storeValue = self.trigger.getValue();
self.fireEvent(BI.DynamicYearMonthCombo.EVENT_CONFIRM);
});
this.trigger.on(BI.DynamicYearMonthCombo.EVENT_FOCUS, function () {
self.fireEvent(BI.DynamicYearMonthCombo.EVENT_FOCUS);
});
this.combo = BI.createWidget({
type: "bi.combo",
isNeedAdjustHeight: false,
isNeedAdjustWidth: false,
el: this.trigger,
popup: {
minWidth: 85,
stopPropagation: false,
el: {
type: "bi.dynamic_year_month_popup",
ref: function () {
self.popup = this;
},
listeners: [{
eventName: BI.DynamicYearMonthPopup.EVENT_CHANGE,
action: function () {
self.setValue(self.popup.getValue());
self.combo.hideView();
self.fireEvent(BI.DynamicYearMonthCombo.EVENT_CONFIRM);
}
}, {
eventName: BI.DynamicYearMonthPopup.BUTTON_CLEAR_EVENT_CHANGE,
action: function () {
self.setValue();
self.combo.hideView();
self.fireEvent(BI.DynamicYearMonthCombo.EVENT_CONFIRM);
}
}, {
eventName: BI.DynamicYearMonthPopup.BUTTON_lABEL_EVENT_CHANGE,
action: function () {
var date = BI.getDate();
self.setValue({year: date.getFullYear()});
self.combo.hideView();
self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM);
}
}, {
eventName: BI.DynamicYearMonthPopup.BUTTON_OK_EVENT_CHANGE,
action: function () {
self.setValue(self.popup.getValue());
self.combo.hideView();
self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM);
}
}],
behaviors: o.behaviors,
min: o.min,
max: o.max
},
value: o.value || ""
}
});
this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
self.popup.setValue(self.storeValue);
self.fireEvent(BI.DynamicYearMonthCombo.EVENT_BEFORE_POPUPVIEW);
});
BI.createWidget({
type: "bi.htape",
element: this,
ref: function () {
self.comboWrapper = this;
},
items: [{
el: {
type: "bi.icon_button",
cls: "bi-trigger-icon-button date-change-h-font",
width: 24,
height: 24,
ref: function () {
self.changeIcon = this;
}
},
width: 24
}, this.combo]
});
this._checkDynamicValue(o.value);
},
_checkDynamicValue: function (v) {
var type = null;
if (BI.isNotNull(v)) {
type = v.type;
}
switch (type) {
case BI.DynamicYearMonthCombo.Dynamic:
this.changeIcon.setVisible(true);
this.comboWrapper.attr("items")[0].width = 24;
this.comboWrapper.resize();
break;
default:
this.comboWrapper.attr("items")[0].width = 0;
this.comboWrapper.resize();
this.changeIcon.setVisible(false);
break;
}
},
hideView: function () {
this.combo.hideView();
},
setValue: function (v) {
this.storeValue = v;
this.trigger.setValue(v);
this._checkDynamicValue(v);
},
getValue: function () {
return this.storeValue;
},
getKey: function () {
return this.trigger.getKey();
}
});
BI.DynamicYearMonthCombo.EVENT_ERROR = "EVENT_ERROR";
BI.DynamicYearMonthCombo.EVENT_VALID = "EVENT_VALID";
BI.DynamicYearMonthCombo.EVENT_FOCUS = "EVENT_FOCUS";
BI.DynamicYearMonthCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.DynamicYearMonthCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
BI.shortcut("bi.dynamic_year_month_combo", BI.DynamicYearMonthCombo);
BI.extend(BI.DynamicYearMonthCombo, {
Static: 1,
Dynamic: 2
});

152
src/widget/dynamic/yearquarter/combo.yearquarter.js

@ -1,152 +0,0 @@
BI.DynamicYearQuarterCombo = BI.inherit(BI.Widget, {
props: {
baseCls: "bi-year-quarter-combo bi-border",
behaviors: {},
min: "1900-01-01", // 最小日期
max: "2099-12-31", // 最大日期
height: 24
},
_init: function () {
BI.DynamicYearQuarterCombo.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.storeValue = o.value;
this.trigger = BI.createWidget({
type: "bi.dynamic_year_quarter_trigger",
min: o.min,
max: o.max,
value: o.value || ""
});
this.trigger.on(BI.DynamicYearQuarterTrigger.EVENT_START, function () {
self.combo.isViewVisible() && self.combo.hideView();
});
this.trigger.on(BI.DynamicYearQuarterTrigger.EVENT_STOP, function () {
self.combo.showView();
});
this.trigger.on(BI.DynamicYearQuarterTrigger.EVENT_ERROR, function () {
self.combo.isViewVisible() && self.combo.hideView();
});
this.trigger.on(BI.DynamicYearQuarterTrigger.EVENT_CONFIRM, function () {
if (self.combo.isViewVisible()) {
return;
}
self.storeValue = self.trigger.getValue();
self.fireEvent(BI.DynamicYearQuarterCombo.EVENT_CONFIRM);
});
this.combo = BI.createWidget({
type: "bi.combo",
isNeedAdjustHeight: false,
isNeedAdjustWidth: false,
el: this.trigger,
popup: {
minWidth: 85,
stopPropagation: false,
el: {
type: "bi.dynamic_year_quarter_popup",
ref: function () {
self.popup = this;
},
listeners: [{
eventName: BI.DynamicYearQuarterPopup.EVENT_CHANGE,
action: function () {
self.setValue(self.popup.getValue());
self.combo.hideView();
self.fireEvent(BI.DynamicYearQuarterCombo.EVENT_CONFIRM);
}
}, {
eventName: BI.DynamicYearQuarterPopup.BUTTON_CLEAR_EVENT_CHANGE,
action: function () {
self.setValue();
self.combo.hideView();
self.fireEvent(BI.DynamicYearQuarterCombo.EVENT_CONFIRM);
}
}, {
eventName: BI.DynamicYearQuarterPopup.BUTTON_lABEL_EVENT_CHANGE,
action: function () {
var date = BI.getDate();
self.setValue({year: date.getFullYear()});
self.combo.hideView();
self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM);
}
}, {
eventName: BI.DynamicYearQuarterPopup.BUTTON_OK_EVENT_CHANGE,
action: function () {
self.setValue(self.popup.getValue());
self.combo.hideView();
self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM);
}
}],
behaviors: o.behaviors,
min: o.min,
max: o.max
},
value: o.value || ""
}
});
this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
self.popup.setValue(self.storeValue);
self.fireEvent(BI.DynamicYearQuarterCombo.EVENT_BEFORE_POPUPVIEW);
});
BI.createWidget({
type: "bi.htape",
element: this,
ref: function () {
self.comboWrapper = this;
},
items: [{
el: {
type: "bi.icon_button",
cls: "bi-trigger-icon-button date-change-h-font",
width: 24,
height: 24,
ref: function () {
self.changeIcon = this;
}
},
width: 24
}, this.combo]
});
this._checkDynamicValue(o.value);
},
_checkDynamicValue: function (v) {
var type = null;
if (BI.isNotNull(v)) {
type = v.type;
}
switch (type) {
case BI.DynamicYearQuarterCombo.Dynamic:
this.changeIcon.setVisible(true);
this.comboWrapper.attr("items")[0].width = 24;
this.comboWrapper.resize();
break;
default:
this.comboWrapper.attr("items")[0].width = 0;
this.comboWrapper.resize();
this.changeIcon.setVisible(false);
break;
}
},
setValue: function (v) {
this.storeValue = v;
this.trigger.setValue(v);
this._checkDynamicValue(v);
},
getValue: function () {
return this.storeValue;
}
});
BI.DynamicYearQuarterCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.DynamicYearQuarterCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
BI.shortcut("bi.dynamic_year_quarter_combo", BI.DynamicYearQuarterCombo);
BI.extend(BI.DynamicYearQuarterCombo, {
Static: 1,
Dynamic: 2
});

2
src/widget/dynamicdate/dynamicdate.popup.js

@ -189,7 +189,7 @@ BI.DynamicDatePopup = BI.inherit(BI.Widget, {
var date = BI.getDate();
this.ymd.setValue({
year: date.getFullYear(),
month: date.getMonth(),
month: date.getMonth() + 1,
day: date.getDate()
});
this.textButton.setValue(BI.i18nText("BI-Multi_Date_Today"));

4
src/widget/dynamicdate/dynamicdate.trigger.js

@ -69,7 +69,7 @@ BI.DynamicDateTrigger = BI.inherit(BI.Trigger, {
type: BI.DynamicDateCombo.Static,
value: {
year: date[0] | 0,
month: date[1] - 1,
month: date[1],
day: date[2] | 0
}
};
@ -198,7 +198,7 @@ BI.DynamicDateTrigger = BI.inherit(BI.Trigger, {
this.editor.setValue("");
this.setTitle("");
} else {
var dateStr = value.year + "-" + (value.month + 1) + "-" + value.day;
var dateStr = value.year + "-" + (value.month) + "-" + value.day;
this.editor.setState(dateStr);
this.editor.setValue(dateStr);
this.setTitle(dateStr);

2
src/widget/dynamicdatetime/dynamicdatetime.popup.js

@ -201,7 +201,7 @@ BI.DynamicDateTimePopup = BI.inherit(BI.Widget, {
var date = BI.getDate();
this.ymd.setValue({
year: date.getFullYear(),
month: date.getMonth(),
month: date.getMonth() + 1,
day: date.getDate()
});
this.timeSelect.setValue();

4
src/widget/dynamicdatetime/dynamicdatetime.trigger.js

@ -69,7 +69,7 @@ BI.DynamicDateTimeTrigger = BI.inherit(BI.Trigger, {
type: BI.DynamicDateCombo.Static,
value: {
year: date[0] | 0,
month: date[1] - 1,
month: date[1],
day: date[2] | 0,
hour: date[3] | 0,
minute: date[4] | 0,
@ -201,7 +201,7 @@ BI.DynamicDateTimeTrigger = BI.inherit(BI.Trigger, {
this.editor.setValue("");
this.setTitle("");
} else {
var dateStr = value.year + "-" + (value.month + 1) + "-" + value.day + " " +
var dateStr = value.year + "-" + (value.month) + "-" + value.day + " " +
(value.hour || "00") + ":" + (value.minute || "00") + ":" + (value.second || "00");
this.editor.setState(dateStr);
this.editor.setValue(dateStr);

4
src/widget/month/popup.month.js

@ -19,7 +19,7 @@ BI.MonthPopup = BI.inherit(BI.Widget, {
var self = this, o = this.options;
// 纵向排列月
var month = [0, 6, 1, 7, 2, 8, 3, 9, 4, 10, 5, 11];
var month = [1, 7, 2, 8, 3, 9, 4, 10, 5, 11, 6, 12];
var items = [];
items.push(month.slice(0, 2));
items.push(month.slice(2, 4));
@ -39,7 +39,7 @@ BI.MonthPopup = BI.inherit(BI.Widget, {
height: 23,
width: 38,
value: td,
text: td + 1
text: td
};
});
});

151
src/widget/multidate/abstract.multidate.datepane.js

@ -1,151 +0,0 @@
/**
* 普通控件
*
* @class BI.MultiDateCard
* @extends BI.Widget
* @abstract
*/
BI.MultiDateCard = BI.inherit(BI.Widget, {
constants: {
lgap: 80,
itemHeight: 35,
defaultEditorValue: "1"
},
_defaultConfig: function () {
return $.extend(BI.MultiDateCard.superclass._defaultConfig.apply(this, arguments), {});
},
dateConfig: function () {
},
defaultSelectedItem: function () {
},
_init: function () {
BI.MultiDateCard.superclass._init.apply(this, arguments);
var self = this, opts = this.options;
this.label = BI.createWidget({
type: "bi.label",
height: this.constants.itemHeight,
textAlign: "left",
text: BI.i18nText("BI-Multi_Date_Relative_Current_Time"),
cls: "bi-multidate-inner-label bi-tips"
});
this.radioGroup = BI.createWidget({
type: "bi.button_group",
chooseType: 0,
items: BI.createItems(this.dateConfig(), {
type: "bi.multidate_segment",
height: this.constants.itemHeight
}),
layouts: [{
type: "bi.vertical"
}]
});
this.radioGroup.on(BI.Controller.EVENT_CHANGE, function (type) {
if (type === BI.Events.CONFIRM) {
self.fireEvent(BI.MultiDateCard.EVENT_CHANGE);
}
});
this.radioGroup.on(BI.ButtonGroup.EVENT_CHANGE, function () {
self.setValue(self.getValue());
self.fireEvent(BI.MultiDateCard.EVENT_CHANGE);
});
BI.createWidget({
element: this,
type: "bi.center_adapt",
lgap: this.constants.lgap,
items: [{
type: "bi.vertical",
items: [this.label, this.radioGroup]
}]
});
},
getValue: function () {
var button = this.radioGroup.getSelectedButtons()[0];
var type = button.getValue(), value = button.getInputValue();
return {
type: type,
value: value
};
},
_isTypeAvaliable: function (type) {
var res = false;
BI.find(this.dateConfig(), function (i, item) {
if (item.value === type) {
res = true;
return true;
}
});
return res;
},
setValue: function (v) {
var self = this;
if (BI.isNotNull(v) && this._isTypeAvaliable(v.type)) {
this.radioGroup.setValue(v.type);
BI.each(this.radioGroup.getAllButtons(), function (i, button) {
if (button.isEditorExist() === true && button.isSelected()) {
button.setInputValue(v.value);
} else {
button.setInputValue(self.constants.defaultEditorValue);
}
});
} else {
this.radioGroup.setValue(this.defaultSelectedItem());
BI.each(this.radioGroup.getAllButtons(), function (i, button) {
button.setInputValue(self.constants.defaultEditorValue);
});
}
},
getCalculationValue: function () {
var valueObject = this.getValue();
var type = valueObject.type, value = valueObject.value;
switch (type) {
case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_PREV:
return BI.getDate().getOffsetDate(-1 * value);
case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_AFTER:
return BI.getDate().getOffsetDate(value);
case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_TODAY:
return BI.getDate();
case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_PREV:
return BI.getDate().getBeforeMultiMonth(value);
case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_AFTER:
return BI.getDate().getAfterMultiMonth(value);
case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_BEGIN:
return BI.getDate(BI.getDate().getFullYear(), BI.getDate().getMonth(), 1);
case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_END:
return BI.getDate(BI.getDate().getFullYear(), BI.getDate().getMonth(), (BI.getDate().getLastDateOfMonth()).getDate());
case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_PREV:
return BI.getDate().getBeforeMulQuarter(value);
case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_AFTER:
return BI.getDate().getAfterMulQuarter(value);
case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_BEGIN:
return BI.getDate().getQuarterStartDate();
case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_END:
return BI.getDate().getQuarterEndDate();
case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_WEEK_PREV:
return BI.getDate().getOffsetDate(-7 * value);
case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_WEEK_AFTER:
return BI.getDate().getOffsetDate(7 * value);
case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_PREV:
return BI.getDate((BI.getDate().getFullYear() - 1 * value), BI.getDate().getMonth(), BI.getDate().getDate());
case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_AFTER:
return BI.getDate((BI.getDate().getFullYear() + 1 * value), BI.getDate().getMonth(), BI.getDate().getDate());
case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_BEGIN:
return BI.getDate(BI.getDate().getFullYear(), 0, 1);
case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_END:
return BI.getDate(BI.getDate().getFullYear(), 11, 31);
}
}
});
BI.MultiDateCard.EVENT_CHANGE = "EVENT_CHANGE";

283
src/widget/multidate/multidate.combo.js

@ -1,283 +0,0 @@
/**
* 日期控件
* @class BI.MultiDateCombo
* @extends BI.Widget
*/
BI.MultiDateCombo = BI.inherit(BI.Single, {
constants: {
popupHeight: 259,
popupWidth: 270,
comboAdjustHeight: 1,
border: 1,
DATE_MIN_VALUE: "1900-01-01",
DATE_MAX_VALUE: "2099-12-31"
},
_defaultConfig: function () {
return BI.extend(BI.MultiDateCombo.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-multidate-combo bi-border",
height: 24
});
},
_init: function () {
BI.MultiDateCombo.superclass._init.apply(this, arguments);
var self = this, opts = this.options;
this.storeTriggerValue = "";
var date = BI.getDate();
this.storeValue = opts.value;
this.trigger = BI.createWidget({
type: "bi.date_trigger",
min: this.constants.DATE_MIN_VALUE,
max: this.constants.DATE_MAX_VALUE,
value: opts.value
});
this.trigger.on(BI.DateTrigger.EVENT_KEY_DOWN, function () {
if (self.combo.isViewVisible()) {
self.combo.hideView();
}
});
this.trigger.on(BI.DateTrigger.EVENT_STOP, function () {
if (!self.combo.isViewVisible()) {
self.combo.showView();
}
});
this.trigger.on(BI.DateTrigger.EVENT_TRIGGER_CLICK, function () {
self.combo.toggle();
});
this.trigger.on(BI.DateTrigger.EVENT_FOCUS, function () {
self.storeTriggerValue = self.trigger.getKey();
if (!self.combo.isViewVisible()) {
self.combo.showView();
}
self.fireEvent(BI.MultiDateCombo.EVENT_FOCUS);
});
this.trigger.on(BI.DateTrigger.EVENT_ERROR, function () {
self.storeValue = {
year: date.getFullYear(),
month: date.getMonth()
};
self.popup.setValue();
self.fireEvent(BI.MultiDateCombo.EVENT_ERROR);
});
this.trigger.on(BI.DateTrigger.EVENT_VALID, function () {
self.fireEvent(BI.MultiDateCombo.EVENT_VALID);
});
this.trigger.on(BI.DateTrigger.EVENT_CHANGE, function () {
self.fireEvent(BI.MultiDateCombo.EVENT_CHANGE);
});
this.trigger.on(BI.DateTrigger.EVENT_CONFIRM, function () {
if (self.combo.isViewVisible()) {
return;
}
var dateStore = self.storeTriggerValue;
var dateObj = self.trigger.getKey();
if (BI.isNotEmptyString(dateObj) && !BI.isEqual(dateObj, dateStore)) {
self.storeValue = self.trigger.getValue();
self.setValue(self.trigger.getValue());
} else if (BI.isEmptyString(dateObj)) {
self.storeValue = null;
self.trigger.setValue();
}
self.fireEvent(BI.MultiDateCombo.EVENT_CONFIRM);
});
this.popup = BI.createWidget({
type: "bi.multidate_popup",
min: this.constants.DATE_MIN_VALUE,
max: this.constants.DATE_MAX_VALUE,
value: opts.value
});
this.popup.on(BI.MultiDatePopup.BUTTON_CLEAR_EVENT_CHANGE, function () {
self.setValue();
self.combo.hideView();
self.fireEvent(BI.MultiDateCombo.EVENT_CONFIRM);
});
this.popup.on(BI.MultiDatePopup.BUTTON_lABEL_EVENT_CHANGE, function () {
var date = BI.getDate();
self.setValue({
year: date.getFullYear(),
month: date.getMonth(),
day: date.getDate()
});
self.combo.hideView();
self.fireEvent(BI.MultiDateCombo.EVENT_CONFIRM);
});
this.popup.on(BI.MultiDatePopup.BUTTON_OK_EVENT_CHANGE, function () {
self.setValue(self.popup.getValue());
self.combo.hideView();
self.fireEvent(BI.MultiDateCombo.EVENT_CONFIRM);
});
this.popup.on(BI.MultiDatePopup.CALENDAR_EVENT_CHANGE, function () {
self.setValue(self.popup.getValue());
self.combo.hideView();
// self.fireEvent(BI.MultiDateCombo.EVENT_CHANGE);
self.fireEvent(BI.MultiDateCombo.EVENT_CONFIRM);
});
this.combo = BI.createWidget({
type: "bi.combo",
toggle: false,
isNeedAdjustHeight: false,
isNeedAdjustWidth: false,
el: this.trigger,
adjustLength: this.constants.comboAdjustHeight,
popup: {
el: this.popup,
width: this.constants.popupWidth,
stopPropagation: false
}
});
this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
self.popup.setValue(self.storeValue);
self.fireEvent(BI.MultiDateCombo.EVENT_BEFORE_POPUPVIEW);
});
var triggerBtn = BI.createWidget({
type: "bi.icon_button",
cls: "bi-trigger-icon-button date-font",
width: 24,
height: 24
});
triggerBtn.on(BI.TriggerIconButton.EVENT_CHANGE, function () {
if (self.combo.isViewVisible()) {
self.combo.hideView();
} else {
self.combo.showView();
}
});
this.changeIcon = BI.createWidget({
type: "bi.icon_button",
cls: "bi-trigger-icon-button date-change-h-font",
width: 24,
height: 24
});
var leftPart = BI.createWidget({
type: "bi.absolute",
items: [{
el: this.combo,
top: 0,
left: 0,
right: 0,
bottom: 0
}, {
el: triggerBtn,
top: 0,
left: 0
}]
});
BI.createWidget({
type: "bi.htape",
element: this,
items: [leftPart, {
el: this.changeIcon,
width: 30
}],
ref: function (_ref) {
self.comboWrapper = _ref;
}
});
this._checkDynamicValue(opts.value);
},
_checkDynamicValue: function (v) {
var type = null;
if (BI.isNotNull(v)) {
type = v.type;
}
switch (type) {
case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_PREV:
case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_AFTER:
case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_BEGIN:
case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_END:
case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_PREV:
case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_AFTER:
case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_BEGIN:
case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_END:
case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_PREV:
case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_AFTER:
case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_BEGIN:
case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_END:
case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_WEEK_PREV:
case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_WEEK_AFTER:
case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_PREV:
case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_AFTER:
case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_TODAY:
this.changeIcon.setVisible(true);
this.comboWrapper.attr("items")[1].width = 30;
this.comboWrapper.resize();
break;
default:
this.comboWrapper.attr("items")[1].width = 0;
this.comboWrapper.resize();
this.changeIcon.setVisible(false);
break;
}
},
setValue: function (v) {
this.storeValue = v;
this.popup.setValue(v);
this.trigger.setValue(v);
this._checkDynamicValue(v);
},
getValue: function () {
return this.storeValue;
},
getKey: function () {
return this.trigger.getKey();
},
hidePopupView: function () {
this.combo.hideView();
}
});
BI.shortcut("bi.multidate_combo", BI.MultiDateCombo);
BI.MultiDateCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.MultiDateCombo.EVENT_FOCUS = "EVENT_FOCUS";
BI.MultiDateCombo.EVENT_CHANGE = "EVENT_CHANGE";
BI.MultiDateCombo.EVENT_VALID = "EVENT_VALID";
BI.MultiDateCombo.EVENT_ERROR = "EVENT_ERROR";
BI.MultiDateCombo.EVENT_BEFORE_POPUPVIEW = "BI.MultiDateCombo.EVENT_BEFORE_POPUPVIEW";
BI.extend(BI.MultiDateCombo, {
MULTI_DATE_YMD_CARD: 1,
MULTI_DATE_YEAR_CARD: 2,
MULTI_DATE_QUARTER_CARD: 3,
MULTI_DATE_MONTH_CARD: 4,
MULTI_DATE_WEEK_CARD: 5,
MULTI_DATE_DAY_CARD: 6
});
BI.extend(BI.MultiDateCombo, {
DATE_TYPE: {
MULTI_DATE_YEAR_PREV: 1,
MULTI_DATE_YEAR_AFTER: 2,
MULTI_DATE_YEAR_BEGIN: 3,
MULTI_DATE_YEAR_END: 4,
MULTI_DATE_MONTH_PREV: 5,
MULTI_DATE_MONTH_AFTER: 6,
MULTI_DATE_MONTH_BEGIN: 7,
MULTI_DATE_MONTH_END: 8,
MULTI_DATE_QUARTER_PREV: 9,
MULTI_DATE_QUARTER_AFTER: 10,
MULTI_DATE_QUARTER_BEGIN: 11,
MULTI_DATE_QUARTER_END: 12,
MULTI_DATE_WEEK_PREV: 13,
MULTI_DATE_WEEK_AFTER: 14,
MULTI_DATE_DAY_PREV: 15,
MULTI_DATE_DAY_AFTER: 16,
MULTI_DATE_DAY_TODAY: 17,
MULTI_DATE_PARAM: 18,
MULTI_DATE_CALENDAR: 19,
YEAR_QUARTER: 20,
YEAR_MONTH: 21,
YEAR_WEEK: 22,
YEAR_DAY: 23,
MONTH_WEEK: 24,
MONTH_DAY: 25,
YEAR: 26,
SAME_PERIOD: 27,
LAST_SAME_PERIOD: 28
}
});

43
src/widget/multidate/multidate.day.js

@ -1,43 +0,0 @@
/**
* 普通控件
*
* @class BI.DayCard
* @extends BI.MultiDateCard
*/
BI.DayCard = BI.inherit(BI.MultiDateCard, {
_defaultConfig: function () {
return $.extend(BI.DayCard.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-multidate-daycard"
});
},
_init: function () {
BI.DayCard.superclass._init.apply(this, arguments);
},
dateConfig: function () {
return [{
isEditorExist: true,
selected: true,
text: BI.i18nText("BI-Multi_Date_Day_Prev"),
value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_PREV
},
{
isEditorExist: true,
text: BI.i18nText("BI-Multi_Date_Day_Next"),
value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_AFTER
},
{
isEditorExist: false,
value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_TODAY,
text: BI.i18nText("BI-Multi_Date_Today")
}];
},
defaultSelectedItem: function () {
return BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_PREV;
}
});
BI.DayCard.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.daycard", BI.DayCard);

47
src/widget/multidate/multidate.month.js

@ -1,47 +0,0 @@
/**
* 普通控件
*
* @class BI.MonthCard
* @extends BI.MultiDateCard
*/
BI.MonthCard = BI.inherit(BI.MultiDateCard, {
_defaultConfig: function () {
return $.extend(BI.MonthCard.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-multidate-monthcard"
});
},
_init: function () {
BI.MonthCard.superclass._init.apply(this, arguments);
},
dateConfig: function () {
return [{
selected: true,
isEditorExist: true,
value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_PREV,
text: BI.i18nText("BI-Multi_Date_Month_Prev")
},
{
isEditorExist: true,
value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_AFTER,
text: BI.i18nText("BI-Multi_Date_Month_Next")
},
{
value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_BEGIN,
isEditorExist: false,
text: BI.i18nText("BI-Multi_Date_Month_Begin")
},
{
value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_END,
isEditorExist: false,
text: BI.i18nText("BI-Multi_Date_Month_End")
}];
},
defaultSelectedItem: function () {
return BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_PREV;
}
});
BI.MonthCard.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.monthcard", BI.MonthCard);

317
src/widget/multidate/multidate.popup.js

@ -1,317 +0,0 @@
/**
* 日期控件
* @class BI.MultiDatePopup
* @extends BI.Widget
*/
BI.MultiDatePopup = BI.inherit(BI.Widget, {
constants: {
tabHeight: 30,
tabWidth: 42,
titleHeight: 27,
itemHeight: 30,
triggerHeight: 24,
buttonWidth: 90,
buttonHeight: 25,
cardHeight: 229,
cardWidth: 270,
popupHeight: 259,
popupWidth: 270,
comboAdjustHeight: 1,
ymdWidth: 58,
lgap: 2,
border: 1
},
_defaultConfig: function () {
return BI.extend(BI.MultiDatePopup.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-multidate-popup",
height: 344
});
},
_init: function () {
BI.MultiDatePopup.superclass._init.apply(this, arguments);
var self = this, opts = this.options;
this.storeValue = "";
this.textButton = BI.createWidget({
type: "bi.text_button",
forceCenter: true,
cls: "bi-multidate-popup-label bi-border-left bi-border-right bi-border-top",
shadow: true,
text: BI.i18nText("BI-Multi_Date_Today")
});
this.textButton.on(BI.TextButton.EVENT_CHANGE, function () {
self.fireEvent(BI.MultiDatePopup.BUTTON_lABEL_EVENT_CHANGE);
});
this.clearButton = BI.createWidget({
type: "bi.text_button",
forceCenter: true,
cls: "bi-multidate-popup-button bi-border-top",
shadow: true,
text: BI.i18nText("BI-Basic_Clear")
});
this.clearButton.on(BI.TextButton.EVENT_CHANGE, function () {
self.fireEvent(BI.MultiDatePopup.BUTTON_CLEAR_EVENT_CHANGE);
});
this.okButton = BI.createWidget({
type: "bi.text_button",
forceCenter: true,
cls: "bi-multidate-popup-button bi-border-top",
shadow: true,
text: BI.i18nText("BI-Basic_OK")
});
this.okButton.on(BI.TextButton.EVENT_CHANGE, function () {
self.fireEvent(BI.MultiDatePopup.BUTTON_OK_EVENT_CHANGE);
});
this.dateTab = BI.createWidget({
type: "bi.tab",
tab: {
cls: "bi-border-bottom",
height: this.constants.tabHeight,
items: BI.createItems([{
text: BI.i18nText("BI-Multi_Date_YMD"),
value: BI.MultiDateCombo.MULTI_DATE_YMD_CARD,
width: this.constants.ymdWidth
}, {
text: BI.i18nText("BI-Multi_Date_Year"),
value: BI.MultiDateCombo.MULTI_DATE_YEAR_CARD
}, {
text: BI.i18nText("BI-Multi_Date_Quarter"),
value: BI.MultiDateCombo.MULTI_DATE_QUARTER_CARD
}, {
text: BI.i18nText("BI-Multi_Date_Month"),
value: BI.MultiDateCombo.MULTI_DATE_MONTH_CARD
}, {
text: BI.i18nText("BI-Multi_Date_Week"),
value: BI.MultiDateCombo.MULTI_DATE_WEEK_CARD
}, {
text: BI.i18nText("BI-Multi_Date_Day"),
value: BI.MultiDateCombo.MULTI_DATE_DAY_CARD
}], {
width: this.constants.tabWidth,
textAlign: "center",
height: this.constants.itemHeight,
cls: "bi-multidate-popup-item bi-list-item-active"
}),
layouts: [{
type: "bi.left"
}]
},
cardCreator: function (v) {
switch (v) {
case BI.MultiDateCombo.MULTI_DATE_YMD_CARD:
self.ymd = BI.createWidget({
type: "bi.date_calendar_popup",
min: self.options.min,
max: self.options.max
});
self.ymd.on(BI.DateCalendarPopup.EVENT_CHANGE, function () {
self.fireEvent(BI.MultiDatePopup.CALENDAR_EVENT_CHANGE);
});
return self.ymd;
case BI.MultiDateCombo.MULTI_DATE_YEAR_CARD:
self.year = BI.createWidget({
type: "bi.yearcard"
});
self.year.on(BI.MultiDateCard.EVENT_CHANGE, function (v) {
self._setInnerValue(self.year, v);
});
return self.year;
case BI.MultiDateCombo.MULTI_DATE_QUARTER_CARD:
self.quarter = BI.createWidget({
type: "bi.quartercard"
});
self.quarter.on(BI.MultiDateCard.EVENT_CHANGE, function (v) {
self._setInnerValue(self.quarter, v);
});
return self.quarter;
case BI.MultiDateCombo.MULTI_DATE_MONTH_CARD:
self.month = BI.createWidget({
type: "bi.monthcard"
});
self.month.on(BI.MultiDateCard.EVENT_CHANGE, function (v) {
self._setInnerValue(self.month, v);
});
return self.month;
case BI.MultiDateCombo.MULTI_DATE_WEEK_CARD:
self.week = BI.createWidget({
type: "bi.weekcard"
});
self.week.on(BI.MultiDateCard.EVENT_CHANGE, function (v) {
self._setInnerValue(self.week, v);
});
return self.week;
case BI.MultiDateCombo.MULTI_DATE_DAY_CARD:
self.day = BI.createWidget({
type: "bi.daycard"
});
self.day.on(BI.MultiDateCard.EVENT_CHANGE, function (v) {
self._setInnerValue(self.day, v);
});
return self.day;
}
}
});
this.dateTab.setSelect(BI.MultiDateCombo.MULTI_DATE_YMD_CARD);
this.cur = BI.MultiDateCombo.MULTI_DATE_YMD_CARD;
this.dateTab.on(BI.Tab.EVENT_CHANGE, function () {
var v = self.dateTab.getSelect();
switch (v) {
case BI.MultiDateCombo.MULTI_DATE_YMD_CARD:
var date = this.getTab(self.cur).getCalculationValue();
self.ymd.setValue({
year: date.getFullYear(),
month: date.getMonth(),
day: date.getDate()
});
self._setInnerValue(self.ymd);
break;
case BI.MultiDateCombo.MULTI_DATE_YEAR_CARD:
self.year.setValue(self.storeValue);
self._setInnerValue(self.year);
break;
case BI.MultiDateCombo.MULTI_DATE_QUARTER_CARD:
self.quarter.setValue(self.storeValue);
self._setInnerValue(self.quarter);
break;
case BI.MultiDateCombo.MULTI_DATE_MONTH_CARD:
self.month.setValue(self.storeValue);
self._setInnerValue(self.month);
break;
case BI.MultiDateCombo.MULTI_DATE_WEEK_CARD:
self.week.setValue(self.storeValue);
self._setInnerValue(self.week);
break;
case BI.MultiDateCombo.MULTI_DATE_DAY_CARD:
self.day.setValue(self.storeValue);
self._setInnerValue(self.day);
break;
}
self.cur = v;
});
this.dateButton = BI.createWidget({
type: "bi.grid",
items: [[this.clearButton, this.textButton, this.okButton]]
});
BI.createWidget({
element: this,
type: "bi.vtape",
items: [{
el: this.dateTab
}, {
el: this.dateButton,
height: 30
}]
});
this.setValue(opts.value);
},
_setInnerValue: function (obj) {
if (this.dateTab.getSelect() === BI.MultiDateCombo.MULTI_DATE_YMD_CARD) {
this.textButton.setValue(BI.i18nText("BI-Multi_Date_Today"));
this.textButton.setEnable(true);
} else {
var date = obj.getCalculationValue();
date = date.print("%Y-%x-%e");
this.textButton.setValue(date);
this.textButton.setEnable(false);
}
},
_checkValueValid: function (value) {
return BI.isNull(value) || BI.isEmptyObject(value) || BI.isEmptyString(value);
},
setValue: function (v) {
this.storeValue = v;
var self = this, date;
var type, value;
if (BI.isNotNull(v)) {
type = v.type || BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_CALENDAR;
value = v.value;
if (BI.isNull(value)) {
value = v;
}
}
switch (type) {
case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_PREV:
case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_AFTER:
case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_BEGIN:
case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_END:
this.dateTab.setSelect(BI.MultiDateCombo.MULTI_DATE_YEAR_CARD);
this.year.setValue({type: type, value: value});
this.cur = BI.MultiDateCombo.MULTI_DATE_YEAR_CARD;
self._setInnerValue(this.year);
break;
case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_PREV:
case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_AFTER:
case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_BEGIN:
case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_END:
this.dateTab.setSelect(BI.MultiDateCombo.MULTI_DATE_QUARTER_CARD);
this.cur = BI.MultiDateCombo.MULTI_DATE_QUARTER_CARD;
this.quarter.setValue({type: type, value: value});
self._setInnerValue(this.quarter);
break;
case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_PREV:
case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_AFTER:
case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_BEGIN:
case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_END:
this.dateTab.setSelect(BI.MultiDateCombo.MULTI_DATE_MONTH_CARD);
this.cur = BI.MultiDateCombo.MULTI_DATE_MONTH_CARD;
this.month.setValue({type: type, value: value});
self._setInnerValue(this.month);
break;
case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_WEEK_PREV:
case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_WEEK_AFTER:
this.dateTab.setSelect(BI.MultiDateCombo.MULTI_DATE_WEEK_CARD);
this.cur = BI.MultiDateCombo.MULTI_DATE_WEEK_CARD;
this.week.setValue({type: type, value: value});
self._setInnerValue(this.week);
break;
case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_PREV:
case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_AFTER:
case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_TODAY:
this.dateTab.setSelect(BI.MultiDateCombo.MULTI_DATE_DAY_CARD);
this.cur = BI.MultiDateCombo.MULTI_DATE_DAY_CARD;
this.day.setValue({type: type, value: value});
self._setInnerValue(this.day);
break;
default:
if (this._checkValueValid(value)) {
var date = BI.getDate();
this.dateTab.setSelect(BI.MultiDateCombo.MULTI_DATE_YMD_CARD);
this.ymd.setValue({
year: date.getFullYear(),
month: date.getMonth(),
day: date.getDate()
});
this.textButton.setValue(BI.i18nText("BI-Multi_Date_Today"));
} else {
this.dateTab.setSelect(BI.MultiDateCombo.MULTI_DATE_YMD_CARD);
this.ymd.setValue(value);
this.textButton.setValue(BI.i18nText("BI-Multi_Date_Today"));
}
this.textButton.setEnable(true);
break;
}
},
getValue: function () {
var tab = this.dateTab.getSelect();
switch (tab) {
case BI.MultiDateCombo.MULTI_DATE_YMD_CARD:
return this.ymd.getValue();
case BI.MultiDateCombo.MULTI_DATE_YEAR_CARD:
return this.year.getValue();
case BI.MultiDateCombo.MULTI_DATE_QUARTER_CARD:
return this.quarter.getValue();
case BI.MultiDateCombo.MULTI_DATE_MONTH_CARD:
return this.month.getValue();
case BI.MultiDateCombo.MULTI_DATE_WEEK_CARD:
return this.week.getValue();
case BI.MultiDateCombo.MULTI_DATE_DAY_CARD:
return this.day.getValue();
}
}
});
BI.MultiDatePopup.BUTTON_OK_EVENT_CHANGE = "BUTTON_OK_EVENT_CHANGE";
BI.MultiDatePopup.BUTTON_lABEL_EVENT_CHANGE = "BUTTON_lABEL_EVENT_CHANGE";
BI.MultiDatePopup.BUTTON_CLEAR_EVENT_CHANGE = "BUTTON_CLEAR_EVENT_CHANGE";
BI.MultiDatePopup.CALENDAR_EVENT_CHANGE = "CALENDAR_EVENT_CHANGE";
BI.shortcut("bi.multidate_popup", BI.MultiDatePopup);

48
src/widget/multidate/multidate.quarter.js

@ -1,48 +0,0 @@
/**
* 普通控件
*
* @class BI.QuarterCard
* @extends BI.MultiDateCard
*/
BI.QuarterCard = BI.inherit(BI.MultiDateCard, {
_defaultConfig: function () {
return $.extend(BI.QuarterCard.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-multidate-quartercard"
});
},
_init: function () {
BI.QuarterCard.superclass._init.apply(this, arguments);
},
dateConfig: function () {
return [{
selected: true,
value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_PREV,
isEditorExist: true,
text: BI.i18nText("BI-Multi_Date_Quarter_Prev")
},
{
value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_AFTER,
isEditorExist: true,
text: BI.i18nText("BI-Multi_Date_Quarter_Next")
},
{
value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_BEGIN,
isEditorExist: false,
text: BI.i18nText("BI-Multi_Date_Quarter_Begin")
},
{
value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_END,
isEditorExist: false,
text: BI.i18nText("BI-Multi_Date_Quarter_End")
}];
},
defaultSelectedItem: function () {
return BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_PREV;
}
});
BI.QuarterCard.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.quartercard", BI.QuarterCard);

127
src/widget/multidate/multidate.segment.js

@ -1,127 +0,0 @@
/**
* 普通控件
*
* @class BI.MultiDateSegment
* @extends BI.Single
*/
BI.MultiDateSegment = BI.inherit(BI.Single, {
constants: {
itemHeight: 24,
maxGap: 15,
minGap: 10,
textWidth: 60,
defaultEditorValue: "1"
},
_defaultConfig: function () {
return $.extend(BI.MultiDateSegment.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-multidate-segment",
text: "",
height: 30,
isEditorExist: true,
selected: false,
defaultEditorValue: "1"
});
},
_init: function () {
BI.MultiDateSegment.superclass._init.apply(this, arguments);
var self = this, opts = this.options;
this.radio = BI.createWidget({
type: "bi.radio",
selected: opts.selected
});
this.radio.on(BI.Controller.EVENT_CHANGE, function (v) {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
});
this.textEditor = BI.createWidget({
type: "bi.text_editor",
value: this.constants.defaultEditorValue,
title: function () {
return self.textEditor.getValue();
},
tipType: "success",
cls: "bi-multidate-editor",
width: this.constants.textWidth,
height: this.constants.itemHeight
});
this.textEditor.on(BI.Controller.EVENT_CHANGE, function (v) {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
});
this.text = BI.createWidget({
type: "bi.label",
textAlign: "left",
cls: "bi-multidate-normal-label",
text: opts.text,
height: this.constants.itemHeight
});
this._createSegment();
},
_createSegment: function () {
if (this.options.isEditorExist === true) {
return BI.createWidget({
element: this,
type: "bi.left",
items: [{
el: {
type: "bi.center_adapt",
items: [this.radio],
height: this.constants.itemHeight
},
lgap: 0
},
{
el: {
type: "bi.center_adapt",
items: [this.textEditor],
widgetName: "textEditor"
},
lgap: this.constants.maxGap
},
{
el: this.text,
lgap: this.constants.minGap
}]
});
}
return BI.createWidget({
element: this,
type: "bi.left",
items: [{
el: {
type: "bi.center_adapt",
items: [this.radio],
height: this.constants.itemHeight
},
lgap: 0
},
{
el: this.text,
lgap: this.constants.maxGap
}]
});
},
setSelected: function (v) {
if (BI.isNotNull(this.radio)) {
this.radio.setSelected(v);
this.textEditor.setEnable(v);
}
},
isSelected: function () {
return this.radio.isSelected();
},
getValue: function () {
return this.options.value;
},
getInputValue: function () {
return this.textEditor.getValue() | 0;
},
setInputValue: function (v) {
this.textEditor.setValue(v);
},
isEditorExist: function () {
return this.options.isEditorExist;
}
});
BI.MultiDateSegment.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.multidate_segment", BI.MultiDateSegment);

37
src/widget/multidate/multidate.week.js

@ -1,37 +0,0 @@
/**
* 普通控件
*
* @class BI.WeekCard
* @extends BI.MultiDateCard
*/
BI.WeekCard = BI.inherit(BI.MultiDateCard, {
_defaultConfig: function () {
return $.extend(BI.WeekCard.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-multidate-weekcard"
});
},
_init: function () {
BI.WeekCard.superclass._init.apply(this, arguments);
},
dateConfig: function () {
return [{
selected: true,
isEditorExist: true,
text: BI.i18nText("BI-Multi_Date_Week_Prev"),
value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_WEEK_PREV
},
{
isEditorExist: true,
text: BI.i18nText("BI-Multi_Date_Week_Next"),
value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_WEEK_AFTER
}];
},
defaultSelectedItem: function () {
return BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_WEEK_PREV;
}
});
BI.WeekCard.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.weekcard", BI.WeekCard);

47
src/widget/multidate/multidate.year.js

@ -1,47 +0,0 @@
/**
* 普通控件
*
* @class BI.YearCard
* @extends BI.MultiDateCard
*/
BI.YearCard = BI.inherit(BI.MultiDateCard, {
_defaultConfig: function () {
return $.extend(BI.YearCard.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-multidate-yearcard"
});
},
_init: function () {
BI.YearCard.superclass._init.apply(this, arguments);
},
dateConfig: function () {
return [{
selected: true,
isEditorExist: true,
text: BI.i18nText("BI-Multi_Date_Year_Prev"),
value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_PREV
},
{
isEditorExist: true,
text: BI.i18nText("BI-Multi_Date_Year_Next"),
value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_AFTER
},
{
isEditorExist: false,
value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_BEGIN,
text: BI.i18nText("BI-Multi_Date_Year_Begin")
},
{
isEditorExist: false,
value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_END,
text: BI.i18nText("BI-Multi_Date_Year_End")
}];
},
defaultSelectedItem: function () {
return BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_PREV;
}
});
BI.YearCard.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.yearcard", BI.YearCard);

0
src/widget/dynamic/year/card.dynamic.year.js → src/widget/year/card.dynamic.year.js

0
src/widget/dynamic/year/card.year.js → src/widget/year/card.year.js

154
src/widget/year/combo.year.js

@ -1,58 +1,51 @@
/**
* 年份下拉框
*
* Created by GUY on 2015/8/28.
* @class BI.YearCombo
* @extends BI.Widget
*/
BI.YearCombo = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.YearCombo.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-year-combo",
behaviors: {},
min: "1900-01-01", // 最小日期
max: "2099-12-31", // 最大日期
height: 25
});
BI.DynamicYearCombo = BI.inherit(BI.Widget, {
props: {
baseCls: "bi-year-combo bi-border",
behaviors: {},
min: "1900-01-01", // 最小日期
max: "2099-12-31", // 最大日期
height: 24
},
_init: function () {
BI.YearCombo.superclass._init.apply(this, arguments);
BI.DynamicYearCombo.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.storeValue = "";
this.storeValue = o.value;
this.trigger = BI.createWidget({
type: "bi.year_trigger",
type: "bi.dynamic_year_trigger",
min: o.min,
max: o.max,
value: o.value || ""
});
this.trigger.on(BI.YearTrigger.EVENT_FOCUS, function () {
self.storeValue = this.getKey();
this.trigger.on(BI.DynamicYearTrigger.EVENT_FOCUS, function () {
self.storeTriggerValue = this.getKey();
});
this.trigger.on(BI.YearTrigger.EVENT_START, function () {
this.trigger.on(BI.DynamicYearTrigger.EVENT_START, function () {
self.combo.isViewVisible() && self.combo.hideView();
});
this.trigger.on(BI.YearTrigger.EVENT_STOP, function () {
this.trigger.on(BI.DynamicYearTrigger.EVENT_STOP, function () {
self.combo.showView();
});
this.trigger.on(BI.YearTrigger.EVENT_ERROR, function () {
this.trigger.on(BI.DynamicYearTrigger.EVENT_ERROR, function () {
self.combo.isViewVisible() && self.combo.hideView();
});
this.trigger.on(BI.YearTrigger.EVENT_CONFIRM, function () {
this.trigger.on(BI.DynamicYearTrigger.EVENT_CONFIRM, function () {
if (self.combo.isViewVisible()) {
return;
}
if (this.getKey() && this.getKey() !== self.storeValue) {
self.setValue(this.getKey());
if (this.getKey() && this.getKey() !== self.storeTriggerValue) {
self.storeValue = self.trigger.getValue();
self.setValue(self.storeValue);
} else if (!this.getKey()) {
self.storeValue = null;
self.setValue();
}
self.fireEvent(BI.YearCombo.EVENT_CONFIRM);
self.fireEvent(BI.DynamicYearCombo.EVENT_CONFIRM);
});
this.combo = BI.createWidget({
type: "bi.combo",
element: this,
destroyWhenHide: true,
isNeedAdjustHeight: false,
isNeedAdjustWidth: false,
el: this.trigger,
@ -60,16 +53,38 @@ BI.YearCombo = BI.inherit(BI.Widget, {
minWidth: 85,
stopPropagation: false,
el: {
type: "bi.year_popup",
type: "bi.dynamic_year_popup",
ref: function () {
self.popup = this;
},
listeners: [{
eventName: BI.YearPopup.EVENT_CHANGE,
eventName: BI.DynamicYearPopup.EVENT_CHANGE,
action: function () {
self.setValue(self.popup.getValue());
self.combo.hideView();
self.fireEvent(BI.YearCombo.EVENT_CONFIRM);
self.fireEvent(BI.DynamicYearCombo.EVENT_CONFIRM);
}
}, {
eventName: BI.DynamicYearPopup.BUTTON_CLEAR_EVENT_CHANGE,
action: function () {
self.setValue();
self.combo.hideView();
self.fireEvent(BI.DynamicYearCombo.EVENT_CONFIRM);
}
}, {
eventName: BI.DynamicYearPopup.BUTTON_lABEL_EVENT_CHANGE,
action: function () {
var date = BI.getDate();
self.setValue({year: date.getFullYear()});
self.combo.hideView();
self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM);
}
}, {
eventName: BI.DynamicYearPopup.BUTTON_OK_EVENT_CHANGE,
action: function () {
self.setValue(self.popup.getValue());
self.combo.hideView();
self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM);
}
}],
behaviors: o.behaviors,
@ -80,30 +95,67 @@ BI.YearCombo = BI.inherit(BI.Widget, {
}
});
this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
var value = self.trigger.getKey();
if (BI.isNotNull(value)) {
self.popup.setValue(value);
} else if (!value && value !== self.storeValue) {
self.popup.setValue(self.storeValue);
} else {
self.setValue();
}
self.fireEvent(BI.YearCombo.EVENT_BEFORE_POPUPVIEW);
self.popup.setValue(self.storeValue);
self.fireEvent(BI.DynamicYearCombo.EVENT_BEFORE_POPUPVIEW);
});
BI.createWidget({
type: "bi.htape",
element: this,
ref: function () {
self.comboWrapper = this;
},
items: [{
el: {
type: "bi.icon_button",
cls: "bi-trigger-icon-button date-change-h-font",
width: 24,
height: 24,
ref: function () {
self.changeIcon = this;
}
},
width: 24
}, this.combo]
});
this._checkDynamicValue(o.value);
},
_checkDynamicValue: function (v) {
var type = null;
if (BI.isNotNull(v)) {
type = v.type;
}
switch (type) {
case BI.DynamicYearCombo.Dynamic:
this.changeIcon.setVisible(true);
this.comboWrapper.attr("items")[0].width = 24;
this.comboWrapper.resize();
break;
default:
this.comboWrapper.attr("items")[0].width = 0;
this.comboWrapper.resize();
this.changeIcon.setVisible(false);
break;
}
},
setValue: function (v) {
this.combo.setValue(v || "");
this.storeValue = v;
this.trigger.setValue(v);
this._checkDynamicValue(v);
},
getValue: function () {
if (BI.isNull(this.popup)) {
return this.options.value;
} else {
return this.popup.getValue();
}
return this.storeValue;
}
});
BI.YearCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.YearCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
BI.shortcut("bi.year_combo", BI.YearCombo);
BI.DynamicYearCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.DynamicYearCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
BI.shortcut("bi.dynamic_year_combo", BI.DynamicYearCombo);
BI.extend(BI.DynamicYearCombo, {
Static: 1,
Dynamic: 2
});

270
src/widget/year/popup.year.js

@ -2,109 +2,205 @@
* 年份展示面板
*
* Created by GUY on 2015/9/2.
* @class BI.YearPopup
* @class BI.DynamicYearPopup
* @extends BI.Trigger
*/
BI.YearPopup = BI.inherit(BI.Widget, {
BI.DynamicYearPopup = BI.inherit(BI.Widget, {
constants: {
tabHeight: 30
},
_defaultConfig: function () {
return BI.extend(BI.YearPopup.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-year-popup",
behaviors: {},
min: "1900-01-01", // 最小日期
max: "2099-12-31" // 最大日期
});
props: {
baseCls: "bi-year-popup",
behaviors: {},
min: "1900-01-01", // 最小日期
max: "2099-12-31", // 最大日期,
width: 180,
height: 240
},
_createYearCalendar: function (v) {
var o = this.options, y = this._year;
render: function () {
var self = this, opts = this.options;
this.storeValue = {type: BI.DynamicYearCombo.Static};
return {
type: "bi.vtape",
items: [{
el: this._getTabJson()
}, {
el: {
type: "bi.grid",
items: [[{
type: "bi.text_button",
forceCenter: true,
cls: "bi-border-top bi-high-light",
shadow: true,
text: BI.i18nText("BI-Basic_Clear"),
listeners: [{
eventName: BI.TextButton.EVENT_CHANGE,
action: function () {
self.fireEvent(BI.DynamicYearPopup.BUTTON_CLEAR_EVENT_CHANGE);
}
}]
}, {
type: "bi.text_button",
forceCenter: true,
cls: "bi-border-left bi-border-right bi-border-top",
shadow: true,
text: BI.i18nText("BI-Basic_Current_Year"),
ref: function () {
self.textButton = this;
},
listeners: [{
eventName: BI.TextButton.EVENT_CHANGE,
action: function () {
self.fireEvent(BI.DynamicYearPopup.BUTTON_lABEL_EVENT_CHANGE);
}
}]
}, {
type: "bi.text_button",
forceCenter: true,
cls: "bi-border-top bi-high-light",
shadow: true,
text: BI.i18nText("BI-Basic_OK"),
listeners: [{
eventName: BI.TextButton.EVENT_CHANGE,
action: function () {
self.fireEvent(BI.DynamicYearPopup.BUTTON_OK_EVENT_CHANGE);
}
}]
}]]
},
height: 24
}]
};
},
var calendar = BI.createWidget({
type: "bi.year_calendar",
behaviors: o.behaviors,
min: o.min,
max: o.max,
logic: {
dynamic: true
},
year: y + v * 12
});
calendar.setValue(this._year);
return calendar;
_setInnerValue: function () {
if (this.dateTab.getSelect() === BI.DynamicDateCombo.Static) {
this.textButton.setValue(BI.i18nText("BI-Basic_Current_Year"));
this.textButton.setEnable(true);
} else {
var date = BI.DynamicDateHelper.getCalculation(this.dynamicPane.getValue());
date = date.print("%Y");
this.textButton.setValue(date);
this.textButton.setEnable(false);
}
},
_init: function () {
BI.YearPopup.superclass._init.apply(this, arguments);
_getTabJson: function () {
var self = this, o = this.options;
this.selectedYear = this._year = BI.getDate().getFullYear();
var backBtn = BI.createWidget({
type: "bi.icon_button",
cls: "pre-page-h-font",
width: 25,
height: 25,
value: -1
});
var preBtn = BI.createWidget({
type: "bi.icon_button",
cls: "next-page-h-font",
width: 25,
height: 25,
value: 1
});
this.navigation = BI.createWidget({
type: "bi.navigation",
element: this,
single: true,
logic: {
dynamic: true
return {
type: "bi.tab",
ref: function () {
self.dateTab = this;
},
tab: {
cls: "year-popup-navigation bi-high-light bi-border-top",
height: 25,
items: [backBtn, preBtn]
type: "bi.linear_segment",
cls: "bi-border-bottom",
height: this.constants.tabHeight,
items: BI.createItems([{
text: BI.i18nText("BI-Basic_Year_Fen"),
value: BI.DynamicYearCombo.Static
}, {
text: BI.i18nText("BI-Basic_Dynamic_Title"),
value: BI.DynamicYearCombo.Dynamic
}], {
textAlign: "center"
})
},
cardCreator: BI.bind(this._createYearCalendar, this),
afterCardShow: function () {
this.setValue(self.selectedYear);
var calendar = this.getSelectedCard();
backBtn.setEnable(!calendar.isFrontYear());
preBtn.setEnable(!calendar.isFinalYear());
}
});
this.navigation.on(BI.Navigation.EVENT_CHANGE, function () {
self.selectedYear = this.getValue();
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
self.fireEvent(BI.YearPopup.EVENT_CHANGE, self.selectedYear);
});
cardCreator: function (v) {
switch (v) {
case BI.DynamicYearCombo.Dynamic:
return {
type: "bi.dynamic_year_card",
listeners: [{
eventName: "EVENT_CHANGE",
action: function () {
self._setInnerValue(self.year, v);
}
}],
ref: function () {
self.dynamicPane = this;
}
};
case BI.DynamicYearCombo.Static:
default:
return {
type: "bi.static_year_card",
behaviors: o.behaviors,
min: self.options.min,
max: self.options.max,
listeners: [{
eventName: BI.StaticYearCard.EVENT_CHANGE,
action: function () {
self.fireEvent(BI.DynamicYearPopup.EVENT_CHANGE);
}
}],
ref: function () {
self.year = this;
}
};
}
},
listeners: [{
eventName: BI.Tab.EVENT_CHANGE,
action: function () {
var v = self.dateTab.getSelect();
switch (v) {
case BI.DynamicYearCombo.Static:
var date = BI.DynamicDateHelper.getCalculation(self.dynamicPane.getValue());
self.year.setValue({year: date.getFullYear()});
self._setInnerValue();
break;
case BI.DynamicYearCombo.Dynamic:
default:
if(self.storeValue && self.storeValue.type === BI.DynamicYearCombo.Dynamic) {
self.dynamicPane.setValue(self.storeValue.value);
}else{
self.dynamicPane.setValue({
year: 0
});
}
self._setInnerValue();
break;
}
}
}]
};
},
if(BI.isKey(o.value)){
this.setValue(o.value);
setValue: function (v) {
this.storeValue = v;
var self = this;
var type, value;
v = v || {};
type = v.type || BI.DynamicDateCombo.Static;
value = v.value || v;
this.dateTab.setSelect(type);
switch (type) {
case BI.DynamicDateCombo.Dynamic:
this.dynamicPane.setValue(value);
self._setInnerValue();
break;
case BI.DynamicDateCombo.Static:
default:
this.year.setValue(value);
this.textButton.setValue(BI.i18nText("BI-Basic_Current_Year"));
this.textButton.setEnable(true);
break;
}
},
getValue: function () {
return this.selectedYear;
},
setValue: function (v) {
var o = this.options;
if (BI.checkDateVoid(v, 1, 1, o.min, o.max)[0]) {
v = BI.getDate().getFullYear();
this.selectedYear = "";
this.navigation.setSelect(BI.YearCalendar.getPageByYear(v));
this.navigation.setValue("");
} else {
this.selectedYear = v;
this.navigation.setSelect(BI.YearCalendar.getPageByYear(v));
this.navigation.setValue(v);
}
return {
type: this.dateTab.getSelect(),
value: this.dateTab.getValue()
};
}
});
BI.YearPopup.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.year_popup", BI.YearPopup);
BI.DynamicYearPopup.BUTTON_CLEAR_EVENT_CHANGE = "BUTTON_CLEAR_EVENT_CHANGE";
BI.DynamicYearPopup.BUTTON_lABEL_EVENT_CHANGE = "BUTTON_lABEL_EVENT_CHANGE";
BI.DynamicYearPopup.BUTTON_OK_EVENT_CHANGE = "BUTTON_OK_EVENT_CHANGE";
BI.DynamicYearPopup.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.dynamic_year_popup", BI.DynamicYearPopup);

132
src/widget/year/trigger.year.js

@ -1,11 +1,4 @@
/**
* 年份trigger
*
* Created by GUY on 2015/8/21.
* @class BI.YearTrigger
* @extends BI.Trigger
*/
BI.YearTrigger = BI.inherit(BI.Trigger, {
BI.DynamicYearTrigger = BI.inherit(BI.Trigger, {
_const: {
hgap: 4,
vgap: 2,
@ -14,21 +7,20 @@ BI.YearTrigger = BI.inherit(BI.Trigger, {
},
_defaultConfig: function () {
return BI.extend(BI.YearTrigger.superclass._defaultConfig.apply(this, arguments), {
extraCls: "bi-year-trigger bi-border",
return BI.extend(BI.DynamicYearTrigger.superclass._defaultConfig.apply(this, arguments), {
extraCls: "bi-year-trigger",
min: "1900-01-01", // 最小日期
max: "2099-12-31", // 最大日期
height: 24
});
},
_init: function () {
BI.YearTrigger.superclass._init.apply(this, arguments);
BI.DynamicYearTrigger.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) {
self.editor.setErrorText(!BI.isPositiveInteger(v) ? c.errorText : c.errorTextInvalid);
return v === "" || (BI.isPositiveInteger(v) && !BI.checkDateVoid(v, 1, 1, o.min, o.max)[0]);
},
quitChecker: function (v) {
@ -36,23 +28,33 @@ BI.YearTrigger = BI.inherit(BI.Trigger, {
},
hgap: c.hgap,
vgap: c.vgap,
watermark: BI.i18nText("BI-Basic_Unrestricted"),
allowBlank: true,
errorText: c.errorText,
value: o.value
errorText: function (v) {
return !BI.isPositiveInteger(v) ? c.errorText : c.errorTextInvalid;
}
});
this.editor.on(BI.SignEditor.EVENT_FOCUS, function () {
self.fireEvent(BI.YearTrigger.EVENT_FOCUS);
self.fireEvent(BI.DynamicYearTrigger.EVENT_FOCUS);
});
this.editor.on(BI.SignEditor.EVENT_STOP, function () {
self.fireEvent(BI.YearTrigger.EVENT_STOP);
self.fireEvent(BI.DynamicYearTrigger.EVENT_STOP);
});
this.editor.on(BI.SignEditor.EVENT_CONFIRM, function () {
var value = self.editor.getValue();
if (BI.isNotNull(value)) {
self.editor.setValue(value);
self.editor.setTitle(value);
}
self.fireEvent(BI.YearTrigger.EVENT_CONFIRM);
if (BI.isNotEmptyString(value)) {
self.storeValue = {
type: BI.DynamicDateCombo.Static,
value: {
year: value
}
};
}
self.fireEvent(BI.DynamicYearTrigger.EVENT_CONFIRM);
});
this.editor.on(BI.SignEditor.EVENT_SPACE, function () {
if (self.editor.isValid()) {
@ -60,47 +62,85 @@ BI.YearTrigger = BI.inherit(BI.Trigger, {
}
});
this.editor.on(BI.SignEditor.EVENT_START, function () {
self.fireEvent(BI.YearTrigger.EVENT_START);
self.fireEvent(BI.DynamicYearTrigger.EVENT_START);
});
this.editor.on(BI.SignEditor.EVENT_ERROR, function () {
self.fireEvent(BI.YearTrigger.EVENT_ERROR);
self.fireEvent(BI.DynamicYearTrigger.EVENT_ERROR);
});
BI.createWidget({
element: this,
type: "bi.htape",
items: [
{
el: this.editor
}, {
el: {
type: "bi.text_button",
baseCls: "bi-trigger-year-text",
text: BI.i18nText("BI-Multi_Date_Year"),
width: o.height
},
items: [{
el: this.editor
}, {
el: {
type: "bi.text_button",
baseCls: "bi-trigger-year-text",
text: BI.i18nText("BI-Multi_Date_Year"),
width: o.height
}, {
el: {
type: "bi.trigger_icon_button",
width: o.height
},
},
width: o.height
}, {
el: {
type: "bi.trigger_icon_button",
width: o.height
}
]
},
width: o.height
}]
});
this.setValue(o.value);
},
_getText: function (obj) {
var value = "";
if(BI.isNotNull(obj.year) && obj.year !== 0) {
value += Math.abs(obj.year) + BI.i18nText("BI-Basic_Year") + (obj.year < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind"));
}
return value;
},
_setInnerValue: function (date, text) {
var dateStr = date.print("%Y");
this.editor.setState(dateStr);
this.editor.setValue(dateStr);
this.setTitle(BI.isEmptyString(text) ? dateStr : (text + ":" + dateStr));
},
setValue: function (v) {
this.editor.setState(v);
this.editor.setValue(v);
this.editor.setTitle(v);
var type, value;
var date = BI.getDate();
this.storeValue = v;
if (BI.isNotNull(v)) {
type = v.type || BI.DynamicDateCombo.Static;
value = v.value || v;
}
switch (type) {
case BI.DynamicDateCombo.Dynamic:
var text = this._getText(value);
date = BI.DynamicDateHelper.getCalculation(value);
this._setInnerValue(date, text);
break;
case BI.DynamicDateCombo.Static:
default:
value = value || {};
this.editor.setState(value.year);
this.editor.setValue(value.year);
this.editor.setTitle(value.year);
break;
}
},
getValue: function () {
return this.storeValue;
},
getKey: function () {
return this.editor.getValue() | 0;
}
});
BI.YearTrigger.EVENT_FOCUS = "EVENT_FOCUS";
BI.YearTrigger.EVENT_ERROR = "EVENT_ERROR";
BI.YearTrigger.EVENT_START = "EVENT_START";
BI.YearTrigger.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.YearTrigger.EVENT_STOP = "EVENT_STOP";
BI.shortcut("bi.year_trigger", BI.YearTrigger);
BI.DynamicYearTrigger.EVENT_FOCUS = "EVENT_FOCUS";
BI.DynamicYearTrigger.EVENT_ERROR = "EVENT_ERROR";
BI.DynamicYearTrigger.EVENT_START = "EVENT_START";
BI.DynamicYearTrigger.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.DynamicYearTrigger.EVENT_STOP = "EVENT_STOP";
BI.shortcut("bi.dynamic_year_trigger", BI.DynamicYearTrigger);

0
src/widget/dynamic/yearmonth/card.dynamic.yearmonth.js → src/widget/yearmonth/card.dynamic.yearmonth.js

4
src/widget/dynamic/yearmonth/card.static.yearmonth.js → src/widget/yearmonth/card.static.yearmonth.js

@ -7,7 +7,7 @@ BI.StaticYearMonthCard = BI.inherit(BI.Widget, {
_createMonths: function () {
// 纵向排列月
var month = [0, 6, 1, 7, 2, 8, 3, 9, 4, 10, 5, 11];
var month = [1, 7, 2, 8, 3, 9, 4, 10, 5, 11, 6, 12];
var items = [];
items.push(month.slice(0, 2));
items.push(month.slice(2, 4));
@ -27,7 +27,7 @@ BI.StaticYearMonthCard = BI.inherit(BI.Widget, {
height: 23,
width: 38,
value: td,
text: td + 1
text: td
};
});
});

197
src/widget/yearmonth/combo.yearmonth.js

@ -1,73 +1,170 @@
/**
* 年份 + 月份下拉框
*
* @class BI.YearMonthCombo
* @extends BI.Widget
*/
BI.YearMonthCombo = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.YearMonthCombo.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-year-month-combo",
yearBehaviors: {},
monthBehaviors: {},
height: 25
});
BI.DynamicYearMonthCombo = BI.inherit(BI.Single, {
props: {
baseCls: "bi-year-month-combo bi-border",
behaviors: {},
min: "1900-01-01", // 最小日期
max: "2099-12-31", // 最大日期
height: 24
},
_init: function () {
BI.YearMonthCombo.superclass._init.apply(this, arguments);
BI.DynamicYearMonthCombo.superclass._init.apply(this, arguments);
var self = this, o = this.options;
o.value = o.value || {};
this.year = BI.createWidget({
type: "bi.year_combo",
behaviors: o.yearBehaviors,
value: o.value.year
this.storeValue = o.value;
this.trigger = BI.createWidget({
type: "bi.dynamic_year_month_trigger",
min: o.min,
max: o.max,
value: o.value || ""
});
this.month = BI.createWidget({
type: "bi.month_combo",
behaviors: o.monthBehaviors,
value: o.value.month
this.trigger.on(BI.DynamicYearMonthTrigger.EVENT_START, function () {
self.combo.isViewVisible() && self.combo.hideView();
});
this.year.on(BI.YearCombo.EVENT_CONFIRM, function () {
self.fireEvent(BI.YearMonthCombo.EVENT_CONFIRM);
this.trigger.on(BI.DynamicYearMonthTrigger.EVENT_STOP, function () {
self.combo.showView();
});
this.trigger.on(BI.DynamicYearMonthTrigger.EVENT_ERROR, function () {
self.combo.isViewVisible() && self.combo.hideView();
self.fireEvent(BI.DynamicYearMonthCombo.EVENT_ERROR);
});
this.trigger.on(BI.DynamicYearMonthTrigger.EVENT_VALID, function () {
self.fireEvent(BI.DynamicYearMonthCombo.EVENT_VALID);
});
this.year.on(BI.YearCombo.EVENT_BEFORE_POPUPVIEW, function () {
self.fireEvent(BI.YearMonthCombo.EVENT_BEFORE_POPUPVIEW);
this.trigger.on(BI.DynamicYearMonthTrigger.EVENT_CONFIRM, function () {
if (self.combo.isViewVisible()) {
return;
}
self.storeValue = self.trigger.getValue();
self.fireEvent(BI.DynamicYearMonthCombo.EVENT_CONFIRM);
});
this.trigger.on(BI.DynamicYearMonthCombo.EVENT_FOCUS, function () {
self.fireEvent(BI.DynamicYearMonthCombo.EVENT_FOCUS);
});
this.month.on(BI.MonthCombo.EVENT_CONFIRM, function () {
self.getValue();
self.fireEvent(BI.YearMonthCombo.EVENT_CONFIRM);
this.combo = BI.createWidget({
type: "bi.combo",
isNeedAdjustHeight: false,
isNeedAdjustWidth: false,
el: this.trigger,
popup: {
minWidth: 85,
stopPropagation: false,
el: {
type: "bi.dynamic_year_month_popup",
ref: function () {
self.popup = this;
},
listeners: [{
eventName: BI.DynamicYearMonthPopup.EVENT_CHANGE,
action: function () {
self.setValue(self.popup.getValue());
self.combo.hideView();
self.fireEvent(BI.DynamicYearMonthCombo.EVENT_CONFIRM);
}
}, {
eventName: BI.DynamicYearMonthPopup.BUTTON_CLEAR_EVENT_CHANGE,
action: function () {
self.setValue();
self.combo.hideView();
self.fireEvent(BI.DynamicYearMonthCombo.EVENT_CONFIRM);
}
}, {
eventName: BI.DynamicYearMonthPopup.BUTTON_lABEL_EVENT_CHANGE,
action: function () {
var date = BI.getDate();
self.setValue({year: date.getFullYear()});
self.combo.hideView();
self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM);
}
}, {
eventName: BI.DynamicYearMonthPopup.BUTTON_OK_EVENT_CHANGE,
action: function () {
self.setValue(self.popup.getValue());
self.combo.hideView();
self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM);
}
}],
behaviors: o.behaviors,
min: o.min,
max: o.max
},
value: o.value || ""
}
});
this.month.on(BI.MonthCombo.EVENT_BEFORE_POPUPVIEW, function () {
self.fireEvent(BI.YearMonthCombo.EVENT_BEFORE_POPUPVIEW);
this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
self.popup.setValue(self.storeValue);
self.fireEvent(BI.DynamicYearMonthCombo.EVENT_BEFORE_POPUPVIEW);
});
BI.createWidget({
type: "bi.center",
type: "bi.htape",
element: this,
hgap: 5,
items: [this.year, this.month]
ref: function () {
self.comboWrapper = this;
},
items: [{
el: {
type: "bi.icon_button",
cls: "bi-trigger-icon-button date-change-h-font",
width: 24,
height: 24,
ref: function () {
self.changeIcon = this;
}
},
width: 24
}, this.combo]
});
this._checkDynamicValue(o.value);
},
_checkDynamicValue: function (v) {
var type = null;
if (BI.isNotNull(v)) {
type = v.type;
}
switch (type) {
case BI.DynamicYearMonthCombo.Dynamic:
this.changeIcon.setVisible(true);
this.comboWrapper.attr("items")[0].width = 24;
this.comboWrapper.resize();
break;
default:
this.comboWrapper.attr("items")[0].width = 0;
this.comboWrapper.resize();
this.changeIcon.setVisible(false);
break;
}
},
hideView: function () {
this.combo.hideView();
},
setValue: function (v) {
v = v || {};
this.month.setValue(v.month);
this.year.setValue(v.year);
this.storeValue = v;
this.trigger.setValue(v);
this._checkDynamicValue(v);
},
getValue: function () {
return {
year: this.year.getValue(),
month: this.month.getValue()
};
return this.storeValue;
},
getKey: function () {
return this.trigger.getKey();
}
});
BI.YearMonthCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.YearMonthCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
BI.shortcut("bi.year_month_combo", BI.YearMonthCombo);
BI.DynamicYearMonthCombo.EVENT_ERROR = "EVENT_ERROR";
BI.DynamicYearMonthCombo.EVENT_VALID = "EVENT_VALID";
BI.DynamicYearMonthCombo.EVENT_FOCUS = "EVENT_FOCUS";
BI.DynamicYearMonthCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.DynamicYearMonthCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
BI.shortcut("bi.dynamic_year_month_combo", BI.DynamicYearMonthCombo);
BI.extend(BI.DynamicYearMonthCombo, {
Static: 1,
Dynamic: 2
});

2
src/widget/dynamic/yearmonth/popup.yearmonth.js → src/widget/yearmonth/popup.yearmonth.js

@ -131,7 +131,7 @@ BI.DynamicYearMonthPopup = BI.inherit(BI.Widget, {
min: self.options.min,
max: self.options.max,
listeners: [{
eventName: BI.YearCard.EVENT_CHANGE,
eventName: BI.StaticYearMonthCard.EVENT_CHANGE,
action: function () {
self.fireEvent(BI.DynamicYearMonthPopup.EVENT_CHANGE);
}

2
src/widget/dynamic/yearmonth/trigger.yearmonth.js → src/widget/yearmonth/trigger.yearmonth.js

@ -179,7 +179,7 @@ BI.DynamicYearMonthTrigger = BI.inherit(BI.Trigger, {
case BI.DynamicDateCombo.Static:
default:
value = value || {};
var month = BI.isNull(value.month) ? null : value.month + 1;
var month = BI.isNull(value.month) ? null : value.month;
this.yearEditor.setValue(value.year);
this.yearEditor.setTitle(value.year);
this.monthEditor.setValue(month);

0
src/widget/dynamic/yearquarter/card.dynamic.yearquarter.js → src/widget/yearquarter/card.dynamic.yearquarter.js

0
src/widget/dynamic/yearquarter/card.static.yearquarter.js → src/widget/yearquarter/card.static.yearquarter.js

178
src/widget/yearquarter/combo.yearquarter.js

@ -1,72 +1,152 @@
/**
* 年份 + 月份下拉框
*
* @class BI.YearQuarterCombo
* @extends BI.Widget
*/
BI.YearQuarterCombo = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.YearQuarterCombo.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-year-quarter-combo",
yearBehaviors: {},
quarterBehaviors: {},
height: 25
});
BI.DynamicYearQuarterCombo = BI.inherit(BI.Widget, {
props: {
baseCls: "bi-year-quarter-combo bi-border",
behaviors: {},
min: "1900-01-01", // 最小日期
max: "2099-12-31", // 最大日期
height: 24
},
_init: function () {
BI.YearQuarterCombo.superclass._init.apply(this, arguments);
BI.DynamicYearQuarterCombo.superclass._init.apply(this, arguments);
var self = this, o = this.options;
o.value = o.value || {};
this.year = BI.createWidget({
type: "bi.year_combo",
behaviors: o.yearBehaviors,
value: o.value.year
this.storeValue = o.value;
this.trigger = BI.createWidget({
type: "bi.dynamic_year_quarter_trigger",
min: o.min,
max: o.max,
value: o.value || ""
});
this.quarter = BI.createWidget({
type: "bi.quarter_combo",
behaviors: o.quarterBehaviors,
value: o.value.quarter
this.trigger.on(BI.DynamicYearQuarterTrigger.EVENT_START, function () {
self.combo.isViewVisible() && self.combo.hideView();
});
this.year.on(BI.YearCombo.EVENT_CONFIRM, function () {
self.fireEvent(BI.YearQuarterCombo.EVENT_CONFIRM);
this.trigger.on(BI.DynamicYearQuarterTrigger.EVENT_STOP, function () {
self.combo.showView();
});
this.trigger.on(BI.DynamicYearQuarterTrigger.EVENT_ERROR, function () {
self.combo.isViewVisible() && self.combo.hideView();
});
this.year.on(BI.YearCombo.EVENT_BEFORE_POPUPVIEW, function () {
self.fireEvent(BI.YearQuarterCombo.EVENT_BEFORE_POPUPVIEW);
this.trigger.on(BI.DynamicYearQuarterTrigger.EVENT_CONFIRM, function () {
if (self.combo.isViewVisible()) {
return;
}
self.storeValue = self.trigger.getValue();
self.fireEvent(BI.DynamicYearQuarterCombo.EVENT_CONFIRM);
});
this.quarter.on(BI.QuarterCombo.EVENT_CONFIRM, function () {
self.fireEvent(BI.YearQuarterCombo.EVENT_CONFIRM);
this.combo = BI.createWidget({
type: "bi.combo",
isNeedAdjustHeight: false,
isNeedAdjustWidth: false,
el: this.trigger,
popup: {
minWidth: 85,
stopPropagation: false,
el: {
type: "bi.dynamic_year_quarter_popup",
ref: function () {
self.popup = this;
},
listeners: [{
eventName: BI.DynamicYearQuarterPopup.EVENT_CHANGE,
action: function () {
self.setValue(self.popup.getValue());
self.combo.hideView();
self.fireEvent(BI.DynamicYearQuarterCombo.EVENT_CONFIRM);
}
}, {
eventName: BI.DynamicYearQuarterPopup.BUTTON_CLEAR_EVENT_CHANGE,
action: function () {
self.setValue();
self.combo.hideView();
self.fireEvent(BI.DynamicYearQuarterCombo.EVENT_CONFIRM);
}
}, {
eventName: BI.DynamicYearQuarterPopup.BUTTON_lABEL_EVENT_CHANGE,
action: function () {
var date = BI.getDate();
self.setValue({year: date.getFullYear()});
self.combo.hideView();
self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM);
}
}, {
eventName: BI.DynamicYearQuarterPopup.BUTTON_OK_EVENT_CHANGE,
action: function () {
self.setValue(self.popup.getValue());
self.combo.hideView();
self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM);
}
}],
behaviors: o.behaviors,
min: o.min,
max: o.max
},
value: o.value || ""
}
});
this.quarter.on(BI.QuarterCombo.EVENT_BEFORE_POPUPVIEW, function () {
self.fireEvent(BI.YearQuarterCombo.EVENT_BEFORE_POPUPVIEW);
this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
self.popup.setValue(self.storeValue);
self.fireEvent(BI.DynamicYearQuarterCombo.EVENT_BEFORE_POPUPVIEW);
});
BI.createWidget({
type: "bi.center",
type: "bi.htape",
element: this,
hgap: 5,
items: [this.year, this.quarter]
ref: function () {
self.comboWrapper = this;
},
items: [{
el: {
type: "bi.icon_button",
cls: "bi-trigger-icon-button date-change-h-font",
width: 24,
height: 24,
ref: function () {
self.changeIcon = this;
}
},
width: 24
}, this.combo]
});
this._checkDynamicValue(o.value);
},
_checkDynamicValue: function (v) {
var type = null;
if (BI.isNotNull(v)) {
type = v.type;
}
switch (type) {
case BI.DynamicYearQuarterCombo.Dynamic:
this.changeIcon.setVisible(true);
this.comboWrapper.attr("items")[0].width = 24;
this.comboWrapper.resize();
break;
default:
this.comboWrapper.attr("items")[0].width = 0;
this.comboWrapper.resize();
this.changeIcon.setVisible(false);
break;
}
},
setValue: function (v) {
v = v || {};
this.quarter.setValue(v.quarter);
this.year.setValue(v.year);
this.storeValue = v;
this.trigger.setValue(v);
this._checkDynamicValue(v);
},
getValue: function () {
return {
year: this.year.getValue(),
quarter: this.quarter.getValue()
};
return this.storeValue;
}
});
BI.YearQuarterCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.YearQuarterCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
BI.shortcut("bi.year_quarter_combo", BI.YearQuarterCombo);
BI.DynamicYearQuarterCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.DynamicYearQuarterCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
BI.shortcut("bi.dynamic_year_quarter_combo", BI.DynamicYearQuarterCombo);
BI.extend(BI.DynamicYearQuarterCombo, {
Static: 1,
Dynamic: 2
});

2
src/widget/dynamic/yearquarter/popup.yearquarter.js → src/widget/yearquarter/popup.yearquarter.js

@ -124,7 +124,7 @@ BI.DynamicYearQuarterPopup = BI.inherit(BI.Widget, {
min: self.options.min,
max: self.options.max,
listeners: [{
eventName: BI.YearCard.EVENT_CHANGE,
eventName: BI.DynamicYearCard.EVENT_CHANGE,
action: function () {
self.fireEvent(BI.DynamicYearQuarterPopup.EVENT_CHANGE);
}

0
src/widget/dynamic/yearquarter/trigger.yearquarter.js → src/widget/yearquarter/trigger.yearquarter.js

Loading…
Cancel
Save