|
1 |
| -/*! jquery.atwho - v1.0.0 %> |
| 1 | +/*! jquery.atwho - v1.0.1 %> |
2 | 2 | * Copyright (c) 2015 chord.luo <chord.luo@gmail.com>;
|
3 | 3 | * homepage: http://ichord.github.com/At.js
|
4 | 4 | * Licensed MIT
|
@@ -327,14 +327,33 @@ Controller = (function() {
|
327 | 327 | return this.view.render(data.slice(0, this.getOpt('limit')));
|
328 | 328 | };
|
329 | 329 |
|
| 330 | + Controller.arrayToDefaultHash = function(data) { |
| 331 | + var item, _i, _len, _results; |
| 332 | + if (!$.isArray(data)) { |
| 333 | + return data; |
| 334 | + } |
| 335 | + _results = []; |
| 336 | + for (_i = 0, _len = data.length; _i < _len; _i++) { |
| 337 | + item = data[_i]; |
| 338 | + if ($.isPlainObject(item)) { |
| 339 | + _results.push(item); |
| 340 | + } else { |
| 341 | + _results.push({ |
| 342 | + name: item |
| 343 | + }); |
| 344 | + } |
| 345 | + } |
| 346 | + return _results; |
| 347 | + }; |
| 348 | + |
330 | 349 | Controller.prototype.lookUp = function(e) {
|
331 | 350 | var query, _callback;
|
332 | 351 | if (!(query = this.catchQuery(e))) {
|
333 | 352 | return;
|
334 | 353 | }
|
335 | 354 | _callback = function(data) {
|
336 | 355 | if (data && data.length > 0) {
|
337 |
| - return this.renderView(data); |
| 356 | + return this.renderView(this.constructor.arrayToDefaultHash(data)); |
338 | 357 | } else {
|
339 | 358 | return this.view.hide();
|
340 | 359 | }
|
@@ -833,22 +852,7 @@ KEY_CODE = {
|
833 | 852 |
|
834 | 853 | DEFAULT_CALLBACKS = {
|
835 | 854 | beforeSave: function(data) {
|
836 |
| - var item, _i, _len, _results; |
837 |
| - if (!$.isArray(data)) { |
838 |
| - return data; |
839 |
| - } |
840 |
| - _results = []; |
841 |
| - for (_i = 0, _len = data.length; _i < _len; _i++) { |
842 |
| - item = data[_i]; |
843 |
| - if ($.isPlainObject(item)) { |
844 |
| - _results.push(item); |
845 |
| - } else { |
846 |
| - _results.push({ |
847 |
| - name: item |
848 |
| - }); |
849 |
| - } |
850 |
| - } |
851 |
| - return _results; |
| 855 | + return Controller.arrayToDefaultHash(data); |
852 | 856 | },
|
853 | 857 | matcher: function(flag, subtext, should_startWithSpace) {
|
854 | 858 | var match, regexp, _a, _y;
|
@@ -934,7 +938,7 @@ Api = {
|
934 | 938 | },
|
935 | 939 | isSelecting: function() {
|
936 | 940 | var _ref;
|
937 |
| - return (_ref = this.controller()) != null ? _ref.view.visiable() : void 0; |
| 941 | + return (_ref = this.controller()) != null ? _ref.view.visible() : void 0; |
938 | 942 | },
|
939 | 943 | setIframe: function(iframe, asRoot) {
|
940 | 944 | this.setupRootElement(iframe, asRoot);
|
|
0 commit comments