Browse Source

Pull request #3145: KERNEL-13158: 优化下useContext

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

* commit '09ddab0130c9dff8f4c64dd8b7e7b0a5e6858eb0':
  KERNEL-13158: 优化下useContext
es6
guy-王川 2 years ago
parent
commit
5f176349c1
  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. 2
      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);
} }
}, },

2
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,

Loading…
Cancel
Save