[Zope-CVS] CVS: Packages/Moztop/moztop/content/workspace - dtmlpagebindings.xml:1.2 genericviewer.xml:1.5 midasbindings.xml:1.2 zptpagebindings.xml:1.5

Paul Everitt paul@zope.com
Thu, 17 Apr 2003 04:53:16 -0400


Update of /cvs-repository/Packages/Moztop/moztop/content/workspace
In directory cvs.zope.org:/tmp/cvs-serv15816

Modified Files:
	dtmlpagebindings.xml genericviewer.xml midasbindings.xml 
	zptpagebindings.xml 
Log Message:
The Midas editor now works for WYSIWYG editing.  It is only used for DTML Pages.

Also, if a resource doesn't supply a DAV D:dst for the location of the 
source, just use the URL to the resource itself as the default.


=== Packages/Moztop/moztop/content/workspace/dtmlpagebindings.xml 1.1 => 1.2 ===
--- Packages/Moztop/moztop/content/workspace/dtmlpagebindings.xml:1.1	Wed Mar 26 06:04:28 2003
+++ Packages/Moztop/moztop/content/workspace/dtmlpagebindings.xml	Thu Apr 17 04:53:16 2003
@@ -4,111 +4,54 @@
   xmlns:html="http://www.w3.org/1999/xhtml"
   xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
 
-  <binding id="dtmlpageviewerbinding" extends="genericviewer.xml#genericviewerbinding">
-    <content>
-      <xul:vbox flex="1">
-      <xul:hbox>
-	<xul:button label="Save" 
-		    oncommand="document.getBindingParent(this).save()"/>
-	<xul:button label="Delete" 
-		    oncommand="document.getBindingParent(this).remove()"/>
-	<xul:spacer flex="1"/>
-      </xul:hbox>
-      <xul:tabbox flex="1">
-
-	<xul:tabs>
-	  <xul:tab label="Content"/>
-	  <xul:tab label="Meta Data"/>
-	  <xul:tab label="Preview"/>
-        </xul:tabs>
-
-	<xul:tabpanels flex="1">
-	  <xul:dtmlpagecontentpanel flex="1"/>
-	  <xul:dtmlpagemetadatapanel flex="1"/>
-	  <xul:dtmlpagepreviewpanel flex="1"/>
-        </xul:tabpanels>
-
-      </xul:tabbox>
-      </xul:vbox>
-    </content>
-  </binding>
-
-  <binding id="dtmlpagecontentpanelbinding" extends="xul:tabpanel">
-    <content orient="vertical">
-      <xul:textbox id="field_source" anonid="content_source" 
-		   value="" flex="1" multiline="true"
-                   style="font-family: monospace; font-size: 12pt"/>
-    </content>
-
-    <implementation>
-      <constructor>
-      </constructor>
-    </implementation>
-
-  </binding>
-
-  <binding id="dtmlpagemetadatapanelbinding" extends="xul:tabpanel">
-    <content orient="vertical">
-
-      <xul:groupbox>
-        <xul:caption label="Edit"/>
-        <xul:grid flex="1">
-          <xul:columns>
-            <xul:column/>
-            <xul:column flex="1"/>
-          </xul:columns>
-          <xul:rows>
-            <xul:row>
-              <xul:label control="field_title" value="Title"/>
-              <xul:textbox id="field_title" flex="1"/>
-            </xul:row>
-            <xul:row>
-              <xul:label control="field_description" value="Description"/>
-              <xul:textbox id="field_description" flex="1"/>
-            </xul:row>
-            <xul:row>
-              <xul:label value="Created on:" />
-              <xul:label id="field_created" value="01/01/2003" />
-            </xul:row>
-            <xul:row>
-              <xul:label value="Last modified on:" />
-              <xul:label id="field_modified" value="01/01/2003" />
-            </xul:row>
-          </xul:rows>
-        </xul:grid>
-        <xul:box orient="horizontal">
-          <xul:button onclick="saveMetaData()" label="Save" />
-          <xul:button onclick="loadMetaData()" label="Refresh" />
-          <xul:spring flex="100%" />
-        </xul:box>
-      </xul:groupbox>
-
-    </content>
-
-    <implementation>
-      <constructor>
-      </constructor>
-    </implementation>
-
-  </binding>
-
-  <binding id="dtmlpagepreviewpanelbinding" extends="xul:tabpanel">
-    <content orient="vertical">
-      <xul:iframe id="preview-frame" src="" flex="1"/>
-      <xul:box orient="horizontal">
-        <xul:button onclick="loadPreview();" label="Reload Content" />
-        <xul:spring flex="100%" />
-      </xul:box>
-    </content>
-
-    <implementation>
-      <constructor>
-        // The constructor assumes that 'urn' is defined in this scope
-        var iframe = document.getElementById('preview-frame');
-        iframe.setAttribute("src", urn);
-      </constructor>
-    </implementation>
+<binding id="dtmlpageviewerbinding" 
+	 extends="genericviewer.xml#genericviewerbinding">
 
