From 129819b22e6871b6e154d7ccd3fdb8c2b011940b Mon Sep 17 00:00:00 2001 From: guy Date: Wed, 19 Oct 2022 16:24:29 +0800 Subject: [PATCH] =?UTF-8?q?feature=EF=BC=9A=E4=BC=98=E5=8C=96=E5=B8=83?= =?UTF-8?q?=E5=B1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/widget/timeinterval/dateinterval.js | 51 +++++-------- src/widget/timeinterval/timeinterval.js | 51 +++++-------- src/widget/timeinterval/timeperiods.js | 73 ++++++------------- src/widget/yearinterval/yearinterval.js | 46 ++++-------- .../yearmonthinterval/yearmonthinterval.js | 52 +++++-------- .../yearquarterinterval.js | 47 ++++-------- template/index.html | 1 - 7 files changed, 103 insertions(+), 218 deletions(-) diff --git a/src/widget/timeinterval/dateinterval.js b/src/widget/timeinterval/dateinterval.js index f6b2176c6..8da68b143 100644 --- a/src/widget/timeinterval/dateinterval.js +++ b/src/widget/timeinterval/dateinterval.js @@ -26,43 +26,26 @@ BI.DateInterval = BI.inherit(BI.Single, { o.value = o.value || {}; this.left = this._createCombo(o.value.start, o.watermark?.start); this.right = this._createCombo(o.value.end, o.watermark?.end); - this.label = BI.createWidget({ - type: "bi.label", - height: o.height, - width: this.constants.width, - text: "-" - }); - BI.createWidget({ - element: self, - type: "bi.center", - height: o.height, + + return { + type: "bi.horizontal_fill", + columnSize: ["fill", "", "fill"], items: [{ - type: "bi.absolute", - items: [{ - el: self.left, - left: this.constants.offset, - right: this.constants.width / 2, - top: 0, - bottom: 0 - }] + el: self.left }, { - type: "bi.absolute", - items: [{ - el: self.right, - left: this.constants.width / 2, - right: this.constants.offset, - top: 0, - bottom: 0 - }] + el: { + type: "bi.label", + height: o.height, + hgap: 5, + text: "-", + ref: function (_ref) { + self.label = _ref; + } + } + }, { + el: self.right }] - }); - BI.createWidget({ - type: "bi.horizontal_auto", - element: this, - items: [ - self.label - ] - }); + }; }, _createCombo: function (v, watermark) { diff --git a/src/widget/timeinterval/timeinterval.js b/src/widget/timeinterval/timeinterval.js index 3910c77e8..00d3b63cb 100644 --- a/src/widget/timeinterval/timeinterval.js +++ b/src/widget/timeinterval/timeinterval.js @@ -26,43 +26,26 @@ BI.TimeInterval = BI.inherit(BI.Single, { o.value = o.value || {}; this.left = this._createCombo(o.value.start, o.watermark?.start); this.right = this._createCombo(o.value.end, o.watermark?.end); - this.label = BI.createWidget({ - type: "bi.label", - height: o.height, - width: this.constants.width, - text: "-" - }); - BI.createWidget({ - element: self, - type: "bi.center", - height: o.height, + + return { + type: "bi.horizontal_fill", + columnSize: ["fill", "", "fill"], items: [{ - type: "bi.absolute", - items: [{ - el: self.left, - left: this.constants.offset, - right: this.constants.width / 2, - top: 0, - bottom: 0 - }] + el: self.left }, { - type: "bi.absolute", - items: [{ - el: self.right, - left: this.constants.width / 2, - right: this.constants.offset, - top: 0, - bottom: 0 - }] + el: { + type: "bi.label", + height: o.height, + hgap: 5, + text: "-", + ref: function (_ref) { + self.label = _ref; + } + } + }, { + el: self.right }] - }); - BI.createWidget({ - type: "bi.horizontal_auto", - element: this, - items: [ - self.label - ] - }); + }; }, _createCombo: function (v, watermark) { diff --git a/src/widget/timeinterval/timeperiods.js b/src/widget/timeinterval/timeperiods.js index 5a0edf56d..4e04533bf 100644 --- a/src/widget/timeinterval/timeperiods.js +++ b/src/widget/timeinterval/timeperiods.js @@ -19,63 +19,32 @@ render: function () { var self = this, o = this.options; + return { - type: "bi.absolute", - height: o.height, + type: "bi.horizontal_fill", + columnSize: ["fill", "", "fill"], items: [{ - el: { - type: "bi.horizontal_auto", - items: [{ - type: "bi.label", - height: o.height, - width: this.constants.width, - text: "-", - ref: function (_ref) { - self.label = _ref; - } - }] - }, - top: 0, - left: 0, - right: 0, - bottom: 0 + el: BI.extend({ + ref: function (_ref) { + self.left = _ref; + } + }, this._createCombo(o.value.start, o.watermark?.start)) }, { el: { - type: "bi.center", + type: "bi.label", height: o.height, - hgap: this.constants.hgap, - items: [{ - type: "bi.absolute", - items: [{ - el: BI.extend({ - ref: function (_ref) { - self.left = _ref; - } - }, this._createCombo(o.value.start, o.watermark?.start)), - left: this.constants.offset, - right: 0, - top: 0, - bottom: 0, - }] - }, { - type: "bi.absolute", - items: [{ - el: BI.extend({ - ref: function (_ref) { - self.right = _ref; - } - }, this._createCombo(o.value.end, o.watermark?.end)), - left: 0, - right: this.constants.offset, - top: 0, - bottom: 0, - }] - }] - }, - top: 0, - left: 0, - right: 0, - bottom: 0 + hgap: 5, + text: "-", + ref: function (_ref) { + self.label = _ref; + } + } + }, { + el: BI.extend({ + ref: function (_ref) { + self.right = _ref; + } + }, this._createCombo(o.value.end, o.watermark?.end)) }] }; }, diff --git a/src/widget/yearinterval/yearinterval.js b/src/widget/yearinterval/yearinterval.js index 9f48d7f5f..56756e60c 100644 --- a/src/widget/yearinterval/yearinterval.js +++ b/src/widget/yearinterval/yearinterval.js @@ -26,41 +26,25 @@ BI.YearInterval = BI.inherit(BI.Single, { this.left = this._createCombo(o.value.start, o.watermark?.start); this.right = this._createCombo(o.value.end, o.watermark?.end); - return [{ - type: "bi.center", - hgap: 15, - height: o.height, + return { + type: "bi.horizontal_fill", + columnSize: ["fill", "", "fill"], items: [{ - type: "bi.absolute", - items: [{ - el: self.left, - left: this.constants.offset, - right: 0, - top: 0, - bottom: 0 - }] + el: self.left }, { - type: "bi.absolute", - items: [{ - el: self.right, - left: 0, - right: this.constants.offset, - top: 0, - bottom: 0 - }] - }] - }, { - type: "bi.horizontal_auto", - items: [{ - type: "bi.label", - height: o.height, - width: this.constants.width, - text: "-", - ref: function (_ref) { - self.label = _ref; + el: { + type: "bi.label", + height: o.height, + hgap: 5, + text: "-", + ref: function (_ref) { + self.label = _ref; + } } + }, { + el: self.right }] - }] + }; }, _createCombo: function (v, watermark) { diff --git a/src/widget/yearmonthinterval/yearmonthinterval.js b/src/widget/yearmonthinterval/yearmonthinterval.js index 85e982e22..d32dbb096 100644 --- a/src/widget/yearmonthinterval/yearmonthinterval.js +++ b/src/widget/yearmonthinterval/yearmonthinterval.js @@ -21,44 +21,26 @@ BI.YearMonthInterval = BI.inherit(BI.Single, { o.value = o.value || {}; this.left = this._createCombo(o.value.start, o.watermark?.start); this.right = this._createCombo(o.value.end, o.watermark?.end); - this.label = BI.createWidget({ - type: "bi.label", - height: o.height, - width: this.constants.width, - text: "-" - }); - BI.createWidget({ - element: self, - type: "bi.center", - hgap: 15, - height: o.height, + + return { + type: "bi.horizontal_fill", + columnSize: ["fill", "", "fill"], items: [{ - type: "bi.absolute", - items: [{ - el: self.left, - left: this.constants.offset, - right: 0, - top: 0, - bottom: 0 - }] + el: self.left }, { - type: "bi.absolute", - items: [{ - el: self.right, - left: 0, - right: this.constants.offset, - top: 0, - bottom: 0 - }] + el: { + type: "bi.label", + height: o.height, + hgap: 5, + text: "-", + ref: function (_ref) { + self.label = _ref; + } + } + }, { + el: self.right }] - }); - BI.createWidget({ - type: "bi.horizontal_auto", - element: this, - items: [ - self.label - ] - }); + }; }, _createCombo: function (v, watermark) { diff --git a/src/widget/yearquarterinterval/yearquarterinterval.js b/src/widget/yearquarterinterval/yearquarterinterval.js index f23134a09..02a0c67d7 100644 --- a/src/widget/yearquarterinterval/yearquarterinterval.js +++ b/src/widget/yearquarterinterval/yearquarterinterval.js @@ -26,41 +26,26 @@ BI.YearQuarterInterval = BI.inherit(BI.Single, { this.left = this._createCombo(o.value.start, o.watermark?.start); this.right = this._createCombo(o.value.end, o.watermark?.end); - return [{ - type: "bi.center", - hgap: 15, - height: o.height, + + return { + type: "bi.horizontal_fill", + columnSize: ["fill", "", "fill"], items: [{ - type: "bi.absolute", - items: [{ - el: self.left, - left: this.constants.offset, - right: 0, - top: 0, - bottom: 0 - }] + el: self.left }, { - type: "bi.absolute", - items: [{ - el: self.right, - left: 0, - right: this.constants.offset, - top: 0, - bottom: 0 - }] - }] - }, { - type: "bi.horizontal_auto", - items: [{ - type: "bi.label", - height: o.height, - width: this.constants.width, - text: "-", - ref: function (_ref) { - self.label = _ref; + el: { + type: "bi.label", + height: o.height, + hgap: 5, + text: "-", + ref: function (_ref) { + self.label = _ref; + } } + }, { + el: self.right }] - }] + }; }, _createCombo: function (v, watermark) { diff --git a/template/index.html b/template/index.html index 2d98bda7b..bcf5ad41a 100644 --- a/template/index.html +++ b/template/index.html @@ -1,4 +1,3 @@ -