1 if(!dojo._hasResource["dijit._editor.html"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
2 dojo._hasResource["dijit._editor.html"] = true;
3 dojo.provide("dijit._editor.html");
5 dijit._editor.escapeXml=function(/*String*/str, /*Boolean*/noSingleQuotes){
7 // Adds escape sequences for special characters in XML: &<>"'
8 // Optionally skips escapes for single quotes
9 str = str.replace(/&/gm, "&").replace(/</gm, "<").replace(/>/gm, ">").replace(/"/gm, """);
11 str = str.replace(/'/gm, "'");
16 dijit._editor.getNodeHtml=function(/* DomNode */node){
18 switch(node.nodeType){
19 case 1: //element node
20 output = '<'+node.nodeName.toLowerCase();
22 //store the list of attributes and sort it to have the
23 //attributes appear in the dictionary order
25 if(dojo.isIE && node.outerHTML){
26 var s = node.outerHTML;
27 s = s.substr(0,s.indexOf('>'));
28 s = s.replace(/(['"])[^"']*\1/g, '');//to make the following regexp safe
29 var reg = /([^\s=]+)=/g;
31 while((m = reg.exec(s))){
33 if(key.substr(0,3) != '_dj'){
34 if(key == 'src' || key == 'href'){
35 if(node.getAttribute('_djrealurl')){
36 attrarray.push([key,node.getAttribute('_djrealurl')]);
41 attrarray.push([key, node.style.cssText.toLowerCase()]);
43 attrarray.push([key, key=='class'?node.className:node.getAttribute(key)]);
48 var attr, i=0, attrs = node.attributes;
49 while((attr=attrs[i++])){
50 //ignore all attributes starting with _dj which are
51 //internal temporary attributes used by the editor
53 if(n.substr(0,3) != '_dj' /*&&
54 (attr.specified == undefined || attr.specified)*/){
56 if(n == 'src' || n == 'href'){
57 if(node.getAttribute('_djrealurl')){
58 v = node.getAttribute('_djrealurl');
61 attrarray.push([n,v]);
65 attrarray.sort(function(a,b){
66 return a[0]<b[0]?-1:(a[0]==b[0]?0:1);
69 while((attr=attrarray[i++])){
70 output += ' '+attr[0]+'="'+
71 (dojo.isString(attr[1]) ? dijit._editor.escapeXml(attr[1],true) : attr[1])+'"';
73 if(node.childNodes.length){
74 output += '>' + dijit._editor.getChildrenHtml(node)+'</'+node.nodeName.toLowerCase()+'>';
81 output = dijit._editor.escapeXml(node.nodeValue,true);
85 output = '<!--'+dijit._editor.escapeXml(node.nodeValue,true)+'-->';
88 output = "Element not recognized - Type: " + node.nodeType + " Name: " + node.nodeName;
93 dijit._editor.getChildrenHtml = function(/* DomNode */dom){
94 // summary: Returns the html content of a DomNode and children
96 if(!dom){ return out; }
97 var nodes = dom["childNodes"]||dom;
100 while((node=nodes[i++])){
101 out += dijit._editor.getNodeHtml(node);
103 return out; // String