[Zope-CVS] CVS: Packages/Moztop/moztop/content/workspace - midasbindings.xml:1.1 genericviewer.xml:1.2 zptpagebindings.xml:1.2 zptpagebindings.xbl:NONE
Paul Everitt
paul@zope.com
Wed, 2 Apr 2003 13:23:40 -0500
Update of /cvs-repository/Packages/Moztop/moztop/content/workspace
In directory cvs.zope.org:/tmp/cvs-serv20064
Modified Files:
genericviewer.xml zptpagebindings.xml
Added Files:
midasbindings.xml
Removed Files:
zptpagebindings.xbl
Log Message:
Major overhaul to support PROPFIND on d:source, but more to come...
=== Added File Packages/Moztop/moztop/content/workspace/midasbindings.xml ===
<?xml version="1.0"?>
<bindings xmlns="http://www.mozilla.org/xbl"
xmlns:xbl="http://www.mozilla.org/xbl"
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">
<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);
]]>
</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>
</bindings>
=== Packages/Moztop/moztop/content/workspace/genericviewer.xml 1.1 => 1.2 ===
--- Packages/Moztop/moztop/content/workspace/genericviewer.xml:1.1 Wed Mar 26 06:04:28 2003
+++ Packages/Moztop/moztop/content/workspace/genericviewer.xml Wed Apr 2 13:23:39 2003
@@ -1,5 +1,8 @@
<?xml version="1.0"?>
-<bindings xmlns="http://www.mozilla.org/xbl" xmlns:xbl="http://www.mozilla.org/xbl" xmlns:html="http://www.w3.org/1999/xhtml" xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+<bindings xmlns="http://www.mozilla.org/xbl"
+ xmlns:xbl="http://www.mozilla.org/xbl"
+ xmlns:html="http://www.w3.org/1999/xhtml"
+ xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<binding id="genericviewerbinding" extends="xul:tabpanel">
<implementation>
@@ -10,12 +13,15 @@
<property name="content">
<getter>
/* First grab this tab widget, then grab the current contents */
+ dump("\nin content getter");
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");
+ dump("\ntextbox.value is " + textbox.value);
+ dump("\nleaving content getter");
return textbox.value;
</getter>
<setter>
@@ -29,6 +35,7 @@
"anonid","content_source");
textbox.value=val;
return val;
+ dump("\nleaving content.setter");
</setter>
</property>
@@ -69,22 +76,24 @@
/* Called by the contructor and refresh to get this object's content */
var url = this.getAttribute("urn");
+ thiswidget = this;
+
/* First retrieve the DAV source property */
- function callback (responseXML, callbackObj) {
+ function callback (response) {
/* Called back by the JS DAV PROPFIND function to save state */
dump("\nstarting getSourceURL callback");
- var dst = responseXML.getElementsByTagNameNS("DAV:", "dst")[0]
- .firstChild.nodeValue;
- callbackObj.setAttribute("sourceurl", dst);
- callbackObj.getContent();
+ var dst = response.responseXML
+ .getElementsByTagNameNS("DAV:", "dst")[0]
+ .firstChild.nodeValue;
+ thiswidget.setAttribute("sourceurl", dst);
+ thiswidget.getContent();
dump("\nfinishing getSourceURL callback with D:dst=" + dst);
return;
}
var jsdav = new DavClient();
- jsdav.callbackObj = this;
var pf = new PropFind();
var p = new Prop("DAV:");
p.addProperty("source");
@@ -96,25 +105,29 @@
<method name="getContent">
<body><![CDATA[
- dump("\nstarting getContent");
-
-
/* Called by the contructor and refresh to get this object's content */
var sourceurl = this.getAttribute("sourceurl");
+ /* For now we must work around the absence of */
+ /* somezptdoc/getSource URLs in Zope 3. */
+ var sourceurl = this.getAttribute("urn");
+ dump("\nin getContent, sourceurl is " + sourceurl);
+
+
+ thiswidget = this;
/* First retrieve the DAV source property */
- function callback (request, callbackObj) {
+ function callback (response) {
/* Called back by the JS DAV GET function to save state */
dump("\nstarting getContent callback");
- dump("\nrequest.responseText is " + request.responseText);
- callbackObj.setAttribute("content", request.responseText);
+ dump("\nresponse.responseText is " + response.responseText);
+ thiswidget.content = response.responseText;
dump("\nfinishing getContent callback");
return;
}
var jsdav = new DavClient();
- jsdav.callbackObj = this;
jsdav.GET(sourceurl, callback);
+ dump("\nfinishing getContent");
return;
]]></body>
@@ -122,6 +135,12 @@
<constructor>
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')
+
return;
</constructor>
@@ -129,163 +148,16 @@
</binding>
-
-
-
-
-<binding id="XXXXXXXgenericviewerbinding" extends="xul:tabpanel">
- <content>
- <xul:tabbox flex="1">
-
- <xul:tabs oncommand="document.getBindingParent(this).onTabsClick(this);">
- <xul:tab label="Contents"/>
- <xul:tab label="Source"/>
- <xul:tab label="Preview"/>
- <xul:tab label="Properties"/>
- <xul:tab label="Web Manage"/>
- </xul:tabs>
-
- <xul:tabpanels>
- <xul:tabpanel flex="1">
- <xul:textbox value="Some sample text" flex="1"/>
- </xul:tabpanel>
- <xul:tabpanel>
- <xul:sourceditor/>
- </xul:tabpanel>
- <xul:tabpanel>
- <xul:preview/>
- </xul:tabpanel>
- <xul:tabpanel>
- <xul:label/>
- </xul:tabpanel>
- <xul:tabpanel>
- <xul:label/>
- </xul:tabpanel>
- </xul:tabpanels>
-
- </xul:tabbox>
- <xul:button label="save"/>
- </content>
+<binding id="genericwidgetbinding" extends="xul:tabpanel">
<implementation>
- <field name="urn"/>
- <field name="resourcetitle"/>
- <field name="sourceurl"/>
- <field name="previewurl"/>
- <field name="saveurl"/>
-
<constructor>
- <![CDATA[
- // code by paul
- var folderviewer = document.getAnonymousNodes(this)[0].parentNode;
- var parent = folderviewer.parentNode.parentNode;
- var tabs = parent.getElementsByTagName("tabs")[0];
- var rt = this.resourcetitle;
- var thistab = document.createElement("tab");
- thistab.setAttribute("label",rt);
- thistab.setAttribute("id",rt + "-tab");
- tabs.appendChild(thistab);
- tabs.selectedItem = thistab;
-
- // code by chregu
- this.currentPanelEditWidget = document.getAnonymousNodes(this)[0].getElementsByTagNameNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul","tabpanels")[0].selectedPanel.childNodes[0];
- ]]>
+ this.parentWidget = document.getBindingParent(this);
</constructor>
-
- <property name="content">
- <getter>
- return this.currentPanelEditWidget.content;
- </getter>
- </property>
+ </implementation>
+</binding>
- <method name="onTabsClick">
- <parameter name="tabs"/>
- <body>
- <![CDATA[
- tab = tabs.parentNode.selectedTab;
- panel = tabs.parentNode.selectedPanel;
- panelwidget = panel.childNodes[0];
- if (panelwidget.update()) {
- this.currentPanelEditWidget = panelwidget;
- }
- ]]>
- </body>
- </method>
- <method name="checkResponse">
- <parameter name="xmlHttpReq"/>
- <body><![CDATA[
- if ((xmlHttpReq.status>=200) && (xmlHttpReq.status<300)) {
- window.defaultStatus = "saved successfully";
- } else {
- alert("save failed with code " + xmlHttpReq.status +
- "and message '" + xmlHttpReq.statusText + "'");
- }
- ]]></body>
- </method>
- <method name="saveIt">
- <body>
- this.perform("PUT");
- </body>
- </method>
- <method name="deleteIt">
- <body>
- this.perform("DELETE");
- </body>
- </method>
- <method name="perform">
- <parameter name="method"/>
- <body>
- dump("Starting to save...");
- if (this.saveurl != "") {
-/*
-
- var p = new XMLHttpRequest();
- p.targetcontainer = sitesds.getSelectedResource();
- if (!p.targetcontainer) {
- alert("Please select a folder");
- return;
- }
-
- p.thisobj = this;
- p.onload = function(e) {
- p = e.target;
- dump("RESPONSE \n"+ p.responseText);
-
- /* Now add a node to the tree */
- var compositeds = sitesds.getCompositeDS();
- var node = compositeds.getNode(p.thisobj.sourceurl);
- var articleprop = "urn:oscom:resourcetypes:article";
- var articleres = compositeds.getNode(articleprop);
- node.addTarget(sitesds.resourcetypeprop,articleres);
- node.addTarget(sitesds.titleprop,p.thisobj.resourcetitle);
- var subitems = p.targetcontainer.getTarget(sitesds.subitemsprop);
- subitems.addChild(node);
-
- dump("\nresource added to tree");
-
- }
- p.open("PUT",this.saveurl);
- p.send(this.content,true);
-
-*/
- var xmlHttpReq = new XMLHttpRequest();
- xmlHttpReq.container = this;
- xmlHttpReq.onload = function(event) {
- xmlHttpReq = event.target;
- xmlHttpReq.container.checkResponse(xmlHttpReq);
- }
- xmlHttpReq.open(method,this.saveurl);
- xmlHttpReq.send(this.content,true);
- }
- else {
- alert("no saveurl provided");
- }
- </body>
- </method>
- </implementation>
- </binding>
-
-
- <binding id="genericsourceeditor" extends="#genericwidget">
+
+ <binding id="genericsourceeditor" extends="#genericwidgetbinding">
<content>
<xul:vbox flex="1">
<xul:textbox name="sourceedit" height="300px" flex="1"/>
@@ -338,12 +210,5 @@
</implementation>
</binding>
- <binding id="genericwidget">
-
- <implementation>
- <constructor>
- this.parentWidget = document.getBindingParent(this);
- </constructor>
- </implementation>
- </binding>
+
</bindings>
=== Packages/Moztop/moztop/content/workspace/zptpagebindings.xml 1.1 => 1.2 ===
--- Packages/Moztop/moztop/content/workspace/zptpagebindings.xml:1.1 Wed Mar 26 06:04:28 2003
+++ Packages/Moztop/moztop/content/workspace/zptpagebindings.xml Wed Apr 2 13:23:39 2003
@@ -4,55 +4,70 @@
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
- <binding id="zptpageviewerbinding" 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).delete()"/>
- <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:zptpagecontentpanel flex="1"/>
- <xul:zptpagemetadatapanel flex="1"/>
- <xul:zptpagepreviewpanel flex="1"/>
- </xul:tabpanels>
-
- </xul:tabbox>
- </xul:vbox>
- </content>
-
- <implementation>
- <constructor>
- </constructor>
- </implementation>
- </binding>
-
- <binding id="zptpagecontentpanelbinding" 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="zptpagemetadatapanelbinding" extends="xul:tabpanel">
- <content orient="vertical">
+<binding id="zptpageviewerbinding"
+ extends="genericviewer.xml#genericviewerbinding">
+ <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:zptpagecontentpanel flex="1" id="content-panel"/>
+<!-- <xul:midaseditor flex="1" id="content-panel"/> -->
+ <xul:zptpagemetadatapanel flex="1" id="properties-panel"/>
+ <xul:zptpagepreviewpanel flex="1" id="preview-panel"/>
+ </xul:tabpanels>
+
+ </xul:tabbox>
+ </content>
+
+<!--
+ <implementation>
+ <constructor>
+ this.sourceFrame = document.getAnonymousNodes(this)[0].getElementsByAttribute('name','sourceedit')[0];
+ </constructor>
+
+ <property name="content">
+ <getter>
+ return(this.sourceFrame.value);
+ </getter>
+ <setter>
+ this.sourceFrame.value = val;
+ </setter>
+ </property>
+
+ <method name="update">
+ <body>
+ this.content = this.parentWidget.content;
+ return true;
+ </body>
+ </method>
+
+ </implementation>
+-->
+
+</binding>
+
+
+<binding id="zptpagecontentpanelbinding"
+ extends="genericviewer.xml#genericwidgetbinding">
+ <content orient="vertical">
+ <xul:textbox id="sourceedit" anonid="content_source" value=""
+ flex="1" multiline="true"
+ style="font-family: monospace; font-size: 12pt"/>
+ </content>
+</binding>
+
+
+<binding id="zptpagemetadatapanelbinding"
+ extends="genericviewer.xml#genericwidgetbinding">
+ <content orient="vertical">
<xul:groupbox>
<xul:caption label="Edit"/>
@@ -87,32 +102,60 @@
</xul:box>
</xul:groupbox>
- </content>
+ </content>
+</binding>
+
- <implementation>
- <constructor>
- </constructor>
- </implementation>
-
- </binding>
-
- <binding id="zptpagepreviewpanelbinding" 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
+<binding id="zptpagepreviewpanelbinding"
+ extends="genericviewer.xml#genericwidgetbinding">
+
+ <content orient="vertical">
+ <xul:iframe id="preview-frame" src=""
+ style="background-color: white" flex="1"/>
+ </content>
+
+ <implementation>
+ <method name="update">
+ <body>
+ thiswidget = document.getAnonymousNodes(this)[0];
+ parentwidget = thiswidget.parentNode.parentNode.parentNode.parentNode.parentNode;
+ dump("\nparentwidget.tagname is " + parentwidget.tagName);
+ dump("\nparentwidget.urn is " + parentwidget.getAttribute("urn"));
+ sourceurl = parentwidget.getAttribute("urn");
var iframe = document.getElementById('preview-frame');
- iframe.setAttribute("src", urn);
- </constructor>
- </implementation>
- </binding>
+ alert("src is " + sourceurl);
+
+ iframe.setAttribute("src", sourceurl);
+ return;
+ alert("srcurl is " + srcurl);
+ var ifr = document.getAnonymousNodes(this)[0].getElementsByTagNameNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul','iframe')[0];
+ if (!ifr.getAttribute('src')) {
+ ifr.setAttribute('src',srcurl);
+ } else {
+ ifr.webNavigation.reload(ifr.webNavigation.LOAD_FLAGS_NONE);
+ }
+ return false;
+ </body>
+ </method>
+
+ <method name="loadPreview">
+ <body>
+ <![CDATA[
+ var iframe = document.getElementById('preview-frame');
+ urn = document.getAnonymousNodes(this)[0].getAttribute("urn");
+alert("urn is " + urn);
+ iframe.setAttribute("src", this.getAttribute("urn"));
+ ]]>
+ </body>
+ </method>
+
+ <constructor>
+ // The constructor assumes that 'urn' is defined in this scope
+ var iframe = document.getElementById('preview-frame');
+ iframe.setAttribute("src", urn);
+ </constructor>
+ </implementation>
+</binding>
</bindings>
=== Removed File Packages/Moztop/moztop/content/workspace/zptpagebindings.xbl ===