diff options
author | Jon Reid | 2012-06-26 14:58:10 -0700 |
---|---|---|
committer | Jon Reid | 2012-06-26 14:58:10 -0700 |
commit | 2599f74d72293b809929d8a0b36fb8e721f194cd (patch) | |
tree | ca4cd45b23b8debea32f95d7dea807c77b6633b2 /js/components/hintable.reel/hintable.js | |
parent | ab9d14780eed98f39786fae4518e69861b34bad7 (diff) | |
parent | e4304b9ac6c58802de4dd334be1f5802533f5160 (diff) | |
download | ninja-2599f74d72293b809929d8a0b36fb8e721f194cd.tar.gz |
Merge remote-tracking branch 'ninja-jduran/TimelineUber' into timeline-local
Diffstat (limited to 'js/components/hintable.reel/hintable.js')
-rw-r--r-- | js/components/hintable.reel/hintable.js | 47 |
1 files changed, 5 insertions, 42 deletions
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 | }, |
278 | _getFirstTextNode : { | ||
279 | value : function(el) { | ||
280 | ///// optional el argument specified container element | ||
281 | var e = el || this._element, | ||
282 | nodes = e.childNodes, node; | ||
283 | |||
284 | if(nodes.length) { | ||
285 | for(var i=0; i<nodes.length; i++) { | ||
286 | if(nodes[i].nodeType === 3) { | ||
287 | ///// found the first text node | ||
288 | node = nodes[i]; | ||
289 | break; | ||
290 | } | ||
291 | } | ||
292 | } | ||
293 | |||
294 | ///// Text node not found | ||
295 | if(!node) { | ||
296 | node = document.createTextNode(''); | ||
297 | e.appendChild(node); | ||
298 | } | ||
299 | |||
300 | |||
301 | return node; | ||
302 | } | ||
303 | }, | ||
304 | _super : { | 266 | _super : { |
305 | value : function(args) { | 267 | value : function(args) { |
306 | this.inheritsFrom[arguments.callee.caller.name].apply(this, args); | 268 | this.inheritsFrom[arguments.callee.caller.name].apply(this, args); |
@@ -309,7 +271,8 @@ exports.Hintable = Montage.create(Editable, { | |||
309 | 271 | ||
310 | /* --------- CONFIG ---------- */ | 272 | /* --------- CONFIG ---------- */ |
311 | hints : { | 273 | hints : { |
312 | value : ['Testing a hint.', 'Testing another hint.', 'Testing the last hint.'] | 274 | value : ['Testing a hint.', 'Testing another hint.', 'Testing the last hint.'], |
275 | distinct: true | ||
313 | }, | 276 | }, |
314 | hintClass : { | 277 | hintClass : { |
315 | value : "hintable-hint" | 278 | value : "hintable-hint" |