diff options
Diffstat (limited to 'node_modules/montage/ui/dynamic-text.reel/dynamic-text.js')
-rwxr-xr-x | node_modules/montage/ui/dynamic-text.reel/dynamic-text.js | 45 |
1 files changed, 23 insertions, 22 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 index 0731b723..8562fdae 100755 --- a/node_modules/montage/ui/dynamic-text.reel/dynamic-text.js +++ b/node_modules/montage/ui/dynamic-text.reel/dynamic-text.js | |||
@@ -20,17 +20,14 @@ exports.DynamicText = Montage.create(Component, /** @lends module:"montage/ui/dy | |||
20 | hasTemplate: { | 20 | hasTemplate: { |
21 | value: false | 21 | value: false |
22 | }, | 22 | }, |
23 | /** | 23 | |
24 | Description TODO | ||
25 | @private | ||
26 | */ | ||
27 | _value: { | 24 | _value: { |
28 | enumerable: false, | ||
29 | value: null | 25 | value: null |
30 | }, | 26 | }, |
31 | /** | 27 | |
28 | /** | ||
32 | Description TODO | 29 | Description TODO |
33 | @type {Function} | 30 | @type {Property} |
34 | @default null | 31 | @default null |
35 | */ | 32 | */ |
36 | value: { | 33 | value: { |
@@ -39,13 +36,14 @@ exports.DynamicText = Montage.create(Component, /** @lends module:"montage/ui/dy | |||
39 | }, | 36 | }, |
40 | set: function(value) { | 37 | set: function(value) { |
41 | if (this._value !== value) { | 38 | if (this._value !== value) { |
39 | this._value = value; | ||
42 | this.needsDraw = true; | 40 | this.needsDraw = true; |
43 | } | 41 | } |
44 | this._value = value; | ||
45 | }, | 42 | }, |
46 | serializable: true | 43 | serializable: true |
47 | }, | 44 | }, |
48 | /** | 45 | |
46 | /** | ||
49 | The Montage converted used to convert or format values displayed by this DynamicText instance. | 47 | The Montage converted used to convert or format values displayed by this DynamicText instance. |
50 | @type {Property} | 48 | @type {Property} |
51 | @default null | 49 | @default null |
@@ -53,7 +51,8 @@ exports.DynamicText = Montage.create(Component, /** @lends module:"montage/ui/dy | |||
53 | converter: { | 51 | converter: { |
54 | value: null | 52 | value: null |
55 | }, | 53 | }, |
56 | /** | 54 | |
55 | /** | ||
57 | The default string value assigned to the DynamicText instance. | 56 | The default string value assigned to the DynamicText instance. |
58 | @type {Property} | 57 | @type {Property} |
59 | @default {String} "" | 58 | @default {String} "" |
@@ -62,32 +61,34 @@ exports.DynamicText = Montage.create(Component, /** @lends module:"montage/ui/dy | |||
62 | value: "" | 61 | value: "" |
63 | }, | 62 | }, |
64 | 63 | ||
65 | /** | ||
66 | @private | ||
67 | */ | ||
68 | _valueNode: { | 64 | _valueNode: { |
69 | value: null, | 65 | value: null |
70 | enumerable: false | 66 | }, |
67 | |||
68 | _RANGE: { | ||
69 | value: document.createRange() | ||
71 | }, | 70 | }, |
72 | 71 | ||
73 | prepareForDraw: { | 72 | prepareForDraw: { |
74 | value: function() { | 73 | value: function() { |
75 | this._element.innerHTML = ""; | 74 | var range = this._RANGE; |
76 | if (!this._element.firstChild) { | 75 | range.selectNodeContents(this.element); |
77 | this._element.appendChild(document.createTextNode("")); | 76 | range.deleteContents(); |
78 | } | 77 | this._valueNode = document.createTextNode(""); |
79 | this._valueNode = this._element.firstChild; | 78 | range.insertNode(this._valueNode); |
80 | } | 79 | } |
81 | }, | 80 | }, |
82 | 81 | ||
83 | |||
84 | draw: { | 82 | draw: { |
85 | value: function() { | 83 | value: function() { |
86 | var displayValue = (this.value || 0 === this.value ) ? this._value : this.defaultValue; | 84 | // get correct value |
85 | var value = this._value, displayValue = (value || 0 === value ) ? value : this.defaultValue; | ||
87 | 86 | ||
88 | if (this.converter) { | 87 | if (this.converter) { |
89 | displayValue = this.converter.convert(displayValue); | 88 | displayValue = this.converter.convert(displayValue); |
90 | } | 89 | } |
90 | |||
91 | //push to DOM | ||
91 | this._valueNode.data = displayValue; | 92 | this._valueNode.data = displayValue; |
92 | } | 93 | } |
93 | } | 94 | } |