From: Thyamad c. <th...@us...> - 2006-01-26 16:25:49
|
Update of /cvsroot/thyapi/thyapi/thywidgets In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4677/thywidgets Modified Files: thyeditbox.js thylistbox.js Added Files: thydropdownbox_ie.js Log Message: Commiting file additions and modification from SVN revision 2720 to 2721... Changes made by vinicius on 2006-01-26 18:31:37 +0100 (Thu, 26 Jan 2006) corresponding to SVN revision 2721 with message: Index: thyeditbox.js =================================================================== RCS file: /cvsroot/thyapi/thyapi/thywidgets/thyeditbox.js,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** thyeditbox.js 10 Jan 2006 19:07:06 -0000 1.7 --- thyeditbox.js 26 Jan 2006 16:25:36 -0000 1.8 *************** *** 3,7 **** * http://www.thyamad.com * * * ! * Copyright (C) 2005 - Raphael Derosso Pereira, Vinicius Cubas Brand * * Based on DynAPI v3.0b1 * * ------------------------------------------------------------------------- * --- 3,7 ---- * http://www.thyamad.com * * * ! * Copyright (C) 2005 - Raphael Derosso Pereira * * Based on DynAPI v3.0b1 * * ------------------------------------------------------------------------- * *************** *** 93,97 **** 'height: 100%;'+ 'left: 0px;'+ ! 'right: 0px'+ 'background: inherit;'+ 'background-color: inherit;'+ --- 93,97 ---- 'height: 100%;'+ 'left: 0px;'+ ! 'right: 0px;'+ 'background: inherit;'+ 'background-color: inherit;'+ Index: thylistbox.js =================================================================== RCS file: /cvsroot/thyapi/thyapi/thywidgets/thylistbox.js,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** thylistbox.js 22 Dec 2005 03:39:38 -0000 1.7 --- thylistbox.js 26 Jan 2006 16:25:36 -0000 1.8 *************** *** 126,129 **** --- 126,130 ---- * will be set to null * + * viniciuscb: why null???? */ p._thyGridAppendRow = p.appendRow; --- NEW FILE: thydropdownbox_ie.js --- /***************************************************************************\ * ThyAPI - Thyamad Javascript API - Drop-Down Combo Box Element * * http://www.thyamad.com * * * * Copyright (C) 2005 - Vinicius Cubas Brand * * 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: thyDropDownBox * * This is the Drop Down Combo Box Element. It provides a <thyGridCell>, * a <thyButton> and a <thyListBox> working together to provide a * Drop-Down Combo Box Widget. * * CSS Classes: * * - <thyPanel> classes * - <thyLabelPanel> classes * - <thyEditBox> classes * * .thyDropDownBox - The class of main element, derived from <thyEditBox> * .thyDropDownBox_button - The <thyButton> element class * .thyDropDownBox_listBox - The <thyListBox> element class * * .<object name> - The class of main element, derived from <thyEditBox> * .<object name>_edit - The <thyEditBox> element class * .<object name>_button - The <thyButton> element class * .<object name>_listBox - The <thyListBox> element class * * Events: * * onselect - When user selects an option * onchange - When there's any change in value (by reset and populate considered) * * See Also: * * - <thyEditBox> * - <thyButton> * - <thyListBox> * - <thyLabelPanel> * - <thyPanel> * */ function thyDropDownBox(name,label) { this.thyLabelPanel = thyLabelPanel; this.thyLabelPanel(name,label); // Atributes //These selected* arguments are only used when this element has not been created this.selectedIndex = null; this.selectedValue = null; this.selectedContent = null; this.defaultValue = null; this.lastSelected = null; this.popcontents = [ ]; this.addCSSClass('thyDropDownBox'); this.onPreCreate(this.preInitThyDropDownBox); this.onCreate(this.initThyDropDownBox); /* Essa classe deve ter os eventos onselect e onchange */ } p = dynapi.setPrototype('thyDropDownBox', 'thyLabelPanel'); /** * Method: initThyDropDownBox * * Initialization Method * */ p.initThyDropDownBox = function() { this.contents.elm.childNodes[0]._dynobj = this; } /** * Method: preInitThyDropDownBox * * Initialization method executed right before element creation * */ p.preInitThyDropDownBox = function() { this.contents.setRelativeness(false); this.setHTML(['<select ', 'class="thyEditBox_input '+this.name+'_input" ', 'style="', 'width: 100%;', 'height: 100%;', 'left: 0px;', 'right: 0px;', 'background: inherit;', 'background-color: inherit;', 'text-align: inherit;', 'color: inherit;', 'border: 0px;', 'z-index: inherit" ', (this.readOnly ? 'readonly ': ''), (this.disabled ? 'disabled ': ''), '>', this._getHTMLContents(), '</select>' ].join('') ); } /** * Method: setDefaultValue * * Sets the default value when widget is reset * * Parameters: * * value - The default value * */ p.setDefaultValue = function (value) { this.defaultValue = value; } /** * Method: getSelectedIndex * * Returns the index of the selected option * */ p.getSelectedIndex = function () { if (!this._created) return this.selectedIndex; return this.contents.elm.childNodes[0].selectedIndex; } /** * Method: getSelectedValue * * Returns the value of the selected option * Vinicius: refazer esta */ p.getSelectedValue = function () { if (!this._created) return this.selectedValue; return this.contents.elm.childNodes[0].value; } /** * Method: getSelectedContent * * Returns the content of the selected option * */ p.getSelectedContent = function () { if (!this._created) return this.selectedContent; var sel = this.contents.elm.childNodes[0]; if (sel[sel.selectedIndex]) { return sel[sel.selectedIndex].text; } } /** * Method: getSelected * * Returns a <thyCollection> with the index, the value and the content * of the selected option * */ p.getSelected = function () { var col = new thyCollection(); if (!this._created) { col.add(this.selectedIndex,'index'); col.add(this.selectedValue,'value'); col.add(this.selectedContent,'content'); return col; } col.add(this.getSelectedIndex(),'index'); col.add(this.getSelectedValue(),'value'); col.add(this.getSelectedContent(),'content'); return col; } /** * Method: getLastSelectedIndex * * Returns the index of the last selected option * */ p.getLastSelectedIndex = function () { return this.lastSelected[0]; } /** * Method: getLastSelectedValue * * Returns the value of the last selected option * */ p.getLastSelectedValue = function () { return this.lastSelected[1]; } /** * Method: getLastSelectedContent * * Returns the content of the selected option * */ p.getLastSelectedContent = function () { return this.lastSelected[2]; } /** * Method: getLastSelected * * Returns a <thyCollection> with the index, the value and the content * of the last selected option * */ p.getLastSelected = function () { var col = new thyCollection(); col.add(this.lastSelected[0],'index'); col.add(this.lastSelected[1],'value'); col.add(this.lastSelected[2],'content'); } /** * Method: getContentByValue * * Returns the associated content with the specified value * * Parameter: * * value - The value associated with the needed content * */ p.getContentByValue = function (value) { var sel_opts = this.contents.elm.childNodes[0].options; for (var i in options) { if (options[i].value == value) { return options[i].text; } } } /** * Method: setContentByValue * * Changes the content associated with the specified value * * Parameters: * * value - The value associated with the needed content * content - The new content * */ p.setContentByValue = function(value,content) { var sel_opts = this.contents.elm.childNodes[0].options; for (var i in options) { if (options[i].value == value) { options[i].text = content; return; } } } p._thyLabelPanelAddChild = p.addChild; /** * Method: addChild * * Overloaded method that prevents the insertion of children in <thyDropDownBox> * */ p.addChild = function () { throw({result: 'No meaning on adding child to thyDropDownBox', location:'thyDropDownBox.addChild'}); } p._thyLabelPanelRemoveChild = p.removeChild; /** * Method: removeChild * * Overloaded method that prevents the removal of children of <thyDropDownBox> * */ p.removeChild = function () { throw({result: 'No meaning on adding child to thyDropDownBox', location:'thyDropDownBox.addChild'}); } p._thyLabelPanelSetName = p.setName; /** * Method: setName * * Overwritten method that sets the name of main, button and listbox * and refreshes CSS Classes * * Parameter: * * name - The new widget name * */ p.setName = function (name) { if (name == null || this.name == name) return; var old_name = this.name; this._thyLabelPanelSetName(name); this.contents.elm.childNodes[0].className += (this.name + '_input'); } /** * Method: hideOption * * Makes an option invisible to the user * * Parameters: One of the two, indexed in an object: * * value - The value of the option to become invisible * index - The index of the option to become invisible * */ p.hideOption = function(params) { /* TODO implement this in IE */ } /** * Method: showOption * * Makes an option visible to the user * * Parameters: One of the two, indexed in an object * * value - The value of the option to become visible * index - The index of the option to become visible * */ p.showOption = function(params) { /* TODO implement this in IE */ } /*************************************************************************\ * Group: Private Methods * \*************************************************************************/ p._thyLabelPanel_destroy = p._destroy; /** * Method: _destroy * * Overloaded method that removes dropList from memory * */ p._destroy = function () { /* This avoids memory leak in IE */ this.contents.elm.childNodes[0]._dynobj = null; this._thyLabelPanel_destroy(); } /** * Method: _cleanUp * * Cleans up all values from the component * */ p._cleanUp = function () { var sel = this.contents.elm.childNodes[0]; while (sel.firstChild) { sel.removeChild(sel.firstChild); } } /** * Method: _reset * * Resets dropList to defaultValue * */ p._reset = function () { this.contents.elm.childNodes[0].value = this.defaultValue; } /** * Method: _populateContents * * Sets the contents of the <thyDropDownBox>. This is the same populate as * <thyListBox>::populate, so pass correct formated data. * * Parameter: * * data - The <thyDropDownBox> possible values * */ p._populateContents = function (data) { /* VINICIUS: mudar isto */ //Esse aqui fica dentro do _updateDOMElement //var oldSelected = this.dropSelected; if (typeof(data) == 'number') { data = {index: data}; } if (typeof(data) == 'object') { this.selectedIndex = data.index; this.selectedValue = data.value; if (data[0]) { delete data.index; delete data.value; //transforming contents in array var contents = [], i; for (i in data) { if (data[i].length < 2) { //This is according to original specifications var dat = [null, data[0]]; contents.push(dat); } else { contents.push(data[i]); } } this.popcontents = contents; } this._updateDOMElement(); } //Fica dentro do _updateDOMElement /* if (this.dropSelected != oldSelected) { this.lastSelected = oldSelected; this.invokeEvent('change', new DynEvent('change', this)); }*/ } /** * Method: _sweepOutContents * * Gets the value that was selected by the user. * */ p._sweepOutContents = function () { return this.getSelected().sweepOut(); } p._thyLabelPanel_addCSSClass = p._addCSSClass; /** * Method: _addCSSClass * * Overwritten method that adds the class to main, button and listbox * * Parameter: * * cssClass - The cssClass to be added * */ p._addCSSClass = function (cssClass) { this._thyLabelPanel_addCSSClass(cssClass); /* VINICIUS: mudar isto */ /* if (this.dropButton) { this.dropEdit._addCSSClass(cssClass+'_edit'); this.dropButton._addCSSClass(cssClass+'_button'); this.dropList._addCSSClass(cssClass+'_listBox'); }*/ } p._thyLabelPanel_removeCSSClass = p._removeCSSClass; /** * Method: _removeCSSClass * * Overwritten method that removes the specified CSS Class from main, * button and listbox * * Parameter: * * cssClass - The cssClass to be removed * */ p._removeCSSClass = function (cssClass) { this._thyLabelPanel_removeCSSClass(cssClass); /* VINICIUS: mudar isto */ /* if (this.dropButton) { this.dropEdit._removeCSSClass(cssClass+'_edit'); this.dropButton._removeCSSClass(cssClass+'_button'); this.dropList._removeCSSClass(cssClass+'_list'); }*/ } /** * Method: _getHTMLContents * * This class is used in the creation of the current component */ p._getHTMLContents = function() { var selected = false, str = [ ], contents = this.popcontents, i, j = 0; for (i in contents) { if (j == this.selectedIndex || contents[i][1] == this.selectedValue) { str.push('<option value="'+contents[i][0]+'" SELECTED>'+contents[i][1]+'</option>'); } else { str.push('<option value="'+contents[i][0]+'">'+contents[i][1]+'</option>'); } j++; } return str.join(''); } /** * Method: _updateDOMElement * * Updates the DOM Element * * Actually, it erases all the select's contents and puts some new contents */ p._updateDOMElement = function() { var cont = this.popcontents; if (!this._created) { //This sets the selectedValue if only selectedIndex was specified and vice-versa if (this.selectedIndex) { this.selectedValue = cont[this.selectedIndex][0]; this.selectedContent = cont[this.selectedIndex][1]; } else if (this.selectedValue) { for (var i in cont) { if (cont[i][0] == this.selectedValue) { this.selectedIndex = i; this.selectedContent = cont[i][1]; break; } } } return; } this._cleanUp(); var sel = this.contents.elm.childNodes[0], j = 0; for (var i in cont) { var opt = this.parent.doc.createElement('option'); opt.value = cont[i][0]; opt.text = cont[i][1]; sel.options.add(opt); if (j == this.selectedIndex || cont[i][0] == this.selectedValue) sel.selectedIndex = j; j++; } //ver se teve changes e chamar o metodo onchange } /*************************************************************************\ * Group: Events Methods * \*************************************************************************/ /** VINICIUS: assignar os eventos desse objeto ao dropdown */ /****************************************************************************\ * Group: Misc Operations * \****************************************************************************/ |