From: Thyamad c. <th...@us...> - 2005-11-21 13:54:25
|
Update of /cvsroot/thyapi/thyapi/thywidgets In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27081/thywidgets Added Files: thyformpanel.js Log Message: Commiting file additions and modification from SVN revision 2290 to 2291... Changes made by rpereira on 2005-11-21 15:35:20 +0100 (Mon, 21 Nov 2005) corresponding to SVN revision 2291 with message: - Added thyFormPanel --- NEW FILE: thyformpanel.js --- /***************************************************************************\ * ThyAPI - Thyamad Javascript API - Panel with DataSource Element * * http://www.thyamad.com * * * * Copyright (C) 2005 - Raphael Derosso Pereira * * Based on DynAPI v3.0b1 * * ------------------------------------------------------------------------- * * This library is free software; you can redistribute it and/or modify it * * under the terms of the GNU Lesser General Public License as published * * by the Free Software Foundation; either version 2.1 of the License, * * or any later version. * * This library is distributed in the hope that it will be useful, but * * WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU Lesser General Public License for more details. * \***************************************************************************/ /** * Class: thyFormPanel * * This class implements a Panel widget with a preconfigured * Data Source component. To use it, just inherit from this class and * in the constructor set the Data Source protocol and the server * methods, either using setServerClass or the other specific methods. * * CSS Classes: * * * Events: * * - onsave - Called when button with code 0 is clicked * - onsavesuccess - Called when server confirms the save call * - oncancel - Called when button with code 1 is clicked * - oncode<n> - Called when button with code <n> is clicked * - onprepopulate - Called just before population * - onpopulate - Called just after population * * (The last 2 are valid only when using default populate method) * * Parameters: * * name - The Object CSS name * startup - The startup messages * */ function thyFormPanel(name, startup) { this.thyDialogWindow = thyDialogWindow; this.thyDialogWindow(name); // Attributes \\ var self = this; this.dataID; this.progress = new thyPanel(this.name+'_progress'); this.toSweep = new thyCollection(); this.dataSrc = new thyDataSource(this.name+'_dataSrc', startup); // Comm this.dataSrc.setProgressHolder(this.progress); this.dataSrc.link(this); /*this.addEventListener({ onsave: function () {self.dataSrc.write(self.dataID)}, oncancel: function () {self.close()}, onclose: function () {self.reset()} });*/ // Events var self = this; this.dataSrc.addEventListener({ onwrite: function () { self.invokeEvent('savesuccess', new DynEvent('savesuccess', self)); self.close(); } }); } p = dynapi.setPrototype('thyFormPanel','thyPanel'); /** * Method: populate * * Updates all interface information given the data. * * This method is written on a general case population, where * server sends information indexed by internal variable names. * * If you want to make some manipulations before or after population * without changing population method, you can use *onprepopulation* * and *onpopulate*, which are called from this method, so if you need * to overwrite populate method AND need to call the events, insert * just before any execution and just after finalization, respectivelly: * *> this.invokeEvent('prepopulation', new DynEvent('prepopulation', this)); *> this.invokeEvent('populate', new DynEvent('populate', this)); * * * Paramters: * * data - An Object whose attributes have the same name as this * */ p.populate = function (data) { this.invokeEvent('prepopulation', new DynEvent('prepopulation', this)); var i; for (i in data) { if (this[i] && typeof(this[i]) == 'object' && typeof(this[i].populate) == 'function') this[i].populate(data[i]); } this.invokeEvent('populate', new DynEvent('populate', this)); } /** * Method: sweepOut * * This is a general method. By default, it returns an object * filled with the sweepOut returned by all internal elements that * are present inside toSweep collection. * * If all you want is to return contents of internal variable * this.sweepData, just add it to the toSweep collection. Eg.: * *> this.toSweep.add('sweepData'); * */ p.sweepOut = function () { var i, elm, length = this.toSweep.length(); var toReturn = {}; for (i=0; i<length; i++) { elm = this.toSweep.i(i); toReturn[elm] = this[elm].sweepOut(); } return toReturn; } p._thyDialogWindowOpen = p.open; /** * Method: open * * Overloaded method that accepts parameters, call Data Source * read method and stores it in case write method is called * * Parameters: * * params - The params to be used in read and write Data Source * methods * */ p.open = function (params) { if (params) { this.dataSrc.read(params); this.dataID = params; } else { this.dataID = null; } this._thyDialogWindowOpen(); } p._thyDialogWindowReset = p.reset; /** * Method: reset * * Overloaded method that resets some internal variables * */ p.reset = function () { this._thyDialogWindowReset(); this.dataID = null; this.setTitle(this.defaultTitle); } |