diff options
author | Ananya Sen | 2012-06-26 16:07:00 -0700 |
---|---|---|
committer | Ananya Sen | 2012-06-26 16:07:00 -0700 |
commit | 1d5372534d11c9c1b818ba5e7d67498c731e9ac6 (patch) | |
tree | bc09c9f08ac2faa955995a91a78337276a81eb77 /js | |
parent | 3391a8e6fd5df0d464edaffd98c2b3fde23acf5a (diff) | |
parent | 46174eb0ce93d660c8d2e9276fbdc4f9a03f056a (diff) | |
download | ninja-1d5372534d11c9c1b818ba5e7d67498c731e9ac6.tar.gz |
Merge branch 'refs/heads/ninja-internal-master' into bugfix-master
Conflicts:
js/ninja.reel/ninja.html
Signed-off-by: Ananya Sen <Ananya.Sen@motorola.com>
Diffstat (limited to 'js')
56 files changed, 3752 insertions, 196 deletions
diff --git a/js/components/editable.reel/editable.js b/js/components/editable.reel/editable.js index 103e418f..88b93b2c 100644 --- a/js/components/editable.reel/editable.js +++ b/js/components/editable.reel/editable.js | |||
@@ -93,12 +93,43 @@ exports.Editable = Montage.create(Component, { | |||
93 | } | 93 | } |
94 | } | 94 | } |
95 | }, | 95 | }, |
96 | |||
97 | _value : { value: null }, | ||
96 | value : { | 98 | value : { |
97 | get: function() { | 99 | get : function() { return this._value; }, |
98 | return this._element.textContent; | 100 | set : function(value) { |
99 | }, | 101 | if(value === this._value) { return; } |
100 | set: function(str) { | 102 | |
101 | this._element.textContent = str; | 103 | var node = this._getFirstTextNode(); |
104 | node.textContent = value; | ||
105 | |||
106 | this._value = value; | ||
107 | } | ||
108 | }, | ||
109 | _getFirstTextNode : { | ||
110 | value : function(el) { | ||
111 | ///// optional el argument specified container element | ||
112 | var e = el || this._element, | ||
113 | nodes = e.childNodes, node; | ||
114 | |||
115 | if(nodes.length) { | ||
116 | for(var i=0; i<nodes.length; i++) { | ||
117 | if(nodes[i].nodeType === 3) { | ||
118 | ///// found the first text node | ||
119 | node = nodes[i]; | ||
120 | break; | ||
121 | } | ||
122 | } | ||
123 | } | ||
124 | |||
125 | ///// Text node not found | ||
126 | if(!node) { | ||
127 | node = document.createTextNode(''); | ||
128 | e.appendChild(node); | ||
129 | } | ||
130 | |||
131 | |||
132 | return node; | ||
102 | } | 133 | } |
103 | }, | 134 | }, |
104 | 135 | ||
@@ -207,6 +238,8 @@ exports.Editable = Montage.create(Component, { | |||
207 | ///// Text input has changed values | 238 | ///// Text input has changed values |
208 | handleInput : { | 239 | handleInput : { |
209 | value : function(e) { | 240 | value : function(e) { |
241 | this.value = this._getFirstTextNode().textContent; | ||
242 | |||
210 | if(!this.isDirty) { | 243 | if(!this.isDirty) { |
211 | this.isDirty = true; | 244 | this.isDirty = true; |
212 | } | 245 | } |
@@ -230,6 +263,8 @@ exports.Editable = Montage.create(Component, { | |||
230 | value: function(e) { | 263 | value: function(e) { |
231 | e.preventDefault(); | 264 | e.preventDefault(); |
232 | document.execCommand('insertHTML', null, e._event.clipboardData.getData("Text")); | 265 | document.execCommand('insertHTML', null, e._event.clipboardData.getData("Text")); |
266 | this.value = this._element.textContent; | ||
267 | |||
233 | this._sendEvent('paste', e); | 268 | this._sendEvent('paste', e); |
234 | } | 269 | } |
235 | }, | 270 | }, |
diff --git a/js/components/hintable.reel/hintable.js b/js/components/hintable.reel/hintable.js index 08e87bf0..fb55c937 100644 --- a/js/components/hintable.reel/hintable.js +++ b/js/components/hintable.reel/hintable.js | |||
@@ -140,19 +140,6 @@ exports.Hintable = Montage.create(Editable, { | |||
140 | } | 140 | } |
141 | } | 141 | } |
142 | }, | 142 | }, |
143 | value : { | ||
144 | get: function() { | ||
145 | return this._getFirstTextNode().textContent; | ||
146 | }, | ||
147 | set: function(str) { | ||
148 | var node = this._getFirstTextNode(); | ||
149 | if (node.textContent !== str) { | ||
150 | node.textContent = str; | ||
151 | } | ||
152 | |||
153 | //node.innerText = str; | ||
154 | } | ||
155 | }, | ||
156 | 143 | ||
157 | handleKeydown : { | 144 | handleKeydown : { |
158 | value : function handleKeydown(e) { | 145 | value : function handleKeydown(e) { |
@@ -189,17 +176,18 @@ exports.Hintable = Montage.create(Editable, { | |||
189 | handleInput : { | 176 | handleInput : { |
190 | value : function handleInput(e) { | 177 | value : function handleInput(e) { |
191 | this._super(arguments); | 178 | this._super(arguments); |
192 | 179 | ||
193 | var val = this.value, | 180 | var val = this.value, |
194 | matches, hint; | 181 | matches, hint; |
195 | //console.log('val = "' + val + '"'); | 182 | //console.log('val = "' + val + '"'); |
196 | //// Handle auto-suggest if configured | 183 | //// Handle auto-suggest if configured |
197 | if(this.hints instanceof Array) { | 184 | if(this.hints && this.hints.length) { |
198 | 185 | ||
199 | if(val.length > 0) { // content is not empty | 186 | if(val.length > 0) { // content is not empty |
200 | 187 | ||
201 | this._matchIndex = 0; | 188 | this._matchIndex = 0; |
202 | this.matches = this.hints.filter(function(h) { | 189 | this.matches = this.hints.filter(function(h) { |
190 | if(!h) { return false; } | ||
203 | return h.indexOf(val) === 0; | 191 | return h.indexOf(val) === 0; |
204 | }).sort(); | 192 | }).sort(); |
205 | 193 | ||
@@ -275,32 +263,6 @@ exports.Hintable = Montage.create(Editable, { | |||
275 | return Array.prototype.slice.call(arrayLikeObj); | 263 | return Array.prototype.slice.call(arrayLikeObj); |
276 | } | 264 | } |
277 | }, | 265 |