dresscode-botex
Advanced tools
Comparing version 0.0.20 to 0.0.21
@@ -10,2 +10,8 @@ Botex.ElemsStore = Bricks.inherit(Bricks.Component, { | ||
this._childs.push(child); | ||
child.getAllElems().forEach(function(item) { | ||
this._fireEvent('addelem', { | ||
name: item.name, | ||
elem: item.elem | ||
}); | ||
}, this); | ||
this._on(child, 'addelem', this.$$_onChildAddElem); | ||
@@ -19,2 +25,8 @@ this._on(child, 'removeelem', this.$$_onChildRemoveElem); | ||
this._un(child, 'removeelem', this.$$_onChildRemoveElem); | ||
child.getAllElems().forEach(function(item) { | ||
this._fireEvent('removeelem', { | ||
name: item.name, | ||
elem: item.elem | ||
}); | ||
}, this); | ||
}, | ||
@@ -52,4 +64,17 @@ | ||
getAllElems: function() { | ||
var elems = []; | ||
Pony.Object.keys(this._elems).forEach(function(name) { | ||
this._elems[name].forEach(function(elem) { | ||
elems.push({name: name, elem: elem}); | ||
}, this); | ||
}, this); | ||
this._childs.forEach(function(child) { | ||
[].push.apply(elems, child.getAllElems()); | ||
}); | ||
return elems; | ||
}, | ||
removeAllElems: function() { | ||
Object.keys(this._elems).forEach(function(name) { | ||
Pony.Object.keys(this._elems).forEach(function(name) { | ||
var elems = this._elems[name]; | ||
@@ -56,0 +81,0 @@ this._elems[name] = []; |
@@ -271,7 +271,2 @@ Botex.Widget = Bricks.inherit(Botex.Tag, { | ||
_appendContent: function(container, beforeEl, content) { | ||
if (beforeEl && typeof beforeEl.insertAdjacentHTML !== 'function') { | ||
var fantom = this._doc.createElement('div'); | ||
container.insertBefore(fantom, beforeEl); | ||
} | ||
if (content instanceof Quantum.Quant) { | ||
@@ -289,9 +284,9 @@ content = new Botex.WidgetMutable({ | ||
content.forEach(function(item) { | ||
this._appendContent(container, fantom || beforeEl, item); | ||
this._appendContent(container, beforeEl, item); | ||
}, this); | ||
} else if (content instanceof Botex.Widget) { | ||
this._registerChild(content); | ||
content.mount(container, fantom || beforeEl); | ||
content.mount(container, beforeEl); | ||
} else if (content instanceof Botex.Tag) { | ||
this._createElement(content.getMeta(), container, fantom || beforeEl); | ||
this._createElement(content.getMeta(), container, beforeEl); | ||
} else if (content && content.ownerDocument === this._doc) { | ||
@@ -301,18 +296,19 @@ container.insertBefore(content, beforeEl); | ||
if (content !== null && content !== undefined) { | ||
if (typeof content === 'string') { | ||
content = Bricks.String.escapeHTML(content); | ||
content = typeof content === 'string' ? Bricks.String.escapeHTML(content) : String(content); | ||
if (content) { | ||
if (beforeEl) { | ||
if (typeof beforeEl.insertAdjacentHTML === 'function') { | ||
beforeEl.insertAdjacentHTML('beforebegin', content); | ||
} else { | ||
var fantom = this._doc.createElement('div'); | ||
container.insertBefore(fantom, beforeEl); | ||
fantom.insertAdjacentHTML('beforebegin', content); | ||
container.removeChild(fantom); | ||
} | ||
} else { | ||
container.insertAdjacentHTML('beforeend', content); | ||
} | ||
} | ||
if (fantom) { | ||
fantom.insertAdjacentHTML('beforebegin', content); | ||
} else if (beforeEl) { | ||
beforeEl.insertAdjacentHTML('beforebegin', content); | ||
} else { | ||
container.insertAdjacentHTML('beforeend', content); | ||
} | ||
} | ||
} | ||
if (fantom) { | ||
container.removeChild(fantom); | ||
} | ||
}, | ||
@@ -319,0 +315,0 @@ |
{ | ||
"name": "dresscode-botex", | ||
"version": "0.0.20", | ||
"version": "0.0.21", | ||
"dependencies": { | ||
@@ -5,0 +5,0 @@ "dresscode-bricks": "latest", |
47346
1267