From 6dfe2e62b1d7a71daf097aac3a31213d564e6122 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Wed, 16 May 2012 00:54:30 -0700 Subject: Removing the old checkbox components. Created a new LabelCheckbox Signed-off-by: Valerio Virgillito --- .../ui/label-checkbox.reel/label-checkbox.js | 67 ++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100755 js/components/ui/label-checkbox.reel/label-checkbox.js (limited to 'js/components/ui/label-checkbox.reel/label-checkbox.js') diff --git a/js/components/ui/label-checkbox.reel/label-checkbox.js b/js/components/ui/label-checkbox.reel/label-checkbox.js new file mode 100755 index 00000000..82c01262 --- /dev/null +++ b/js/components/ui/label-checkbox.reel/label-checkbox.js @@ -0,0 +1,67 @@ +/* +This file contains proprietary software owned by Motorola Mobility, Inc.
+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. +
*/ + +var Montage = require("montage/core/core").Montage; +var Component = require("montage/ui/component").Component; + +exports.LabelCheckbox = Montage.create(Component, { + + _label: { + value: "" + }, + + label: { + get: function() { + return this._label; + }, + set: function(value) { + if(this._label !== value) { + this._label = value; + this.needsDraw = true; + } + } + }, + + _checked: { + value: false + }, + + checked: { + serializable: true, + get: function() { + return this._checked; + }, + set: function(value) { + if(this._checked !== value) { + this._checked = value; + this.needsDraw = true; + } + } + }, + + value: { + value: false + }, + + handleAction: { + value: function(event) { + var e = document.createEvent("CustomEvent"); + e.initEvent("change", true, true); + e.type = "change"; + e.wasSetByCode = false; + this.value = e.value = this._checkbox.checked; + this.dispatchEvent(e); + } + }, + + draw: { + value: function() { + this._labelText.value = this.label; + this._checkbox.checked = this.checked; + } + + } +}); \ No newline at end of file -- cgit v1.2.3 From 65cea92d839bcd25ea9094a0798190a4dc4bea35 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Thu, 17 May 2012 00:16:43 -0700 Subject: Adding a disabled property to the label-checkbox. Signed-off-by: Valerio Virgillito --- .../ui/label-checkbox.reel/label-checkbox.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'js/components/ui/label-checkbox.reel/label-checkbox.js') diff --git a/js/components/ui/label-checkbox.reel/label-checkbox.js b/js/components/ui/label-checkbox.reel/label-checkbox.js index 82c01262..21b72cb5 100755 --- a/js/components/ui/label-checkbox.reel/label-checkbox.js +++ b/js/components/ui/label-checkbox.reel/label-checkbox.js @@ -42,6 +42,25 @@ exports.LabelCheckbox = Montage.create(Component, { } }, + _enabled: { + enumerable: false, + value: true + }, + + enabled: { + enumerable: true, + serializable: true, + get: function() { + return this._enabled; + }, + set: function(value) { + if(value !== this._enabled) { + this._enabled = value; + this.needsDraw = true; + } + } + }, + value: { value: false }, @@ -52,7 +71,7 @@ exports.LabelCheckbox = Montage.create(Component, { e.initEvent("change", true, true); e.type = "change"; e.wasSetByCode = false; - this.value = e.value = this._checkbox.checked; + this.checked = this.value = e.value = this._checkbox.checked; this.dispatchEvent(e); } }, @@ -61,6 +80,7 @@ exports.LabelCheckbox = Montage.create(Component, { value: function() { this._labelText.value = this.label; this._checkbox.checked = this.checked; + this._checkbox.disabled = !this._enabled; } } -- cgit v1.2.3