Browse Source

Merge branch 'master' of ssh://cloud.finedevelop.com:7999/~kira/fineui

es6
Kira 3 years ago
parent
commit
dbade796a4
  1. 5
      .eslintrc
  2. 2
      changelog.md
  3. 2
      package.json
  4. 17
      src/base/combination/combo.js
  5. 1
      src/base/single/a/a.js
  6. 14
      src/base/single/input/checkbox/checkbox.js
  7. 6
      src/base/single/input/radio/radio.js
  8. 1
      src/case/layer/pane.list.js
  9. 4
      src/case/toolbar/toolbar.multiselect.js
  10. 7
      src/less/base/single/button/button.half.less
  11. 8
      src/less/base/single/input/checkbox.less
  12. 3
      src/less/base/single/input/radio.less
  13. 2
      src/less/base/tree/ztree.less
  14. 407
      src/widget/dynamicdate/dynamicdate.combo.js
  15. 426
      src/widget/dynamicdatetime/dynamicdatetime.combo.js
  16. 41
      src/widget/year/combo.year.js
  17. 40
      src/widget/yearmonth/combo.yearmonth.js
  18. 40
      src/widget/yearquarter/combo.yearquarter.js

5
.eslintrc

@ -27,7 +27,10 @@
"plugins": ["@typescript-eslint/eslint-plugin"],
"overrides": [{
"files": ["src/*.js","src/**/*.js", "demo/*.js", "demo/**/*.js", "i18n/**/*.js", "i18n/*.js", "test/**/*.js", "test/*.js"],
"extends": "plugin:@fui/es5"
"extends": "plugin:@fui/es5",
"rules": {
"comma-dangle": ["error", "never"] // 多行对象字面量中要求拖尾逗号
}
}, {
"files": ["webpack/*.js", "types/*.ts", "typescript/*.ts","typescript/**/*.ts", "./*.js", "lib/**/*.js", "lib/*.js"],
"extends": "plugin:@fui/typescript"

2
changelog.md

@ -1,4 +1,6 @@
# 更新日志
2.0(2021-10)
- combo增加window.blur事件触发隐藏
2.0(2021-09)
- 支持自动watch
- 支持h函数传递left、right,优化left_right_vertical_adapt布局的jsx写法

2
package.json

@ -1,6 +1,6 @@
{
"name": "fineui",
"version": "2.0.20211004210446",
"version": "2.0.20211013101239",
"description": "fineui",
"main": "dist/fineui.min.js",
"types": "dist/lib/index.d.ts",

17
src/base/combination/combo.js

@ -296,18 +296,21 @@
this.popupView && this.popupView.destroy();
this.popupView = null;
this._rendered = false;
if (!e || !this.combo.element.__isMouseInBounds__(e)) {
this.element.removeClass(this.options.hoverClass);
}
} else {
this.popupView && this.popupView.invisible();
}
if (!e || !this.combo.element.__isMouseInBounds__(e)) {
this.element.removeClass(this.options.hoverClass);
// 应对bi-focus-shadow在收起时不失焦
this.element.blur();
}
this.element.removeClass(this.options.comboClass);
delete needHideWhenAnotherComboOpen[this.getName()];
BI.Widget._renderEngine.createElement(document).unbind("mousedown." + this.getName()).unbind("mousewheel." + this.getName());
BI.Widget._renderEngine.createElement(window).unbind("blur." + this.getName());
this.fireEvent(BI.Combo.EVENT_AFTER_HIDEVIEW);
},
@ -331,7 +334,10 @@
this.element.addClass(this.options.comboClass);
BI.Widget._renderEngine.createElement(document).unbind("mousedown." + this.getName()).unbind("mousewheel." + this.getName());
BI.Widget._renderEngine.createElement(window).unbind("blur." + this.getName());
BI.Widget._renderEngine.createElement(document).bind("mousedown." + this.getName(), BI.bind(this._hideIf, this)).bind("mousewheel." + this.getName(), BI.bind(this._hideIf, this));
BI.Widget._renderEngine.createElement(window).bind("blur." + this.getName(), BI.bind(this._hideIf, this));
this.fireEvent(BI.Combo.EVENT_AFTER_POPUPVIEW);
},
@ -553,7 +559,8 @@
.unbind("mousewheel." + this.getName())
.unbind("mouseenter." + this.getName())
.unbind("mousemove." + this.getName())
.unbind("mouseleave." + this.getName())
.unbind("mouseleave." + this.getName());
BI.Widget._renderEngine.createElement(window)
.unbind("blur." + this.getName());
BI.Resizers.remove(this.getName());
this.popupView && this.popupView._destroy();

1
src/base/single/a/a.js

