r1512 - branches/bxe_2_0/js
[email protected] Wed, 27 Sep 2006 13:14:16 +0200 (CEST)
| Newsgroups | gmane.editors.bitflux.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: chregu
Date: Wed Sep 27 13:14:15 2006
New Revision: 1512
Modified:
branches/bxe_2_0/js/bxeFunctions.js
Log:
fixed bechtle bug 38
clean inline ueber z.B. bold-Element: BXE haengt sich auf
Modified: branches/bxe_2_0/js/bxeFunctions.js
==============================================================================
--- branches/bxe_2_0/js/bxeFunctions.js (original)
+++ branches/bxe_2_0/js/bxeFunctions.js Wed Sep 27 13:14:15 2006
@@ -1531,7 +1531,7 @@
}
// the following is legacy code. actually not needed anymore, AFAIK..
var cssr = sel.getEditableRange();
- if (cssr && cssr.top._SourceMode) {
+ if (cssr && cssr.top && cssr.top._SourceMode) {
alert(bxe_i18n.getText("You're in Source Mode. Not possible to use this button"));
return true;
}
@@ -1639,8 +1639,14 @@
function bxe_CleanInline(e) {
bxe_CleanInlineIntern();
}
-
-function bxe_CleanInlineIntern(localName, namespaceUri) {
+function bxe_CleanInlineIntern(localName, namespaceUri, z) {
+ if (!z) {z = 0;}
+ z++;
+ if (z > 10) {
+ bxe_Transform();
+ dump("recursive protection\n");
+ return;
+ }
var sel = window.getSelection();
var doitagain = 0;
if (bxe_checkForSourceMode(sel)) {
@@ -1648,70 +1654,84 @@
}
var cssr = sel.getEditableRange();
+ if (!cssr) {
+ return;
+ }
+
if(cssr.collapsed)
return;
// go through all text nodes in the range and link to them unless already set to cssr link
var textNodes = cssr.textNodes;
- for(i=0; i<textNodes.length; i++) {
+ var len = textNodes.length;
+ for(i=0; i<len; i++) {
// figure out cssr and then it's on to efficiency before subroutines ... ex of sub ...
// try text nodes returning one node ie/ node itself! could cut down on normalize calls ...
+
if (textNodes[i].parentNode.XMLNode) {
- var textContainer = textNodes[i].parentNode.XMLNode._node;
- if (textNodes[i].parentNode && textNodes[i].parentNode.getCStyle("display") == "inline") {
- if (localName) {
- if (textContainer.parentNode && textContainer.parentNode.firstChild == textContainer) {
- textNodes.push(textContainer);
- }
- if(!(textContainer.XMLNode.localName == localName &&
- textContainer.XMLNode.namespaceURI == namespaceUri)) {
- continue;
- }
- }
- if(textContainer.childNodes.length > 1) {
- var siblingHolder;
-
- // leave any nodes before or after cssr one with their own copy of the container
- if(textNodes[i].previousSibling) {
- if (textNodes[i].previousSibling.nodeType == 3) {
- var siblingHolder = textContainer.cloneNode(false);
- textContainer.parentNode.insertBefore(siblingHolder, textContainer);
- siblingHolder.appendChild(textNodes[i].previousSibling);
+ var textContainer = textNodes[i].parentNode.XMLNode._node;
+ if (textNodes[i].parentNode && textNodes[i].parentNode.getCStyle("display") == "inline") {
+ if (localName) {
+ if (textContainer.parentNode && textContainer.parentNode.firstChild == textContainer) {
+ textNodes.push(textContainer);
+ }
+ if(!(textContainer.XMLNode.localName == localName &&
+ textContainer.XMLNode.namespaceURI == namespaceUri)) {
+ continue;
}
}
- if(textNodes[i].nextSibling) {
- if (textNodes[i].nextSibling.nodeType == 3) {
- var siblingHolder = textContainer.cloneNode(false);
- if(textContainer.nextSibling) {
- textContainer.parentNode.insertBefore(siblingHolder, textContainer.nextSibling);
- } else {
- textContainer.parentNode.appendChild(siblingHolder);
+ if(textContainer.childNodes.length > 1) {
+
+ var siblingHolder;
+
+ // leave any nodes before or after cssr one with their own copy of the container
+ if(textNodes[i].previousSibling) {
+ if (textNodes[i].previousSibling.nodeType == 3) {
+ var siblingHolder = textContainer.cloneNode(false);
+ textContainer.parentNode.insertBefore(siblingHolder, textContainer);
+ siblingHolder.appendChild(textNodes[i].previousSibling);
}
- siblingHolder.appendChild(textNodes[i].nextSibling);
- } else {
- textContainer.split(1);
}
-
+ if(textNodes[i].nextSibling) {
+ if (textNodes[i].nextSibling.nodeType == 3) {
+ var siblingHolder = textContainer.cloneNode(false);
+ if(textContainer.nextSibling) {
+ textContainer.parentNode.insertBefore(siblingHolder, textContainer.nextSibling);
+ } else {
+ textContainer.parentNode.appendChild(siblingHolder);
+ }
+ siblingHolder.appendChild(textNodes[i].nextSibling);
+ } else {
+ textContainer.split(1);
+ }
+
+ }
}
- }
- // rename it to span and remove its href. If span is empty then delete span
- if (textContainer.parentNode) {
- doitagain++;
- textContainer.parentNode.removeChildOnly(textContainer);
- }
+ if (textContainer.parentNode) {
+ doitagain++;
+ var _par = textContainer.parentNode;
+ _par.removeChildOnly(textContainer);
+ _par.normalize();
+ }
+ }
+
}
-}
}
+ bxe_Transform();
+ /*
-
+ FIXME: It doesn't clean nested inline styles right now.... This would be the way to do it,
+ if we could keep selections over transformations. Look into it later
if (doitagain > 1 || (!localName && cssr.startContainer.parentNode.getCStyle("display") == "inline")) {
- bxe_CleanInlineIntern(localName,namespaceUri);
+ bxe_Transform();
+ bxe_CleanInlineIntern(localName,namespaceUri,z);
} else {
bxe_Transform();
- }
+
+ }*/
}
@@ -2187,7 +2207,6 @@
var _childPosition = bxe_getChildPosition(sel.anchorNode);
var _offset =sel.anchorOffset;
-
bxe_config.xmldoc.documentElement.init();
dump ("getDomDocument " + (new Date() - startTimer)/1000 + " sec\n");
@@ -2288,9 +2307,11 @@
}
} else {
try {
+
sel.collapse(_topNode.childNodes[_childPosition], _offset);
} catch(e) {
//didn't work
+
}
}
--
Bx-editor-cvs mailing list
[email protected]
http://lists.bitflux.ch/cgi-bin/listinfo/bx-editor-cvs