r1681 - in xwiki/trunk/web/standard/src/main/webapp/wiki_editor_2: . plugins
Phung Hai Nam
namphunghai at users.forge.objectweb.org
Wed Dec 6 09:21:11 CET 2006
Author: namphunghai
Date: 2006-12-06 09:21:10 +0100 (Wed, 06 Dec 2006)
New Revision: 1681
Modified:
xwiki/trunk/web/standard/src/main/webapp/wiki_editor_2/plugins/core.js
xwiki/trunk/web/standard/src/main/webapp/wiki_editor_2/wiki_editor.js
Log:
XWIKI-398: Rename methods convertFontsInternal -> convertStylesInternal and convertFontsExternal -> convertStylesExternal in Core.js and convertFontsInternal => SplitOverlapSpans in wiki_editor.js.
Modified: xwiki/trunk/web/standard/src/main/webapp/wiki_editor_2/plugins/core.js
===================================================================
--- xwiki/trunk/web/standard/src/main/webapp/wiki_editor_2/plugins/core.js 2006-12-05 10:07:16 UTC (rev 1680)
+++ xwiki/trunk/web/standard/src/main/webapp/wiki_editor_2/plugins/core.js 2006-12-06 08:21:10 UTC (rev 1681)
@@ -23,8 +23,8 @@
// Must remove the html tag format so it won't interfere with paragraph conversion
this.addExternalProcessor((/<%([\s\S]+?)%>/ig), '<%$1%>');
- this.addExternalProcessor((/\{style:\s*(.*?)\}([\s\S]+?)\{style\}/i), 'convertFontExternal');
- this.addInternalProcessor((/<(font|span|div)\s*(.*?)>([\s\S]+?)<\/(font|span|div)>/i), 'convertFontInternal');
+ this.addExternalProcessor((/\{style:\s*(.*?)\}([\s\S]+?)\{style\}/i), 'convertStyleExternal');
+ this.addInternalProcessor((/<(font|span|div)\s*(.*?)>([\s\S]+?)<\/(font|span|div)>/i), 'convertStyleInternal');
this.addExternalProcessor((/((\s|\S)*)/i), 'convertParagraphExternal');
this.addInternalProcessor((/<\s*p\s*([^>]*)>(.*?)<\s*\/\s*p\s*>/gi), '\r\n$2\r\n');
@@ -918,7 +918,7 @@
return str;
}
-WikiEditor.prototype.convertFontExternal = function(regexp, result, content) {
+WikiEditor.prototype.convertStyleExternal = function(regexp, result, content) {
var str = "";
var tag = "font";
var atts = result[1].split("|");
@@ -949,13 +949,13 @@
return content.replace(regexp, str) ;
}
-WikiEditor.prototype.convertFontInternal = function(regexp, result, content) {
+WikiEditor.prototype.convertStyleInternal = function(regexp, result, content) {
var type = result[1];
var str = "";
if (type == "span" || type =="div") {
var attributes = this.readAttributes(result[2]);
str += "{style:type=" + type;
- if (attributes["style"]) {
+ if (attributes && attributes["style"]) {
var atts = attributes["style"].split(";");
for (var i=0; i < atts.length ; i++) {
var att = this.trimString(atts[i].substring(0, atts[i].indexOf(":")));
Modified: xwiki/trunk/web/standard/src/main/webapp/wiki_editor_2/wiki_editor.js
===================================================================
--- xwiki/trunk/web/standard/src/main/webapp/wiki_editor_2/wiki_editor.js 2006-12-05 10:07:16 UTC (rev 1680)
+++ xwiki/trunk/web/standard/src/main/webapp/wiki_editor_2/wiki_editor.js 2006-12-06 08:21:10 UTC (rev 1681)
@@ -284,7 +284,7 @@
and returning a Wiki Syntax equivalent.
*/
WikiEditor.prototype.convertInternal = function(content) {
- this.convertFontsInternal(content);
+ this.splitOverlapSpans(content);
var regexp, r;
var lines;
var lastIndex;
@@ -318,7 +318,7 @@
}
// This function to convert Fonts from Wiki syntax to internal html representation
-WikiEditor.prototype.convertFontsInternal = function(content) {
+WikiEditor.prototype.splitOverlapSpans = function(content) {
var doc = this.core.selectedInstance.getDoc();
var s = doc.getElementsByTagName("span");
for (var i = s.length - 1; i >= 0 ; i--) {
@@ -335,30 +335,33 @@
var childAtts = childNodes[j].style;
newNode = childNodes[j].cloneNode(true);
- for (var k=0; k < parentAtts.length; k++) {
- var overlap = new Boolean("true");
- for (var kk=0 ; kk < childAtts.length; kk++) {
- if (this.trimString(parentAtts[k]) == this.trimString(childAtts[kk])) {
- overlap = false;
+ if (parentAtts != null) {
+ for (var k=0; k < parentAtts.length; k++) {
+ var overlap = new Boolean("true");
+ if (childAtts != null)
+ for (var kk=0 ; kk < childAtts.length; kk++) {
+ if (this.trimString(parentAtts[k]) == this.trimString(childAtts[kk]))
+ overlap = false;
+ }
+ else overlap = false;
+
+ if (overlap) {
+ switch (parentAtts[k]) {
+ case "color" :
+ newNode.style.color = s[i].style.color;
+ break;
+ case "background-color" :
+ newNode.style.backgroundColor = s[i].style.backgroundColor;
+ break;
+ case "font-family" :
+ newNode.style.fontFamily = s[i].style.fontFamily;
+ break;
+ case "font-size" :
+ newNode.style.fontSize = s[i].style.fontSize;
+ break;
+ }
}
}
- if (overlap) {
- switch (parentAtts[k]) {
- case "color" :
- newNode.style.color = s[i].style.color;
- break;
- case "background-color" :
- newNode.style.backgroundColor = s[i].style.backgroundColor;
- break;
- case "font-family" :
- newNode.style.fontFamily = s[i].style.fontFamily;
- break;
- case "font-size" :
- newNode.style.fontSize = s[i].style.fontSize;
- break;
- }
- }
-
}
parent.insertBefore(newNode, node);
newNode = node.cloneNode(false);
More information about the Xwiki-notifications
mailing list