a:29:{s:9:"#provides";s:9:"dojo.html";s:9:"#resource";s:7:"html.js";s:9:"#requires";a:1:{i:0;a:2:{i:0;s:6:"common";i:1;s:11:"dojo.parser";}}s:24:"dojo.html._ContentSetter";a:5:{s:4:"type";s:8:"Function";s:10:"parameters";a:2:{s:6:"params";a:1:{s:4:"type";s:6:"Object";}s:4:"node";a:1:{s:4:"type";s:14:"String|DomNode";}}s:6:"source";s:453:" dojo.mixin(this, params || {}); // give precedence to params.node vs. the node argument // and ensure its a node, not an id string node = this.node = dojo.byId( this.node || node ); if(!this.id){ this.id = [ "Setter", (node) ? node.id || node.tagName : "", idCounter++ ].join("_"); } if(! (this.node || node)){ new Error(this.declaredClass + ": no node provided to " + this.id); }";s:7:"summary";s:210:"Provides a configurable, extensible object to wrap the setting on content on a node call the set() method to actually set the content.. the original params are mixed directly into the instance "this"";s:9:"classlike";b:1;}s:29:"dojo.html._ContentSetter.node";a:4:{s:9:"prototype";s:24:"dojo.html._ContentSetter";s:8:"instance";s:24:"dojo.html._ContentSetter";s:4:"type";s:14:"DomNode|String";s:7:"summary";s:65:"An node which will be the parent element that we set content into";}s:32:"dojo.html._ContentSetter.content";a:4:{s:9:"prototype";s:24:"dojo.html._ContentSetter";s:8:"instance";s:24:"dojo.html._ContentSetter";s:4:"type";s:23:"String|DomNode|DomNode[";s:7:"summary";s:108:"The content to be placed in the node. Can be an HTML string, a node reference, or a enumerable list of nodes";}s:27:"dojo.html._ContentSetter.id";a:4:{s:9:"prototype";s:24:"dojo.html._ContentSetter";s:4:"type";s:6:"String";s:7:"summary";s:67:"Usually only used internally, and auto-generated with each instance";s:8:"instance";s:24:"dojo.html._ContentSetter";}s:37:"dojo.html._ContentSetter.cleanContent";a:3:{s:9:"prototype";s:24:"dojo.html._ContentSetter";s:4:"type";s:7:"Boolean";s:7:"summary";s:139:"Should the content be treated as a full html document, and the real content stripped of <html>, <body> wrapper before injection";}s:39:"dojo.html._ContentSetter.extractContent";a:3:{s:9:"prototype";s:24:"dojo.html._ContentSetter";s:4:"type";s:7:"Boolean";s:7:"summary";s:139:"Should the content be treated as a full html document, and the real content stripped of <html>, <body> wrapper before injection";}s:37:"dojo.html._ContentSetter.parseContent";a:3:{s:9:"prototype";s:24:"dojo.html._ContentSetter";s:4:"type";s:7:"Boolean";s:7:"summary";s:87:"Should the node by passed to the parser after the new content is set lifecyle methods";}s:28:"dojo.html._ContentSetter.set";a:5:{s:9:"prototype";s:24:"dojo.html._ContentSetter";s:4:"type";s:8:"Function";s:10:"parameters";a:2:{s:4:"cont";a:3:{s:8:"optional";b:1;s:4:"type";s:23:"String|DomNode|NodeList";s:7:"summary";s:135:"An html string, node or enumerable list of nodes for insertion into the dom If not provided, the object's content property will be used";}s:6:"params";a:2:{s:8:"optional";b:1;s:4:"type";s:6:"Object";}}s:6:"source";s:273:" if(undefined !== cont){ this.content = cont; } // in the re-use scenario, set needs to be able to mixin new configuration if(params){ this._mixin(params); } this.onBegin(); this.setContent(); this.onEnd(); return this.node;";s:7:"summary";s:37:"front-end to the set-content sequence";}s:35:"dojo.html._ContentSetter.setContent";a:4:{s:9:"prototype";s:24:"dojo.html._ContentSetter";s:4:"type";s:8:"Function";s:6:"source";s:720:" var node = this.node; if(!node) { console.error("setContent given no node"); } try{ node = dojo.html._setNodeContent(node, this.content); }catch(e){ // check if a domfault occurs when we are appending this.errorMessage // like for instance if domNode is a UL and we try append a DIV // FIXME: need to allow the user to provide a content error message string var errMess = this.onContentError(e); try{ node.innerHTML = errMess; }catch(e){ console.error('Fatal ' + this.declaredClass + '.setContent could not change content due to '+e.message, e); } } // always put back the node for the next method this.node = node; // DomNode";s:7:"summary";s:28:"sets the content on the node";}s:30:"dojo.html._ContentSetter.empty";a:5:{s:9:"prototype";s:24:"dojo.html._ContentSetter";s:4:"type";s:8:"Function";s:6:"source";s:7129:"dojo.provide("dojo.html"); // the parser might be needed.. dojo.require("dojo.parser"); (function(){ // private scope, sort of a namespace // idCounter is incremented with each instantiation to allow asignment of a unique id for tracking, logging purposes var idCounter = 0; dojo.html._secureForInnerHtml = function(/*String*/ cont){ // summary: // removes !DOCTYPE and title elements from the html string. // // khtml is picky about dom faults, you can't attach a style or node as child of body // must go into head, so we need to cut out those tags // cont: // An html string for insertion into the dom // return cont.replace(/(?:\s*<!DOCTYPE\s[^>]+>|<title[^>]*>[\s\S]*?<\/title>)/ig, ""); // String }; /*==== dojo.html._emptyNode = function(node){ // summary: // removes all child nodes from the given node // node: DOMNode // the parent element }; =====*/ dojo.html._emptyNode = dojo.empty; dojo.html._setNodeContent = function(/* DomNode */ node, /* String|DomNode|NodeList */ cont, /* Boolean? */ shouldEmptyFirst){ // summary: // inserts the given content into the given node // overlaps similiar functionality in dijit.layout.ContentPane._setContent // node: // the parent element // content: // the content to be set on the parent element. // This can be an html string, a node reference or a NodeList, dojo.NodeList, Array or other enumerable list of nodes // shouldEmptyFirst // if shouldEmptyFirst is true, the node will first be emptied of all content before the new content is inserted // defaults to false if(shouldEmptyFirst){ dojo.html._emptyNode(node); } if(typeof cont == "string"){ // there's some hoops to jump through before we can set innerHTML on the would-be parent element. // rationale for this block: // if node is a table derivate tag, some browsers dont allow innerHTML on those // TODO: <select>, <dl>? what other elements will give surprises if you naively set innerHTML? var pre = '', post = '', walk = 0, name = node.nodeName.toLowerCase(); switch(name){ case 'tr': pre = '<tr>'; post = '</tr>'; walk += 1;//fallthrough case 'tbody': case 'thead':// children of THEAD is of same type as TBODY pre = '<tbody>' + pre; post += '</tbody>'; walk += 1;// falltrough case 'table': pre = '<table>' + pre; post += '</table>'; walk += 1; break; } if(walk){ var n = node.ownerDocument.createElement('div'); n.innerHTML = pre + cont + post; do{ n = n.firstChild; }while(--walk); // now we can safely add the child nodes... dojo.forEach(n.childNodes, function(n){ node.appendChild(n.cloneNode(true)); }); }else{ // innerHTML the content as-is into the node (element) // should we ever support setting content on non-element node types? // e.g. text nodes, comments, etc.? node.innerHTML = cont; } }else{ // DomNode or NodeList if(cont.nodeType){ // domNode (htmlNode 1 or textNode 3) node.appendChild(cont); }else{// nodelist or array such as dojo.Nodelist dojo.forEach(cont, function(n){ node.appendChild(n.cloneNode(true)); }); } } // return DomNode return node; }; // we wrap up the content-setting operation in a object dojo.declare("dojo.html._ContentSetter", null, { // node: DomNode|String // An node which will be the parent element that we set content into node: "", // content: String|DomNode|DomNode[] // The content to be placed in the node. Can be an HTML string, a node reference, or a enumerable list of nodes content: "", // id: String? // Usually only used internally, and auto-generated with each instance id: "", // cleanContent: Boolean // Should the content be treated as a full html document, // and the real content stripped of <html>, <body> wrapper before injection cleanContent: false, // extractContent: Boolean // Should the content be treated as a full html document, and the real content stripped of <html>, <body> wrapper before injection extractContent: false, // parseContent: Boolean // Should the node by passed to the parser after the new content is set parseContent: false, // lifecyle methods constructor: function(/* Object */params, /* String|DomNode */node){ // summary: // Provides a configurable, extensible object to wrap the setting on content on a node // call the set() method to actually set the content.. // the original params are mixed directly into the instance "this" dojo.mixin(this, params || {}); // give precedence to params.node vs. the node argument // and ensure its a node, not an id string node = this.node = dojo.byId( this.node || node ); if(!this.id){ this.id = [ "Setter", (node) ? node.id || node.tagName : "", idCounter++ ].join("_"); } if(! (this.node || node)){ new Error(this.declaredClass + ": no node provided to " + this.id); } }, set: function(/* String|DomNode|NodeList? */ cont, /* Object? */ params){ // summary: // front-end to the set-content sequence // cont: // An html string, node or enumerable list of nodes for insertion into the dom // If not provided, the object's content property will be used if(undefined !== cont){ this.content = cont; } // in the re-use scenario, set needs to be able to mixin new configuration if(params){ this._mixin(params); } this.onBegin(); this.setContent(); this.onEnd(); return this.node; }, setContent: function(){ // summary: // sets the content on the node var node = this.node; if(!node) { console.error("setContent given no node"); } try{ node = dojo.html._setNodeContent(node, this.content); }catch(e){ // check if a domfault occurs when we are appending this.errorMessage // like for instance if domNode is a UL and we try append a DIV // FIXME: need to allow the user to provide a content error message string var errMess = this.onContentError(e); try{ node.innerHTML = errMess; }catch(e){ console.error('Fatal ' + this.declaredClass + '.setContent could not change content due to '+e.message, e); } } // always put back the node for the next method this.node = node; // DomNode }, empty: function() { // summary // cleanly empty out existing content // destroy any widgets from a previous run // NOTE: if you dont want this you'll need to empty // the parseResults array property yourself to avoid bad things happenning if(this.parseResults && this.parseResults.length) { dojo.forEach(this.parseResults, function(w) { if(w.destroy){ w.destroy(); } }); delete this.parseResults; } // this is fast, but if you know its already empty or safe, you could // override empty to skip this step dojo.html._emptyNode(this.node);";s:7:"returns";s:6:"String";s:7:"summary";s:0:"";}s:32:"dojo.html._ContentSetter.onBegin";a:5:{s:9:"prototype";s:24:"dojo.html._ContentSetter";s:4:"type";s:8:"Function";s:6:"source";s:7994:"dojo.provide("dojo.html"); // the parser might be needed.. dojo.require("dojo.parser"); (function(){ // private scope, sort of a namespace // idCounter is incremented with each instantiation to allow asignment of a unique id for tracking, logging purposes var idCounter = 0; dojo.html._secureForInnerHtml = function(/*String*/ cont){ // summary: // removes !DOCTYPE and title elements from the html string. // // khtml is picky about dom faults, you can't attach a style or <title> node as child of body // must go into head, so we need to cut out those tags // cont: // An html string for insertion into the dom // return cont.replace(/(?:\s*<!DOCTYPE\s[^>]+>|<title[^>]*>[\s\S]*?<\/title>)/ig, ""); // String }; /*==== dojo.html._emptyNode = function(node){ // summary: // removes all child nodes from the given node // node: DOMNode // the parent element }; =====*/ dojo.html._emptyNode = dojo.empty; dojo.html._setNodeContent = function(/* DomNode */ node, /* String|DomNode|NodeList */ cont, /* Boolean? */ shouldEmptyFirst){ // summary: // inserts the given content into the given node // overlaps similiar functionality in dijit.layout.ContentPane._setContent // node: // the parent element // content: // the content to be set on the parent element. // This can be an html string, a node reference or a NodeList, dojo.NodeList, Array or other enumerable list of nodes // shouldEmptyFirst // if shouldEmptyFirst is true, the node will first be emptied of all content before the new content is inserted // defaults to false if(shouldEmptyFirst){ dojo.html._emptyNode(node); } if(typeof cont == "string"){ // there's some hoops to jump through before we can set innerHTML on the would-be parent element. // rationale for this block: // if node is a table derivate tag, some browsers dont allow innerHTML on those // TODO: <select>, <dl>? what other elements will give surprises if you naively set innerHTML? var pre = '', post = '', walk = 0, name = node.nodeName.toLowerCase(); switch(name){ case 'tr': pre = '<tr>'; post = '</tr>'; walk += 1;//fallthrough case 'tbody': case 'thead':// children of THEAD is of same type as TBODY pre = '<tbody>' + pre; post += '</tbody>'; walk += 1;// falltrough case 'table': pre = '<table>' + pre; post += '</table>'; walk += 1; break; } if(walk){ var n = node.ownerDocument.createElement('div'); n.innerHTML = pre + cont + post; do{ n = n.firstChild; }while(--walk); // now we can safely add the child nodes... dojo.forEach(n.childNodes, function(n){ node.appendChild(n.cloneNode(true)); }); }else{ // innerHTML the content as-is into the node (element) // should we ever support setting content on non-element node types? // e.g. text nodes, comments, etc.? node.innerHTML = cont; } }else{ // DomNode or NodeList if(cont.nodeType){ // domNode (htmlNode 1 or textNode 3) node.appendChild(cont); }else{// nodelist or array such as dojo.Nodelist dojo.forEach(cont, function(n){ node.appendChild(n.cloneNode(true)); }); } } // return DomNode return node; }; // we wrap up the content-setting operation in a object dojo.declare("dojo.html._ContentSetter", null, { // node: DomNode|String // An node which will be the parent element that we set content into node: "", // content: String|DomNode|DomNode[] // The content to be placed in the node. Can be an HTML string, a node reference, or a enumerable list of nodes content: "", // id: String? // Usually only used internally, and auto-generated with each instance id: "", // cleanContent: Boolean // Should the content be treated as a full html document, // and the real content stripped of <html>, <body> wrapper before injection cleanContent: false, // extractContent: Boolean // Should the content be treated as a full html document, and the real content stripped of <html>, <body> wrapper before injection extractContent: false, // parseContent: Boolean // Should the node by passed to the parser after the new content is set parseContent: false, // lifecyle methods constructor: function(/* Object */params, /* String|DomNode */node){ // summary: // Provides a configurable, extensible object to wrap the setting on content on a node // call the set() method to actually set the content.. // the original params are mixed directly into the instance "this" dojo.mixin(this, params || {}); // give precedence to params.node vs. the node argument // and ensure its a node, not an id string node = this.node = dojo.byId( this.node || node ); if(!this.id){ this.id = [ "Setter", (node) ? node.id || node.tagName : "", idCounter++ ].join("_"); } if(! (this.node || node)){ new Error(this.declaredClass + ": no node provided to " + this.id); } }, set: function(/* String|DomNode|NodeList? */ cont, /* Object? */ params){ // summary: // front-end to the set-content sequence // cont: // An html string, node or enumerable list of nodes for insertion into the dom // If not provided, the object's content property will be used if(undefined !== cont){ this.content = cont; } // in the re-use scenario, set needs to be able to mixin new configuration if(params){ this._mixin(params); } this.onBegin(); this.setContent(); this.onEnd(); return this.node; }, setContent: function(){ // summary: // sets the content on the node var node = this.node; if(!node) { console.error("setContent given no node"); } try{ node = dojo.html._setNodeContent(node, this.content); }catch(e){ // check if a domfault occurs when we are appending this.errorMessage // like for instance if domNode is a UL and we try append a DIV // FIXME: need to allow the user to provide a content error message string var errMess = this.onContentError(e); try{ node.innerHTML = errMess; }catch(e){ console.error('Fatal ' + this.declaredClass + '.setContent could not change content due to '+e.message, e); } } // always put back the node for the next method this.node = node; // DomNode }, empty: function() { // summary // cleanly empty out existing content // destroy any widgets from a previous run // NOTE: if you dont want this you'll need to empty // the parseResults array property yourself to avoid bad things happenning if(this.parseResults && this.parseResults.length) { dojo.forEach(this.parseResults, function(w) { if(w.destroy){ w.destroy(); } }); delete this.parseResults; } // this is fast, but if you know its already empty or safe, you could // override empty to skip this step dojo.html._emptyNode(this.node); }, onBegin: function(){ // summary // Called after instantiation, but before set(); // It allows modification of any of the object properties // - including the node and content provided - before the set operation actually takes place // This default implementation checks for cleanContent and extractContent flags to // optionally pre-process html string content var cont = this.content; if(dojo.isString(cont)){ if(this.cleanContent){ cont = dojo.html._secureForInnerHtml(cont); } if(this.extractContent){ var match = cont.match(/<body[^>]*>\s*([\s\S]+)\s*<\/body>/im); if(match){ cont = match[1]; } } } // clean out the node and any cruft associated with it - like widgets this.empty(); this.content = cont; return this.node; /* DomNode */";s:7:"returns";s:14:"String|DomNode";s:7:"summary";s:0:"";}s:30:"dojo.html._ContentSetter.onEnd";a:5:{s:9:"prototype";s:24:"dojo.html._ContentSetter";s:4:"type";s:8:"Function";s:6:"source";s:8480:"dojo.provide("dojo.html"); // the parser might be needed.. dojo.require("dojo.parser"); (function(){ // private scope, sort of a namespace // idCounter is incremented with each instantiation to allow asignment of a unique id for tracking, logging purposes var idCounter = 0; dojo.html._secureForInnerHtml = function(/*String*/ cont){ // summary: // removes !DOCTYPE and title elements from the html string. // // khtml is picky about dom faults, you can't attach a style or <title> node as child of body // must go into head, so we need to cut out those tags // cont: // An html string for insertion into the dom // return cont.replace(/(?:\s*<!DOCTYPE\s[^>]+>|<title[^>]*>[\s\S]*?<\/title>)/ig, ""); // String }; /*==== dojo.html._emptyNode = function(node){ // summary: // removes all child nodes from the given node // node: DOMNode // the parent element }; =====*/ dojo.html._emptyNode = dojo.empty; dojo.html._setNodeContent = function(/* DomNode */ node, /* String|DomNode|NodeList */ cont, /* Boolean? */ shouldEmptyFirst){ // summary: // inserts the given content into the given node // overlaps similiar functionality in dijit.layout.ContentPane._setContent // node: // the parent element // content: // the content to be set on the parent element. // This can be an html string, a node reference or a NodeList, dojo.NodeList, Array or other enumerable list of nodes // shouldEmptyFirst // if shouldEmptyFirst is true, the node will first be emptied of all content before the new content is inserted // defaults to false if(shouldEmptyFirst){ dojo.html._emptyNode(node); } if(typeof cont == "string"){ // there's some hoops to jump through before we can set innerHTML on the would-be parent element. // rationale for this block: // if node is a table derivate tag, some browsers dont allow innerHTML on those // TODO: <select>, <dl>? what other elements will give surprises if you naively set innerHTML? var pre = '', post = '', walk = 0, name = node.nodeName.toLowerCase(); switch(name){ case 'tr': pre = '<tr>'; post = '</tr>'; walk += 1;//fallthrough case 'tbody': case 'thead':// children of THEAD is of same type as TBODY pre = '<tbody>' + pre; post += '</tbody>'; walk += 1;// falltrough case 'table': pre = '<table>' + pre; post += '</table>'; walk += 1; break; } if(walk){ var n = node.ownerDocument.createElement('div'); n.innerHTML = pre + cont + post; do{ n = n.firstChild; }while(--walk); // now we can safely add the child nodes... dojo.forEach(n.childNodes, function(n){ node.appendChild(n.cloneNode(true)); }); }else{ // innerHTML the content as-is into the node (element) // should we ever support setting content on non-element node types? // e.g. text nodes, comments, etc.? node.innerHTML = cont; } }else{ // DomNode or NodeList if(cont.nodeType){ // domNode (htmlNode 1 or textNode 3) node.appendChild(cont); }else{// nodelist or array such as dojo.Nodelist dojo.forEach(cont, function(n){ node.appendChild(n.cloneNode(true)); }); } } // return DomNode return node; }; // we wrap up the content-setting operation in a object dojo.declare("dojo.html._ContentSetter", null, { // node: DomNode|String // An node which will be the parent element that we set content into node: "", // content: String|DomNode|DomNode[] // The content to be placed in the node. Can be an HTML string, a node reference, or a enumerable list of nodes content: "", // id: String? // Usually only used internally, and auto-generated with each instance id: "", // cleanContent: Boolean // Should the content be treated as a full html document, // and the real content stripped of <html>, <body> wrapper before injection cleanContent: false, // extractContent: Boolean // Should the content be treated as a full html document, and the real content stripped of <html>, <body> wrapper before injection extractContent: false, // parseContent: Boolean // Should the node by passed to the parser after the new content is set parseContent: false, // lifecyle methods constructor: function(/* Object */params, /* String|DomNode */node){ // summary: // Provides a configurable, extensible object to wrap the setting on content on a node // call the set() method to actually set the content.. // the original params are mixed directly into the instance "this" dojo.mixin(this, params || {}); // give precedence to params.node vs. the node argument // and ensure its a node, not an id string node = this.node = dojo.byId( this.node || node ); if(!this.id){ this.id = [ "Setter", (node) ? node.id || node.tagName : "", idCounter++ ].join("_"); } if(! (this.node || node)){ new Error(this.declaredClass + ": no node provided to " + this.id); } }, set: function(/* String|DomNode|NodeList? */ cont, /* Object? */ params){ // summary: // front-end to the set-content sequence // cont: // An html string, node or enumerable list of nodes for insertion into the dom // If not provided, the object's content property will be used if(undefined !== cont){ this.content = cont; } // in the re-use scenario, set needs to be able to mixin new configuration if(params){ this._mixin(params); } this.onBegin(); this.setContent(); this.onEnd(); return this.node; }, setContent: function(){ // summary: // sets the content on the node var node = this.node; if(!node) { console.error("setContent given no node"); } try{ node = dojo.html._setNodeContent(node, this.content); }catch(e){ // check if a domfault occurs when we are appending this.errorMessage // like for instance if domNode is a UL and we try append a DIV // FIXME: need to allow the user to provide a content error message string var errMess = this.onContentError(e); try{ node.innerHTML = errMess; }catch(e){ console.error('Fatal ' + this.declaredClass + '.setContent could not change content due to '+e.message, e); } } // always put back the node for the next method this.node = node; // DomNode }, empty: function() { // summary // cleanly empty out existing content // destroy any widgets from a previous run // NOTE: if you dont want this you'll need to empty // the parseResults array property yourself to avoid bad things happenning if(this.parseResults && this.parseResults.length) { dojo.forEach(this.parseResults, function(w) { if(w.destroy){ w.destroy(); } }); delete this.parseResults; } // this is fast, but if you know its already empty or safe, you could // override empty to skip this step dojo.html._emptyNode(this.node); }, onBegin: function(){ // summary // Called after instantiation, but before set(); // It allows modification of any of the object properties // - including the node and content provided - before the set operation actually takes place // This default implementation checks for cleanContent and extractContent flags to // optionally pre-process html string content var cont = this.content; if(dojo.isString(cont)){ if(this.cleanContent){ cont = dojo.html._secureForInnerHtml(cont); } if(this.extractContent){ var match = cont.match(/<body[^>]*>\s*([\s\S]+)\s*<\/body>/im); if(match){ cont = match[1]; } } } // clean out the node and any cruft associated with it - like widgets this.empty(); this.content = cont; return this.node; /* DomNode */ }, onEnd: function(){ // summary // Called after set(), when the new content has been pushed into the node // It provides an opportunity for post-processing before handing back the node to the caller // This default implementation checks a parseContent flag to optionally run the dojo parser over the new content if(this.parseContent){ // populates this.parseResults if you need those.. this._parse(); } return this.node; /* DomNode */";s:7:"returns";s:14:"String|DomNode";s:7:"summary";s:0:"";}s:33:"dojo.html._ContentSetter.tearDown";a:5:{s:9:"prototype";s:24:"dojo.html._ContentSetter";s:4:"type";s:8:"Function";s:6:"source";s:8946:"dojo.provide("dojo.html"); // the parser might be needed.. dojo.require("dojo.parser"); (function(){ // private scope, sort of a namespace // idCounter is incremented with each instantiation to allow asignment of a unique id for tracking, logging purposes var idCounter = 0; dojo.html._secureForInnerHtml = function(/*String*/ cont){ // summary: // removes !DOCTYPE and title elements from the html string. // // khtml is picky about dom faults, you can't attach a style or <title> node as child of body // must go into head, so we need to cut out those tags // cont: // An html string for insertion into the dom // return cont.replace(/(?:\s*<!DOCTYPE\s[^>]+>|<title[^>]*>[\s\S]*?<\/title>)/ig, ""); // String }; /*==== dojo.html._emptyNode = function(node){ // summary: // removes all child nodes from the given node // node: DOMNode // the parent element }; =====*/ dojo.html._emptyNode = dojo.empty; dojo.html._setNodeContent = function(/* DomNode */ node, /* String|DomNode|NodeList */ cont, /* Boolean? */ shouldEmptyFirst){ // summary: // inserts the given content into the given node // overlaps similiar functionality in dijit.layout.ContentPane._setContent // node: // the parent element // content: // the content to be set on the parent element. // This can be an html string, a node reference or a NodeList, dojo.NodeList, Array or other enumerable list of nodes // shouldEmptyFirst // if shouldEmptyFirst is true, the node will first be emptied of all content before the new content is inserted // defaults to false if(shouldEmptyFirst){ dojo.html._emptyNode(node); } if(typeof cont == "string"){ // there's some hoops to jump through before we can set innerHTML on the would-be parent element. // rationale for this block: // if node is a table derivate tag, some browsers dont allow innerHTML on those // TODO: <select>, <dl>? what other elements will give surprises if you naively set innerHTML? var pre = '', post = '', walk = 0, name = node.nodeName.toLowerCase(); switch(name){ case 'tr': pre = '<tr>'; post = '</tr>'; walk += 1;//fallthrough case 'tbody': case 'thead':// children of THEAD is of same type as TBODY pre = '<tbody>' + pre; post += '</tbody>'; walk += 1;// falltrough case 'table': pre = '<table>' + pre; post += '</table>'; walk += 1; break; } if(walk){ var n = node.ownerDocument.createElement('div'); n.innerHTML = pre + cont + post; do{ n = n.firstChild; }while(--walk); // now we can safely add the child nodes... dojo.forEach(n.childNodes, function(n){ node.appendChild(n.cloneNode(true)); }); }else{ // innerHTML the content as-is into the node (element) // should we ever support setting content on non-element node types? // e.g. text nodes, comments, etc.? node.innerHTML = cont; } }else{ // DomNode or NodeList if(cont.nodeType){ // domNode (htmlNode 1 or textNode 3) node.appendChild(cont); }else{// nodelist or array such as dojo.Nodelist dojo.forEach(cont, function(n){ node.appendChild(n.cloneNode(true)); }); } } // return DomNode return node; }; // we wrap up the content-setting operation in a object dojo.declare("dojo.html._ContentSetter", null, { // node: DomNode|String // An node which will be the parent element that we set content into node: "", // content: String|DomNode|DomNode[] // The content to be placed in the node. Can be an HTML string, a node reference, or a enumerable list of nodes content: "", // id: String? // Usually only used internally, and auto-generated with each instance id: "", // cleanContent: Boolean // Should the content be treated as a full html document, // and the real content stripped of <html>, <body> wrapper before injection cleanContent: false, // extractContent: Boolean // Should the content be treated as a full html document, and the real content stripped of <html>, <body> wrapper before injection extractContent: false, // parseContent: Boolean // Should the node by passed to the parser after the new content is set parseContent: false, // lifecyle methods constructor: function(/* Object */params, /* String|DomNode */node){ // summary: // Provides a configurable, extensible object to wrap the setting on content on a node // call the set() method to actually set the content.. // the original params are mixed directly into the instance "this" dojo.mixin(this, params || {}); // give precedence to params.node vs. the node argument // and ensure its a node, not an id string node = this.node = dojo.byId( this.node || node ); if(!this.id){ this.id = [ "Setter", (node) ? node.id || node.tagName : "", idCounter++ ].join("_"); } if(! (this.node || node)){ new Error(this.declaredClass + ": no node provided to " + this.id); } }, set: function(/* String|DomNode|NodeList? */ cont, /* Object? */ params){ // summary: // front-end to the set-content sequence // cont: // An html string, node or enumerable list of nodes for insertion into the dom // If not provided, the object's content property will be used if(undefined !== cont){ this.content = cont; } // in the re-use scenario, set needs to be able to mixin new configuration if(params){ this._mixin(params); } this.onBegin(); this.setContent(); this.onEnd(); return this.node; }, setContent: function(){ // summary: // sets the content on the node var node = this.node; if(!node) { console.error("setContent given no node"); } try{ node = dojo.html._setNodeContent(node, this.content); }catch(e){ // check if a domfault occurs when we are appending this.errorMessage // like for instance if domNode is a UL and we try append a DIV // FIXME: need to allow the user to provide a content error message string var errMess = this.onContentError(e); try{ node.innerHTML = errMess; }catch(e){ console.error('Fatal ' + this.declaredClass + '.setContent could not change content due to '+e.message, e); } } // always put back the node for the next method this.node = node; // DomNode }, empty: function() { // summary // cleanly empty out existing content // destroy any widgets from a previous run // NOTE: if you dont want this you'll need to empty // the parseResults array property yourself to avoid bad things happenning if(this.parseResults && this.parseResults.length) { dojo.forEach(this.parseResults, function(w) { if(w.destroy){ w.destroy(); } }); delete this.parseResults; } // this is fast, but if you know its already empty or safe, you could // override empty to skip this step dojo.html._emptyNode(this.node); }, onBegin: function(){ // summary // Called after instantiation, but before set(); // It allows modification of any of the object properties // - including the node and content provided - before the set operation actually takes place // This default implementation checks for cleanContent and extractContent flags to // optionally pre-process html string content var cont = this.content; if(dojo.isString(cont)){ if(this.cleanContent){ cont = dojo.html._secureForInnerHtml(cont); } if(this.extractContent){ var match = cont.match(/<body[^>]*>\s*([\s\S]+)\s*<\/body>/im); if(match){ cont = match[1]; } } } // clean out the node and any cruft associated with it - like widgets this.empty(); this.content = cont; return this.node; /* DomNode */ }, onEnd: function(){ // summary // Called after set(), when the new content has been pushed into the node // It provides an opportunity for post-processing before handing back the node to the caller // This default implementation checks a parseContent flag to optionally run the dojo parser over the new content if(this.parseContent){ // populates this.parseResults if you need those.. this._parse(); } return this.node; /* DomNode */ }, tearDown: function(){ // summary // manually reset the Setter instance if its being re-used for example for another set() // description // tearDown() is not called automatically. // In normal use, the Setter instance properties are simply allowed to fall out of scope // but the tearDown method can be called to explicitly reset this instance. delete this.parseResults; delete this.node; delete this.content; ";s:7:"returns";s:14:"String|DomNode";s:7:"summary";s:0:"";}s:39:"dojo.html._ContentSetter.onContentError";a:5:{s:9:"prototype";s:24:"dojo.html._ContentSetter";s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:3:"err";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:52:" return "Error occured setting content: " + err; ";s:7:"summary";s:0:"";}s:31:"dojo.html._ContentSetter._mixin";a:7:{s:9:"prototype";s:24:"dojo.html._ContentSetter";s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:6:"params";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:9693:"dojo.provide("dojo.html"); // the parser might be needed.. dojo.require("dojo.parser"); (function(){ // private scope, sort of a namespace // idCounter is incremented with each instantiation to allow asignment of a unique id for tracking, logging purposes var idCounter = 0; dojo.html._secureForInnerHtml = function(/*String*/ cont){ // summary: // removes !DOCTYPE and title elements from the html string. // // khtml is picky about dom faults, you can't attach a style or <title> node as child of body // must go into head, so we need to cut out those tags // cont: // An html string for insertion into the dom // return cont.replace(/(?:\s*<!DOCTYPE\s[^>]+>|<title[^>]*>[\s\S]*?<\/title>)/ig, ""); // String }; /*==== dojo.html._emptyNode = function(node){ // summary: // removes all child nodes from the given node // node: DOMNode // the parent element }; =====*/ dojo.html._emptyNode = dojo.empty; dojo.html._setNodeContent = function(/* DomNode */ node, /* String|DomNode|NodeList */ cont, /* Boolean? */ shouldEmptyFirst){ // summary: // inserts the given content into the given node // overlaps similiar functionality in dijit.layout.ContentPane._setContent // node: // the parent element // content: // the content to be set on the parent element. // This can be an html string, a node reference or a NodeList, dojo.NodeList, Array or other enumerable list of nodes // shouldEmptyFirst // if shouldEmptyFirst is true, the node will first be emptied of all content before the new content is inserted // defaults to false if(shouldEmptyFirst){ dojo.html._emptyNode(node); } if(typeof cont == "string"){ // there's some hoops to jump through before we can set innerHTML on the would-be parent element. // rationale for this block: // if node is a table derivate tag, some browsers dont allow innerHTML on those // TODO: <select>, <dl>? what other elements will give surprises if you naively set innerHTML? var pre = '', post = '', walk = 0, name = node.nodeName.toLowerCase(); switch(name){ case 'tr': pre = '<tr>'; post = '</tr>'; walk += 1;//fallthrough case 'tbody': case 'thead':// children of THEAD is of same type as TBODY pre = '<tbody>' + pre; post += '</tbody>'; walk += 1;// falltrough case 'table': pre = '<table>' + pre; post += '</table>'; walk += 1; break; } if(walk){ var n = node.ownerDocument.createElement('div'); n.innerHTML = pre + cont + post; do{ n = n.firstChild; }while(--walk); // now we can safely add the child nodes... dojo.forEach(n.childNodes, function(n){ node.appendChild(n.cloneNode(true)); }); }else{ // innerHTML the content as-is into the node (element) // should we ever support setting content on non-element node types? // e.g. text nodes, comments, etc.? node.innerHTML = cont; } }else{ // DomNode or NodeList if(cont.nodeType){ // domNode (htmlNode 1 or textNode 3) node.appendChild(cont); }else{// nodelist or array such as dojo.Nodelist dojo.forEach(cont, function(n){ node.appendChild(n.cloneNode(true)); }); } } // return DomNode return node; }; // we wrap up the content-setting operation in a object dojo.declare("dojo.html._ContentSetter", null, { // node: DomNode|String // An node which will be the parent element that we set content into node: "", // content: String|DomNode|DomNode[] // The content to be placed in the node. Can be an HTML string, a node reference, or a enumerable list of nodes content: "", // id: String? // Usually only used internally, and auto-generated with each instance id: "", // cleanContent: Boolean // Should the content be treated as a full html document, // and the real content stripped of <html>, <body> wrapper before injection cleanContent: false, // extractContent: Boolean // Should the content be treated as a full html document, and the real content stripped of <html>, <body> wrapper before injection extractContent: false, // parseContent: Boolean // Should the node by passed to the parser after the new content is set parseContent: false, // lifecyle methods constructor: function(/* Object */params, /* String|DomNode */node){ // summary: // Provides a configurable, extensible object to wrap the setting on content on a node // call the set() method to actually set the content.. // the original params are mixed directly into the instance "this" dojo.mixin(this, params || {}); // give precedence to params.node vs. the node argument // and ensure its a node, not an id string node = this.node = dojo.byId( this.node || node ); if(!this.id){ this.id = [ "Setter", (node) ? node.id || node.tagName : "", idCounter++ ].join("_"); } if(! (this.node || node)){ new Error(this.declaredClass + ": no node provided to " + this.id); } }, set: function(/* String|DomNode|NodeList? */ cont, /* Object? */ params){ // summary: // front-end to the set-content sequence // cont: // An html string, node or enumerable list of nodes for insertion into the dom // If not provided, the object's content property will be used if(undefined !== cont){ this.content = cont; } // in the re-use scenario, set needs to be able to mixin new configuration if(params){ this._mixin(params); } this.onBegin(); this.setContent(); this.onEnd(); return this.node; }, setContent: function(){ // summary: // sets the content on the node var node = this.node; if(!node) { console.error("setContent given no node"); } try{ node = dojo.html._setNodeContent(node, this.content); }catch(e){ // check if a domfault occurs when we are appending this.errorMessage // like for instance if domNode is a UL and we try append a DIV // FIXME: need to allow the user to provide a content error message string var errMess = this.onContentError(e); try{ node.innerHTML = errMess; }catch(e){ console.error('Fatal ' + this.declaredClass + '.setContent could not change content due to '+e.message, e); } } // always put back the node for the next method this.node = node; // DomNode }, empty: function() { // summary // cleanly empty out existing content // destroy any widgets from a previous run // NOTE: if you dont want this you'll need to empty // the parseResults array property yourself to avoid bad things happenning if(this.parseResults && this.parseResults.length) { dojo.forEach(this.parseResults, function(w) { if(w.destroy){ w.destroy(); } }); delete this.parseResults; } // this is fast, but if you know its already empty or safe, you could // override empty to skip this step dojo.html._emptyNode(this.node); }, onBegin: function(){ // summary // Called after instantiation, but before set(); // It allows modification of any of the object properties // - including the node and content provided - before the set operation actually takes place // This default implementation checks for cleanContent and extractContent flags to // optionally pre-process html string content var cont = this.content; if(dojo.isString(cont)){ if(this.cleanContent){ cont = dojo.html._secureForInnerHtml(cont); } if(this.extractContent){ var match = cont.match(/<body[^>]*>\s*([\s\S]+)\s*<\/body>/im); if(match){ cont = match[1]; } } } // clean out the node and any cruft associated with it - like widgets this.empty(); this.content = cont; return this.node; /* DomNode */ }, onEnd: function(){ // summary // Called after set(), when the new content has been pushed into the node // It provides an opportunity for post-processing before handing back the node to the caller // This default implementation checks a parseContent flag to optionally run the dojo parser over the new content if(this.parseContent){ // populates this.parseResults if you need those.. this._parse(); } return this.node; /* DomNode */ }, tearDown: function(){ // summary // manually reset the Setter instance if its being re-used for example for another set() // description // tearDown() is not called automatically. // In normal use, the Setter instance properties are simply allowed to fall out of scope // but the tearDown method can be called to explicitly reset this instance. delete this.parseResults; delete this.node; delete this.content; }, onContentError: function(err){ return "Error occured setting content: " + err; }, _mixin: function(params){ // mix properties/methods into the instance // TODO: the intention with tearDown is to put the Setter's state // back to that of the original constructor (vs. deleting/resetting everything regardless of ctor params) // so we could do something here to move the original properties aside for later restoration var empty = {}, key; for(key in params){ if(key in empty){ continue; } // TODO: here's our opportunity to mask the properties we dont consider configurable/overridable // .. but history shows we'll almost always guess wrong this[key] = params[key]; }";s:7:"returns";s:14:"String|DomNode";s:7:"private";b:1;s:7:"summary";s:0:"";}s:31:"dojo.html._ContentSetter._parse";a:5:{s:9:"prototype";s:24:"dojo.html._ContentSetter";s:4:"type";s:8:"Function";s:6:"source";s:267:" var rootNode = this.node; try{ // store the results (widgets, whatever) for potential retrieval this.parseResults = dojo.parser.parse(rootNode, true); }catch(e){ this._onError('Content', e, "Error parsing in _ContentSetter#"+this.id); }";s:7:"summary";s:155:"runs the dojo parser over the node contents, storing any results in this.parseResults Any errors resulting from parsing are passed to _onError for handling";s:7:"private";b:1;}s:33:"dojo.html._ContentSetter._onError";a:6:{s:9:"prototype";s:24:"dojo.html._ContentSetter";s:4:"type";s:8:"Function";s:10:"parameters";a:3:{s:4:"type";a:1:{s:4:"type";s:0:"";}s:3:"err";a:1:{s:4:"type";s:0:"";}s:11:"consoleText";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:255:" var errText = this['on' + type + 'Error'].call(this, err); if(consoleText){ console.error(consoleText, err); }else if(errText){ // a empty string won't change current content dojo.html._setNodeContent(this.node, errText, true); }";s:7:"summary";s:127:"shows user the string that is returned by on[type]Error overide/implement on[type]Error and return your own string to customize";s:7:"private";b:1;}s:37:"dojo.html._ContentSetter.parseResults";a:2:{s:8:"instance";s:24:"dojo.html._ContentSetter";s:7:"summary";s:0:"";}s:20:"dojo.html._emptyNode";a:2:{s:7:"private";b:1;s:7:"summary";s:0:"";}s:29:"dojo.html._secureForInnerHtml";a:6:{s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:4:"cont";a:2:{s:4:"type";s:6:"String";s:7:"summary";s:41:"An html string for insertion into the dom";}}s:6:"source";s:96:" return cont.replace(/(?:\s*<!DOCTYPE\s[^>]+>|<title[^>]*>[\s\S]*?<\/title>)/ig, ""); // String";s:7:"summary";s:207:"removes !DOCTYPE and title elements from the html string. khtml is picky about dom faults, you can't attach a style or <title> node as child of body must go into head, so we need to cut out those tags";s:7:"returns";s:6:"String";s:7:"private";b:1;}s:25:"dojo.html._setNodeContent";a:5:{s:4:"type";s:8:"Function";s:10:"parameters";a:3:{s:4:"node";a:2:{s:4:"type";s:7:"DomNode";s:7:"summary";s:332:"the parent element content: the content to be set on the parent element. This can be an html string, a node reference or a NodeList, dojo.NodeList, Array or other enumerable list of nodes shouldEmptyFirst if shouldEmptyFirst is true, the node will first be emptied of all content before the new content is inserted defaults to false";}s:4:"cont";a:1:{s:4:"type";s:23:"String|DomNode|NodeList";}s:16:"shouldEmptyFirst";a:2:{s:8:"optional";b:1;s:4:"type";s:7:"Boolean";}}s:6:"source";s:1656:" if(shouldEmptyFirst){ dojo.html._emptyNode(node); } if(typeof cont == "string"){ // there's some hoops to jump through before we can set innerHTML on the would-be parent element. // rationale for this block: // if node is a table derivate tag, some browsers dont allow innerHTML on those // TODO: <select>, <dl>? what other elements will give surprises if you naively set innerHTML? var pre = '', post = '', walk = 0, name = node.nodeName.toLowerCase(); switch(name){ case 'tr': pre = '<tr>'; post = '</tr>'; walk += 1;//fallthrough case 'tbody': case 'thead':// children of THEAD is of same type as TBODY pre = '<tbody>' + pre; post += '</tbody>'; walk += 1;// falltrough case 'table': pre = '<table>' + pre; post += '</table>'; walk += 1; break; } if(walk){ var n = node.ownerDocument.createElement('div'); n.innerHTML = pre + cont + post; do{ n = n.firstChild; }while(--walk); // now we can safely add the child nodes... dojo.forEach(n.childNodes, function(n){ node.appendChild(n.cloneNode(true)); }); }else{ // innerHTML the content as-is into the node (element) // should we ever support setting content on non-element node types? // e.g. text nodes, comments, etc.? node.innerHTML = cont; } }else{ // DomNode or NodeList if(cont.nodeType){ // domNode (htmlNode 1 or textNode 3) node.appendChild(cont); }else{// nodelist or array such as dojo.Nodelist dojo.forEach(cont, function(n){ node.appendChild(n.cloneNode(true)); }); } } // return DomNode return node;";s:7:"summary";s:117:"inserts the given content into the given node overlaps similiar functionality in dijit.layout.ContentPane._setContent";s:7:"private";b:1;}s:13:"dojo.html.set";a:6:{s:4:"type";s:8:"Function";s:10:"parameters";a:3:{s:4:"node";a:2:{s:4:"type";s:7:"DomNode";s:7:"summary";s:48:"the parent element that will receive the content";}s:4:"cont";a:2:{s:4:"type";s:23:"String|DomNode|NodeList";s:7:"summary";s:159:"the content to be set on the parent element. This can be an html string, a node reference or a NodeList, dojo.NodeList, Array or other enumerable list of nodes";}s:6:"params";a:3:{s:8:"optional";b:1;s:4:"type";s:6:"Object";s:7:"summary";s:88:"Optional flags/properties to configure the content-setting. See dojo.html._ContentSetter";}}s:6:"source";s:496:" if(undefined == cont){ console.warn("dojo.html.set: no cont argument provided, using empty string"); cont = ""; } if(!params){ // simple and fast return dojo.html._setNodeContent(node, cont, true); }else{ // more options but slower // note the arguments are reversed in order, to match the convention for instantiation via the parser var op = new dojo.html._ContentSetter(dojo.mixin( params, { content: cont, node: node } )); return op.set(); }";s:7:"summary";s:148:"inserts (replaces) the given content into the given node. dojo.place(cont, node, "only") may be a better choice for simple HTML insertion.";s:11:"description";s:398:"Unless you need to use the params capabilities of this method, you should use dojo.place(cont, node, "only"). dojo.place() has more robust support for injecting an HTML string into the DOM, but it only handles inserting an HTML string as DOM elements, or inserting a DOM node. dojo.place does not handle NodeList insertions or the other capabilities as defined by the params object for this method.";s:8:"examples";a:1:{i:0;s:229:"A safe string/node/nodelist content replacement/injection with hooks for extension Example Usage: dojo.html.set(node, "some string"); dojo.html.set(node, contentNode, {options}); dojo.html.set(node, myNode.childNodes, {options});";}}s:14:"params.content";a:1:{s:7:"summary";s:0:"";}s:11:"params.node";a:1:{s:7:"summary";s:0:"";}s:9:"dojo.html";a:2:{s:4:"type";s:6:"Object";s:7:"summary";s:0:"";}s:4:"dojo";a:2:{s:4:"type";s:6:"Object";s:7:"summary";s:0:"";}}