-  </binding>
+  <content>
+    <xul:tabbox flex="1">
+      <xul:tabs>
+	<xul:tab label="Content" id="content-tab"/>
+	<xul:tab label="Properties" id="properties-tab"/>
+	<xul:tab label="Preview" id="preview-tab" 
+		 onclick="parentWidget=document.getBindingParent(this);
+			  parentWidget.previewWidget.update();
+			  return false;"/>
+      </xul:tabs>
+
+      <xul:tabpanels flex="1">
+        <xul:midaseditor flex="1" id="content-panel"/>
+	<xul:zptpagemetadatapanel flex="1" value="x" id="properties-panel"/>
+	<xul:zptpagepreviewpanel flex="1" id="preview-panel"/>
+      </xul:tabpanels>
+
+    </xul:tabbox>
+  </content>
+
+  <implementation>
+    <method name="createResource">
+      <body><![CDATA[
+
+	url = this.getAttribute("urn");
+	thiswidget = this;
+
+        function callback (response) {
+            // Called back by jsdav.PUT
+
+	    container = sitesmanager.getSelectedResource();
+            ds = sitesmanager.getDataSource(container.datasource.URI);
+            resource = ds.getNode(url);            
+	    resource.modifyTarget(sitesmanager.titleprop, 
+                   thiswidget.resourcetitle,val);
+            alert("Made it here");
+        }
+
+        var jsdav = new DavClient();
+        jsdav.PUT(url, "", null, callback);
+        return;
+      ]]></body>
+
+    </method>
+  </implementation>
+</binding>
 
 </bindings>


=== Packages/Moztop/moztop/content/workspace/genericviewer.xml 1.4 => 1.5 ===
--- Packages/Moztop/moztop/content/workspace/genericviewer.xml:1.4	Mon Apr  7 07:21:40 2003
+++ Packages/Moztop/moztop/content/workspace/genericviewer.xml	Thu Apr 17 04:53:16 2003
@@ -27,6 +27,8 @@
     <property name="content">
       <getter>
 	/* First grab this tab widget, then grab the current contents */
+
+	return this.contentWidget.content;
 	dump("\nin content getter");
 	var xulns = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
 	var thisobj = document.getAnonymousNodes(this)[0]
@@ -44,10 +46,10 @@
 	var xulns = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
 	var thisobj = document.getAnonymousNodes(this)[0]
 	              .getElementsByTagNameNS(xulns,"tabpanels")[0].selectedPanel;
-	var textbox = document
-                       .getAnonymousElementByAttribute(thisobj,
-		       "anonid","content_source");
-        textbox.value=val;
+//	var textbox = document
+//                       .getAnonymousElementByAttribute(thisobj,
+//		       "anonid","content_source");
+        this.contentWidget.content=val;
 	return val;
 	dump("\nleaving content.setter");
       </setter>
@@ -67,8 +69,13 @@
              }
          }
 
+         thiswidget = this;
+         function callback (response) {
+             // Do nothing.
+         }
+
 	 var davclient = new DavClient();
-	 davclient.PUT(url,this.content,"PageTemplate");
+	 davclient.PUT(url,this.content,"PageTemplate", callback);
       ]]></body>
     </method>
 
@@ -98,8 +105,12 @@
 
             dump("\nstarting getSourceURL callback");
             var dst = response.responseXML
-                         .getElementsByTagNameNS("DAV:", "dst")[0]
-                         .firstChild.nodeValue;
+                         .getElementsByTagNameNS("DAV:", "dst")
+            if (dst.length) {
+                var dst = dst[0].firstChild.nodeValue;
+            } else {
+                var dst = thiswidget.sourceurl;
+            }
             thiswidget.setAttribute("sourceurl", dst);
             thiswidget.getContent();
             
