From: Thyamad c. <th...@us...> - 2005-09-01 13:11:54
|
Update of /cvsroot/thyapi/thyapi/thywidgets In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20002/thywidgets Modified Files: thywindow.js Added Files: thyformdialog.js Log Message: Commiting file additions and modification from SVN revision 1876 to 1877... Changes made by rpereira on 2005-09-01 15:28:52 +0200 (Thu, 01 Sep 2005) corresponding to SVN revision 1877 with message: - New thyFormDialog which implements a thyDialog with a Data Source - bugfixing on thyDataSource, thyWindow and thyProtocol Index: thywindow.js =================================================================== RCS file: /cvsroot/thyapi/thyapi/thywidgets/thywindow.js,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** thywindow.js 29 Aug 2005 04:02:08 -0000 1.3 --- thywindow.js 1 Sep 2005 13:11:43 -0000 1.4 *************** *** 533,537 **** p.ondragend = function(e) { - this.dragging = false; this.winDragBorder.setDisplay(true); this.setX(this.winDragBorder.getAbsoluteX()); --- 533,536 ---- *************** *** 542,555 **** /** ! * Method: ondragmove * ! * OnDragMove Event. It updates the drag layer position * */ ! p.ondragmove = function(e) { - if (this.dragging) return; this.setDisplay(false); - this.dragging = true; } --- 541,552 ---- /** ! * Method: ondragstart * ! * OnDragStart Event. * */ ! p.ondragstart = function(e) { this.setDisplay(false); } --- NEW FILE: thyformdialog.js --- /***************************************************************************\ * ThyAPI - Thyamad Javascript API - Dialog Window 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: thyFormDialog * * This class implements a Dialog Window widget with a preconfigured * Data Source algorithm. 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 thyFormDialog(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));} }); } p = dynapi.setPrototype('thyFormDialog','thyDialogWindow'); /** * 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; // First check for Title if (data.title) { this.setTitle(data.title); data.title = null; } // Then check for Buttons if (data.buttons) { for (i in data.buttons) { if (this.buttons[i]) { this.buttons[i].populate(data.buttons[i]); } } data.buttons = null; } // Now check the rest 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; } |