r1687 - branches/bxe_2_0/js

[email protected] Wed, 30 May 2007 17:04:01 +0200 (CEST)
Newsgroups gmane.editors.bitflux.cvs
Message-ID <[email protected]>
Author: chregu
Date: Wed May 30 17:04:01 2007
New Revision: 1687

Log:
BXEB-15
Table Types: Move up/down


Modified:
   branches/bxe_2_0/js/bxeFunctions.js
   branches/bxe_2_0/js/table.js

Modified: branches/bxe_2_0/js/bxeFunctions.js
==============================================================================
--- branches/bxe_2_0/js/bxeFunctions.js	(original)
+++ branches/bxe_2_0/js/bxeFunctions.js	Wed May 30 17:04:01 2007
@@ -800,20 +800,45 @@
 		}, bxe_i18n.getText("Removes the Element, but not its children"));
 	}
 
-	if (node.previousSibling) {
+	var previousSibling = node.previousSibling;
+	while (previousSibling && previousSibling.nodeType != 1) {
+		previousSibling = previousSibling.previousSibling;
+	}
+	
+	if (previousSibling) {
 		popup.addMenuItem(bxe_i18n.getText("Move up"), function (e) {
 			var widget = e.currentTarget.Widget;
 			var appNode = widget.MenuPopup.MainNode;
 			bxe_moveUp(appNode);
 		});
+		if (previousSibling.vdom.bxeTabletype == "table-cell" || previousSibling.vdom.bxeTabletype == "table-col" ) {
+					var menui = popup.addMenuItem(bxe_i18n.getText("Move left"), function(e) {
+				var widget = e.currentTarget.Widget;
+				var _par = widget.MenuPopup.MainNode._node.parentNode;
+				widget.MenuPopup.MainNode._node.TableCellMoveLeft();
+				bxe_Transform(true,false,widget.MenuPopup.MainNode.parentNode);
+			});
+		}
+		
 	}
-	
-	if (node.nextSibling) {
+	var nextSibling = node.nextSibling;
+	while (nextSibling && nextSibling.nodeType != 1) {
+		nextSibling = nextSibling.nextSibling;
+	}
+	if (nextSibling) {
 		popup.addMenuItem(bxe_i18n.getText("Move down"), function (e) {
 			var widget = e.currentTarget.Widget;
 			var appNode = widget.MenuPopup.MainNode;
 			bxe_moveDown(appNode);
 		});
+		if (nextSibling.vdom.bxeTabletype == "table-cell" || nextSibling.vdom.bxeTabletype == "table-col" ) {
+					var menui = popup.addMenuItem(bxe_i18n.getText("Move right"), function(e) {
+				var widget = e.currentTarget.Widget;
+				var _par = widget.MenuPopup.MainNode._node.parentNode;
+				widget.MenuPopup.MainNode._node.TableCellMoveRight();
+				bxe_Transform(true,false,widget.MenuPopup.MainNode.parentNode);
+			});
+		}
 	}
 	
 
@@ -870,10 +895,7 @@
 		}
 		
 		
-		var nextSibling = node.nextSibling;
-		while (nextSibling && nextSibling.nodeType != 1) {
-			nextSibling = nextSibling.nextSibling;
-		}
+		
 		if (nextSibling && (nextSibling.vdom.bxeTabletype == "table-cell" || nextSibling.vdom.bxeTabletype == "table-col" )) {
 			var menui = popup.addMenuItem(bxe_i18n.getText("Merge right"), function(e) {
 				var widget = e.currentTarget.Widget;
@@ -882,6 +904,7 @@
 				bxe_Transform(true,false,widget.MenuPopup.MainNode.parentNode);
 				//_par.updateXMLNode();
 			});
+
 		}
 	
 		var _par = node.parentNode;

Modified: branches/bxe_2_0/js/table.js
==============================================================================
--- branches/bxe_2_0/js/table.js	(original)
+++ branches/bxe_2_0/js/table.js	Wed May 30 17:04:01 2007
@@ -76,11 +76,7 @@
 			return;
 		
 	}
-	/*
-	var nextSibling = this.nextSibling;
-	while (nextSibling && nextSibling.nodeType != 1) {
-		nextSibling = nextSibling.nextSibling;
-	}*/
+
 	var child = rightCol.firstChild;
 	while (child) {
 		var nextchild = child.nextSibling;
@@ -94,6 +90,51 @@
 	return this.parentNode.parentNode;
 }
 
+Element.prototype.TableCellMoveRight = function () {
+	var positions = bxe_table_getRowAndColPosition(this);
+	var matrix = positions['matrix'];
+	var rowPos = positions['row'];
+	var colPos = positions['col'];
+	
+	var thisColspan = bxe_table_getSpanCount(this.getAttribute("colspan"));
+	var rightCol = matrix[rowPos][colPos+thisColspan][1];
+	if (!rightCol) {
+		alert(bxe_i18n.getText("There's no right cell to be moved"));
+		return;
+	}
+	
+	for(var y = 1; y <= matrix[0][0][0]; y++) {
+		var tmp = matrix[y][colPos] ;
+		matrix[y][colPos] = matrix[y][colPos + 1]
+		matrix[y][colPos + 1] = tmp;
+	}
+	return bxe_rebuildTableByTableMatrix(this, matrix);
+	
+}
+
+
+Element.prototype.TableCellMoveLeft = function () {
+	var positions = bxe_table_getRowAndColPosition(this);
+	var matrix = positions['matrix'];
+	var rowPos = positions['row'];
+	var colPos = positions['col'];
+	console.log(colPos);
+	if (colPos == 1) {
+	
+		alert(bxe_i18n.getText("There's no left cell to be moved"));
+		return;
+	}
+	
+	for(var y = 1; y <= matrix[0][0][0]; y++) {
+		var tmp = matrix[y][colPos] ;
+		matrix[y][colPos] = matrix[y][colPos - 1]
+		matrix[y][colPos -1] = tmp;
+	}
+	return bxe_rebuildTableByTableMatrix(this, matrix);
+	
+}
+
+
 
 
 Element.prototype.TableCellMergeDown = function () {
@@ -994,7 +1035,6 @@
 function bxe_table_getTableRowInfo(tbody, refCell) {
 		// get tr field info
 	var ac  = tbody.XMLNode.allowedChildren;
-	
 	if (typeof refCell != "undefined" && refCell.XMLNode.vdom.bxeTabletype == "table-col") {
 		
 		var celltype = 	"table-colgroup";
-- 
Bx-editor-cvs mailing list
[email protected]
http://lists.bitflux.ch/cgi-bin/listinfo/bx-editor-cvs