+++ /dev/null
-/*\r
-� Copyright 2008 Nokia Corporation. All rights reserved.\r
-\r
-IMPORTANT: The Nokia software ("WRTKit and Example Widget files") is supplied to you by Nokia\r
-Corporation (�Nokia�) in consideration of your agreement to the following terms. Your use, installation\r
-and/or redistribution of the WRTKit and Example Widget files constitutes acceptance of these terms. If\r
-you do not agree with these terms, please do not use, install, or redistribute the WRTKit and Example\r
-Widget files.\r
-\r
-In consideration of your agreement to abide by the following terms, and subject to these terms, Nokia\r
-grants you a personal, non-exclusive license, under Nokia�s copyrights in the WRTKit and Example\r
-Widget files, to use, reproduce, and redistribute the WRTKit and Example files, in text form (for HTML,\r
-CSS, or JavaScript files) or binary form (for associated images), for the sole purpose of creating S60\r
-Widgets.\r
-\r
-If you redistribute the WRTKit and Example files, you must retain this entire notice in all such\r
-redistributions of the WRTKit and Example files.\r
-\r
-You may not use the name, trademarks, service marks or logos of Nokia to endorse or promote products\r
-that include the WRTKit and Example files without the prior written explicit agreement with Nokia.\r
-Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by\r
-Nokia herein, including but not limited to any patent rights that may be infringed by your products that\r
-incorporate the WRTKit and Example files or by other works in which the WRTKit and Example files\r
-may be incorporated.\r
-\r
-The WRTKit and Example files are provided on an "AS IS" basis. NOKIA MAKES NO\r
-WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED\r
-WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A\r
-PARTICULAR PURPOSE, REGARDING THE EXAMPLES OR ITS USE AND OPERATION\r
-ALONE OR IN COMBINATION WITH YOUR PRODUCTS.\r
-\r
-IN NO EVENT SHALL NOKIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR\r
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r
-INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, AND/OR\r
-DISTRIBUTION OF THE EXAMPLES, HOWEVER CAUSED AND WHETHER UNDER THEORY\r
-OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE,\r
-EVEN IF NOKIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
-\r
-*/\r
-\r
-///////////////////////////////////////////////////////////////////////////////\r
-// The NavigationButton class implements a button control for use in\r
-// navigational contexts in menu-style UIs.\r
-\r
-// Constructor.\r
-function NavigationButton(id, image, text) {\r
- if (id != UI_NO_INIT_ID) {\r
- this.init(id, image, text);\r
- }\r
-}\r
-\r
-// NavigationButton inherits from ActionControl.\r
-NavigationButton.prototype = new ActionControl(UI_NO_INIT_ID);\r
-\r
-// Button table element.\r
-NavigationButton.prototype.tableElement = null;\r
-\r
-// Button table row element.\r
-NavigationButton.prototype.tableRowElement = null;\r
-\r
-// Button table left cell element.\r
-NavigationButton.prototype.tableLeftCellElement = null;\r
-\r
-// Button table right cell element.\r
-NavigationButton.prototype.tableRightCellElement = null;\r
-\r
-// Button image element.\r
-NavigationButton.prototype.imageElement = null;\r
-\r
-// Button link element.\r
-NavigationButton.prototype.linkElement = null;\r
-\r
-// Button text element.\r
-NavigationButton.prototype.textElement = null;\r
-\r
-// Initializer - called from constructor.\r
-NavigationButton.prototype.init = function(id, image, text) {\r
- uiLogger.debug("NavigationButton.init(" + id + ", " + image + ", " + text + ")");\r
- \r
- // call superclass initializer\r
- ActionControl.prototype.init.call(this, id, null);\r
- \r
- // remove caption element\r
- this.assemblyElement.removeChild(this.captionElement);\r
- \r
- // construct the button\r
- this.buttonElement = document.createElement("div");\r
- this.tableElement = document.createElement("table");\r
- this.tableRowElement = document.createElement("tr");\r
- this.tableLeftCellElement = document.createElement("td");\r
- this.tableRightCellElement = document.createElement("td");\r
- this.imageElement = null;\r
- this.linkElement = document.createElement("a");\r
- this.linkElement.href = "JavaScript:void(0)";\r
- this.textElement = document.createElement("span");\r
- this.tableElement.appendChild(this.tableRowElement);\r
- this.tableRowElement.appendChild(this.tableLeftCellElement);\r
- this.tableRowElement.appendChild(this.tableRightCellElement);\r
- this.tableRightCellElement.appendChild(this.linkElement);\r
- this.linkElement.appendChild(this.textElement);\r
- this.buttonElement.appendChild(this.tableElement);\r
- this.controlElement.appendChild(this.buttonElement);\r
- \r
- // set the image and text\r
- this.setImage(image);\r
- this.setText(text);\r
- \r
- // bind event listeners\r
- this.bindActionControlListeners();\r
- \r
- // update the style\r
- this.updateStyleFromState();\r
-}\r
-\r
-// Sets the enabled state.\r
-NavigationButton.prototype.setEnabled = function(enabled) {\r
- uiLogger.debug("NavigationButton.setEnabled(" + enabled + ")");\r
- \r
- // bail out early if there is no change in state\r
- if (this.enabled == enabled) {\r
- return;\r
- }\r
- \r
- // set the enabled state\r
- this.enabled = enabled;\r
- \r
- if (this.enabled) {\r
- // diabled -> enabled\r
- this.tableRightCellElement.removeChild(this.textElement);\r
- this.tableRightCellElement.appendChild(this.linkElement);\r
- this.linkElement.appendChild(this.textElement);\r
- } else {\r
- // enabled -> diabled\r
- this.linkElement.removeChild(this.textElement);\r
- this.tableRightCellElement.removeChild(this.linkElement);\r
- this.tableRightCellElement.appendChild(this.textElement);\r
- }\r
- \r
- // update the style\r
- this.updateStyleFromState();\r
-}\r
-\r
-// Returns the button image (URL); null if none.\r
-NavigationButton.prototype.getImage = function() {\r
- return (this.imageElement != null) ? this.imageElement.src : null;\r
-}\r
-\r
-// Sets the button image (URL); null if none.\r
-NavigationButton.prototype.setImage = function(image) {\r
- uiLogger.debug("NavigationButton.setImage(" + image + ")");\r
- \r
- if (image == null) {\r
- // remove image - if any\r
- if (this.imageElement != null) {\r
- this.tableLeftCellElement.removeChild(this.imageElement);\r
- }\r
- } else {\r
- // default to not append image element\r
- var append = false;\r
- \r
- // create image element if one doesn't exist\r
- if (this.imageElement == null) {\r
- this.imageElement = document.createElement("img");\r
- this.imageElement.setAttribute("alt", "");\r
- append = true;\r
- }\r
- \r
- // set image source URL\r
- this.imageElement.src = image;\r
- \r
- // append the image element to the left cell?\r
- if (append) {\r
- this.tableLeftCellElement.appendChild(this.imageElement);\r
- }\r
- }\r
-}\r
-\r
-// Returns the button text.\r
-NavigationButton.prototype.getText = function() {\r
- return this.textElement.innerHTML;\r
-}\r
-\r
-// Sets the button text.\r
-NavigationButton.prototype.setText = function(text) {\r
- uiLogger.debug("NavigationButton.setText(" + text + ")");\r
- this.textElement.innerHTML = (text == null) ? "" : text;;\r
-}\r
-\r
-// Updates the style of the control to reflects the state of the control.\r
-NavigationButton.prototype.updateStyleFromState = function() {\r
- uiLogger.debug("NavigationButton.updateStyleFromState()");\r
- \r
- // determine the state name\r
- var stateName = this.getStyleStateName();\r
- \r
- // set root element class name\r
- this.setClassName(this.rootElement, "Control");\r
- \r
- // set the control assembly class names\r
- this.setClassName(this.assemblyElement, "ControlAssembly ControlAssembly" + stateName);\r
- \r
- // control element\r
- this.setClassName(this.controlElement, "ControlElement NavigationButtonControlElement");\r
- \r
- // set the button table class names\r
- this.setClassName(this.buttonElement, "NavigationButton");\r
- this.setClassName(this.tableElement, "NavigationButtonTable");\r
- this.setClassName(this.tableRowElement, "NavigationButtonRow");\r
- this.setClassName(this.tableLeftCellElement, "NavigationButtonImageCell");\r
- this.setClassName(this.tableRightCellElement, "NavigationButtonTextCell");\r
- \r
- // set image class names\r
- if (this.imageElement) {\r
- this.setClassName(this.imageElement, "NavigationButtonImage");\r
- }\r
- \r
- // set the button text class name\r
- this.setClassName(this.textElement, "NavigationButtonText NavigationButtonText" + stateName);\r
-}\r