- var elementContent = this._container().contents();
- var element = this;
- elementContent.each(function(idx) {
- var childElement = DocumentElement.fromHTMLElement(this, element.canvas);
- if(childElement === undefined)
- return true;
- if(idx === 0 && elementContent.length > 1 && elementContent[1].nodeType === Node.ELEMENT_NODE && (childElement instanceof DocumentTextElement) && $.trim($(this).text()) === '')
- return true;
- if(idx > 0 && childElement instanceof DocumentTextElement) {
- if(toret[toret.length-1] instanceof DocumentNodeElement && $.trim($(this).text()) === '')
- return true;
- }
- toret.push(childElement);
- });
- return toret;
- },
- childIndex: function(child) {
- var children = this.children(),
- toret = null;
- children.forEach(function(c, idx) {
- if(c.sameNode(child)) {
- toret = idx;
- return false;
- }
- });
- return toret;
- },
- getWlxmlTag: function() {
- return this._container().attr('wlxml-tag');
- },
- setWlxmlTag: function(tag) {
- if(tag === this.getWlxmlTag())
- return;
-
- this._container().attr('wlxml-tag', tag);
- if(!this.__updatingWlxml)
- this._updateWlxmlManager();
- },
- getWlxmlClass: function() {
- var klass = this._container().attr('wlxml-class');
- if(klass)
- return klass.replace(/-/g, '.');
- return undefined;
- },
- setWlxmlClass: function(klass) {
- if(klass === this.getWlxmlClass())
- return;
-
- this.getWlxmlMetaAttrs().forEach(function(attr) {
- if(!classAttributes.hasMetaAttr(klass, attr.name))
- this.dom().removeAttr('wlxml-meta-' + attr.name);
- }, this);
-
- if(klass)
- this._container().attr('wlxml-class', klass.replace(/\./g, '-'));
- else
- this._container().removeAttr('wlxml-class');
- if(!this.__updatingWlxml)
- this._updateWlxmlManager();
- },
- setWlxml: function(params) {
- this.__updatingWlxml = true;
- if(params.tag !== undefined)
- this.setWlxmlTag(params.tag);
- if(params.klass !== undefined)
- this.setWlxmlClass(params.klass);
- this._updateWlxmlManager();
- this.__updatingWlxml = false;
- },
- _updateWlxmlManager: function() {
- var manager = wlxmlManagers.getFor(this);
- this.data('_wlxmlManager', manager);
- manager.setup();
- },
- is: function(what) {
- if(what === 'list' && _.contains(['list.items', 'list.items.enum'], this.getWlxmlClass()))
- return true;
- return false;