[Zope-CVS] CVS: Packages/Moztop/moztop/content/ContentObjects/ZPTPage - Content.js:1.1 Content.xul:1.1 MetaData.js:1.1 MetaData.xul:1.1 Preview.js:1.1 Preview.xul:1.1 Security.xul:1.1

Stephan Richter srichter@cbu.edu
Thu, 16 Jan 2003 08:49:37 -0500


Update of /cvs-repository/Packages/Moztop/moztop/content/ContentObjects/ZPTPage
In directory cvs.zope.org:/tmp/cvs-serv24810/moztop/content/ContentObjects/ZPTPage

Added Files:
	Content.js Content.xul MetaData.js MetaData.xul Preview.js 
	Preview.xul Security.xul 
Log Message:
Now ZPT Views work. You can edit the source and preview it. Works really 
nice.


=== Added File Packages/Moztop/moztop/content/ContentObjects/ZPTPage/Content.js ===
/*****************************************************************************
*
* Copyright (c) 2002, 2003 Zope Corporation and Contributors.
* All Rights Reserved.
*
* This software is subject to the provisions of the Zope Public License,
* Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
* WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
* FOR A PARTICULAR PURPOSE.
*
******************************************************************************
Content Tab specific Javascript functions. 

$Id: Content.js,v 1.1 2003/01/16 13:49:33 srichter Exp $

******************************************************************************/

/* Retrieve path of active content object. */
function getActiveContentObjectPath() {
    doc = getDocumentOfWindowWithId("moztop-main-window");
    var tabs = doc.getElementById("active-contents-tabs");
    return tabs.selectedItem.getAttribute('label')
}

/* XML-RPC setup stuff. */
function getClient() {
    return Components.classes['@mozilla.org/xml-rpc/client;1']
        .createInstance(Components.interfaces.nsIXmlRpcClient);
}

var xmlRpcClient;
function getXmlRpc() {
    if (!xmlRpcClient) xmlRpcClient = getClient();
    return xmlRpcClient;
}

var SaveListener = {
    onResult: function(client, ctxt, result) {
	alert('Saved');
    },
    onFault: function(client, ctxt, fault) {
        alert('Fault! ' + fault + '\n');
    },
    onError: function(client, ctxt, status, errorMsg) {
        alert('Error! <(' + status.toString(16) + ') ' + errorMsg + '>\n');
    }
};

/* Uploading the file to the server. */
function saveSource() {
    path = getActiveContentObjectPath();
    var xmlRpc = getXmlRpc();
    xmlRpc.init(XMLRPC_BASE + path + '/');
    var source = xmlRpc.createType(xmlRpc.STRING, {});
    source.data = document.getElementById("field_source").value;
    xmlRpc.asyncCall(SaveListener, null, 'setZPTSource', [source], 1);
}

/* Load image info */
var LoadListener = {
    onResult: function(client, ctxt, result) {
        result = result.QueryInterface(
	    Components.interfaces.nsISupportsCString);
	document.getElementById("field_source").value = result.data;
    },
    onFault: function(client, ctxt, fault) {
        alert('Fault! ' + fault + '\n');
    },
    onError: function(client, ctxt, status, errorMsg) {
        alert('Error! <(' + status.toString(16) + ') ' + errorMsg + '>\n');
    }
};

/* Refresh the info. */
function updateSource() {
    path = getActiveContentObjectPath();
    var xmlRpc = getXmlRpc();
    xmlRpc.init(XMLRPC_BASE + path + '/');
    xmlRpc.asyncCall(LoadListener, null, 'getZPTSource', [], 0);
}



=== Added File Packages/Moztop/moztop/content/ContentObjects/ZPTPage/Content.xul ===
<?xml version="1.0"?>

<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://moztop/skin" type="text/css"?>

<window
   orient="vertical"
   onload="updateSource();"
   xmlns = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

  <script type="application/x-javascript" 
          src="chrome://moztop/content/setup.js"/>
  <script type="application/x-javascript" 
          src="chrome://moztop/content/global.js"/>
  <script type="application/x-javascript" src="Content.js"/>


    <grid>
      <columns>
        <column/>
        <column flex="1"/>
      </columns>
      <rows>
        <row>
          <label control="field_source" value="Template Source"/>
          <textbox id="field_source" value="" 
                   flex="1" multiline="true"
		   style="height: 25em; font-family: monospace; font-size: 12pt"/>
        </row>
      </rows>
    </grid>
    <box orient="horizontal">
      <button onclick="saveSource()" label="Save" />
      <button onclick="updateSource()" label="Refresh" />
      <spring flex="100%" />
    </box>


</window>

=== Added File Packages/Moztop/moztop/content/ContentObjects/ZPTPage/MetaData.js ===
/*****************************************************************************
*
* Copyright (c) 2002, 2003 Zope Corporation and Contributors.
* All Rights Reserved.
*
* This software is subject to the provisions of the Zope Public License,
* Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
* WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
* FOR A PARTICULAR PURPOSE.
*
******************************************************************************
Meta Data Tab specific Javascript functions. With them you can load and save
the meta data.

$Id: MetaData.js,v 1.1 2003/01/16 13:49:33 srichter Exp $

******************************************************************************/

/* Retrieve path of active content object. */
function getActiveContentObjectPath() {
    doc = getDocumentOfWindowWithId("moztop-main-window");
    var tabs = doc.getElementById("active-contents-tabs");
    return tabs.selectedItem.getAttribute('label')
}

/* XML-RPC setup stuff. */
function getClient() {
    return Components.classes['@mozilla.org/xml-rpc/client;1']
        .createInstance(Components.interfaces.nsIXmlRpcClient);
}

var xmlRpcClient;
function getXmlRpc() {
    if (!xmlRpcClient) xmlRpcClient = getClient();
    return xmlRpcClient;
}

