Browse Source

Pull request #2417: 无JIRA任务 chore: 整理代码

Merge in VISUAL/fineui from ~GUY/fineui:master to master

* commit 'fb3c102632a9257eb220a29a7a9ee568cb064306':
  chore: 整理代码
es6
guy 3 years ago
parent
commit
048def04ca
  1. 6
      src/less/base/colorchooser/colorchooser.trigger.less
  2. 83
      src/widget/dynamicdate/dynamicdate.combo.js
  3. 11
      src/widget/dynamicdate/dynamicdate.trigger.js
  4. 84
      src/widget/dynamicdatetime/dynamicdatetime.combo.js
  5. 10
      src/widget/dynamicdatetime/dynamicdatetime.trigger.js

6
src/less/base/colorchooser/colorchooser.trigger.less

@ -3,3 +3,9 @@
.bi-color-chooser-trigger { .bi-color-chooser-trigger {
.border-radius(2px); .border-radius(2px);
} }
.bi-combo-popup {
.bi-color-chooser-trigger {
border-color: @color-bi-border-hover-combo;
}
}

83
src/widget/dynamicdate/dynamicdate.combo.js

@ -36,8 +36,20 @@ BI.DynamicDateCombo = BI.inherit(BI.Single, {
type: "bi.absolute", type: "bi.absolute",
items: [{ items: [{
el: { el: {
type: "bi.htape", type: "bi.combo",
cls: (opts.simple ? "bi-border-bottom" : "bi-border") + " bi-border-radius bi-focus-shadow", cls: (opts.simple ? "bi-border-bottom" : "bi-border") + " bi-border-radius bi-focus-shadow",
container: opts.container,
ref: function () {
self.combo = this;
},
toggle: false,
isNeedAdjustHeight: opts.isNeedAdjustHeight,
isNeedAdjustWidth: opts.isNeedAdjustWidth,
destroyWhenHide: true,
el: {
type: "bi.horizontal_fill",
columnSize: [opts.height - border, "fill"],
height: opts.height - border,
items: [{ items: [{
el: { el: {
type: "bi.icon_button", type: "bi.icon_button",
@ -48,21 +60,7 @@ BI.DynamicDateCombo = BI.inherit(BI.Single, {
self.changeIcon = this; self.changeIcon = this;
} }
}, },
width: opts.height - border
}, { }, {
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,
el: {
type: "bi.dynamic_date_trigger", type: "bi.dynamic_date_trigger",
simple: opts.simple, simple: opts.simple,
min: opts.minDate, min: opts.minDate,
@ -70,6 +68,7 @@ BI.DynamicDateCombo = BI.inherit(BI.Single, {
format: opts.format, format: opts.format,
allowEdit: opts.allowEdit, allowEdit: opts.allowEdit,
watermark: opts.watermark, watermark: opts.watermark,
iconWidth: opts.height - border,
height: opts.height - border, height: opts.height - border,
value: opts.value, value: opts.value,
ref: function () { ref: function () {
@ -114,13 +113,13 @@ BI.DynamicDateCombo = BI.inherit(BI.Single, {
month: date.getMonth() + 1 month: date.getMonth() + 1
} }
}; };
self.comboWrapper.element.addClass("error"); self.combo.element.addClass("error");
self.fireEvent(BI.DynamicDateCombo.EVENT_ERROR); self.fireEvent(BI.DynamicDateCombo.EVENT_ERROR);
} }
}, { }, {
eventName: BI.DynamicDateTrigger.EVENT_VALID, eventName: BI.DynamicDateTrigger.EVENT_VALID,
action: function () { action: function () {
self.comboWrapper.element.removeClass("error"); self.combo.element.removeClass("error");
self.fireEvent(BI.DynamicDateCombo.EVENT_VALID); self.fireEvent(BI.DynamicDateCombo.EVENT_VALID);
} }
}, { }, {
@ -147,6 +146,7 @@ BI.DynamicDateCombo = BI.inherit(BI.Single, {
self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM); self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM);
} }
}] }]
}]
}, },
adjustLength: this.constants.comboAdjustHeight, adjustLength: this.constants.comboAdjustHeight,
popup: { popup: {
@ -206,12 +206,11 @@ BI.DynamicDateCombo = BI.inherit(BI.Single, {
} }
}] }]
}, },
stopPropagation: false
},
// DEC-4250 和复选下拉一样,点击triggerBtn不默认收起
hideChecker: function (e) {
return self.triggerBtn.element.find(e.target).length === 0;
}, },
// // DEC-4250 和复选下拉一样,点击triggerBtn不默认收起
// hideChecker: function (e) {
// return self.triggerBtn.element.find(e.target).length === 0;
// },
listeners: [{ listeners: [{
eventName: BI.Combo.EVENT_BEFORE_POPUPVIEW, eventName: BI.Combo.EVENT_BEFORE_POPUPVIEW,
action: function () { action: function () {
@ -226,38 +225,6 @@ BI.DynamicDateCombo = BI.inherit(BI.Single, {
left: 0, left: 0,
right: 0, right: 0,
bottom: 0 bottom: 0
}, {
el: {
type: "bi.icon_button",
cls: "bi-trigger-icon-button date-font",
width: opts.height - border,
height: opts.height - border,
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;
}
},
top: 0,
left: 0,
right: 0,
bottom: 0
}] }]
}; };
}, },
@ -275,12 +242,12 @@ BI.DynamicDateCombo = BI.inherit(BI.Single, {
switch (type) { switch (type) {
case BI.DynamicDateCombo.Dynamic: case BI.DynamicDateCombo.Dynamic:
this.changeIcon.setVisible(true); this.changeIcon.setVisible(true);
this.comboWrapper.attr("items")[0].width = o.height - this.options.simple ? 1 : 2; // this.comboWrapper.attr("items")[0].width = o.height - this.options.simple ? 1 : 2;
this.comboWrapper.resize(); // this.comboWrapper.resize();
break; break;
default: default:
this.comboWrapper.attr("items")[0].width = 0; // this.comboWrapper.attr("items")[0].width = 0;
this.comboWrapper.resize(); // this.comboWrapper.resize();
this.changeIcon.setVisible(false); this.changeIcon.setVisible(false);
break; break;
} }

11
src/widget/dynamicdate/dynamicdate.trigger.js

@ -13,6 +13,7 @@ BI.DynamicDateTrigger = BI.inherit(BI.Trigger, {
min: "1900-01-01", // 最小日期 min: "1900-01-01", // 最小日期
max: "2099-12-31", // 最大日期 max: "2099-12-31", // 最大日期
height: 24, height: 24,
iconWidth: 24,
format: "", // 显示的日期格式化方式 format: "", // 显示的日期格式化方式
allowEdit: true, // 是否允许编辑 allowEdit: true, // 是否允许编辑
watermark: "" watermark: ""
@ -122,8 +123,12 @@ BI.DynamicDateTrigger = BI.inherit(BI.Trigger, {
items: [{ items: [{
el: this.editor el: this.editor
}, { }, {
el: BI.createWidget(), el: {
width: 24 type: "bi.icon_button",
cls: "bi-trigger-icon-button date-font",
width: o.iconWidth
},
width: o.iconWidth
}] }]
}); });
!o.allowEdit && BI.createWidget({ !o.allowEdit && BI.createWidget({
@ -135,7 +140,7 @@ BI.DynamicDateTrigger = BI.inherit(BI.Trigger, {
title: BI.bind(this._getTitle, this) title: BI.bind(this._getTitle, this)
}, },
left: 0, left: 0,
right: 24, right: o.iconWidth,
top: 0, top: 0,
bottom: 0 bottom: 0
}] }]

84
src/widget/dynamicdatetime/dynamicdatetime.combo.js

@ -36,8 +36,20 @@ BI.DynamicDateTimeCombo = BI.inherit(BI.Single, {
type: "bi.absolute", type: "bi.absolute",
items: [{ items: [{
el: { el: {
type: "bi.htape", type: "bi.combo",
cls: (opts.simple ? "bi-border-bottom" : "bi-border") + " bi-border-radius bi-focus-shadow", cls: (opts.simple ? "bi-border-bottom" : "bi-border") + " bi-border-radius bi-focus-shadow",
destroyWhenHide: true,
container: opts.container,
ref: function () {
self.combo = this;
},
toggle: false,
isNeedAdjustHeight: opts.isNeedAdjustHeight,
isNeedAdjustWidth: opts.isNeedAdjustWidth,
el: {
type: "bi.horizontal_fill",
columnSize: [opts.height - border, "fill"],
height: opts.height - border,
items: [{ items: [{
el: { el: {
type: "bi.icon_button", type: "bi.icon_button",
@ -48,22 +60,7 @@ BI.DynamicDateTimeCombo = BI.inherit(BI.Single, {
self.changeIcon = this; self.changeIcon = this;
} }
}, },
width: opts.height - border
}, { }, {
type: "bi.absolute",
items: [{
el: {
type: "bi.combo",
cls: "bi-focus-shadow",
destroyWhenHide: true,
container: opts.container,
ref: function () {
self.combo = this;
},
toggle: false,
isNeedAdjustHeight: opts.isNeedAdjustHeight,
isNeedAdjustWidth: opts.isNeedAdjustWidth,
el: {
type: "bi.dynamic_date_time_trigger", type: "bi.dynamic_date_time_trigger",
simple: opts.simple, simple: opts.simple,
min: opts.minDate, min: opts.minDate,
@ -71,6 +68,7 @@ BI.DynamicDateTimeCombo = BI.inherit(BI.Single, {
allowEdit: opts.allowEdit, allowEdit: opts.allowEdit,
watermark: opts.watermark, watermark: opts.watermark,
format: opts.format, format: opts.format,
iconWidth: opts.height - border,
height: opts.height - border, height: opts.height - border,
value: opts.value, value: opts.value,
ref: function () { ref: function () {
@ -120,13 +118,13 @@ BI.DynamicDateTimeCombo = BI.inherit(BI.Single, {
month: date.getMonth() + 1 month: date.getMonth() + 1
} }
}; };
self.comboWrapper.element.addClass("error"); self.combo.element.addClass("error");
self.fireEvent(BI.DynamicDateTimeCombo.EVENT_ERROR); self.fireEvent(BI.DynamicDateTimeCombo.EVENT_ERROR);
} }
}, { }, {
eventName: BI.DynamicDateTimeTrigger.EVENT_VALID, eventName: BI.DynamicDateTimeTrigger.EVENT_VALID,
action: function () { action: function () {
self.comboWrapper.element.removeClass("error"); self.combo.element.removeClass("error");
self.fireEvent(BI.DynamicDateTimeCombo.EVENT_VALID); self.fireEvent(BI.DynamicDateTimeCombo.EVENT_VALID);
} }
}, { }, {
@ -153,6 +151,7 @@ BI.DynamicDateTimeCombo = BI.inherit(BI.Single, {
self.fireEvent(BI.DynamicDateTimeCombo.EVENT_CONFIRM); self.fireEvent(BI.DynamicDateTimeCombo.EVENT_CONFIRM);
} }
}] }]
}]
}, },
adjustLength: this.constants.comboAdjustHeight, adjustLength: this.constants.comboAdjustHeight,
popup: { popup: {
@ -215,7 +214,6 @@ BI.DynamicDateTimeCombo = BI.inherit(BI.Single, {
} }
}] }]
}, },
stopPropagation: false
}, },
listeners: [{ listeners: [{
eventName: BI.Combo.EVENT_BEFORE_POPUPVIEW, eventName: BI.Combo.EVENT_BEFORE_POPUPVIEW,
@ -226,42 +224,10 @@ BI.DynamicDateTimeCombo = BI.inherit(BI.Single, {
self.fireEvent(BI.DynamicDateTimeCombo.EVENT_BEFORE_POPUPVIEW); self.fireEvent(BI.DynamicDateTimeCombo.EVENT_BEFORE_POPUPVIEW);
} }
}], }],
// DEC-4250 和复选下拉一样,点击不收起 // // DEC-4250 和复选下拉一样,点击不收起
hideChecker: function (e) { // hideChecker: function (e) {
return self.triggerBtn.element.find(e.target).length === 0; // 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 - border,
height: opts.height - border,
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;
}
}, },
top: 0, top: 0,
left: 0, left: 0,
@ -284,12 +250,12 @@ BI.DynamicDateTimeCombo = BI.inherit(BI.Single, {
switch (type) { switch (type) {
case BI.DynamicDateTimeCombo.Dynamic: case BI.DynamicDateTimeCombo.Dynamic:
this.changeIcon.setVisible(true); this.changeIcon.setVisible(true);
this.comboWrapper.attr("items")[0].width = o.height - this.options.simple ? 1 : 2; // this.comboWrapper.attr("items")[0].width = o.height - (this.options.simple ? 1 : 2);
this.comboWrapper.resize(); // this.comboWrapper.resize();
break; break;
default: default:
this.comboWrapper.attr("items")[0].width = 0; // this.comboWrapper.attr("items")[0].width = 0;
this.comboWrapper.resize(); // this.comboWrapper.resize();
this.changeIcon.setVisible(false); this.changeIcon.setVisible(false);
break; break;
} }

10
src/widget/dynamicdatetime/dynamicdatetime.trigger.js

@ -13,6 +13,7 @@ BI.DynamicDateTimeTrigger = BI.inherit(BI.Trigger, {
min: "1900-01-01", // 最小日期 min: "1900-01-01", // 最小日期
max: "2099-12-31", // 最大日期 max: "2099-12-31", // 最大日期
height: 24, height: 24,
iconWidth: 24,
format: "", // 显示的日期格式化方式 format: "", // 显示的日期格式化方式
allowEdit: true, // 是否允许编辑 allowEdit: true, // 是否允许编辑
watermark: "" watermark: ""
@ -120,8 +121,11 @@ BI.DynamicDateTimeTrigger = BI.inherit(BI.Trigger, {
items: [{ items: [{
el: this.editor el: this.editor
}, { }, {
el: BI.createWidget(), el: {
width: 24 type: "bi.icon_button",
cls: "bi-trigger-icon-button date-font",
},
width: o.iconWidth
}] }]
}); });
@ -134,7 +138,7 @@ BI.DynamicDateTimeTrigger = BI.inherit(BI.Trigger, {
title: BI.bind(this._getTitle, this) title: BI.bind(this._getTitle, this)
}, },
left: 0, left: 0,
right: 24, right: o.iconWidth,
top: 0, top: 0,
bottom: 0 bottom: 0
}] }]

Loading…
Cancel
Save