Browse Source

Merge pull request #201964 in DEC/fineui from master to feature/x

* commit '5f176349c13c1e156646e05e95e7de3219b4f86b':
  KERNEL-13158: 优化下useContext
master
superman 2 years ago
parent
commit
a9615f5501
  1. 7
      examples/useContext.html
  2. 7
      src/base/combination/group.button.js
  3. 2
      src/base/combination/navigation.js
  4. 2
      src/base/combination/tab.js
  5. 8
      src/core/4.widget.js
  6. 4
      src/widget/date/calendar/popup.month.js

7
examples/useContext.html

@ -5,8 +5,8 @@
<!-- <link rel="stylesheet" type="text/css" href="../dist/2.0/fineui.min.css"/> <!-- <link rel="stylesheet" type="text/css" href="../dist/2.0/fineui.min.css"/>
<script src="../dist/2.0/fineui.js"></script> --> <script src="../dist/2.0/fineui.js"></script> -->
<link rel="stylesheet" type="text/css" href="http://fanruan.design/fineui/2.0/fineui.min.css"/> <link rel="stylesheet" type="text/css" href="http://fanruan.design/fineui/2.0/fineui.min.css"/>
<script src="http://fanruan.design/fineui/2.0/fineui.min.js"></script> <!-- <script src="http://fanruan.design/fineui/2.0/fineui.min.js"></script>-->
<!-- <script src="http://localhost:9001/fineui.js"></script>--> <script src="http://localhost:9001/fineui.js"></script>
</head> </head>
<style> <style>
.my-parent { .my-parent {
@ -50,6 +50,9 @@
if (!BI.isNumber(pix)) { if (!BI.isNumber(pix)) {
return pix; return pix;
} }
if (border > 0) {
return "calc(var(--css-scale) * " + pix + "px" + " - " + border + "px"+")";
}
return "calc(var(--css-scale) * " + pix + "px)"; return "calc(var(--css-scale) * " + pix + "px)";
}; };

7
src/base/combination/group.button.js

@ -42,9 +42,12 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
}, },
_createBtns: function (items) { _createBtns: function (items) {
return BI.createWidgets(BI.createItems(items, { BI.Widget.pushContext(this);
var btns = BI.createWidgets(BI.createItems(items, {
type: "bi.text_button", type: "bi.text_button",
}), this); }));
BI.Widget.popContext();
return btns;
}, },
_btnsCreator: function (items) { _btnsCreator: function (items) {

2
src/base/combination/navigation.js

@ -104,7 +104,9 @@ BI.Navigation = BI.inherit(BI.Widget, {
_assertCard: function (v) { _assertCard: function (v) {
if (!this.layout.isCardExisted(v)) { if (!this.layout.isCardExisted(v)) {
BI.Widget.pushContext(this);
var card = this.options.cardCreator(v); var card = this.options.cardCreator(v);
BI.Widget.popContext();
this.cardMap[v] = card; this.cardMap[v] = card;
this.layout.addCardByName(v, card); this.layout.addCardByName(v, card);
this.afterCardCreated(v); this.afterCardCreated(v);

2
src/base/combination/tab.js

@ -72,7 +72,9 @@ BI.Tab = BI.inherit(BI.Widget, {
_assertCard: function (v) { _assertCard: function (v) {
if (!this.layout.isCardExisted(v)) { if (!this.layout.isCardExisted(v)) {
BI.Widget.pushContext(this);
var card = this.options.cardCreator(v); var card = this.options.cardCreator(v);
BI.Widget.popContext();
this.cardMap[v] = card; this.cardMap[v] = card;
this.layout.addCardByName(v, card); this.layout.addCardByName(v, card);
} }

8
src/core/4.widget.js

@ -288,14 +288,18 @@
_initElementWidth: function () { _initElementWidth: function () {
var o = this.options; var o = this.options;
if (BI.isWidthOrHeight(o.width)) { if (BI.isArray(o.width)) {
this.element.css("width", BI.pixFormat(...o.width));
} else if (BI.isWidthOrHeight(o.width)) {
this.element.css("width", BI.isNumber(o.width) ? BI.pixFormat(o.width) : o.width); this.element.css("width", BI.isNumber(o.width) ? BI.pixFormat(o.width) : o.width);
} }
}, },
_initElementHeight: function () { _initElementHeight: function () {
var o = this.options; var o = this.options;
if (BI.isWidthOrHeight(o.height)) { if (BI.isArray(o.height)) {
this.element.css("height", BI.pixFormat(...o.height));
} else if (BI.isWidthOrHeight(o.height)) {
this.element.css("height", BI.isNumber(o.height) ? BI.pixFormat(o.height) : o.height); this.element.css("height", BI.isNumber(o.height) ? BI.pixFormat(o.height) : o.height);
} }
}, },

4
src/widget/date/calendar/popup.month.js

@ -67,7 +67,7 @@ BI.MonthPopup = BI.inherit(BI.Widget, {
whiteSpace: "nowrap", whiteSpace: "nowrap",
once: false, once: false,
forceSelected: true, forceSelected: true,
height: BI.pixFormat(BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, 1), height: [BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, 1],
width: 30, width: 30,
value: td, value: td,
text: td, text: td,
@ -94,4 +94,4 @@ BI.MonthPopup = BI.inherit(BI.Widget, {
} }
}); });
BI.MonthPopup.EVENT_CHANGE = "EVENT_CHANGE"; BI.MonthPopup.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.month_popup", BI.MonthPopup); BI.shortcut("bi.month_popup", BI.MonthPopup);

Loading…
Cancel
Save