Browse Source

chore: 整理代码

es6
guy 3 years ago
parent
commit
fb3c102632
  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 {
.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",
items: [{
el: {
type: "bi.htape",
type: "bi.combo",
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: [{
el: {
type: "bi.icon_button",
@ -48,21 +60,7 @@ BI.DynamicDateCombo = BI.inherit(BI.Single, {
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",
simple: opts.simple,
min: opts.minDate,
@ -70,6 +68,7 @@ BI.DynamicDateCombo = BI.inherit(BI.Single, {
format: opts.format,
allowEdit: opts.allowEdit,
watermark: opts.watermark,
iconWidth: opts.height - border,
height: opts.height - border,
value: opts.value,
ref: function () {
@ -114,13 +113,13 @@ BI.DynamicDateCombo = BI.inherit(BI.Single, {
month: date.getMonth() + 1
}
};
self.comboWrapper.element.addClass("error");
self.combo.element.addClass("error");
self.fireEvent(BI.DynamicDateCombo.EVENT_ERROR);
}
}, {
eventName: BI.DynamicDateTrigger.EVENT_VALID,
action: function () {
self.comboWrapper.element.removeClass("error");
self.combo.element.removeClass("error");
self.fireEvent(BI.DynamicDateCombo.EVENT_VALID);
}
}, {
@ -147,6 +146,7 @@ BI.DynamicDateCombo = BI.inherit(BI.Single, {
self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM);
}
}]
}]
},
adjustLength: this.constants.comboAdjustHeight,
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: [{
eventName: BI.Combo.EVENT_BEFORE_POPUPVIEW,
action: function () {
@ -226,38 +225,6 @@ BI.DynamicDateCombo = BI.inherit(BI.Single, {
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,
left: 0,
right: 0,
bottom: 0
}]
};
},
@ -275,12 +242,12 @@ 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.options.simple ? 1 : 2;
this.comboWrapper.resize();
// this.comboWrapper.attr("items")[0].width = o.height - this.options.simple ? 1 : 2;
// this.comboWrapper.resize();
break;
default:
this.comboWrapper.attr("items")[0].width = 0;
this.comboWrapper.resize();
// this.comboWrapper.attr("items")[0].width = 0;
// this.comboWrapper.resize();
this.changeIcon.setVisible(false);
break;
}

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

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

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

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

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

@ -13,6 +13,7 @@ BI.DynamicDateTimeTrigger = BI.inherit(BI.Trigger, {
min: "1900-01-01", // 最小日期
max: "2099-12-31", // 最大日期
height: 24,
iconWidth: 24,
format: "", // 显示的日期格式化方式
allowEdit: true, // 是否允许编辑
watermark: ""
@ -120,8 +121,11 @@ BI.DynamicDateTimeTrigger = BI.inherit(BI.Trigger, {
items: [{
el: this.editor
}, {
el: BI.createWidget(),
width: 24
el: {
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)
},
left: 0,
right: 24,
right: o.iconWidth,
top: 0,
bottom: 0
}]

Loading…
Cancel
Save