@ -20,6 +20,7 @@ BI.A = BI.inherit(BI.Text, {
render: function () {
var o = this.options;
BI.A.superclass.render.apply(this, arguments);
this.element.attr({href: o.href, target: o.target});
if (o.el) {
BI.createWidget(o.el, {

14
src/base/single/input/checkbox/checkbox.js

@ -9,10 +9,10 @@ BI.Checkbox = BI.inherit(BI.BasicButton, {
baseCls: "bi-checkbox",
selected: false,
handler: BI.emptyFn,
width: 16,
height: 16,
iconWidth: 16,
iconHeight: 16
width: 14,
height: 14,
iconWidth: 14,
iconHeight: 14
},
render: function () {
@ -25,8 +25,8 @@ BI.Checkbox = BI.inherit(BI.BasicButton, {
self.checkbox = _ref;
},
cls: "checkbox-content",
width: o.iconWidth - 2,
height: o.iconHeight - 2
width: o.iconWidth,
height: o.iconHeight
}]
};
},
@ -58,4 +58,4 @@ BI.Checkbox = BI.inherit(BI.BasicButton, {
});
BI.Checkbox.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.checkbox", BI.Checkbox);
BI.shortcut("bi.checkbox", BI.Checkbox);

6
src/base/single/input/radio/radio.js

@ -9,8 +9,8 @@ BI.Radio = BI.inherit(BI.BasicButton, {
baseCls: "bi-radio",
selected: false,
handler: BI.emptyFn,
width: 16,
height: 16,
width: 14,
height: 14,
iconWidth: 14,
iconHeight: 14
},
@ -59,4 +59,4 @@ BI.Radio = BI.inherit(BI.BasicButton, {
});
BI.Radio.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.radio", BI.Radio);
BI.shortcut("bi.radio", BI.Radio);

1
src/case/layer/pane.list.js

@ -130,6 +130,7 @@ BI.ListPane = BI.inherit(BI.Pane, {
} else {
BI.ListPane.superclass.populate.apply(this, arguments);
this.button_group.populate.apply(this.button_group, arguments);
BI.isEmptyArray(BI.get(arguments, [0], [])) && this.setTipText(o.tipText);
}
},

4
src/case/toolbar/toolbar.multiselect.js

@ -19,8 +19,8 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, {
},
halfSelected: false,
iconWrapperWidth: 26,
iconWidth: 16,
iconHeight: 16,
iconWidth: 14,
iconHeight: 14,
});
},
_init: function () {

7
src/less/base/single/button/button.half.less

@ -2,13 +2,14 @@
.bi-half-button {
.border-radius(2px);
box-sizing: border-box;
&:after {
position: absolute;
left: 3px;
top: 3px;
left: 2px;
top: 2px;
width: 8px;
height: 8px;
background-color: @color-bi-background-highlight;
content: '';
}
}
}

8
src/less/base/single/input/checkbox.less

@ -4,6 +4,7 @@
& .checkbox-content, &.checkbox-content {
.border-radius(2px);
border: 1px solid @color-bi-border-dark-line;
box-sizing: border-box;
&:after {
position: absolute;
display: table;
@ -12,8 +13,9 @@
border: 2px solid transparent;
border-top: 0;
border-left: 0;
width: 4px;
height: 8px;
width: 6px;
height: 9px;
.box-sizing(border-box);
.transform(rotate(45deg) scale(1) translate(-50%, -50%));
content: '';
}
@ -74,4 +76,4 @@
}
}
}
}
}

3
src/less/base/single/input/radio.less

@ -4,6 +4,7 @@
& .radio-content, &.radio-content {
.border-radius(8px);
border: 1px solid @color-bi-border-dark-line;
.box-sizing(border-box);
&:after {
content: "";
}
@ -74,4 +75,4 @@
}
}
}
}
}

2
src/less/base/tree/ztree.less

