r1396 - trunk/js

[email protected]
Newsgroups gmane.editors.bitflux.cvs
Message-ID <[email protected]>
Author: chregu
Date: Fri Sep 30 19:58:23 2005
New Revision: 1396

Modified:
   trunk/js/bxeFunctions.js
   trunk/js/widget.js
Log:
make attributes of non editable nodes also editble 


Modified: trunk/js/bxeFunctions.js
==============================================================================
--- trunk/js/bxeFunctions.js	(original)
+++ trunk/js/bxeFunctions.js	Fri Sep 30 19:58:23 2005
@@ -646,7 +646,6 @@
 		var menui = popup.addMenuItem("Edit " + e.target.XMLNode.nodeName  + " Attributes", mozilla.getWidgetGlobals().EditAttributes.popup);
 		menui.MenuPopup._node = node._node;
 	}
-
 	popup.addMenuItem("Copy "  + e.target.XMLNode.nodeName  + " Element", function (e) {
 		var widget = e.currentTarget.Widget;
 		var delNode = widget.MenuPopup.MainNode;
@@ -940,13 +939,18 @@
 		var cb = bxe_getCallback(e.additionalInfo.localName,e.additionalInfo.namespaceURI);
 		
 		if (cb ) {
-			bxe_doCallback(cb, aNode);
+			var sel = window.getSelection();
+			sel.collapse(aNode._node.nextSibling,0);
+			bxe_doCallback(cb, aNode, true);
 			return;
 		}
 		var newNode = new XMLNodeElement(e.additionalInfo.namespaceURI,e.additionalInfo.localName, 1 ) ;
+		
 		aNode.parentNode.insertAfter(newNode,aNode);
 		
 		newNode.parentNode.isNodeValid(true,2);
+		newNode._node.parentNode.insertBefore(newNode._node.ownerDocument.createTextNode(" "),newNode._node);
+		
 		newNode.makeDefaultNodes(e.additionalInfo.noPlaceholderText);
 		
 	}
@@ -1685,9 +1689,21 @@
 	sel.anchorNode.updateXMLNode();
 }
 
-function bxe_InsertLinkExtern(href,title) {
+function bxe_InsertLinkExtern(href,title,text) {
 	var sel = window.getSelection();
-	sel.linkText(href,title);
+	if (sel.toString().length == 0) {
+		var text = document.createTextNode(text);
+		var  a = document.createElementNS(XHTMLNS,"span");
+		a.setAttribute("class","a");
+		a.setAttribute("href",href);
+		if (title) {
+			a.setAttribute("title",title);
+		}
+		a.appendChild(text);
+		sel.insertNodeRaw(a);
+	} else {
+		sel.linkText(href,title);
+	}
 	sel.anchorNode.parentNode.updateXMLNode(true);
 	sel.focusNode.parentNode.updateXMLNode(true);
 }
@@ -2075,10 +2091,10 @@
 	}
 }
 
-function bxe_doCallback(cb, node ) {
+function bxe_doCallback(cb, node,dontPrecheck ) {
 	window.bxe_ContextNode = node;
 	//this is for prechecking, if an eventual popup should be called at all
-	if (cb["precheck"]) {
+	if (cb["precheck"] && !dontPrecheck) {
 		if (!(eval(cb["precheck"] +"(node)"))) {
 			return false;
 		} 

Modified: trunk/js/widget.js
==============================================================================
--- trunk/js/widget.js	(original)
+++ trunk/js/widget.js	Fri Sep 30 19:58:23 2005
@@ -811,7 +811,14 @@
 	}
 	
 	ac.sort(nodeSort);
-	
+		
+	if (node.XMLNode.vdom && node.XMLNode.vdom.hasAttributes ) {
+		
+		var menui = this.addMenuItem("Edit Attributes", mozilla.getWidgetGlobals().EditAttributes.popup);
+		menui.MenuPopup.MainNode = node.XMLNode;
+		
+	}
+				
 	for (i = 0; i < ac.length; i++) {
 		if (!bxe_config.dontShowInContext[ac[i].namespaceURI + ":" +ac[i].localName] && ac[i].nodeType != 3 ) {
 				var menui = this.addMenuItem("Insert " + ac[i].nodeName, function(e) { 
@@ -1035,6 +1042,7 @@
 		
 	var box = mozilla.getWidgetGlobals().EditAttributes;
 	var xmlnode = e.target.Widget.MenuPopup.MainNode;
+
 	box.reset("Edit Attributes of " + xmlnode.localName, function(values) {
 		
 		this.setAttributes(values);
-- 
Bx-editor-cvs mailing list
[email protected]
http://lists.bitflux.ch/cgi-bin/listinfo/bx-editor-cvs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.