From 8fe92b94ce5e1e2857d088752d94e19db7e3d8a8 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Sun, 17 Jun 2012 22:31:44 -0700 Subject: montage v11 merge into ninja Signed-off-by: Valerio Virgillito --- node_modules/montage/ui/progress.reel/progress.js | 127 +++++++++++++++++----- 1 file changed, 98 insertions(+), 29 deletions(-) (limited to 'node_modules/montage/ui/progress.reel/progress.js') diff --git a/node_modules/montage/ui/progress.reel/progress.js b/node_modules/montage/ui/progress.reel/progress.js index 06704f9f..d5886561 100755 --- a/node_modules/montage/ui/progress.reel/progress.js +++ b/node_modules/montage/ui/progress.reel/progress.js @@ -3,47 +3,116 @@ No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. */ - /** - @module "montage/ui/progress.reel" - @requires montage/ui/commponent - @requires montage/ui/native-control + @module "montage/ui/bluemoon/progress.reel" + @requires montage/core/core + @requires montage/ui/component */ - var Montage = require("montage").Montage, Component = require("ui/component").Component, - NativeControl = require("ui/native-control").NativeControl; - + NativeProgress = require("ui/native/progress.reel").Progress; /** - The Progress component wraps a native <progress> element and exposes its standard attributes as bindable properties. - @class module:"montage/ui/progress.reel".Progress - @extends module:montage/native-control.NativeControl - + @class module:montage/ui/progress.Progress + @extends module:montage/ui/component.Component */ -var Progress = exports.Progress = Montage.create(NativeControl, { +exports.Progress = Montage.create(NativeProgress,/** @lends module:"montage/ui/bluemoon/progress.reel".Progress# */ { -}); - -Progress.addAttributes( /** @lends module:"montage/ui/progress.reel".Progress# */{ + hasTemplate: {value: true}, /** - The value of the id attribute of the form with which to associate the component's element. - @type string} - @default null + Description TODO + @private */ - form: null, - + _barElement: { + enumerable: false, + serializable: true, + value: null + }, /** - The maximum value displayed but the progress control. - @type {number} - @default null + Description TODO + @private */ - max: {dataType: 'number'}, + _value: { + enumerable: false, + serializable: true, + value: null + }, +/** + Description TODO + @type {Function} + @default {Number} 0 + */ + value: { + serializable: true, + get: function() { + return this._value; + }, + set: function(val) { + if(val !== this._value) { + this._value = String.isString(val) ? parseInt(val, 10) : val; + if(this._max && (this._value > this._max)) { + this._value = this._max; + } + if(this._value < 0) { + this._value = 0; + } + this.needsDraw = true; + } + } + }, /** - The current value displayed but the progress control. - @type {number} - @default null + Description TODO + @private */ - value: {dataType: 'number'} -}); \ No newline at end of file + _max: { + enumerable: false, + serializable: true, + value: null + }, +/** + Description TODO + @type {Function} + @default {Number} 100 + */ + max: { + serializable: true, + get: function() { + return this._max; + }, + set: function(val) { + if(val !== this._max) { + this._max = String.isString(val) ? parseInt(val, 10) : val; + if(this._max <= 0) { + this._max = 1; // Prevent divide by zero errors + } + this.needsDraw = true; + } + } + }, + + didCreate: { + value: function() { + + if(NativeProgress.didCreate) { + NativeProgress.didCreate.call(this); + } + } + }, + +/** + Description TODO + @function + */ + draw: { + enumerable: false, + value: function() { + var ratio = this._value / this._max; + // constrain to interval [0, 1] + ratio = Math.min(Math.max(ratio, 0), 1); + // map into [0, 100] + var percentage = ratio * 100; + this._barElement.style.width = percentage + '%'; + } + } +}); -- cgit v1.2.3