@ -108,6 +108,7 @@
.ztree li span.button.chk {
&.bi-checkbox {
border: 1px solid @color-bi-border-dark-line;
box-sizing: border-box;
&.active {
background-color: @color-bi-background-highlight;
border-color: @color-bi-border-highlight;;
@ -115,6 +116,7 @@
}
&.bi-half-button {
border: 1px solid @color-bi-border-highlight;
box-sizing: border-box;
}
}

407
src/widget/dynamicdate/dynamicdate.combo.js

@ -30,221 +30,231 @@ BI.DynamicDateCombo = BI.inherit(BI.Single, {
this.storeTriggerValue = "";
var date = BI.getDate();
this.storeValue = opts.value;
return {
type: "bi.htape",
cls: "bi-border bi-border-radius",
type: "bi.absolute",
items: [{
el: {
type: "bi.icon_button",
cls: "bi-trigger-icon-button date-change-h-font",
width: opts.height,
height: opts.height - 2,
ref: function () {
self.changeIcon = this;
}
},
width: opts.height
}, {
type: "bi.absolute",
items: [{
el: {
type: "bi.combo",
container: opts.container,
ref: function () {
self.combo = this;
},
toggle: false,
isNeedAdjustHeight: opts.isNeedAdjustHeight,
isNeedAdjustWidth: opts.isNeedAdjustWidth,
destroyWhenHide: true,
type: "bi.htape",
cls: "bi-border bi-border-radius bi-focus-shadow",
items: [{
el: {
type: "bi.dynamic_date_trigger",
min: opts.minDate,
max: opts.maxDate,
format: opts.format,
allowEdit: opts.allowEdit,
watermark: opts.watermark,
type: "bi.icon_button",
cls: "bi-trigger-icon-button date-change-h-font",
width: opts.height - 2,
height: opts.height - 2,
value: opts.value,
ref: function () {
self.trigger = this;
},
listeners: [{
eventName: BI.DynamicDateTrigger.EVENT_KEY_DOWN,
action: function () {
if (self.combo.isViewVisible()) {
self.combo.hideView();
}
self.fireEvent(BI.DynamicDateCombo.EVENT_KEY_DOWN, arguments);
}
}, {
eventName: BI.DynamicDateTrigger.EVENT_STOP,
action: function () {
if (!self.combo.isViewVisible()) {
self.combo.showView();
}
}
}, {
eventName: BI.DynamicDateTrigger.EVENT_FOCUS,
action: function () {
self.storeTriggerValue = self.trigger.getKey();
if (!self.combo.isViewVisible()) {
self.combo.showView();
}
self.fireEvent(BI.DynamicDateCombo.EVENT_FOCUS);
}
}, {
eventName: BI.DynamicDateTrigger.EVENT_BLUR,
action: function () {
self.fireEvent(BI.DynamicDateCombo.EVENT_BLUR);
}
}, {
eventName: BI.DynamicDateTrigger.EVENT_ERROR,
action: function () {
self.storeValue = {
type: BI.DynamicDateCombo.Static,
value: {
year: date.getFullYear(),
month: date.getMonth() + 1
}
};
self.fireEvent(BI.DynamicDateCombo.EVENT_ERROR);
}
}, {
eventName: BI.DynamicDateTrigger.EVENT_VALID,
action: function () {
self.fireEvent(BI.DynamicDateCombo.EVENT_VALID);
}
}, {
eventName: BI.DynamicDateTrigger.EVENT_CHANGE,
action: function () {
self.fireEvent(BI.DynamicDateCombo.EVENT_CHANGE);
}
}, {
eventName: BI.DynamicDateTrigger.EVENT_CONFIRM,
action: function () {
var dateStore = self.storeTriggerValue;
var dateObj = self.trigger.getKey();
if (self.combo.isViewVisible() || BI.isEqual(dateObj, dateStore)) {
return;
}
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._checkDynamicValue(self.storeValue);
self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM);
}
}]
self.changeIcon = this;
}
},
adjustLength: this.constants.comboAdjustHeight,
popup: {
width: opts.height - 2
}, {
type: "bi.absolute",
items: [{
el: {
type: "bi.dynamic_date_popup",
width: opts.isNeedAdjustWidth ? opts.width : undefined,
supportDynamic: opts.supportDynamic,
behaviors: opts.behaviors,
min: opts.minDate,
max: opts.maxDate,
type: "bi.combo",
container: opts.container,
ref: function () {
self.popup = this;
self.combo = this;
},
listeners: [{
eventName: BI.DynamicDatePopup.BUTTON_CLEAR_EVENT_CHANGE,
action: function () {
self.setValue();
self.combo.hideView();
self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM);
}
}, {
eventName: BI.DynamicDatePopup.BUTTON_lABEL_EVENT_CHANGE,
action: function () {
var date = BI.getDate();
self.setValue({
type: BI.DynamicDateCombo.Static,
value: {
year: date.getFullYear(),
month: date.getMonth() + 1,
day: date.getDate()
toggle: false,
isNeedAdjustHeight: opts.isNeedAdjustHeight,
isNeedAdjustWidth: opts.isNeedAdjustWidth,
destroyWhenHide: true,
el: {
type: "bi.dynamic_date_trigger",
min: opts.minDate,
max: opts.maxDate,
format: opts.format,
allowEdit: opts.allowEdit,
watermark: opts.watermark,
height: opts.height - 2,
value: opts.value,
ref: function () {
self.trigger = this;
},
listeners: [{
eventName: BI.DynamicDateTrigger.EVENT_KEY_DOWN,
action: function () {
if (self.combo.isViewVisible()) {
self.combo.hideView();
}
});
self.combo.hideView();
self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM);
}
}, {
eventName: BI.DynamicDatePopup.BUTTON_OK_EVENT_CHANGE,
action: function () {
var value = self.popup.getValue();
if(self._checkValue(value)) {
self.setValue(value);
self.fireEvent(BI.DynamicDateCombo.EVENT_KEY_DOWN, arguments);
}
self.combo.hideView();
self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM);
}
}, {
eventName: BI.DynamicDatePopup.EVENT_CHANGE,
}, {
eventName: BI.DynamicDateTrigger.EVENT_STOP,
action: function () {
if (!self.combo.isViewVisible()) {
self.combo.showView();
}
}
}, {
eventName: BI.DynamicDateTrigger.EVENT_FOCUS,
action: function () {
self.storeTriggerValue = self.trigger.getKey();
if (!self.combo.isViewVisible()) {
self.combo.showView();
}
self.fireEvent(BI.DynamicDateCombo.EVENT_FOCUS);
}
}, {
eventName: BI.DynamicDateTrigger.EVENT_BLUR,
action: function () {
self.fireEvent(BI.DynamicDateCombo.EVENT_BLUR);
}
}, {
eventName: BI.DynamicDateTrigger.EVENT_ERROR,
action: function () {
self.storeValue = {
type: BI.DynamicDateCombo.Static,
value: {
year: date.getFullYear(),
month: date.getMonth() + 1
}
};
self.fireEvent(BI.DynamicDateCombo.EVENT_ERROR);
}
}, {
eventName: BI.DynamicDateTrigger.EVENT_VALID,
action: function () {
self.fireEvent(BI.DynamicDateCombo.EVENT_VALID);
}
}, {
eventName: BI.DynamicDateTrigger.EVENT_CHANGE,
action: function () {
self.fireEvent(BI.DynamicDateCombo.EVENT_CHANGE);
}
}, {
eventName: BI.DynamicDateTrigger.EVENT_CONFIRM,
action: function () {
var dateStore = self.storeTriggerValue;
var dateObj = self.trigger.getKey();
if (self.combo.isViewVisible() || BI.isEqual(dateObj, dateStore)) {
return;
}
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._checkDynamicValue(self.storeValue);
self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM);
}
}]
},
adjustLength: this.constants.comboAdjustHeight,
popup: {
el: {
type: "bi.dynamic_date_popup",
width: opts.isNeedAdjustWidth ? opts.width : undefined,
supportDynamic: opts.supportDynamic,
behaviors: opts.behaviors,
min: opts.minDate,
max: opts.maxDate,
ref: function () {
self.popup = this;
},
listeners: [{
eventName: BI.DynamicDatePopup.BUTTON_CLEAR_EVENT_CHANGE,
action: function () {
self.setValue();
self.combo.hideView();
self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM);
}
}, {
eventName: BI.DynamicDatePopup.BUTTON_lABEL_EVENT_CHANGE,
action: function () {
var date = BI.getDate();
self.setValue({
type: BI.DynamicDateCombo.Static,
value: {
year: date.getFullYear(),
month: date.getMonth() + 1,
day: date.getDate()
}
});
self.combo.hideView();
self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM);
}
}, {
eventName: BI.DynamicDatePopup.BUTTON_OK_EVENT_CHANGE,
action: function () {
var value = self.popup.getValue();
if (self._checkValue(value)) {
self.setValue(value);
}
self.combo.hideView();
self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM);
}
}, {
eventName: BI.DynamicDatePopup.EVENT_CHANGE,
action: function () {
self.setValue(self.popup.getValue());
self.combo.hideView();
self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM);
}
}, {
eventName: BI.DynamicDatePopup.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW,
action: function () {
self.fireEvent(BI.DynamicDateCombo.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW);
}
}]
},
stopPropagation: false
},
// DEC-4250 和复选下拉一样,点击triggerBtn不默认收起
hideChecker: function (e) {
return self.triggerBtn.element.find(e.target).length === 0;
},
listeners: [{
eventName: BI.Combo.EVENT_BEFORE_POPUPVIEW,
action: function () {
self.setValue(self.popup.getValue());
self.combo.hideView();
self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM);
self.popup.setMinDate(opts.minDate);
self.popup.setMaxDate(opts.maxDate);
self.popup.setValue(self.storeValue);
self.fireEvent(BI.DynamicDateCombo.EVENT_BEFORE_POPUPVIEW);
}
}, {
eventName: BI.DynamicDatePopup.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW,
}]
},
top: 0,
left: 0,
right: 0,
bottom: 0
}, {
el: {
type: "bi.icon_button",
cls: "bi-trigger-icon-button date-font",
width: opts.height - 2,
height: opts.height - 2,
listeners: [{
eventName: BI.IconButton.EVENT_CHANGE,
action: function () {
self.fireEvent(BI.DynamicDateCombo.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW);
if (self.combo.isViewVisible()) {
// self.combo.hideView();
} else {
self.combo.showView();
}
}
}]
}],
ref: function () {
self.triggerBtn = this;
}
},
stopPropagation: false
},
// DEC-4250 和复选下拉一样,点击triggerBtn不默认收起
hideChecker: function (e) {
return self.triggerBtn.element.find(e.target).length === 0;
},
listeners: [{
eventName: BI.Combo.EVENT_BEFORE_POPUPVIEW,
action: function () {
self.popup.setMinDate(opts.minDate);
self.popup.setMaxDate(opts.maxDate);
self.popup.setValue(self.storeValue);
self.fireEvent(BI.DynamicDateCombo.EVENT_BEFORE_POPUPVIEW);
}
top: 0,
right: 0
}]
},
top: 0,
left: 0,
right: 0,
bottom: 0
}, {
el: {
type: "bi.icon_button",
cls: "bi-trigger-icon-button date-font",
width: opts.height,
height: opts.height,
listeners: [{
eventName: BI.IconButton.EVENT_CHANGE,
action: function () {
if (self.combo.isViewVisible()) {
// self.combo.hideView();
} else {
self.combo.showView();
}
}
}],
ref: function () {
self.triggerBtn = this;
}
},
top: 0,
right: 0
}]
}],
ref: function (_ref) {
self.comboWrapper = _ref;
}
}],
ref: function (_ref) {
self.comboWrapper = _ref;
}
},
top: 1,
left: 1,
right: 1,
bottom: 1
}]
};
},
@ -261,7 +271,7 @@ BI.DynamicDateCombo = BI.inherit(BI.Single, {
switch (type) {
case BI.DynamicDateCombo.Dynamic:
this.changeIcon.setVisible(true);
this.comboWrapper.attr("items")[0].width = o.height;
this.comboWrapper.attr("items")[0].width = o.height - 2;
this.comboWrapper.resize();
break;
default:
@ -279,6 +289,7 @@ BI.DynamicDateCombo = BI.inherit(BI.Single, {
return BI.isNotEmptyObject(v.value);
case BI.DynamicDateCombo.Static:
var value = v.value || {};
return !BI.checkDateVoid(value.year, value.month, value.day, o.minDate, o.maxDate)[0];
default:
return true;

426
src/widget/dynamicdatetime/dynamicdatetime.combo.js

@ -30,229 +30,240 @@ BI.DynamicDateTimeCombo = BI.inherit(BI.Single, {
this.storeTriggerValue = "";
var date = BI.getDate();
this.storeValue = opts.value;
return {
type: "bi.htape",
cls: "bi-border bi-border-radius",
type: "bi.absolute",
items: [{
el: {
type: "bi.icon_button",
cls: "bi-trigger-icon-button date-change-h-font",
width: opts.height,
height: opts.height - 2,
ref: function () {
self.changeIcon = this;
}
},
width: opts.height
}, {
type: "bi.absolute",
items: [{
el: {
type: "bi.combo",
destroyWhenHide: true,
container: opts.container,
ref: function () {
self.combo = this;
},
toggle: false,
isNeedAdjustHeight: opts.isNeedAdjustHeight,
isNeedAdjustWidth: opts.isNeedAdjustWidth,
type: "bi.htape",
cls: "bi-border bi-border-radius bi-focus-shadow",
items: [{
el: {
type: "bi.dynamic_date_time_trigger",
min: opts.minDate,
max: opts.maxDate,
allowEdit: opts.allowEdit,
watermark: opts.watermark,
format: opts.format,
type: "bi.icon_button",
cls: "bi-trigger-icon-button date-change-h-font",
width: opts.height - 2,
height: opts.height - 2,
value: opts.value,
ref: function () {
self.trigger = this;
},
listeners: [{
eventName: BI.DynamicDateTimeTrigger.EVENT_KEY_DOWN,
action: function () {
if (self.combo.isViewVisible()) {
self.combo.hideView();
}
self.fireEvent(BI.DynamicDateTimeCombo.EVENT_KEY_DOWN, arguments);
}
}, {
eventName: BI.DynamicDateTimeTrigger.EVENT_STOP,
action: function () {
if (!self.combo.isViewVisible()) {
self.combo.showView();
}
}
}, {
eventName: BI.DynamicDateTimeTrigger.EVENT_TRIGGER_CLICK,
action: function () {
self.combo.toggle();
}
}, {
eventName: BI.DynamicDateTimeTrigger.EVENT_FOCUS,
action: function () {
self.storeTriggerValue = self.trigger.getKey();
if (!self.combo.isViewVisible()) {
self.combo.showView();
}
self.fireEvent(BI.DynamicDateTimeCombo.EVENT_FOCUS);
}
}, {
eventName: BI.DynamicDateTimeTrigger.EVENT_BLUR,
action: function () {
self.fireEvent(BI.DynamicDateTimeCombo.EVENT_BLUR);
}
}, {
eventName: BI.DynamicDateTimeTrigger.EVENT_ERROR,
action: function () {
self.storeValue = {
type: BI.DynamicDateTimeCombo.Static,
value: {
year: date.getFullYear(),
month: date.getMonth() + 1
}
};
self.fireEvent(BI.DynamicDateTimeCombo.EVENT_ERROR);
}
}, {
eventName: BI.DynamicDateTimeTrigger.EVENT_VALID,
action: function () {
self.fireEvent(BI.DynamicDateTimeCombo.EVENT_VALID);
}
}, {
eventName: BI.DynamicDateTimeTrigger.EVENT_CHANGE,
action: function () {
self.fireEvent(BI.DynamicDateTimeCombo.EVENT_CHANGE);
}
}, {
eventName: BI.DynamicDateTimeTrigger.EVENT_CONFIRM,
action: function () {
var dateStore = self.storeTriggerValue;
var dateObj = self.trigger.getKey();
if (self.combo.isViewVisible() || BI.isEqual(dateObj, dateStore)) {
return;
}
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._checkDynamicValue(self.storeValue);
self.fireEvent(BI.DynamicDateTimeCombo.EVENT_CONFIRM);
}
}]
self.changeIcon = this;
}
},
adjustLength: this.constants.comboAdjustHeight,
popup: {
width: opts.height - 2
}, {
type: "bi.absolute",
items: [{
el: {
type: "bi.dynamic_date_time_popup",
width: opts.isNeedAdjustWidth ? opts.width : undefined,
supportDynamic: opts.supportDynamic,
behaviors: opts.behaviors,
min: opts.minDate,
max: opts.maxDate,
type: "bi.combo",
cls: "bi-focus-shadow",
destroyWhenHide: true,
container: opts.container,
ref: function () {
self.popup = this;
self.combo = this;
},
listeners: [{
eventName: BI.DynamicDateTimePopup.BUTTON_CLEAR_EVENT_CHANGE,
action: function () {
self.setValue();
self.combo.hideView();
self.fireEvent(BI.DynamicDateTimeCombo.EVENT_CONFIRM);
}
}, {
eventName: BI.DynamicDateTimePopup.BUTTON_lABEL_EVENT_CHANGE,
action: function () {
var date = BI.getDate();
self.setValue({
type: BI.DynamicDateTimeCombo.Static,
value: {
year: date.getFullYear(),
month: date.getMonth() + 1,
day: date.getDate(),
hour: 0,
minute: 0,
second: 0
toggle: false,
isNeedAdjustHeight: opts.isNeedAdjustHeight,
isNeedAdjustWidth: opts.isNeedAdjustWidth,
el: {
type: "bi.dynamic_date_time_trigger",
min: opts.minDate,
max: opts.maxDate,
allowEdit: opts.allowEdit,
watermark: opts.watermark,
format: opts.format,
height: opts.height - 2,
value: opts.value,
ref: function () {
self.trigger = this;
},
listeners: [{
eventName: BI.DynamicDateTimeTrigger.EVENT_KEY_DOWN,
action: function () {
if (self.combo.isViewVisible()) {
self.combo.hideView();
}
});
self.combo.hideView();
self.fireEvent(BI.DynamicDateTimeCombo.EVENT_CONFIRM);
}
}, {
eventName: BI.DynamicDateTimePopup.BUTTON_OK_EVENT_CHANGE,
action: function () {
var value = self.popup.getValue();
if(self._checkValue(value)) {
self.setValue(value);
self.fireEvent(BI.DynamicDateTimeCombo.EVENT_KEY_DOWN, arguments);
}
self.combo.hideView();
self.fireEvent(BI.DynamicDateTimeCombo.EVENT_CONFIRM);
}
}, {
eventName: BI.DynamicDateTimePopup.EVENT_CHANGE,
}, {
eventName: BI.DynamicDateTimeTrigger.EVENT_STOP,
action: function () {
if (!self.combo.isViewVisible()) {
self.combo.showView();
}
}
}, {
eventName: BI.DynamicDateTimeTrigger.EVENT_TRIGGER_CLICK,
action: function () {
self.combo.toggle();
}
}, {
eventName: BI.DynamicDateTimeTrigger.EVENT_FOCUS,
action: function () {
self.storeTriggerValue = self.trigger.getKey();
if (!self.combo.isViewVisible()) {
self.combo.showView();
}
self.fireEvent(BI.DynamicDateTimeCombo.EVENT_FOCUS);
}
}, {
eventName: BI.DynamicDateTimeTrigger.EVENT_BLUR,
action: function () {
self.fireEvent(BI.DynamicDateTimeCombo.EVENT_BLUR);
}
}, {
eventName: BI.DynamicDateTimeTrigger.EVENT_ERROR,
action: function () {
self.storeValue = {
type: BI.DynamicDateTimeCombo.Static,
value: {
year: date.getFullYear(),
month: date.getMonth() + 1
}
};
self.fireEvent(BI.DynamicDateTimeCombo.EVENT_ERROR);
}
}, {
eventName: BI.DynamicDateTimeTrigger.EVENT_VALID,
action: function () {
self.fireEvent(BI.DynamicDateTimeCombo.EVENT_VALID);
}
}, {
eventName: BI.DynamicDateTimeTrigger.EVENT_CHANGE,
action: function () {
self.fireEvent(BI.DynamicDateTimeCombo.EVENT_CHANGE);
}
}, {
eventName: BI.DynamicDateTimeTrigger.EVENT_CONFIRM,
action: function () {
var dateStore = self.storeTriggerValue;
var dateObj = self.trigger.getKey();
if (self.combo.isViewVisible() || BI.isEqual(dateObj, dateStore)) {
return;
}
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._checkDynamicValue(self.storeValue);
self.fireEvent(BI.DynamicDateTimeCombo.EVENT_CONFIRM);
}
}]
},
adjustLength: this.constants.comboAdjustHeight,
popup: {
el: {
type: "bi.dynamic_date_time_popup",
width: opts.isNeedAdjustWidth ? opts.width : undefined,
supportDynamic: opts.supportDynamic,
behaviors: opts.behaviors,
min: opts.minDate,
max: opts.maxDate,
ref: function () {
self.popup = this;
},
listeners: [{
eventName: BI.DynamicDateTimePopup.BUTTON_CLEAR_EVENT_CHANGE,
action: function () {
self.setValue();
self.combo.hideView();
self.fireEvent(BI.DynamicDateTimeCombo.EVENT_CONFIRM);
}
}, {
eventName: BI.DynamicDateTimePopup.BUTTON_lABEL_EVENT_CHANGE,
action: function () {
var date = BI.getDate();
self.setValue({
type: BI.DynamicDateTimeCombo.Static,
value: {
year: date.getFullYear(),
month: date.getMonth() + 1,
day: date.getDate(),
hour: 0,
minute: 0,
second: 0
}
});
self.combo.hideView();
self.fireEvent(BI.DynamicDateTimeCombo.EVENT_CONFIRM);
}
}, {
eventName: BI.DynamicDateTimePopup.BUTTON_OK_EVENT_CHANGE,
action: function () {
var value = self.popup.getValue();
if (self._checkValue(value)) {
self.setValue(value);
}
self.combo.hideView();
self.fireEvent(BI.DynamicDateTimeCombo.EVENT_CONFIRM);
}
}, {
eventName: BI.DynamicDateTimePopup.EVENT_CHANGE,
action: function () {
self.setValue(self.popup.getValue());
self.combo.hideView();
self.fireEvent(BI.DynamicDateTimeCombo.EVENT_CONFIRM);
}
}, {
eventName: BI.DynamicDateTimePopup.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW,
action: function () {
self.fireEvent(BI.DynamicDateTimeCombo.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW);
}
}]
},
stopPropagation: false
},
listeners: [{
eventName: BI.Combo.EVENT_BEFORE_POPUPVIEW,
action: function () {
self.setValue(self.popup.getValue());
self.combo.hideView();
self.fireEvent(BI.DynamicDateTimeCombo.EVENT_CONFIRM);
self.popup.setMinDate(opts.minDate);
self.popup.setMaxDate(opts.maxDate);
self.popup.setValue(self.storeValue);
self.fireEvent(BI.DynamicDateTimeCombo.EVENT_BEFORE_POPUPVIEW);
}
}, {
eventName: BI.DynamicDateTimePopup.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW,
}],
// DEC-4250 和复选下拉一样,点击不收起
hideChecker: function (e) {
return self.triggerBtn.element.find(e.target).length === 0;
}
},
top: 0,
left: 0,
right: 0,
bottom: 0
}, {
el: {
type: "bi.icon_button",
cls: "bi-trigger-icon-button date-font",
width: opts.height - 2,
height: opts.height - 2,
listeners: [{
eventName: BI.IconButton.EVENT_CHANGE,
action: function () {
self.fireEvent(BI.DynamicDateTimeCombo.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW);
if (self.combo.isViewVisible()) {
// self.combo.hideView();
} else {
self.combo.showView();
}
}
}]
},
stopPropagation: false
},
listeners: [{
eventName: BI.Combo.EVENT_BEFORE_POPUPVIEW,
action: function () {
self.popup.setMinDate(opts.minDate);
self.popup.setMaxDate(opts.maxDate);
self.popup.setValue(self.storeValue);
self.fireEvent(BI.DynamicDateTimeCombo.EVENT_BEFORE_POPUPVIEW);
}
}],
// DEC-4250 和复选下拉一样,点击不收起
hideChecker: function (e) {
return self.triggerBtn.element.find(e.target).length === 0;
}
},
top: 0,
left: 0,
right: 0,
bottom: 0
}, {
el: {
type: "bi.icon_button",
cls: "bi-trigger-icon-button date-font",
width: opts.height,
height: opts.height,
listeners: [{
eventName: BI.IconButton.EVENT_CHANGE,
action: function () {
if (self.combo.isViewVisible()) {
// self.combo.hideView();
} else {
self.combo.showView();
}],
ref: function () {
self.triggerBtn = this;
}
}
}],
ref: function () {
self.triggerBtn = this;
}
},
top: 0,
right: 0
}]
}],
ref: function (_ref) {
self.comboWrapper = _ref;
}
},
top: 0,
right: 0
}]
}],
ref: function (_ref) {
self.comboWrapper = _ref;
}
},
top: 1,
left: 1,
right: 1,
bottom: 1
}]
};
},
@ -269,7 +280,7 @@ BI.DynamicDateTimeCombo = BI.inherit(BI.Single, {
switch (type) {
case BI.DynamicDateTimeCombo.Dynamic:
this.changeIcon.setVisible(true);
this.comboWrapper.attr("items")[0].width = o.height;
this.comboWrapper.attr("items")[0].width = o.height - 2;
this.comboWrapper.resize();
break;
default:
@ -287,6 +298,7 @@ BI.DynamicDateTimeCombo = BI.inherit(BI.Single, {
return BI.isNotEmptyObject(v.value);
case BI.DynamicDateCombo.Static:
var value = v.value || {};
return !BI.checkDateVoid(value.year, value.month, value.day, o.minDate, o.maxDate)[0];
default:
return true;

41
src/widget/year/combo.year.js

@ -6,7 +6,7 @@ BI.DynamicYearCombo = BI.inherit(BI.Widget, {
minDate: "1900-01-01", // 最小日期
maxDate: "2099-12-31", // 最大日期
height: 24,
supportDynamic: true,
supportDynamic: true
},
_init: function () {
@ -92,7 +92,7 @@ BI.DynamicYearCombo = BI.inherit(BI.Widget, {
eventName: BI.DynamicYearPopup.BUTTON_lABEL_EVENT_CHANGE,
action: function () {
var date = BI.getDate();
self.setValue({type: BI.DynamicYearCombo.Static, value: {year: date.getFullYear()}});
self.setValue({ type: BI.DynamicYearCombo.Static, value: { year: date.getFullYear() } });
self.combo.hideView();
self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM);
}
@ -119,24 +119,33 @@ BI.DynamicYearCombo = BI.inherit(BI.Widget, {
});
BI.createWidget({
type: "bi.htape",
cls: "bi-border bi-border-radius",
type: "bi.absolute",
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: o.height - 2,
type: "bi.htape",
cls: "bi-border bi-border-radius bi-focus-shadow",
ref: function () {
self.changeIcon = this;
}
self.comboWrapper = this;
},
items: [{
el: {
type: "bi.icon_button",
cls: "bi-trigger-icon-button date-change-h-font",
width: o.height - 2,
height: o.height - 2,
ref: function () {
self.changeIcon = this;
}
},
width: o.height - 2
}, this.combo]
},
width: 24
}, this.combo]
top: 1,
left: 1,
right: 1,
bottom: 1
}]
});
this._checkDynamicValue(o.value);
},
@ -149,7 +158,7 @@ BI.DynamicYearCombo = BI.inherit(BI.Widget, {
switch (type) {
case BI.DynamicYearCombo.Dynamic:
this.changeIcon.setVisible(true);
this.comboWrapper.attr("items")[0].width = 24;
this.comboWrapper.attr("items")[0].width = this.options.height - 2,
this.comboWrapper.resize();
break;
default:

40
src/widget/yearmonth/combo.yearmonth.js

@ -93,7 +93,7 @@ BI.DynamicYearMonthCombo = BI.inherit(BI.Single, {
eventName: BI.DynamicYearMonthPopup.BUTTON_lABEL_EVENT_CHANGE,
action: function () {
var date = BI.getDate();
self.setValue({type: BI.DynamicYearMonthCombo.Static, value: {year: date.getFullYear(), month: date.getMonth() + 1}});
self.setValue({ type: BI.DynamicYearMonthCombo.Static, value: { year: date.getFullYear(), month: date.getMonth() + 1 } });
self.combo.hideView();
self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM);
}
@ -123,24 +123,33 @@ BI.DynamicYearMonthCombo = BI.inherit(BI.Single, {
});
BI.createWidget({
type: "bi.htape",
cls: "bi-border bi-border-radius",
type: "bi.absolute",
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: o.height - 2,
type: "bi.htape",
cls: "bi-border bi-border-radius bi-focus-shadow",
ref: function () {
self.changeIcon = this;
}
self.comboWrapper = this;
},
items: [{
el: {
type: "bi.icon_button",
cls: "bi-trigger-icon-button date-change-h-font",
width: o.height - 2,
height: o.height - 2,
ref: function () {
self.changeIcon = this;
}
},
width: o.height - 2
}, this.combo]
},
width: 24
}, this.combo]
top: 1,
left: 1,
right: 1,
bottom: 1
}]
});
this._checkDynamicValue(o.value);
},
@ -153,7 +162,7 @@ BI.DynamicYearMonthCombo = BI.inherit(BI.Single, {
switch (type) {
case BI.DynamicYearMonthCombo.Dynamic:
this.changeIcon.setVisible(true);
this.comboWrapper.attr("items")[0].width = 24;
this.comboWrapper.attr("items")[0].width = this.options.height - 2,
this.comboWrapper.resize();
break;
default:
@ -171,6 +180,7 @@ BI.DynamicYearMonthCombo = BI.inherit(BI.Single, {
return BI.isNotEmptyObject(v.value);
case BI.DynamicDateCombo.Static:
var value = v.value || {};
return !BI.checkDateVoid(value.year, value.month, 1, o.minDate, o.maxDate)[0];
default:
return true;

40
src/widget/yearquarter/combo.yearquarter.js

@ -93,7 +93,7 @@ BI.DynamicYearQuarterCombo = BI.inherit(BI.Widget, {
eventName: BI.DynamicYearQuarterPopup.BUTTON_lABEL_EVENT_CHANGE,
action: function () {
var date = BI.getDate();
self.setValue({type: BI.DynamicYearMonthCombo.Static, value: {year: date.getFullYear(), quarter: BI.getQuarter(date)}});
self.setValue({ type: BI.DynamicYearMonthCombo.Static, value: { year: date.getFullYear(), quarter: BI.getQuarter(date) } });
self.combo.hideView();
self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM);
}
@ -123,24 +123,33 @@ BI.DynamicYearQuarterCombo = BI.inherit(BI.Widget, {
});
BI.createWidget({
type: "bi.htape",
cls: "bi-border bi-border-radius",
type: "bi.absolute",
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: o.height - 2,
type: "bi.htape",
cls: "bi-border bi-border-radius bi-focus-shadow",
ref: function () {
self.changeIcon = this;
}
self.comboWrapper = this;
},
items: [{
el: {
type: "bi.icon_button",
cls: "bi-trigger-icon-button date-change-h-font",
width: o.height - 2,
height: o.height - 2,
ref: function () {
self.changeIcon = this;
}
},
width: o.height - 2
}, this.combo]
},
width: 24
}, this.combo]
top: 1,
left: 1,
right: 1,
bottom: 1
}]
});
this._checkDynamicValue(o.value);
},
@ -153,7 +162,7 @@ BI.DynamicYearQuarterCombo = BI.inherit(BI.Widget, {
switch (type) {
case BI.DynamicYearQuarterCombo.Dynamic:
this.changeIcon.setVisible(true);
this.comboWrapper.attr("items")[0].width = 24;
this.comboWrapper.attr("items")[0].width = this.options.height - 2;
this.comboWrapper.resize();
break;
default:
@ -171,6 +180,7 @@ BI.DynamicYearQuarterCombo = BI.inherit(BI.Widget, {
return BI.isNotEmptyObject(v.value);
case BI.DynamicDateCombo.Static:
var value = v.value || {};
return !BI.checkDateVoid(value.year, (value.quarter - 1) * 3 + 1, 1, o.minDate, o.maxDate)[0];
default:
return true;

Loading…
Cancel
Save