From: Thyamad c. <th...@us...> - 2006-01-27 10:29:46
|
Update of /cvsroot/thyapi/thyapi/thywidgets In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2439/thywidgets Modified Files: thydropdownbox_ie.js thypanel.js Added Files: thywindow_ie.js Log Message: Commiting file additions and modification from SVN revision 2724 to 2725... Changes made by vinicius on 2006-01-27 12:35:51 +0100 (Fri, 27 Jan 2006) corresponding to SVN revision 2725 with message: tested & committed thydropdown component Index: thypanel.js =================================================================== RCS file: /cvsroot/thyapi/thyapi/thywidgets/thypanel.js,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** thypanel.js 1 Sep 2005 18:15:38 -0000 1.5 --- thypanel.js 27 Jan 2006 10:29:35 -0000 1.6 *************** *** 1126,1129 **** --- 1126,1154 ---- } + /** + * Method: _attachWindowed + * + * Attach a windowed control (eg. components that have select or iframe) + * to the nearest parent windowed container + * + * This is used to disable components unsensitive to z-indexes, + * http://msdn.microsoft.com/workshop/author/dhtml/reference/objects/select.asp + * + * Author: Vinicius Cubas Brand + */ + p._attachWindowed = function(element) + { + if (this.windowedContainer) + { + if (!this.windowedElements) this.windowedElements = [ ]; + this.windowedElements.push(element); + element.containerWindow = this; + } + else if (this.parent && this.parent._attachWindowed) + { + this.parent._attachWindowed(element); + } + } + /*************************************************************************\ * Events * *************** *** 1139,1142 **** --- 1164,1168 ---- p.onmouseover = function (e) { + /* Viniciuscb: ripped out for performance. Thanks to JRmiron var actual; if (!this.cssClasses || (actual = this.cssClasses[this.cssActualSelection]) == null) return; *************** *** 1145,1148 **** --- 1171,1175 ---- this.cssExtraClasses['onmouseover'] = extra ; this.setCSSClass(this.cssActualSelection); + */ } *************** *** 1156,1163 **** --- 1183,1192 ---- p.onmouseout = function (e) { + /* Viniciuscb: ripped out for performance. Thanks to JRmiron var actual; if (!this.cssClasses || (actual = this.cssClasses[this.cssActualSelection]) == null) return; delete this.cssExtraClasses['onmouseover']; this.setCSSClass(this.cssActualSelection); + */ } --- NEW FILE: thywindow_ie.js --- /***************************************************************************\ * ThyAPI - Thyamad Javascript API - Window 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: thyWindow * * This class implements the infamous Window widget. As it is derivate * from thyBorderPanel, it has borders and all the CSS classes that widget * has. * * CSS classes: * * - .thyWindow_title * - .thyWindow_contents * - .thyWindow_btnClose * - .thyWindow_btnStick * - .thyWindow_ondrag * * - .<object name>_title * - .<object name>_contents * - .<object name>_btnClose * - .<object name>_btnStick * - .<object name>_ondrag * * Author: * * Raphael Derosso Pereira <rap...@us...> * */ function thyWindow(name,title,html) { this.thyBorderPanel = thyBorderPanel; this.thyBorderPanel(name); //adds this window to the list of windows if (!dynapi.document._thyWindowInstances) { dynapi.document._thyWindowInstances = { }; } dynapi.document._thyWindowInstances[this.name] = this ; //Class Atribute /* this manages windowed atributes in ie (selectbox), making them disapear when window is not focused */ this.windowedContainer = true; this.windowedElements = [ ]; // Attributes this.openned = false; this.sticked = false; this.focused = false; this.title = title || this.name; this.html = html; this.content = new thyPanel(this.name+'_contents',this.html); this.titleLayer = new thyPanel(this.name+'_title', this.title); this.btnClose = new thyPanel(this.name+'_btnClose'); this.btnStick = new thyPanel(this.name+'_btnStick'); this.winDragBorder = new thyPanel(this.name+'_ondrag',this.title); this.cssClasses['window'] = ['window']; this.addCSSClass('thyWindow'); this.content.cssExtraClasses = this.cssExtraClasses; this.titleLayer.cssExtraClasses = this.cssExtraClasses; // Turn Window into Draggable element this.winDragBorder.setAnchor({ topA: this.id, leftA: this.id }); this.winDragBorder.setRelativeness(false); this.winDragBorder.setDisplay(false); // Initialize Title Bar var self = this; this.titleLayer.setRelativeness(false); //this.titleLayer.setTextSelectable(false); // Initialize Close Button this.btnClose.setRelativeness(false); this.btnClose.addEventListener({ onclick: function(e){self.close()} }); // Initialize Stick Button this.btnStick.setRelativeness(false); this.btnStick.addEventListener({ onclick: function(e){self.switchStick()} }); // Initialize Content this.content.invokeEvent = function (type,e,args){dynapi.document.invokeEvent(type,e,args);}; this._thyBorderPanelAddChild(this.titleLayer); this._thyBorderPanelAddChild(this.btnStick); this._thyBorderPanelAddChild(this.btnClose); this._thyBorderPanelAddChild(this.content); //this.setVisible(false); this.setDisplay(false); this.setSize(0,0); //if (!this.thyWindow) this.onPreCreate(this.initThyWindow); this.onPreCreate(this.initThyWindow); this.onCreate(function() { }); } p = dynapi.setPrototype('thyWindow','thyBorderPanel'); /** * Method: initThyWindow * * Initialization method * */ p.initThyWindow = function () { this.setDragEnabled(true,null,true); this.setDragIcon(this.winDragBorder); //dynapi.document.addChild(this.winDragBorder); } /** * Method: populate * * Sets the title of the widow * */ p.populate = function (data) { if (data['title']) this.setTitle(data['title']); } /** * Method: setTitle * * Sets the Title of the window * */ p.setTitle = function(title) { this.titleLayer.setHTML(''); this.setSize('',''); this.setDisplay(true); var w = this.titleLayer.getWidth(); this.titleLayer.setHTML(title); var length = title.length; if (w >= this.titleLayer.getWidth()) { this.winDragBorder.setHTML(title); } else { while (w < this.titleLayer.getWidth() && length > 0) { length--; this.titleLayer.setHTML(dynapi.functions.limitString(title,length)); } this.titleLayer.setHTML(dynapi.functions.limitString(title,length-3)); } if (!this.openned) { this.setDisplay(false); this.setSize(0,0); } } /** * Method: getTitle * * Returns the actual title set * */ p.getTitle = function () { return this.titleLayer.getHTML(); } /** * Method: open * * UnHide the window * */ p.open = function() { var self = this; this.setSize('',''); this.setDisplay(true); var position = function() { var pos = thyWindow._getWindowPosition(self); self.setX(pos.x); self.setY(pos.y); }; if (!this._created) { this.onCreate(position); } else { position(); } this.setZIndex({topmost: true}); this.titleLayer.setZIndex({above: this}); this.openned = true; this.invokeEvent('open', new DynEvent('open',this)); this.focus(); } /** * Method: close * * Hides the window * */ p.close = function() { this.setDisplay(false); this.setSize(0,0); thyWindow._unsetWindowPosition(this); this.openned = false; this.invokeEvent('close', new DynEvent('close',this)); focusTopWindow(); } p._thyBordePanelSetName = p.setName; /** * Method: setName * * Overwritten method that sets the name of main, title, contents and drag border * and refreshes CSS Classes * * Parameter: * * name - The new widget name * */ p.setName = function (name) { if (name == null || this.name == name) return; this._thyBorderPanelSetName(name); if (this.titleLayer) this.titleLayer.setName(name+'_title'); if (this.content) this.content.setName(name+'_contents'); if (this.btnClose) this.btnClose.setName(name+'_btnClose'); if (this.btnStick) this.btnStick.setName(name+'_btnStick'); if (this.winDragBorder) this.winDragBorder.setName(name+'_ondrag'); } p._thyBorderPanelSetCSSClass = p.setCSSClass; /** * Method: setCSSClass * * Overwritten method that calls parent setCSSClass and also sets CSS of title, * content, buttons and drag border * * Parameter: * * type - The class type * */ p.setCSSClass = function (type) { this._thyBorderPanelSetCSSClass(type); if (this.titleLayer) this.titleLayer.setCSSClass(type); if (this.content) this.content.setCSSClass(type); if (this.btnClose) this.btnClose.setCSSClass(type); if (this.btnStick) this.btnStick.setCSSClass(type); if (this.winDragBorder) this.winDragBorder.setCSSClass(type); } p._thyBorderPanelAddChild = p.addChild; /** * Method: addChild * * Overwritten AddChild method that insert childs in contents * */ p.addChild = function (c,alias,inlineID) { this.content.addChild(c,alias,inlineID); } p._thyBorderPanelRemoveChild = p.removeChild; /** * Method: removeChild * * Overwritten RemoveChild method that removes childs from contents * */ p.removeChild = function (c) { this.content.removeChild(c); } /** * Method: getInnerHTML * * Overwritten getInnerHTML that inserts Title * * @public */ p.getInnerHTML = function() { var html=['<table border="0" id="'+this.name+'_mainHolder'+'" cellspacing="0" cellpadding="0" border="0">', '<tr><td id="'+this.name+'_t'+'" class="'+this.getCSSClasses('top')+'" colspan="3"></td></tr>', '<tr><td id="'+this.name+'_l'+'" class="'+this.getCSSClasses('left')+'"></td>', '<td id="'+this.name+'_contentHolder" class="'+this.getCSSClasses('window')+'">', /* style="position: relative">'+this._thyBorderPanelGetInnerHTML(), */ '<div style="position: relative; width: 100%; height: 100%">'+this._thyPanelGetInnerHTML()+'</div>', '</td>', '<td id="'+this.name+'_r'+'" class="'+this.getCSSClasses('right')+'"></td></tr>', '<tr><td id="'+this.name+'_b'+'" class="'+this.getCSSClasses('bottom')+'" colspan="3"></td></tr></table>'].join(''); //alert(html); return html; } /** * Method: stick * * Makes window unmovable * */ p.stick = function () { if (this.sticked) return; this.sticked = true; this.btnStick.cssExtraClasses['sticked'] = {}; this.btnStick.cssExtraClasses['sticked'][this.btnStick.cssActualSelection] = ['sticked']; this.btnStick.setCSSClass(this.btnStick.cssActualSelection); this.setDragEnabled(false); } /** * Method: unstick * * Release window for movement * */ p.unstick = function () { if (!this.sticked) return; this.sticked = false; delete this.btnStick.cssExtraClasses['sticked']; this.btnStick.setCSSClass(this.btnStick.cssActualSelection); this.setDragEnabled(true,null,true); } /** * Method: switchStick * * Change from one sticked state to another * */ p.switchStick = function () { if (this.sticked) this.unstick(); else this.stick(); } /** * Method: focus * * Makes the window gain focus */ p.focus = function() { if (this.focused) return; this.focused = true; //unfocus all other windows var winInstances = dynapi.document._thyWindowInstances; for (var i in winInstances) { if (winInstances[i] && winInstances[i] != this && winInstances[i].blur) { winInstances[i].blur(); } } //enable all dropdowns for (var i in this.windowedElements) { this.windowedElements[i].setDisplay(true); } } /** * Method: blur * */ p.blur = function() { if (!this.focused) return; this.focused = false; //disable all dropdowns for (var i in this.windowedElements) { this.windowedElements[i].setDisplay(false); } } /*************************************************************************\ * Private Methods * \*************************************************************************/ thyWindow._positions_x = new Object(); thyWindow._positions_y = new Object(); /** * Method: _getWindowPosition * * STATIC method that returns the next position to be used * by a window when opened * * Parameter: * * thyWin - The thyWindow object that will be opened * */ thyWindow._getWindowPosition = function (thyWin) { var positions_x = thyWindow._positions_x; var positions_y = thyWindow._positions_y; var w = dynapi.document.getWidth(); var h = dynapi.document.getHeight(); var sx = dynapi.document.getXScroll(); var sy = dynapi.document.getYScroll(); var ww = thyWin.content.getWidth(); var wh = thyWin.content.getHeight(); var x = w/2 + sx - ww/2; var y = h/2 + sy - wh/2; var i; for (i in positions_x) { while (positions_x[i][x]) { x += 10; } } for (i in positions_y) { while (positions_y[i][y]) { y += 10; } } if (!positions_x[thyWin.name]) { positions_x[thyWin.name] = new Object(); positions_y[thyWin.name] = new Object(); } positions_x[thyWin.name][x] = x; positions_y[thyWin.name][y] = y; if (x<0) x=0; if (y<0) y=0; return {x:x,y:y}; } /** * Method: _unsetWindowPosition * * STATIC method that removes the position from the list * */ thyWindow._unsetWindowPosition = function (thyWin) { var positions_x = thyWindow._positions_x; var positions_y = thyWindow._positions_y; if (positions_x[thyWin.name]) { delete positions_x[thyWin.name]; } if (positions_y[thyWin.name]) { delete positions_y[thyWin.name]; } } p._thyBorderPanel_destroy = p._destroy; /** * Method: _destroy * * Overloaded method that removes winBorderPanel from memory * */ p._destroy = function () { this.winDragBorder._destroy(); this._thyBorderPanel_destroy(); } p._thyBorderPanel_addCSSClass = p._addCSSClass; /** * Method: _addCSSClass * * Overwritten method that adds the base class to main, title, contents, drag border * and buttons * * Paramenter: * * cssClass - The base class string * */ p._addCSSClass = function (cssClass) { this._thyBorderPanel_addCSSClass(cssClass); if (this.titleLayer) { this.titleLayer._addCSSClass(cssClass+'_title'); this.content._addCSSClass(cssClass+'_contents'); this.btnClose._addCSSClass(cssClass+'_btnClose'); this.btnStick._addCSSClass(cssClass+'_btnStick'); this.winDragBorder._addCSSClass(cssClass+'_ondrag'); } } p._thyBorderPanel_removeCSSClass = p._removeCSSClass; /** * Method: _removeCSSClass * * Removes the specified CSS Class from main, title, contents, drag border * and buttons * * Parameter: * * cssClass - The CSS Class to be removes * */ p._removeCSSClass = function (cssClass) { this._thyBorderPanel_removeCSSClass(cssClass); if (this.titleLayer) { this.titleLayer._removeCSSClass(cssClass+'_title'); this.content._removeCSSClass(cssClass+'_contents'); this.btnClose._removeCSSClass(cssClass+'_btnClose'); this.btnStick._removeCSSClass(cssClass+'_btnStick'); this.winDragBorder._removeCSSClass(cssClass+'_ondrag'); } } /** * Method: ondragend * * OnDragEnd Event. It switches the drag DynLayer to the Window Layer * */ p.ondragend = function(e) { this.winDragBorder.setDisplay(true); var absx = this.winDragBorder.getAbsoluteX(); var absy = this.winDragBorder.getAbsoluteY(); this.setX((absx<0)?0:absx); this.setY((absy<0)?0:absy); this.winDragBorder.setDisplay(false); this.setDisplay(true); } /** * Method: ondragstart * * OnDragStart Event. * */ p.ondragstart = function(e) { this.setDisplay(false); } /** * Method: onmousedown * * OnMouseDown Event. Change z-index of drag layer and window. * */ p.onmousedown = function(e) { if (this.focused) return; this.focus(); this.setZIndex({topmost: true}); this.winDragBorder.setZIndex({below: this}); } /** * Method: focusTopWindow * * Focuses the top window */ function focusTopWindow() { var winInstances = dynapi.document._thyWindowInstances; var topmost , topZ = -1000; for (var i in winInstances) { if (winInstances[i] && winInstances[i].openned && winInstances[i].focus && winInstances[i].getZIndex() > topZ) { topZ = winInstances[i].getZIndex(); topmost = winInstances[i]; } } if (topmost) { topmost.focus(); } } Index: thydropdownbox_ie.js =================================================================== RCS file: /cvsroot/thyapi/thyapi/thywidgets/thydropdownbox_ie.js,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** thydropdownbox_ie.js 26 Jan 2006 16:25:36 -0000 1.1 --- thydropdownbox_ie.js 27 Jan 2006 10:29:35 -0000 1.2 *************** *** 3,7 **** * http://www.thyamad.com * * * ! * Copyright (C) 2005 - Vinicius Cubas Brand * * Based on DynAPI v3.0b1 * * ------------------------------------------------------------------------- * --- 3,7 ---- * http://www.thyamad.com * * * ! * Copyright (C) 2005, 2006 - Raphael Derosso Pereira, Vinicius Cubas Brand * * Based on DynAPI v3.0b1 * * ------------------------------------------------------------------------- * *************** *** 20,26 **** * 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: --- 20,25 ---- * Class: thyDropDownBox * ! * This is the Drop Down Combo Box Element. This IE-optimized version ! * uses a select html component instead of ThyAPI components * * CSS Classes: *************** *** 60,63 **** --- 59,64 ---- // Atributes + this.containerWindow = null; + //These selected* arguments are only used when this element has not been created this.selectedIndex = null; *************** *** 74,77 **** --- 75,81 ---- this.onCreate(this.initThyDropDownBox); + this.addEventListener({ + onparentchange: this._dropDownParentChange() + }); /* *************** *** 156,160 **** * * Returns the value of the selected option - * Vinicius: refazer esta */ p.getSelectedValue = function () --- 160,163 ---- *************** *** 380,384 **** --- 383,410 ---- /* TODO implement this in IE */ } + + /** + * Method: reset + * + * Resets dropdown to defaultValue + * + */ + p.reset = function () + { + if (this.defaultValue) { this.contents.elm.childNodes[0].value = this.defaultValue; } + else { this.contents.elm.childNodes[0].selectedIndex = 0; } + } + + /** + * Method: hide + * + * Hides + */ + p.hide = function() + { + + } + /*************************************************************************\ * Group: Private Methods * *************** *** 415,427 **** } /** ! * Method: _reset * ! * Resets dropList to defaultValue * */ ! p._reset = function () { ! this.contents.elm.childNodes[0].value = this.defaultValue; } --- 441,458 ---- } + p._thyLabelPanel_setDisabled = p._setDisabled; /** ! * Method: _setDisabled * ! * Executed when non-private <thyPanel> setDisabled method is called * */ ! p._setDisabled = function () { ! this._thyLabelPanel_setDisabled(); ! ! if (!this._created) return; ! this.contents.elm.childNodes[0].setAttribute('disabled', ''); ! this.contents.elm.childNodes[0].disabled = this.disabled; } *************** *** 628,631 **** --- 659,678 ---- /** VINICIUS: assignar os eventos desse objeto ao dropdown */ + + p._dropDownParentChange = function() + { + var self = this; + return function() + { + if (self.parent && self.parent._attachWindowed) + { + self.parent._attachWindowed(self); + } + else + { + self.containerWindow = null; + } + } + } |