From 24b483db367291b72170f969de78efcb1a9b95bd Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Thu, 3 May 2012 22:53:07 -0700 Subject: integrating the latest montage version Signed-off-by: Valerio Virgillito --- node_modules/montage/ui/button.reel/button.js | 214 ++++++++++++++++++++------ 1 file changed, 164 insertions(+), 50 deletions(-) (limited to 'node_modules/montage/ui/button.reel/button.js') diff --git a/node_modules/montage/ui/button.reel/button.js b/node_modules/montage/ui/button.reel/button.js index 315cf505..eead3124 100644 --- a/node_modules/montage/ui/button.reel/button.js +++ b/node_modules/montage/ui/button.reel/button.js @@ -4,46 +4,63 @@ (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. */ /*global require, exports*/ + +/** + @module "montage/ui/button.reel" + @requires montage/core/core + @requires montage/ui/component + @requires montage/ui/native-control + @requires montage/ui/composer/press-composer +*/ var Montage = require("montage").Montage, Component = require("ui/component").Component, NativeControl = require("ui/native-control").NativeControl, PressComposer = require("ui/composer/press-composer").PressComposer; -/** - * The Button input - */ -var Button = exports.Button = Montage.create(NativeControl, { - - /** - @event - @name action - @param {Event} event - - Dispatched when the button is activated through a mouse click, finger tap, - or when focused and the spacebar is pressed. - */ - - /** - @event - @name hold - @param {Event} event - - Dispatched when the button is pressed for a period of time, set by - {@link holdTimeout}. - */ /** - Description TODO - @private + Wraps a native <button> or <input[type="button"]> HTML element. The element's standard attributes are exposed as bindable properties. + @class module:"montage/ui/button.reel".Button + @extends module:montage/native-control.NativeControl + @example +JavaScript example +var b1 = Button.create(); +b1.element = document.querySelector("btnElement"); +b1.addEventListener("action", function(event) { + console.log("Got event 'action' event"); +}); + @example +Serialized example +{ + "aButton": { + "prototype": "montage/ui/button.reel", + "properties": { + "element": {"#": "btnElement"} + }, + "listeners": [ + { + "type": "action", + "listener": {"@": "appListener"} + } + ] + }, + "listener": { + "prototype": "appListener" + } +} +<button data-montage-id="btnElement"> */ +var Button = exports.Button = Montage.create(NativeControl, /** @lends module:"montage/ui/button.reel".Button# */ { + _preventFocus: { enumerable: false, value: false }, /** - Description TODO - @type {Function} - @default {Boolean} false + Specifies whether the button should receive focus or not. + @type {boolean} + @default false + @event longpress */ preventFocus: { get: function () { @@ -58,6 +75,10 @@ var Button = exports.Button = Montage.create(NativeControl, { } }, + +/** + Enables or disables the Button from user input. When this property is set to false, the "disabled" CSS style is applied to the button's DOM element during the next draw cycle. When set to true the "disabled" CSS class is removed from the element's class list. +*/ //TODO we should prefer positive properties like enabled vs disabled, get rid of disabled enabled: { dependencies: ["disabled"], @@ -70,7 +91,7 @@ var Button = exports.Button = Montage.create(NativeControl, { }, /** - The Montage converted used to convert or format values displayed by this Button instance. + A Montage converter object used to convert or format the label displayed by the Button instance. When a new value is assigned to label, the converter object's convert() method is invoked, passing it the newly assigned label value. @type {Property} @default null */ @@ -86,15 +107,14 @@ var Button = exports.Button = Montage.create(NativeControl, { _labelNode: {value:undefined, enumerable: false}, _label: { value: undefined, enumerable: false }, + /** - The label for the button. + The label for the button. In an <input> element this is taken from the element's value attribute. On any other element (including <button>) this is the first child node which is a text node. If one isn't found then it will be created. - In an `` element this is the value property. On any other element - (including `