@@ -160,15 +171,17 @@
 	return;
       }
 
-      dump("\nkdkdkd;lkjasd;fljas;fjasd fkj");
       this.getSourceURL();
 
       // Some shortcuts for grabbing subwidget elements
-      this.contentWidget = document.getAnonymousElementByAttribute(this, 'id','content-panel')
-      this.propertiesWidget = document.getAnonymousElementByAttribute(this, 'id','properties-panel')
-      this.previewWidget = document.getAnonymousElementByAttribute(this, 'id','preview-panel')
+      this.contentWidget = document
+              .getAnonymousElementByAttribute(this, 'id','content-panel');
+      this.propertiesWidget = document
+              .getAnonymousElementByAttribute(this, 'id','properties-panel');
+      this.previewWidget = document
+              .getAnonymousElementByAttribute(this, 'id','preview-panel');
 
-      return;
+      return true;
     </constructor>
 
   </implementation>


=== Packages/Moztop/moztop/content/workspace/midasbindings.xml 1.1 => 1.2 ===
--- Packages/Moztop/moztop/content/workspace/midasbindings.xml:1.1	Wed Apr  2 13:23:39 2003
+++ Packages/Moztop/moztop/content/workspace/midasbindings.xml	Thu Apr 17 04:53:16 2003
@@ -6,111 +6,142 @@
     xmlns:html="http://www.w3.org/1999/xhtml"
     xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
     
-    
-    
-<binding id="midaseditorbinding" extends="genericviewer.xml#genericwidgetbinding">
+<binding id="midaseditorbinding"
+	 extends="genericviewer.xml#genericviewerbinding">
   <content>
