Browse Source

删除与整理

master
windy 7 years ago
parent
commit
6f7854d17f
  1. 25808
      dist/bundle.js
  2. 25776
      dist/widget.js
  3. 110
      src/widget/date/calendar/popup.year.js
  4. 0
      src/widget/datepane/card.static.datepane.js
  5. 220
      src/widget/datepane/datepane.js
  6. 0
      src/widget/datetimepane/card.static.datetimepane.js
  7. 0
      src/widget/datetimepane/datetimepane.js
  8. 140
      src/widget/dynamic/datepane/datepane.js
  9. 161
      src/widget/dynamic/year/combo.year.js
  10. 206
      src/widget/dynamic/year/popup.year.js
  11. 146
      src/widget/dynamic/year/trigger.year.js
  12. 170
      src/widget/dynamic/yearmonth/combo.yearmonth.js
  13. 152
      src/widget/dynamic/yearquarter/combo.yearquarter.js
  14. 151
      src/widget/multidate/abstract.multidate.datepane.js
  15. 283
      src/widget/multidate/multidate.combo.js
  16. 43
      src/widget/multidate/multidate.day.js
  17. 47
      src/widget/multidate/multidate.month.js
  18. 317
      src/widget/multidate/multidate.popup.js
  19. 48
      src/widget/multidate/multidate.quarter.js
  20. 127
      src/widget/multidate/multidate.segment.js
  21. 37
      src/widget/multidate/multidate.week.js
  22. 47
      src/widget/multidate/multidate.year.js
  23. 0
      src/widget/year/card.dynamic.year.js
  24. 0
      src/widget/year/card.year.js
  25. 154
      src/widget/year/combo.year.js
  26. 270
      src/widget/year/popup.year.js
  27. 132
      src/widget/year/trigger.year.js
  28. 0
      src/widget/yearmonth/card.dynamic.yearmonth.js
  29. 0
      src/widget/yearmonth/card.static.yearmonth.js
  30. 197
      src/widget/yearmonth/combo.yearmonth.js
  31. 2
      src/widget/yearmonth/popup.yearmonth.js
  32. 0
      src/widget/yearmonth/trigger.yearmonth.js
  33. 0
      src/widget/yearquarter/card.dynamic.yearquarter.js
  34. 0
      src/widget/yearquarter/card.static.yearquarter.js
  35. 178
      src/widget/yearquarter/combo.yearquarter.js
  36. 2
      src/widget/yearquarter/popup.yearquarter.js
  37. 0
      src/widget/yearquarter/trigger.yearquarter.js

25808
dist/bundle.js vendored

File diff suppressed because it is too large Load Diff

25776
dist/widget.js vendored

File diff suppressed because it is too large Load Diff

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
});

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

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

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);
}

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

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