/* XML-RPC listener for loading meta data. */
var LoadListener = {
    onResult: function(client, ctxt, result) {
        result = result.QueryInterface(
	    Components.interfaces.nsIDictionary);
	title = result.getValue('title').QueryInterface(
	    Components.interfaces.nsISupportsCString);
	document.getElementById("field_title").value = title;

	desc = result.getValue('description').QueryInterface(
	    Components.interfaces.nsISupportsCString);
	document.getElementById("field_description").value = desc;

	created = result.getValue('created').QueryInterface(
	    Components.interfaces.nsISupportsCString);
	document.getElementById("field_created").value = created;

	modified = result.getValue('modified').QueryInterface(
	    Components.interfaces.nsISupportsCString);
	document.getElementById("field_modified").value = modified;
    },
    onFault: function(client, ctxt, fault) {
        alert('Fault! ' + fault + '\n');
    },
    onError: function(client, ctxt, status, errorMsg) {
        alert('Error! <(' + status.toString(16) + ') ' + errorMsg + '>\n');
    }
};

/* Load meta data from server. */
function loadMetaData() {
    path = getActiveContentObjectPath();
    var xmlRpc = getXmlRpc();
    xmlRpc.init(XMLRPC_BASE + path + '/');
    xmlRpc.asyncCall(LoadListener, null, 'getMetaData', [], 0);
}


/* XML-RPC listener for saving meta data. */
var SaveListener = {
    onResult: function(client, ctxt, result) {
	loadMetaData();
    },
    onFault: function(client, ctxt, fault) {
        alert('Fault! ' + fault + '\n');
    },
    onError: function(client, ctxt, status, errorMsg) {
        alert('Error! <(' + status.toString(16) + ') ' + errorMsg + '>\n');
    }
};

/* Save meta data to server. */
function saveMetaData() {
    path = getActiveContentObjectPath();
    var xmlRpc = getXmlRpc();
    xmlRpc.init(XMLRPC_BASE + path + '/');
    var title = xmlRpc.createType(xmlRpc.STRING, {});
    title.data = document.getElementById("field_title").value;
    var desc = xmlRpc.createType(xmlRpc.STRING, {});
    desc.data = document.getElementById("field_description").value;
    xmlRpc.asyncCall(SaveListener, null, 'setMetaData', [title, desc], 2);
}


=== Added File Packages/Moztop/moztop/content/ContentObjects/ZPTPage/MetaData.xul ===
<?xml version="1.0"?>

<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://moztop/skin" type="text/css"?>

<window
    xmlns = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
    onload="loadMetaData();">

  <script type="application/x-javascript" 
          src="chrome://moztop/content/setup.js"/>
  <script type="application/x-javascript" 
          src="chrome://moztop/content/global.js"/>
  <script type="application/x-javascript" src="MetaData.js"/>

  <groupbox>
    <caption label="Edit"/>

    <grid flex="1">
      <columns>
        <column/>
        <column flex="1"/>
      </columns>
      <rows>
        <row>
          <label control="field_title" value="Title"/>
          <textbox id="field_title" flex="1"/>
        </row>
        <row>
          <label control="field_description" value="Description"/>
          <textbox id="field_description" flex="1"/>
        </row>
        <row>
          <label value="Created on:" />
	  <label id="field_created" value="01/01/2003" />
        </row>
        <row>
          <label value="Last modified on:" />
	  <label id="field_modified" value="01/01/2003" />
        </row>
      </rows>
    </grid>
    <box orient="horizontal">
      <button onclick="saveMetaData()" label="Save" />
      <button onclick="loadMetaData()" label="Refresh" />
      <spring flex="100%" />
    </box>
  </groupbox>

</window>

=== Added File Packages/Moztop/moztop/content/ContentObjects/ZPTPage/Preview.js ===
/*****************************************************************************
*
* Copyright (c) 2002, 2003 Zope Corporation and Contributors.
* All Rights Reserved.
*
* This software is subject to the provisions of the Zope Public License,
* Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
* WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
* FOR A PARTICULAR PURPOSE.
*
******************************************************************************
Preview Tab specific Javascript functions. 

$Id: Preview.js,v 1.1 2003/01/16 13:49:33 srichter Exp $

******************************************************************************/

/* Retrieve path of active content object. */
function getActiveContentObjectPath() {
    doc = getDocumentOfWindowWithId("moztop-main-window");
    var tabs = doc.getElementById("active-contents-tabs");
    return tabs.selectedItem.getAttribute('label')
}

/* Load preview in IFrame */
function loadPreview() {
    iframe = document.getElementById('preview-frame');
    iframe.setAttribute('src', HTML_BASE + getActiveContentObjectPath());
}


=== Added File Packages/Moztop/moztop/content/ContentObjects/ZPTPage/Preview.xul ===
<?xml version="1.0"?>

<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://moztop/skin" type="text/css"?>

<window
   orient = "vertical"
   onload = "loadPreview();"
   xmlns = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

  <script type="application/x-javascript" 
          src="chrome://moztop/content/setup.js"/>
  <script type="application/x-javascript" 
          src="chrome://moztop/content/global.js"/>
  <script type="application/x-javascript" src="Preview.js"/>

   <iframe id="preview-frame" flex="1"/>
   <box orient="horizontal">
     <button onclick="loadPreview();" label="Reload Content" />
     <spring flex="100%" />
   </box>

</window>

=== Added File Packages/Moztop/moztop/content/ContentObjects/ZPTPage/Security.xul ===
<?xml version="1.0"?>

<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://moztop/skin" type="text/css"?>

<window
   xmlns = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

    <label value="Security" />
    <image src="chrome://moztop/content/moztop.png" />

</window>