aboutsummaryrefslogtreecommitdiff
path: root/js/components/hintable.reel
diff options
context:
space:
mode:
authorJose Antonio Marquez2012-06-27 09:59:01 -0700
committerJose Antonio Marquez2012-06-27 09:59:01 -0700
commitca1e79d4dc36a55c47b6f8cb92069eafc95383b5 (patch)
tree2bf23250a605ca42a33f7bc75698357e0258d624 /js/components/hintable.reel
parent245e70117f9605dc5603328c97685b2e5a10f220 (diff)
parent2ebf3e3ea24d0d580575dfa13d31588dac1de445 (diff)
downloadninja-ca1e79d4dc36a55c47b6f8cb92069eafc95383b5.tar.gz
Merge branch 'refs/heads/Ninja-Internal' into Document
Diffstat (limited to 'js/components/hintable.reel')
-rw-r--r--js/components/hintable.reel/hintable.js47
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"