Merge branch 'master' of https://github.com/AlloyTeam/Nuclear
Conflicts: dist/nuclear.js dist/nuclear.min.js src/nuclear.js
This commit is contained in:
commit
94bd3ddd8b
|
@ -8,15 +8,14 @@ Some HTML + Scoped CSS + JS === Reusable Component
|
|||
|
||||
![preview](http://alloyteam.github.io/Nuclear/img/guide.png)
|
||||
|
||||
We have several examples on [the website](http://alloyteam.github.io/Nuclear/en.html).
|
||||
Several examples on [the website](http://alloyteam.github.io/Nuclear/en.html).
|
||||
|
||||
Performance-testing on [the website](http://alloyteam.github.io/Nuclear/pt/).
|
||||
|
||||
|
||||
# Install
|
||||
|
||||
the file is here: [nuclear.js](https://raw.githubusercontent.com/AlloyTeam/Nuclear/master/dist/nuclear.js) or [nuclear.min.js](https://raw.githubusercontent.com/AlloyTeam/Nuclear/master/dist/nuclear.min.js)
|
||||
|
||||
You can also install it via npm:
|
||||
You can install it via npm:
|
||||
|
||||
```html
|
||||
npm install alloynuclear
|
||||
|
|
|
@ -18,7 +18,8 @@
|
|||
|
||||
var Nuclear={};
|
||||
|
||||
Nuclear.create = function (obj) {
|
||||
Nuclear.create = function (obj, setting) {
|
||||
obj._nuclearSetting = setting;
|
||||
Nuclear._mixObj(obj);
|
||||
var currentEvn = this === Nuclear ? Nuclear.Class : this;
|
||||
var component = currentEvn.extend(obj);
|
||||
|
@ -29,7 +30,11 @@ Nuclear.create = function (obj) {
|
|||
Nuclear._mixObj = function (obj) {
|
||||
obj.ctor = function (option, selector) {
|
||||
this._ncInstanceId=Nuclear.getInstanceId();
|
||||
//加window防止构建到webpack中,Nuclear是局部而非全局
|
||||
this._nuclearTwoWay = true;
|
||||
if(this._nuclearSetting&&this._nuclearSetting.twoWay === false) {
|
||||
this._nuclearTwoWay = false;
|
||||
}
|
||||
//加window防止构建到webpack中,Nuclear是局部而非全局
|
||||
window.Nuclear.instances[this._ncInstanceId] = this;
|
||||
this._nuclearParentEmpty = !selector;
|
||||
this.HTML = "";
|
||||
|
@ -60,7 +65,7 @@ Nuclear._mixObj = function (obj) {
|
|||
this._nuclearTimer = null;
|
||||
this._preNuclearTime = new Date();
|
||||
|
||||
if (this.option) {
|
||||
if (this.option && this._nuclearTwoWay) {
|
||||
Nuclear.observe(this.option, function (prop, value, oldValue, path) {
|
||||
if (!this.onOptionChange||(this.onOptionChange && this.onOptionChange(prop, value, oldValue, path)!==false)) {
|
||||
clearTimeout(this._nuclearTimer);
|
||||
|
@ -124,14 +129,14 @@ Nuclear._mixObj = function (obj) {
|
|||
this.node = null;
|
||||
this.HTML = "";
|
||||
} else {
|
||||
var newNode = Nuclear.str2Dom(this._nuclearWrap(Nuclear.Tpl.render(Nuclear._fixEvent(Nuclear._fixTplIndex(item.tpl), this._ncInstanceId), item.data)));
|
||||
var newNode = Nuclear.str2Dom(this._nuclearWrap(Nuclear.render(Nuclear._fixEvent(Nuclear._fixTplIndex(item.tpl), this._ncInstanceId), item.data)));
|
||||
item.parent.replaceChild(newNode, this.node);
|
||||
this.node = newNode;
|
||||
}
|
||||
} else {
|
||||
//第一次渲染
|
||||
if (!Nuclear.isUndefined(item.tpl)) {
|
||||
item.parent.insertAdjacentHTML("beforeEnd", this._nuclearWrap(Nuclear.Tpl.render(Nuclear._fixEvent(Nuclear._fixTplIndex(item.tpl), this._ncInstanceId), item.data)));
|
||||
item.parent.insertAdjacentHTML("beforeEnd", this._nuclearWrap(Nuclear.render(Nuclear._fixEvent(Nuclear._fixTplIndex(item.tpl), this._ncInstanceId), item.data)));
|
||||
this.node = item.parent.lastChild;
|
||||
}
|
||||
}
|
||||
|
@ -212,7 +217,7 @@ Nuclear._mixObj = function (obj) {
|
|||
var item = this._nuclearRenderInfo, rpLen = item.refreshPart.length;
|
||||
item.tpl = this._nuclearTplGenerator();
|
||||
if (rpLen > 0) {
|
||||
var parts = Nuclear.str2Dom(this._nuclearWrap(Nuclear.Tpl.render(Nuclear._fixEvent(Nuclear._fixTplIndex(item.tpl), this._ncInstanceId), item.data))).querySelectorAll('*[nc-refresh]');
|
||||
var parts = Nuclear.str2Dom(this._nuclearWrap(Nuclear.render(Nuclear._fixEvent(Nuclear._fixTplIndex(item.tpl), this._ncInstanceId), item.data))).querySelectorAll('*[nc-refresh]');
|
||||
for (var j = 0; j < rpLen; j++) {
|
||||
var part = item.refreshPart[j];
|
||||
//执行完replaceChild,原part的parentNode就为null,代表其已经被子节点替换掉了
|
||||
|
@ -320,6 +325,7 @@ Nuclear.instances = {};
|
|||
;(function defineMustache (global, factory) {
|
||||
Nuclear.Tpl = {};
|
||||
factory(Nuclear.Tpl); // script, wsh, asp
|
||||
Nuclear.render=Nuclear.Tpl.render;
|
||||
}(this, function mustacheFactory (mustache) {
|
||||
|
||||
var objectToString = Object.prototype.toString;
|
||||
|
@ -1201,6 +1207,7 @@ Nuclear.Class.extend = function (prop) {
|
|||
|
||||
|
||||
if ("scoped" in document.createElement("style")) {
|
||||
Nuclear.refreshStyle= function(){};
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -9,7 +9,7 @@
|
|||
<script src="../dist/nuclear.js"></script>
|
||||
<script src="../asset/arttemplate.js"></script>
|
||||
<script>
|
||||
Nuclear.Tpl.render=function(tpl,data){
|
||||
Nuclear.render=function(tpl,data){
|
||||
return template.compile(tpl)(data);
|
||||
};
|
||||
</script>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "alloynuclear",
|
||||
"version": "0.1.3",
|
||||
"version": "0.1.7",
|
||||
"description": "made UI super easy.",
|
||||
"main": "nuclear.js",
|
||||
"scripts": {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
var Nuclear={};
|
||||
|
||||
Nuclear.create = function (obj) {
|
||||
Nuclear.create = function (obj, setting) {
|
||||
obj._nuclearSetting = setting;
|
||||
Nuclear._mixObj(obj);
|
||||
var currentEvn = this === Nuclear ? Nuclear.Class : this;
|
||||
var component = currentEvn.extend(obj);
|
||||
|
@ -11,7 +12,11 @@ Nuclear.create = function (obj) {
|
|||
Nuclear._mixObj = function (obj) {
|
||||
obj.ctor = function (option, selector) {
|
||||
this._ncInstanceId=Nuclear.getInstanceId();
|
||||
//加window防止构建到webpack中,Nuclear是局部而非全局
|
||||
this._nuclearTwoWay = true;
|
||||
if(this._nuclearSetting&&this._nuclearSetting.twoWay === false) {
|
||||
this._nuclearTwoWay = false;
|
||||
}
|
||||
//加window防止构建到webpack中,Nuclear是局部而非全局
|
||||
window.Nuclear.instances[this._ncInstanceId] = this;
|
||||
this._nuclearParentEmpty = !selector;
|
||||
this.HTML = "";
|
||||
|
@ -42,7 +47,7 @@ Nuclear._mixObj = function (obj) {
|
|||
this._nuclearTimer = null;
|
||||
this._preNuclearTime = new Date();
|
||||
|
||||
if (this.option) {
|
||||
if (this.option && this._nuclearTwoWay) {
|
||||
Nuclear.observe(this.option, function (prop, value, oldValue, path) {
|
||||
if (!this.onOptionChange||(this.onOptionChange && this.onOptionChange(prop, value, oldValue, path)!==false)) {
|
||||
clearTimeout(this._nuclearTimer);
|
||||
|
@ -106,14 +111,14 @@ Nuclear._mixObj = function (obj) {
|
|||
this.node = null;
|
||||
this.HTML = "";
|
||||
} else {
|
||||
var newNode = Nuclear.str2Dom(this._nuclearWrap(Nuclear.Tpl.render(Nuclear._fixEvent(Nuclear._fixTplIndex(item.tpl), this._ncInstanceId), item.data)));
|
||||
var newNode = Nuclear.str2Dom(this._nuclearWrap(Nuclear.render(Nuclear._fixEvent(Nuclear._fixTplIndex(item.tpl), this._ncInstanceId), item.data)));
|
||||
item.parent.replaceChild(newNode, this.node);
|
||||
this.node = newNode;
|
||||
}
|
||||
} else {
|
||||
//第一次渲染
|
||||
if (!Nuclear.isUndefined(item.tpl)) {
|
||||
item.parent.insertAdjacentHTML("beforeEnd", this._nuclearWrap(Nuclear.Tpl.render(Nuclear._fixEvent(Nuclear._fixTplIndex(item.tpl), this._ncInstanceId), item.data)));
|
||||
item.parent.insertAdjacentHTML("beforeEnd", this._nuclearWrap(Nuclear.render(Nuclear._fixEvent(Nuclear._fixTplIndex(item.tpl), this._ncInstanceId), item.data)));
|
||||
this.node = item.parent.lastChild;
|
||||
}
|
||||
}
|
||||
|
@ -194,7 +199,7 @@ Nuclear._mixObj = function (obj) {
|
|||
var item = this._nuclearRenderInfo, rpLen = item.refreshPart.length;
|
||||
item.tpl = this._nuclearTplGenerator();
|
||||
if (rpLen > 0) {
|
||||
var parts = Nuclear.str2Dom(this._nuclearWrap(Nuclear.Tpl.render(Nuclear._fixEvent(Nuclear._fixTplIndex(item.tpl), this._ncInstanceId), item.data))).querySelectorAll('*[nc-refresh]');
|
||||
var parts = Nuclear.str2Dom(this._nuclearWrap(Nuclear.render(Nuclear._fixEvent(Nuclear._fixTplIndex(item.tpl), this._ncInstanceId), item.data))).querySelectorAll('*[nc-refresh]');
|
||||
for (var j = 0; j < rpLen; j++) {
|
||||
var part = item.refreshPart[j];
|
||||
//执行完replaceChild,原part的parentNode就为null,代表其已经被子节点替换掉了
|
||||
|
|
|
@ -86,6 +86,7 @@
|
|||
|
||||
|
||||
if ("scoped" in document.createElement("style")) {
|
||||
Nuclear.refreshStyle= function(){};
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
;(function defineMustache (global, factory) {
|
||||
Nuclear.Tpl = {};
|
||||
factory(Nuclear.Tpl); // script, wsh, asp
|
||||
Nuclear.render=Nuclear.Tpl.render;
|
||||
}(this, function mustacheFactory (mustache) {
|
||||
|
||||
var objectToString = Object.prototype.toString;
|
||||
|
|
Loading…
Reference in New Issue