Browse Source

Pull request #2072: 无JIRA任务 loader的特殊context处理可以去掉了

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

* commit '900588428b96198d12deb3829957a7dd6a61447a':
  loader的context处理可以去掉了
es6
guy 3 years ago
parent
commit
895d920722
  1. 18
      dist/fix/fix.compact.ie.js
  2. 26
      dist/fix/fix.compact.js
  3. 124
      examples/loader-context.html
  4. 7
      examples/tab-context.html
  5. 2
      src/base/combination/group.button.js
  6. 2
      src/core/2.base.js

18
dist/fix/fix.compact.ie.js vendored

@ -93,15 +93,15 @@
}
}
_.each(["populate", "addItems", "prependItems"], function (name) {
var old = BI.Loader.prototype[name];
BI.Loader.prototype[name] = function () {
BI.Widget.pushContext(this);
var result = old.apply(this, arguments);
BI.Widget.popContext();
return result;
};
});
// _.each(["populate", "addItems", "prependItems"], function (name) {
// var old = BI.Loader.prototype[name];
// BI.Loader.prototype[name] = function () {
// BI.Widget.pushContext(this);
// var result = old.apply(this, arguments);
// BI.Widget.popContext();
// return result;
// };
// });
function createStore () {
var needPop = false;

26
dist/fix/fix.compact.js vendored

@ -97,19 +97,19 @@
}
}
_.each(["populate", "addItems", "prependItems"], function (name) {
var old = BI.Loader.prototype[name];
BI.Loader.prototype[name] = function () {
BI.Widget.pushContext(this);
try {
var result = old.apply(this, arguments);
} catch (e) {
console.error(e);
}
BI.Widget.popContext();
return result;
};
});
// _.each(["populate", "addItems", "prependItems"], function (name) {
// var old = BI.Loader.prototype[name];
// BI.Loader.prototype[name] = function () {
// BI.Widget.pushContext(this);
// try {
// var result = old.apply(this, arguments);
// } catch (e) {
// console.error(e);
// }
// BI.Widget.popContext();
// return result;
// };
// });
function createStore () {
var needPop = false;

124
examples/loader-context.html

@ -0,0 +1,124 @@
<html>
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" type="text/css" href="../dist/2.0/fineui.css"/>
<script src="../dist/2.0/fineui.js"></script>
</head>
<body>
<div id="wrapper"></div>
<script>
// tab上下文环境测试
var Model = BI.inherit(Fix.Model, {
state: function () {
return {
expand: false
};
},
childContext: ["text"],
computed: {
text: function () {
return this.model.expand ? "text-yes" : "text-not";
}
},
actions: {
toggle: function () {
this.model.expand = !this.model.expand;
}
}
});
BI.model("demo.model", Model);
var ChildModel = BI.inherit(Fix.Model, {
context: ["text"]
});
BI.model("demo.child_model", ChildModel);
var Child = BI.inherit(BI.Widget, {
setup: function () {
var label
var store = BI.useStore(function () {
return BI.Models.getModel("demo.child_model");
});
BI.watch("text", function (text) {
label.setText(text)
});
return {
render: function () {
return {
type: "bi.label",
ref: function (_ref) {
label = _ref;
},
text: store.model.text
};
}
};
}
});
BI.shortcut("demo.child", Child);
var Widget = BI.inherit(BI.Widget, {
props: {
updateMode: "auto"
},
setup: function () {
var child, loader;
var store = BI.useStore(function () {
return BI.Models.getModel("demo.model");
});
setInterval(function () {
store.toggle();
}, 1000);
BI.watch("text", function () {
// child.reset();
});
return function () {
return {
type: "bi.vertical",
vgap: 20,
items: [{
type: "demo.child",
ref: function (_ref) {
child = _ref;
}
}, {
type: "bi.button",
text: "点击加载",
handler: function () {
loader.populate();
}
}, {
type: "bi.loader",
isDefaultInit: false,
itemsCreator: function (op, callback) {
callback([{
type: "demo.child"
}]);
},
ref: function (_ref) {
loader = _ref
}
}]
};
};
}
});
BI.shortcut("demo.parent", Widget);
BI.createWidget({
type: "bi.absolute",
items: [{
el: {
type: "demo.parent"
},
top: 100,
left: 100
}],
element: "#wrapper"
});
</script>
</body>
</html>

7
examples/tab-context.html

@ -39,13 +39,20 @@
var Child = BI.inherit(BI.Widget, {
setup: function () {
var label
var store = BI.useStore(function () {
return BI.Models.getModel("demo.child_model");
});
BI.watch("text", function (text) {
label.setText(text)
});
return {
render: function () {
return {
type: "bi.label",
ref: function (_ref) {
label = _ref;
},
text: store.model.text
};
}

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

@ -40,7 +40,7 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
var o = this.options;
return BI.createWidgets(BI.createItems(items, {
type: "bi.text_button"
}));
}), this);
},
_btnsCreator: function (items) {

2
src/core/2.base.js

@ -84,7 +84,7 @@ if (!_global.BI) {
options || (options = {});
}
return BI.map(BI.flatten(items), function (i, item) {
return BI.createWidget(item, BI.deepClone(options));
return BI.createWidget(item, BI.deepClone(options), context);
});
},

Loading…
Cancel
Save