You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
109 lines
2.8 KiB
109 lines
2.8 KiB
4 years ago
|
<html>
|
||
|
<head>
|
||
|
<meta charset="utf-8">
|
||
|
<title></title>
|
||
4 years ago
|
<link rel="stylesheet" type="text/css" href="../dist/2.0/fineui.css"/>
|
||
|
<!-- <script src="../dist/2.0/fineui.js"></script>-->
|
||
4 years ago
|
<script src="http://localhost:9001/fineui.js"></script>
|
||
|
</head>
|
||
|
<body>
|
||
|
<div id="wrapper"></div>
|
||
|
<script>
|
||
|
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 store = BI.useStore(function () {
|
||
|
return BI.Models.getModel("demo.child_model");
|
||
|
});
|
||
|
return {
|
||
|
render: function () {
|
||
|
return {
|
||
|
type: "bi.vertical",
|
||
|
items: [{
|
||
|
type: "bi.button",
|
||
|
text: store.model.text
|
||
|
}, {
|
||
|
type: "bi.label",
|
||
|
text: store.model.text
|
||
|
}]
|
||
|
};
|
||
|
}
|
||
|
};
|
||
|
}
|
||
|
});
|
||
|
BI.shortcut("demo.child", Child);
|
||
|
|
||
|
var Widget = BI.inherit(BI.Widget, {
|
||
|
props: {
|
||
|
updateMode: "auto"
|
||
|
},
|
||
|
setup: function () {
|
||
4 years ago
|
var child;
|
||
4 years ago
|
var store = BI.useStore(function () {
|
||
|
return BI.Models.getModel("demo.model");
|
||
|
});
|
||
4 years ago
|
setInterval(function () {
|
||
|
store.toggle();
|
||
|
}, 1000);
|
||
4 years ago
|
BI.watch("text", function () {
|
||
|
child.populate();
|
||
|
});
|
||
4 years ago
|
return function () {
|
||
|
return {
|
||
|
type: "bi.vertical",
|
||
|
vgap: 20,
|
||
4 years ago
|
items: [{
|
||
4 years ago
|
type: "demo.child",
|
||
|
ref: function (_ref) {
|
||
|
child = _ref;
|
||
|
}
|
||
4 years ago
|
}, {
|
||
|
type: "demo.child"
|
||
|
}]
|
||
4 years ago
|
};
|
||
|
};
|
||
|
}
|
||
|
});
|
||
|
BI.shortcut("demo.parent", Widget);
|
||
4 years ago
|
BI.createWidget({
|
||
4 years ago
|
type: "bi.absolute",
|
||
|
items: [{
|
||
|
el: {
|
||
|
type: "demo.parent"
|
||
|
},
|
||
|
top: 100,
|
||
|
left: 100
|
||
|
}],
|
||
|
element: "#wrapper"
|
||
|
});
|
||
|
</script>
|
||
|
</body>
|
||
|
</html>
|