diff options
Diffstat (limited to 'js/components/hintable.reel/hintable.js')
-rw-r--r-- | js/components/hintable.reel/hintable.js | 34 |
1 files changed, 5 insertions, 29 deletions
diff --git a/js/components/hintable.reel/hintable.js b/js/components/hintable.reel/hintable.js index 08e87bf0..810f0d65 100644 --- a/js/components/hintable.reel/hintable.js +++ b/js/components/hintable.reel/hintable.js | |||
@@ -189,17 +189,18 @@ exports.Hintable = Montage.create(Editable, { | |||
189 | handleInput : { | 189 | handleInput : { |
190 | value : function handleInput(e) { | 190 | value : function handleInput(e) { |
191 | this._super(arguments); | 191 | this._super(arguments); |
192 | 192 | ||
193 | var val = this.value, | 193 | var val = this.value, |
194 | matches, hint; | 194 | matches, hint; |
195 | //console.log('val = "' + val + '"'); | 195 | //console.log('val = "' + val + '"'); |
196 | //// Handle auto-suggest if configured | 196 | //// Handle auto-suggest if configured |
197 | if(this.hints instanceof Array) { | 197 | if(this.hints && this.hints.length) { |
198 | 198 | ||
199 | if(val.length > 0) { // content is not empty | 199 | if(val.length > 0) { // content is not empty |
200 | 200 | ||
201 | this._matchIndex = 0; | 201 | this._matchIndex = 0; |
202 | this.matches = this.hints.filter(function(h) { | 202 | this.matches = this.hints.filter(function(h) { |
203 | if(!h) { return false; } | ||
203 | return h.indexOf(val) === 0; | 204 | return h.indexOf(val) === 0; |
204 | }).sort(); | 205 | }).sort(); |
205 | 206 | ||
@@ -275,32 +276,6 @@ exports.Hintable = Montage.create(Editable, { | |||
275 | return Array.prototype.slice.call(arrayLikeObj); | 276 | return Array.prototype.slice.call(arrayLikeObj); |
276 | } | 277 | } |
277 | }, | 278 | }, |
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 : { | 279 | _super : { |
305 | value : function(args) { | 280 | value : function(args) { |
306 | this.inheritsFrom[arguments.callee.caller.name].apply(this, args); | 281 | this.inheritsFrom[arguments.callee.caller.name].apply(this, args); |
@@ -309,7 +284,8 @@ exports.Hintable = Montage.create(Editable, { | |||
309 | 284 | ||
310 | /* --------- CONFIG ---------- */ | 285 | /* --------- CONFIG ---------- */ |
311 | hints : { | 286 | hints : { |
312 | value : ['Testing a hint.', 'Testing another hint.', 'Testing the last hint.'] | 287 | value : ['Testing a hint.', 'Testing another hint.', 'Testing the last hint.'], |
288 | distinct: true | ||
313 | }, | 289 | }, |
314 | hintClass : { | 290 | hintClass : { |
315 | value : "hintable-hint" | 291 | value : "hintable-hint" |