| Newsgroups |
gmane.editors.bitflux.cvs |
| Message-ID |
<[email protected]> |
Author: chregu
Date: Thu Dec 15 15:15:14 2005
New Revision: 1419
Modified:
branches/bxe_2_0/js/bxeFunctions.js
branches/bxe_2_0/js/bxeNodeElements.js
branches/bxe_2_0/js/bxeXMLNode.js
branches/bxe_2_0/js/table.js
Log:
use new table element detection
Modified: branches/bxe_2_0/js/bxeFunctions.js
==============================================================================
--- branches/bxe_2_0/js/bxeFunctions.js (original)
+++ branches/bxe_2_0/js/bxeFunctions.js Thu Dec 15 15:15:14 2005
@@ -766,8 +766,7 @@
}
-
- if (node.localName == "td" || node.localName == "th") {
+ if (node.vdom.bxeTabletype && node.vdom.bxeTabletype == "table-cell") {
popup.addSeparator();
// merge right
// popup.addSeparator();
@@ -801,7 +800,7 @@
while (nextSibling && nextSibling.nodeType != 1) {
nextSibling = nextSibling.nextSibling;
}
- if (nextSibling && (nextSibling.localName == "td" || nextSibling.localName == "th")) {
+ if (nextSibling && (nextSibling.vdom.bxeTabletype == "table-cell")) {
var menui = popup.addMenuItem(bxe_i18n.getText("Merge right"), function(e) {
var widget = e.currentTarget.Widget;
var _par = widget.MenuPopup.MainNode._node.parentNode;
@@ -812,7 +811,7 @@
}
var _par = node.parentNode;
- while(_par && _par.localName != "tr") {
+ while(_par && _par.vdom.bxeTabletype == "table-row") {
_par = _par.parentNode;
}
@@ -1028,6 +1027,29 @@
}
}
+function bxe_changeLinesContainer2(e) {
+ bxe_history_snapshot();
+ //alert (window.bxe_ContextNode.nodeName);
+
+ var nodeParts = e.split("=");
+ if (nodeParts.length < 2 ) {
+ nodeParts[1] = null;
+ }
+
+ var newContainer = window.bxe_ContextNode._node.changeContainer(nodeParts[1], nodeParts[0]);
+
+ newContainer.XMLNode = new XMLNodeElement( nodeParts[1], nodeParts[0], window.bxe_ContextNode._node.nodeType);
+ try {
+ newContainer.updateXMLNode();
+ } catch(e) {alert(newContainer + " can't be updateXMLNode()'ed\n" + e);
+ }
+
+ newContainer.XMLNode.parentNode.isNodeValid(false, 2,false,true);
+ bxe_history_snapshot_async();
+ window.bxe_ContextNode = newContainer.XMLNode;
+ //bxe_delayedUpdateXPath();
+}
+
function bxe_changeLinesContainer(e) {
@@ -1229,7 +1251,10 @@
//make toolbar
bxe_toolbar = new Widget_ToolBar();
- bxe_format_list = new Widget_MenuList("m",function(e) {eDOMEventCall("changeLinesContainer",document,this.value)});
+ bxe_format_list = new Widget_MenuList("m",function(e) {
+ bxe_changeLinesContainer2(this.value);
+ // eDOMEventCall("changeLinesContainer",document,this.value)
+ });
bxe_toolbar.addItem(bxe_format_list);
@@ -1295,9 +1320,8 @@
bxe_format_list.appendItem(bxe_i18n.getText("no block found"),"");
return false;
}
-
+ window.bxe_ContextNode = thisNode;
var ac = thisNode.parentNode.allowedChildren;
-
var menuitem;
var thisLocalName = thisNode.localName;
var thisNamespaceURI = thisNode.namespaceURI;
Modified: branches/bxe_2_0/js/bxeNodeElements.js
==============================================================================
--- branches/bxe_2_0/js/bxeNodeElements.js (original)
+++ branches/bxe_2_0/js/bxeNodeElements.js Thu Dec 15 15:15:14 2005
@@ -110,6 +110,43 @@
} while(node );
}
+Element.prototype.changeContainer = function(namespace, localName) {
+ var keep = false;
+ if (namespace == XHTMLNS) {
+ var removeClass = false;
+ //if (lines[i].__container.getAttribute("class"));
+ if (this.XMLNode) {
+ if (this.XMLNode.nodeName == this.getAttribute("class")) {
+ removeClass = true;
+ }
+ }
+ var newNode = documentCreateXHTMLElement(localName)
+ if (removeClass) {
+ this.removeAttribute("class");
+ }
+ } else {
+ var newNode = document.createElementNS(XHTMLNS,"div");
+ this.setAttribute("class", containerName);
+ }
+
+ for(var i=0; i<this.attributes.length; i++)
+ {
+ var childAttribute = this.attributes.item(i);
+ var childAttributeCopy = childAttribute.cloneNode(true);
+ newNode.setAttributeNode(childAttributeCopy);
+ }
+ var childContents = document.createRange();
+ childContents.selectNodeContents(this);
+
+ newNode.appendChild(childContents.extractContents());
+ childContents.detach();
+ this.parentNode.replaceChild(newNode, this);
+
+
+ newNode.setAttribute("__bxe_ns", namespace);
+ return newNode;
+
+}
Node.prototype.getXPathString = function(rebuilt) {
if (this._xpathstring && !rebuilt) {
Modified: branches/bxe_2_0/js/bxeXMLNode.js
==============================================================================
--- branches/bxe_2_0/js/bxeXMLNode.js (original)
+++ branches/bxe_2_0/js/bxeXMLNode.js Thu Dec 15 15:15:14 2005
@@ -316,13 +316,13 @@
} else {
var ac = this.allowedChildren;
if (ac.length == 1) {
- eDOMEventCall("appendChildNode",document,{"noTransform": true, "appendToNode": this, "localName":ac[0].nodeName,"namespaceURI":ac[0].namespaceURI});
+ eDOMEventCall("appendChildNode",document,{"noTransform": true, "appendToNode": this, "localName":ac[0].localName,"namespaceURI":ac[0].namespaceURI});
ret = this;
} else if (ac.length > 1) {
var _hasMust = false;
for ( var i in ac) {
if (!(ac[i].optional ) ) {
- eDOMEventCall("appendChildNode",document,{"noTransform": true, "appendToNode": this, "localName":ac[i].nodeName,"namespaceURI":ac[i].namespaceURI});
+ eDOMEventCall("appendChildNode",document,{"noTransform": true, "appendToNode": this, "localName":ac[i].localName,"namespaceURI":ac[i].namespaceURI});
_hasMust =true;
}
Modified: branches/bxe_2_0/js/table.js
==============================================================================
--- branches/bxe_2_0/js/table.js (original)
+++ branches/bxe_2_0/js/table.js Thu Dec 15 15:15:14 2005
@@ -45,7 +45,7 @@
var prevSibling = this.previousSibling;
var pos = 1;
while(prevSibling) {
- if (prevSibling.nodeType == 1 && (prevSibling.localName == "td" || cell.localName == "th")) {
+ if (prevSibling.nodeType == 1 && (prevSibling.XMLNode.vdom.bxeTabletype == "table-cell")) {
var _attr = prevSibling.getAttribute("colspan");
if (_attr > 0) {
pos += parseInt( _attr);
@@ -206,7 +206,7 @@
var nextpos = 1;
while (cell) {
- if (cell.nodeType == 1 && (cell.localName == "td" || cell.localName == "th")) {
+ if (cell.nodeType == 1 && (cell.XMLNode.vdom.bxeTabletype == "table-cell")) {
if (nextpos >= pos) {
return cell;
}
@@ -306,7 +306,7 @@
var cellLeft = null;
var pos;
for (var i=0; i< tr.childNodes.length; i++) {
- if (tr.childNodes[i].localName == "td") {
+ if (tr.childNodes[i].XMLNode.vdom.bxeTabletype == "table-cell") {
if (tr.childNodes[i] == td) {
pos = i;
break;
@@ -405,7 +405,7 @@
return;
}
// <cope> changed != "entry" to "xhtml:td" in order to get the fucking col/rowspan work
- if (BX_range.startContainer.parentNode.nodeName.toLowerCase() != "xhtml:td")
+ if (BX_range.startContainer.parentNode.XMLNode.vdom.bxeTabletype == "table-cell")
{
alert(bxe_i18n.getText("No table-cell (but {0}) selected, please choose one",new Array(BX_range.startContainer.parentNode.nodeName)));
return ;
@@ -446,7 +446,6 @@
function bxe_table_insert_row(cell)
{
-
var positions = bxe_table_getRowAndColPosition(cell);
var matrix = positions['matrix'];
var rowPos = positions['row'];
@@ -737,7 +736,7 @@
// find on which row position we are
for (var i = 0; i < tbody.childNodes.length; i++)
{
- if (tbody.childNodes[i].nodeName.toLowerCase() != "tr") continue;
+ if(! (tbody.childNodes[i].XMLNode && tbody.childNodes[i].XMLNode.vdom && tbody.childNodes[i].XMLNode.vdom.bxeTabletype == "table-row")) { continue; }
ii++;
if (tbody.childNodes[i] == row)
{
@@ -968,15 +967,14 @@
var firstRow = null;
for(var r = 0; r < table_node.childNodes.length; r++) {
row = table_node.childNodes[r];
- if(row.nodeName.toLowerCase() != "tr") { continue; }
+ if(!(row.XMLNode && row.XMLNode.vdom && row.XMLNode.vdom.bxeTabletype == "table-row")) { continue; }
if (!firstRow) { firstRow = row;}
rows += bxe_table_getSpanCount(row.getAttribute("rowspan"));
}
var nodeName = "";
for(var r = 0; r < firstRow.childNodes.length; r++) {
cell = firstRow.childNodes[r];
- nodeName = cell.nodeName.toLowerCase();
- if(!(nodeName == "td" || nodeName == "th")) { continue; }
+ if(!(cell.XMLNode && cell.XMLNode.vdom && cell.XMLNode.vdom.bxeTabletype == "table-cell")) { continue; }
cols += bxe_table_getSpanCount(cell.getAttribute("colspan"));
}
@@ -1010,15 +1008,20 @@
var tr = 0; //matrix coordinates
var tc = 0;
//loop all real existing table rows
+ debug ("hhh\n");
for(var r = 0; r < tbody.childNodes.length; r++) {
row = tbody.childNodes[r];
- if(row.nodeName.toLowerCase() != "tr") continue; //caution: may be there are text nodes (CRLF or whitespace)
+ debug ("hhh " + tr +"\n");
+ if(! (row.XMLNode && row.XMLNode.vdom && row.XMLNode.vdom.bxeTabletype == "table-row")) { continue; } //caution: may be there are text nodes (CRLF or whitespace)
tr++;
+
tc = 0;
//loop all real existing table cells
for(var c = 0; c < row.childNodes.length; c++) {
cell = row.childNodes[c];
- if(cell.nodeName.toLowerCase() != "td" && cell.nodeName.toLowerCase() != "th") continue; //caution: may be there are text nodes (CRLF or whitespace)
+
+ if(! (cell.XMLNode && cell.XMLNode.vdom && cell.XMLNode.vdom.bxeTabletype == "table-cell")) {continue;} //caution: may be there are text nodes (CRLF or whitespace)
+
tc++;
//find the homogenious matrix pos
//alert("tr="+tr+" tc="+tc);
--
Bx-editor-cvs mailing list
[email protected]
http://lists.bitflux.ch/cgi-bin/listinfo/bx-editor-cvs