aboutsummaryrefslogtreecommitdiff
path: root/node_modules/montage/ui/dynamic-text.reel/dynamic-text.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/montage/ui/dynamic-text.reel/dynamic-text.js')
-rwxr-xr-xnode_modules/montage/ui/dynamic-text.reel/dynamic-text.js95
1 files changed, 95 insertions, 0 deletions
diff --git a/node_modules/montage/ui/dynamic-text.reel/dynamic-text.js b/node_modules/montage/ui/dynamic-text.reel/dynamic-text.js
new file mode 100755
index 00000000..0731b723
--- /dev/null
+++ b/node_modules/montage/ui/dynamic-text.reel/dynamic-text.js
@@ -0,0 +1,95 @@
1/* <copyright>
2 This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
3 No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/>
4 (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
5 </copyright> */
6/**
7 @module "montage/ui/dynamic-text.reel"
8 @requires montage/core/core
9 @requires montage/ui/component
10*/
11var Montage = require("montage").Montage,
12 Component = require("ui/component").Component;
13
14/**
15 @class module:"montage/ui/dynamic-text.reel".DynamicText
16 @extends module:montage/ui/component.Component
17 */
18exports.DynamicText = Montage.create(Component, /** @lends module:"montage/ui/dynamic-text.reel".DynamicText# */ {
19
20 hasTemplate: {
21 value: false
22 },
23/**
24 Description TODO
25 @private
26*/
27 _value: {
28 enumerable: false,
29 value: null
30 },
31/**
32 Description TODO
33 @type {Function}
34 @default null
35 */
36 value: {
37 get: function() {
38 return this._value;
39 },
40 set: function(value) {
41 if (this._value !== value) {
42 this.needsDraw = true;
43 }
44 this._value = value;
45 },
46 serializable: true
47 },
48/**
49 The Montage converted used to convert or format values displayed by this DynamicText instance.
50 @type {Property}
51 @default null
52 */
53 converter: {
54 value: null
55 },
56/**
57 The default string value assigned to the DynamicText instance.
58 @type {Property}
59 @default {String} ""
60 */
61 defaultValue: {
62 value: ""
63 },
64
65 /**
66 @private
67 */
68 _valueNode: {
69 value: null,
70 enumerable: false
71 },
72
73 prepareForDraw: {
74 value: function() {
75 this._element.innerHTML = "";
76 if (!this._element.firstChild) {
77 this._element.appendChild(document.createTextNode(""));
78 }
79 this._valueNode = this._element.firstChild;
80 }
81 },
82
83
84 draw: {
85 value: function() {
86 var displayValue = (this.value || 0 === this.value ) ? this._value : this.defaultValue;
87
88 if (this.converter) {
89 displayValue = this.converter.convert(displayValue);
90 }
91 this._valueNode.data = displayValue;
92 }
93 }
94
95});