mirror of
https://git.tt-rss.org/git/tt-rss.git
synced 2025-12-15 22:26:00 +00:00
upgrade Dojo to 1.6.1
This commit is contained in:
@@ -1,147 +1,193 @@
|
||||
/*
|
||||
Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
|
||||
Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
|
||||
Available via Academic Free License >= 2.1 OR the modified BSD license.
|
||||
see: http://dojotoolkit.org/license for details
|
||||
*/
|
||||
|
||||
|
||||
if(!dojo._hasResource["dijit._editor.html"]){
|
||||
dojo._hasResource["dijit._editor.html"]=true;
|
||||
if(!dojo._hasResource["dijit._editor.html"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
|
||||
dojo._hasResource["dijit._editor.html"] = true;
|
||||
dojo.provide("dijit._editor.html");
|
||||
dijit._editor.escapeXml=function(_1,_2){
|
||||
_1=_1.replace(/&/gm,"&").replace(/</gm,"<").replace(/>/gm,">").replace(/"/gm,""");
|
||||
if(!_2){
|
||||
_1=_1.replace(/'/gm,"'");
|
||||
}
|
||||
return _1;
|
||||
|
||||
dojo.getObject("_editor", true, dijit);
|
||||
|
||||
dijit._editor.escapeXml=function(/*String*/str, /*Boolean?*/noSingleQuotes){
|
||||
// summary:
|
||||
// Adds escape sequences for special characters in XML: &<>"'
|
||||
// Optionally skips escapes for single quotes
|
||||
str = str.replace(/&/gm, "&").replace(/</gm, "<").replace(/>/gm, ">").replace(/"/gm, """);
|
||||
if(!noSingleQuotes){
|
||||
str = str.replace(/'/gm, "'");
|
||||
}
|
||||
return str; // string
|
||||
};
|
||||
dijit._editor.getNodeHtml=function(_3){
|
||||
var _4;
|
||||
switch(_3.nodeType){
|
||||
case 1:
|
||||
var _5=_3.nodeName.toLowerCase();
|
||||
if(!_5||_5.charAt(0)=="/"){
|
||||
return "";
|
||||
}
|
||||
_4="<"+_5;
|
||||
var _6=[];
|
||||
var _7;
|
||||
if(dojo.isIE&&_3.outerHTML){
|
||||
var s=_3.outerHTML;
|
||||
s=s.substr(0,s.indexOf(">")).replace(/(['"])[^"']*\1/g,"");
|
||||
var _8=/(\b\w+)\s?=/g;
|
||||
var m,_9;
|
||||
while((m=_8.exec(s))){
|
||||
_9=m[1];
|
||||
if(_9.substr(0,3)!="_dj"){
|
||||
if(_9=="src"||_9=="href"){
|
||||
if(_3.getAttribute("_djrealurl")){
|
||||
_6.push([_9,_3.getAttribute("_djrealurl")]);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
var _a,_b;
|
||||
switch(_9){
|
||||
case "style":
|
||||
_a=_3.style.cssText.toLowerCase();
|
||||
break;
|
||||
case "class":
|
||||
_a=_3.className;
|
||||
break;
|
||||
case "width":
|
||||
if(_5==="img"){
|
||||
_b=/width=(\S+)/i.exec(s);
|
||||
if(_b){
|
||||
_a=_b[1];
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "height":
|
||||
if(_5==="img"){
|
||||
_b=/height=(\S+)/i.exec(s);
|
||||
if(_b){
|
||||
_a=_b[1];
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
_a=_3.getAttribute(_9);
|
||||
}
|
||||
if(_a!=null){
|
||||
_6.push([_9,_a.toString()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
var i=0;
|
||||
while((_7=_3.attributes[i++])){
|
||||
var n=_7.name;
|
||||
if(n.substr(0,3)!="_dj"){
|
||||
var v=_7.value;
|
||||
if(n=="src"||n=="href"){
|
||||
if(_3.getAttribute("_djrealurl")){
|
||||
v=_3.getAttribute("_djrealurl");
|
||||
}
|
||||
}
|
||||
_6.push([n,v]);
|
||||
}
|
||||
}
|
||||
}
|
||||
_6.sort(function(a,b){
|
||||
return a[0]<b[0]?-1:(a[0]==b[0]?0:1);
|
||||
});
|
||||
var j=0;
|
||||
while((_7=_6[j++])){
|
||||
_4+=" "+_7[0]+"=\""+(dojo.isString(_7[1])?dijit._editor.escapeXml(_7[1],true):_7[1])+"\"";
|
||||
}
|
||||
if(_5==="script"){
|
||||
_4+=">"+_3.innerHTML+"</"+_5+">";
|
||||
}else{
|
||||
if(_3.childNodes.length){
|
||||
_4+=">"+dijit._editor.getChildrenHtml(_3)+"</"+_5+">";
|
||||
}else{
|
||||
switch(_5){
|
||||
case "br":
|
||||
case "hr":
|
||||
case "img":
|
||||
case "input":
|
||||
case "base":
|
||||
case "meta":
|
||||
case "area":
|
||||
case "basefont":
|
||||
_4+=" />";
|
||||
break;
|
||||
default:
|
||||
_4+="></"+_5+">";
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
case 3:
|
||||
_4=dijit._editor.escapeXml(_3.nodeValue,true);
|
||||
break;
|
||||
case 8:
|
||||
_4="<!--"+dijit._editor.escapeXml(_3.nodeValue,true)+"-->";
|
||||
break;
|
||||
default:
|
||||
_4="<!-- Element not recognized - Type: "+_3.nodeType+" Name: "+_3.nodeName+"-->";
|
||||
}
|
||||
return _4;
|
||||
|
||||
dijit._editor.getNodeHtml=function(/* DomNode */node){
|
||||
var output;
|
||||
switch(node.nodeType){
|
||||
case 1: //element node
|
||||
var lName = node.nodeName.toLowerCase();
|
||||
if(!lName || lName.charAt(0) == "/"){
|
||||
// IE does some strange things with malformed HTML input, like
|
||||
// treating a close tag </span> without an open tag <span>, as
|
||||
// a new tag with tagName of /span. Corrupts output HTML, remove
|
||||
// them. Other browsers don't prefix tags that way, so will
|
||||
// never show up.
|
||||
return "";
|
||||
}
|
||||
output = '<' + lName;
|
||||
|
||||
//store the list of attributes and sort it to have the
|
||||
//attributes appear in the dictionary order
|
||||
var attrarray = [];
|
||||
var attr;
|
||||
if(dojo.isIE && node.outerHTML){
|
||||
var s = node.outerHTML;
|
||||
s = s.substr(0, s.indexOf('>'))
|
||||
.replace(/(['"])[^"']*\1/g, ''); //to make the following regexp safe
|
||||
var reg = /(\b\w+)\s?=/g;
|
||||
var m, key;
|
||||
while((m = reg.exec(s))){
|
||||
key = m[1];
|
||||
if(key.substr(0,3) != '_dj'){
|
||||
if(key == 'src' || key == 'href'){
|
||||
if(node.getAttribute('_djrealurl')){
|
||||
attrarray.push([key,node.getAttribute('_djrealurl')]);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
var val, match;
|
||||
switch(key){
|
||||
case 'style':
|
||||
val = node.style.cssText.toLowerCase();
|
||||
break;
|
||||
case 'class':
|
||||
val = node.className;
|
||||
break;
|
||||
case 'width':
|
||||
if(lName === "img"){
|
||||
// This somehow gets lost on IE for IMG tags and the like
|
||||
// and we have to find it in outerHTML, known IE oddity.
|
||||
match=/width=(\S+)/i.exec(s);
|
||||
if(match){
|
||||
val = match[1];
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'height':
|
||||
if(lName === "img"){
|
||||
// This somehow gets lost on IE for IMG tags and the like
|
||||
// and we have to find it in outerHTML, known IE oddity.
|
||||
match=/height=(\S+)/i.exec(s);
|
||||
if(match){
|
||||
val = match[1];
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
val = node.getAttribute(key);
|
||||
}
|
||||
if(val != null){
|
||||
attrarray.push([key, val.toString()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
var i = 0;
|
||||
while((attr = node.attributes[i++])){
|
||||
//ignore all attributes starting with _dj which are
|
||||
//internal temporary attributes used by the editor
|
||||
var n = attr.name;
|
||||
if(n.substr(0,3) != '_dj' /*&&
|
||||
(attr.specified == undefined || attr.specified)*/){
|
||||
var v = attr.value;
|
||||
if(n == 'src' || n == 'href'){
|
||||
if(node.getAttribute('_djrealurl')){
|
||||
v = node.getAttribute('_djrealurl');
|
||||
}
|
||||
}
|
||||
attrarray.push([n,v]);
|
||||
}
|
||||
}
|
||||
}
|
||||
attrarray.sort(function(a,b){
|
||||
return a[0] < b[0] ? -1 : (a[0] == b[0] ? 0 : 1);
|
||||
});
|
||||
var j = 0;
|
||||
while((attr = attrarray[j++])){
|
||||
output += ' ' + attr[0] + '="' +
|
||||
(dojo.isString(attr[1]) ? dijit._editor.escapeXml(attr[1], true) : attr[1]) + '"';
|
||||
}
|
||||
if(lName === "script"){
|
||||
// Browsers handle script tags differently in how you get content,
|
||||
// but innerHTML always seems to work, so insert its content that way
|
||||
// Yes, it's bad to allow script tags in the editor code, but some people
|
||||
// seem to want to do it, so we need to at least return them right.
|
||||
// other plugins/filters can strip them.
|
||||
output += '>' + node.innerHTML +'</' + lName + '>';
|
||||
}else{
|
||||
if(node.childNodes.length){
|
||||
output += '>' + dijit._editor.getChildrenHtml(node)+'</' + lName +'>';
|
||||
}else{
|
||||
switch(lName){
|
||||
case 'br':
|
||||
case 'hr':
|
||||
case 'img':
|
||||
case 'input':
|
||||
case 'base':
|
||||
case 'meta':
|
||||
case 'area':
|
||||
case 'basefont':
|
||||
// These should all be singly closed
|
||||
output += ' />';
|
||||
break;
|
||||
default:
|
||||
// Assume XML style separate closure for everything else.
|
||||
output += '></' + lName + '>';
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 4: // cdata
|
||||
case 3: // text
|
||||
// FIXME:
|
||||
output = dijit._editor.escapeXml(node.nodeValue, true);
|
||||
break;
|
||||
case 8: //comment
|
||||
// FIXME:
|
||||
output = '<!--' + dijit._editor.escapeXml(node.nodeValue, true) + '-->';
|
||||
break;
|
||||
default:
|
||||
output = "<!-- Element not recognized - Type: " + node.nodeType + " Name: " + node.nodeName + "-->";
|
||||
}
|
||||
return output;
|
||||
};
|
||||
dijit._editor.getChildrenHtml=function(_c){
|
||||
var _d="";
|
||||
if(!_c){
|
||||
return _d;
|
||||
}
|
||||
var _e=_c["childNodes"]||_c;
|
||||
var _f=!dojo.isIE||_e!==_c;
|
||||
var _10,i=0;
|
||||
while((_10=_e[i++])){
|
||||
if(!_f||_10.parentNode==_c){
|
||||
_d+=dijit._editor.getNodeHtml(_10);
|
||||
}
|
||||
}
|
||||
return _d;
|
||||
|
||||
dijit._editor.getChildrenHtml = function(/* DomNode */dom){
|
||||
// summary:
|
||||
// Returns the html content of a DomNode and children
|
||||
var out = "";
|
||||
if(!dom){ return out; }
|
||||
var nodes = dom["childNodes"] || dom;
|
||||
|
||||
//IE issue.
|
||||
//If we have an actual node we can check parent relationships on for IE,
|
||||
//We should check, as IE sometimes builds invalid DOMS. If no parent, we can't check
|
||||
//And should just process it and hope for the best.
|
||||
var checkParent = !dojo.isIE || nodes !== dom;
|
||||
|
||||
var node, i = 0;
|
||||
while((node = nodes[i++])){
|
||||
//IE is broken. DOMs are supposed to be a tree. But in the case of malformed HTML, IE generates a graph
|
||||
//meaning one node ends up with multiple references (multiple parents). This is totally wrong and invalid, but
|
||||
//such is what it is. We have to keep track and check for this because otherise the source output HTML will have dups.
|
||||
//No other browser generates a graph. Leave it to IE to break a fundamental DOM rule. So, we check the parent if we can
|
||||
//If we can't, nothing more we can do other than walk it.
|
||||
if(!checkParent || node.parentNode == dom){
|
||||
out += dijit._editor.getNodeHtml(node);
|
||||
}
|
||||
}
|
||||
return out; // String
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user