Browse Source

KERNEL-13158: 优化下useContext

es6
guy 2 years ago
parent
commit
fb1e854877
  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"/>
<script src="../dist/2.0/fineui.js"></script> -->
<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://localhost:9001/fineui.js"></script>-->
<!-- <script src="http://fanruan.design/fineui/2.0/fineui.min.js"></script>-->
<script src="http://localhost:9001/fineui.js"></script>
</head>
<style>
.my-parent {
@ -50,6 +50,9 @@
if (!BI.isNumber(pix)) {
return pix;
}
if (border > 0) {
return "calc(var(--css-scale) * " + pix + "px" + " - " + border + "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) {
return BI.createWidgets(BI.createItems(items, {
BI.Widget.pushContext(this);
var btns = BI.createWidgets(BI.createItems(items, {
type: "bi.text_button",
}), this);
}));
BI.Widget.popContext();
return btns;
},
_btnsCreator: function (items) {

2
src/base/combination/navigation.js

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

2
src/base/combination/tab.js

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

8
src/core/4.widget.js

@ -288,14 +288,18 @@
_initElementWidth: function () {
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);
}
},
_initElementHeight: function () {
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);
}
},

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

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

Loading…
Cancel
Save