mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-23 05:09:56 +09:00
17223554 : xquared upgrade to 0.7
git-svn-id: http://xe-core.googlecode.com/svn/sandbox@4968 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
5956e254e7
commit
7c3b336e41
59 changed files with 34562 additions and 8454 deletions
84
modules/editor/skins/xquared/javascripts/validator/W3.js
Normal file
84
modules/editor/skins/xquared/javascripts/validator/W3.js
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
/**
|
||||
* @requires Xquared.js
|
||||
* @requires validator/Base.js
|
||||
*/
|
||||
xq.validator.W3 = xq.Class(xq.validator.Base,
|
||||
/**
|
||||
* @name xq.validator.W3
|
||||
* @lends xq.validator.W3.prototype
|
||||
* @extends xq.validator.Base
|
||||
* @constructor
|
||||
*/
|
||||
{
|
||||
validateDom: function(element) {
|
||||
var rdom = xq.rdom.Base.createInstance();
|
||||
rdom.setRoot(element);
|
||||
this.removeDangerousElements(element);
|
||||
rdom.removePlaceHoldersAndEmptyNodes(element);
|
||||
this.validateFont(element);
|
||||
},
|
||||
|
||||
validateString: function(html) {
|
||||
try {
|
||||
html = this.replaceTag(html, "b", "strong");
|
||||
html = this.replaceTag(html, "i", "em");
|
||||
|
||||
html = this.validateStrike(html);
|
||||
html = this.validateUnderline(html);
|
||||
html = this.addNbspToEmptyBlocks(html);
|
||||
html = this.performFullValidation(html);
|
||||
html = this.insertNewlineBetweenBlockElements(html);
|
||||
} catch(ignored) {}
|
||||
|
||||
return html;
|
||||
},
|
||||
|
||||
invalidateDom: function(element) {
|
||||
this.invalidateFont(element);
|
||||
this.invalidateStrikesAndUnderlines(element);
|
||||
},
|
||||
|
||||
invalidateString: function(html) {
|
||||
html = this.replaceTag(html, "strong", "b");
|
||||
html = this.replaceTag(html, "em", "i");
|
||||
html = this.removeComments(html);
|
||||
html = this.replaceNbspToBr(html);
|
||||
return html;
|
||||
},
|
||||
|
||||
performFullValidation: function(html) {
|
||||
html = this.validateSelfClosingTags(html);
|
||||
html = this.applyWhitelist(html);
|
||||
|
||||
if(this.urlValidationMode === 'relative') {
|
||||
html = this.makeUrlsRelative(html);
|
||||
} else if(this.urlValidationMode === 'host_relative') {
|
||||
html = this.makeUrlsHostRelative(html);
|
||||
} else if(this.urlValidationMode === 'absolute') {
|
||||
html = this.makeUrlsAbsolute(html);
|
||||
}
|
||||
|
||||
return html;
|
||||
},
|
||||
|
||||
insertNewlineBetweenBlockElements: function(html) {
|
||||
var blocks = new xq.DomTree().getBlockTags().join("|");
|
||||
var regex = new RegExp("</(" + blocks + ")>([^\n])", "img");
|
||||
return html.replace(regex, '</$1>\n$2');
|
||||
},
|
||||
|
||||
addNbspToEmptyBlocks: function(content) {
|
||||
var blocks = new xq.DomTree().getBlockTags().join("|");
|
||||
var regex = new RegExp("<(" + blocks + ")>\\s*?</(" + blocks + ")>", "img");
|
||||
return content.replace(regex, '<$1> </$2>');
|
||||
},
|
||||
|
||||
replaceNbspToBr: function(content) {
|
||||
var blocks = new xq.DomTree().getBlockTags().join("|");
|
||||
|
||||
// Safari replaces into \xA0
|
||||
var regex = new RegExp("<(" + blocks + ")>( |\xA0)?</(" + blocks + ")>", "img");
|
||||
var rdom = xq.rdom.Base.createInstance();
|
||||
return content.replace(regex, '<$1>' + rdom.makePlaceHolderString() + '</$3>');
|
||||
}
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue