r1729 - in branches/bxe_2_0: js relaxng

[email protected] Mon, 13 Aug 2007 22:13:34 +0200 (CEST)
Newsgroups gmane.editors.bitflux.cvs
Message-ID <[email protected]>
Author: chregu
Date: Mon Aug 13 22:13:33 2007
New Revision: 1729

Log:
fix error with "wegclicken" of subelement chooser


Modified:
   branches/bxe_2_0/js/bxeFunctions.js
   branches/bxe_2_0/js/widget.js
   branches/bxe_2_0/relaxng/DocumentVAL.js

Modified: branches/bxe_2_0/js/bxeFunctions.js
==============================================================================
--- branches/bxe_2_0/js/bxeFunctions.js	(original)
+++ branches/bxe_2_0/js/bxeFunctions.js	Mon Aug 13 22:13:33 2007
@@ -145,13 +145,11 @@
 
 
 function bxe_history_snapshot() {
-
 	var xmlstr = bxe_getXmlDocument();
 	if (!xmlstr) { return false;}
 	bxe_snapshots_position++;
 	bxe_snapshots_last = bxe_snapshots_position;
 	bxe_snapshots[bxe_snapshots_position] = xmlstr;
-	
 	var i = bxe_snapshots_last + 1;
 	while (bxe_snapshots[i]) {
 		bxe_snapshots[i] = null;
@@ -165,7 +163,6 @@
 		}
 		bxe_snapshots = _temp;
 	}
-	
 	return (xmlstr);
 }
 
@@ -198,7 +195,8 @@
 	bxe_history_snapshot()
 }
 
-function bxe_history_undo() {
+function bxe_history_undo(last) {
+				
 	if (bxe_snapshots_position >= 0) {
 		if (bxe_snapshots_position == bxe_snapshots_last) {
 			var currXmlStr = bxe_history_snapshot();
@@ -210,7 +208,9 @@
 		if (!currXmlStr) { alert(bxe_i18n.getText("You're in Source Mode. Not possible to use this button")); return false;} 
 		var xmlstr = bxe_snapshots[bxe_snapshots_position];
 		if (xmlstr) {
-			bxe_snapshots_position--;
+			if (!last) {
+				bxe_snapshots_position--;
+			}
 			while(currXmlStr == xmlstr && bxe_snapshots[bxe_snapshots_position ] ) {
 				xmlstr = bxe_snapshots[bxe_snapshots_position];
 				bxe_snapshots_position--;
@@ -1397,12 +1397,13 @@
 				var menuitem;
 				var thisLocalName = thisNode.localName;
 				var thisNamespaceURI = thisNode.namespaceURI;
-				
-				for (i = 0; i < ac.length; i++) {
-					if (ac[i].nodeType != 3 && !ac[i].bxeDontshow && ac[i].vdom.canHaveChildren)  {
-						menuitem = bxe_format_list.appendItem(ac[i].vdom.bxeName, ac[i].localName + "=" + ac[i].namespaceURI);
-						if (ac[i].localName == thisLocalName &&  ac[i].namespaceURI == thisNamespaceURI) {
-							menuitem.selected=true;
+				if (ac) {
+					for (i = 0; i < ac.length; i++) {
+						if (ac[i].nodeType != 3 && !ac[i].bxeDontshow && ac[i].vdom.canHaveChildren)  {
+							menuitem = bxe_format_list.appendItem(ac[i].vdom.bxeName, ac[i].localName + "=" + ac[i].namespaceURI);
+							if (ac[i].localName == thisLocalName &&  ac[i].namespaceURI == thisNamespaceURI) {
+								menuitem.selected=true;
+							}
 						}
 					}
 				}

Modified: branches/bxe_2_0/js/widget.js
==============================================================================
--- branches/bxe_2_0/js/widget.js	(original)
+++ branches/bxe_2_0/js/widget.js	Mon Aug 13 22:13:33 2007
@@ -370,6 +370,13 @@
 		var widget = null;
 		while (widget = glob.HideOnClick.pop()) 
 		{ 
+			if (widget.isElementChooser && e.target.className != 'MenuItem') {
+						
+				while (!bxe_config.xmldoc.XMLNode.validateDocument(true)) {
+					bxe_history_undo();
+				}
+				
+			}
 			widget.hide();
 		}
 		glob.HideOnClick = newHideOnClick;
@@ -770,6 +777,8 @@
 
 Widget_ContextMenu.prototype.buildElementChooserPopup = function (node, ac ) {
 	this.Popup.removeAllMenuItems();
+	bxe_history_snapshot();
+	
 	this.Popup.initTitle(bxe_i18n.getText("Choose Subelement of {0}",new Array(node.vdom.bxeName)));
 	ac.sort(bxe_nodeSort);
 	for (i = 0; i < ac.length; i++) {
@@ -788,7 +797,7 @@
 	this.Popup.draw();
 	this.Popup.position(200,  window.scrollY + 200 );
 	this.Popup.draw();
-		
+	this.Popup.isElementChooser = true;
 	this.Popup._node = node;
 
 }
@@ -1279,6 +1288,7 @@
 	titeldiv.appendChild(document.createTextNode(title));
 	this.node.appendChild(titeldiv);
 	this.TitleNode = titeldiv;
+	this.isElementChooser = false;
 }
 
 Widget_ModalBox.prototype.initPane = function() {

Modified: branches/bxe_2_0/relaxng/DocumentVAL.js
==============================================================================
--- branches/bxe_2_0/relaxng/DocumentVAL.js	(original)
+++ branches/bxe_2_0/relaxng/DocumentVAL.js	Mon Aug 13 22:13:33 2007
@@ -23,7 +23,7 @@
 	return this._vdom.loadSchema(file, callback);
 }
 
-XMLNodeDocument.prototype.validateDocument = function() {
+XMLNodeDocument.prototype.validateDocument = function(noError) {
 	
 	if (!this.vdom) {
 		//if vdom was not attached to the document, try to find the global one...
@@ -38,7 +38,7 @@
 	if (!this.documentElement) {
 		this.documentElement = this._node.documentElement.XMLNode;
 	}
-	var c =  this.documentElement.isNodeValid(true);
+	var c =  this.documentElement.isNodeValid(true,null,noError);
 	/*FIXME: HACK... Sometimes the above statement does not check
 	   deep enough, do another check here for all editable Areas
 	   
@@ -50,7 +50,7 @@
 		if ((areaNodes[i]._SourceMode)) {
 			return false;
 		}
-		c = c & areaNodes[i].XMLNode.isNodeValid(true)
+		c = c & areaNodes[i].XMLNode.isNodeValid(true,null,noError)
 	}
 	
 	
-- 
Bx-editor-cvs mailing list
[email protected]
http://lists.bitflux.ch/cgi-bin/listinfo/bx-editor-cvs