-    <xul:tabbox flex="1">
-      <xul:vbox flex="1">
-        <xul:toolbox >
-          <xul:toolbar id="FormatToolbar" persist="collapsed" tbalign="center">
-            <xul:toolbarbutton id="boldButton" oncommand='document.getBindingParent(this).midasCommand("Bold");'/>
-                            <xul:toolbarbutton id="italicButton" oncommand='document.getBindingParent(this).midasCommand("Italic");'/>                        
-                            <xul:toolbarbutton id="underlineButton" oncommand='document.getBindingParent(this).midasCommand("Underline");'/> 
-                            <xul:toolbarbutton id="olButton" oncommand='document.getBindingParent(this).midasCommand("insertorderedlist");'/> 
-                            <xul:toolbarbutton id="ulButton" oncommand='document.getBindingParent(this).midasCommand("insertunorderedlist");'/> 
-                            <xul:toolbarbutton id="outdentButton" oncommand='document.getBindingParent(this).midasCommand("outdent");'/> 
-                            <xul:toolbarbutton id="indentButton" oncommand='document.getBindingParent(this).midasCommand("indent");'/> 
-                            <xul:toolbarbutton id="align-left-button" oncommand='document.getBindingParent(this).midasCommand("justifyleft");'/> 
-                            <xul:toolbarbutton id="align-center-button" oncommand='document.getBindingParent(this).midasCommand("justifycenter");'/> 
-                            <xul:toolbarbutton id="align-right-button" oncommand='document.getBindingParent(this).midasCommand("justifyright");'/> 
-                            <xul:toolbarbutton id="align-justify-button" oncommand='document.getBindingParent(this).midasCommand("justifyfull");'/> 
-                        </xul:toolbar>
-                    </xul:toolbox>                    
-                    <xul:spacer flex="1" height="5px"/>
-                    <xul:iframe src="" height="300px" flex="1"/>
-                </xul:vbox> 
-            </xul:tabbox>
-        </content>
-        <implementation>
-            <constructor>
-                // this has to be changed. it only works, if this widget is on the first tab... waiting for proposal of paul about better solution
-                this.startUp()
-            </constructor>
-            
-            <field name="editFrame"/>
-            
-
-            <property name="content">
-                <getter>
-                    <![CDATA[ 
-
-                    var ser = new XMLSerializer();
-                    var children = this.editFrame.contentDocument.body.childNodes;
-                    var out = "";
-                    for (i = 0; i < children.length; i++ ) {
-                        out += ser.serializeToString(children[i]);
-                    }
-                    return out;
-                    ]]>
-                </getter>
-                <setter>
-                    this.editFrame.contentDocument.body.innerHTML = val;
-                </setter>
-            </property>
-            
-            <method name="update">
-                <body>
-                    this.content = this.parentWidget.content;
-                    return true;
-                </body>
-            </method>
-            
-            <method name="startUp">
-                <body>
-                    this.loadHTML();    
-                </body>
-            </method>
-            
-            <method name="setEditFrame">
-                <body>
-                    <![CDATA[ 
-              this.editFrame = document.getAnonymousNodes(this)[0].getElementsByTagNameNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul","iframe")[0];
-            ]]>              
-                </body>
-            </method>
-            
-            
-            <method name="enableDesignMode">
-                <parameter name="event"/>
-                <body>
-                    <![CDATA[ 
-        // this = iframe here, since it's called from the onload event of the iframe
-            this.contentDocument.designMode = "on";
-            this.contentDocument.execCommand("useCSS", false, true);  
+    <xul:vbox flex="1">
+      <xul:toolbox>
+        <xul:toolbar id="FormatToolbar" persist="collapsed" tbalign="center">
+
+          <xul:toolbarbutton id="cutButton" tooltiptext="Cut" 
+			     oncommand="document.getBindingParent(this).midasCommand('')"/>
+          <xul:toolbarbutton id="copyButton" tooltiptext="Copy" 
+			     oncommand="document.getBindingParent(this).midasCommand('')"/>
+          <xul:toolbarbutton id="pasteButton" tooltiptext="Paste" 
+			     oncommand="document.getBindingParent(this).midasCommand('')"/>
+
+          <xul:toolbarbutton id="undoButton" tooltiptext="Undo" 
+			     oncommand="document.getBindingParent(this).midasCommand('')"/>
+          <xul:toolbarbutton id="redoButton" tooltiptext="Redo" 
+			     oncommand="document.getBindingParent(this).midasCommand('')"/>
+
+          <xul:toolbarbutton id="boldButton" tooltiptext="Bold" 
+			     oncommand="document.getBindingParent(this).midasCommand('Bold')"/>
+          <xul:toolbarbutton id="italicButton" tooltiptext="Italic" 
+			     oncommand="document.getBindingParent(this).midasCommand('Italic')"/>
+          <xul:toolbarbutton id="underlineButton" tooltiptext="Underline" 
+			     oncommand="document.getBindingParent(this).midasCommand('Underline')"/>
+          <xul:toolbarbutton id="olButton" tooltiptext="Numbered List" 
+			     oncommand="document.getBindingParent(this).midasCommand('insertorderedlist')"/>
+          <xul:toolbarbutton id="ulButton" tooltiptext="Bulleted List" 
+			     oncommand="document.getBindingParent(this).midasCommand('insertunorderedlist')"/>
+          <xul:toolbarbutton id="indentButton" tooltiptext="Indent" 
+			     oncommand="document.getBindingParent(this).midasCommand('indent')"/>
+          <xul:toolbarbutton id="alignleftButton" tooltiptext="Left Align" 
+			     oncommand="document.getBindingParent(this).midasCommand('justifyleft')"/>
+          <xul:toolbarbutton id="aligncenterButton" tooltiptext="Center" 
+			     oncommand="document.getBindingParent(this).midasCommand('justifycenter')"/>
+          <xul:toolbarbutton id="alignrightButton" tooltiptext="Right Align" 
+			     oncommand="document.getBindingParent(this).midasCommand('justifyright')"/>
+
+          <xul:toolbarbutton id="linkButton" tooltiptext="Link" 
+			     oncommand="alert('Not implemented yet.');"/>
+          <xul:toolbarbutton id="viewsourceButton" tooltiptext="View Source" 
+			     oncommand="document.getBindingParent(this).viewsource()"/>
+        </xul:toolbar>
+      </xul:toolbox>
+      <xul:iframe id="editbox" src="" height="100%" width="100%" flex="1"/>
+    </xul:vbox> 
+  </content>
+
+  <implementation>
+
+    <property name="content">
+      <getter>
+        <![CDATA[ 
+
+        var ser = new XMLSerializer();
+        var children = this.editFrame.contentDocument.body.childNodes;
+        var out = "";
+        for (i = 0; i < children.length; i++ ) {
+           out += ser.serializeToString(children[i]);
+        }
+        return out;
         ]]>
-                </body>
-            </method>
-            <method name="loadHTML">
-                <body><![CDATA[ 
-
-                    this.setEditFrame();
-
-                    this.editFrame.onload = this.enableDesignMode;
-                    if (this.editFrame.getAttribute("src") == "" ) {
-                        this.editFrame.setAttribute("src", document.getBindingParent(this).sourceurl );
-                    }
-                    
-              ]]></body>
-            </method>
-            <method name="midasCommand">
-                <parameter name="commandName"/>
-                <body><![CDATA[ 
-                    this.editFrame.contentDocument.execCommand(commandName, false, null);
-              ]]></body>
-            </method>
-            
-        </implementation>
-    </binding>
+      </getter>
+      <setter>
+        this.editFrame.contentDocument.body.innerHTML = val;
+        this.editFrame.contentDocument.designMode = "on";
+        //this.editFrame.contentDocument.execCommand("useCSS", false, true);  
+      </setter>
+    </property>
+
+
+    <method name="enableDesignMode">
+      <parameter name="event"/>
+        <body>
+          <![CDATA[ 
+          // this = iframe here, since it's called from the onload event of the iframe
+          this.contentDocument.designMode = "on";
+          this.contentDocument.execCommand("useCSS", false, true);  
+          ]]>
+        </body>
+    </method>
+
+
+    <method name="loadHTML">
+      <body>
+        xulns = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
+        this.editFrame = document.getAnonymousNodes(this)[0]
+           .getElementsByTagNameNS(xulns,"iframe")[0];
+	// This next line is now done inside the content sette above
+        //this.editFrame.onload = this.enableDesignMode;
+        return true;
+      </body>
+    </method>
+
+
+    <method name="viewsource">
+      <body>
+
+      // First find out if the toolbarbutton is set to view source or WYSIWYG
+      viewsourcebutton = document.getAnonymousElementByAttribute(this, "id", "viewsourceButton");
+      source = viewsourcebutton.getAttribute("issource");
+
+      if (source == "0") {
+        var html = document.createTextNode(document.getElementById('editbox')
+                .contentWindow.document.body.innerHTML);
+        document.getElementById('editbox').contentWindow.document.body.innerHTML = "";
+        document.getElementById('editbox').contentWindow.document.body.appendChild(html);
+        viewsourcebutton.setAttribute("issource", "1");
+      } 
+      else {
+        var html = document.getElementById('editbox').contentWindow
+                .document.body.ownerDocument.createRange();
+        html.selectNodeContents(document.getElementById('editbox').contentWindow.document.body);
+        document.getElementById('editbox').contentWindow.document.body.innerHTML = html.toString();
+        viewsourcebutton.setAttribute("issource", "0");
+      }
+
+      </body>
+    </method>
+
+
+    <method name="midasCommand">
+      <parameter name="commandName"/>
+      <body><![CDATA[ 
+        this.editFrame.contentDocument.execCommand(commandName, false, null);
+      ]]></body>
+    </method>
+
+
+    <constructor>
+      this.loadHTML();
+      return true;
+    </constructor>
+
+  </implementation>
+
+</binding>
 
 </bindings>


=== Packages/Moztop/moztop/content/workspace/zptpagebindings.xml 1.4 => 1.5 ===
--- Packages/Moztop/moztop/content/workspace/zptpagebindings.xml:1.4	Mon Apr  7 07:21:40 2003
+++ Packages/Moztop/moztop/content/workspace/zptpagebindings.xml	Thu Apr 17 04:53:16 2003
@@ -63,6 +63,28 @@
 		 flex="1" multiline="true"
                  style="font-family: monospace; font-size: 12pt"/>
   </content>
+
+  <implementation>
+
+    <property name="content">
+      <getter>
+        <![CDATA[ 
+        xulns = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
+        editFrame = document.getAnonymousElementByAttribute(this,
+	       "anonid","content_source");
+        return editFrame.value;
+        ]]>
+      </getter>
+      <setter>
+        xulns = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
+        editFrame = document.getAnonymousElementByAttribute(this,
+	       "anonid","content_source");
+        editFrame.value = val;
+      </setter>
+    </property>
+
+  </implementation>
+
 </binding>