jquery-atwho-rails 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/changelog.md CHANGED
@@ -1,2 +1,3 @@
1
+ * 2013.3.1 - v0.2.2 fix some bugs.
1
2
  * 2013.1.24 updated to v0.2.0.
2
3
  * 2012.7.1 remove the mirror(copy) element of the textarea(inputor) which will disturb css style. increase timeout of displaying the result list view.
@@ -20,7 +20,7 @@
20
20
  var Controller, DEFAULT_CALLBACKS, DEFAULT_TPL, KEY_CODE, Mirror, View;
21
21
  Mirror = (function() {
22
22
 
23
- Mirror.prototype.css_attr = ["overflowY", "height", "width", "paddingTop", "paddingLeft", "paddingRight", "paddingBottom", "marginTop", "marginLeft", "marginRight", "marginBottom", 'fontFamily', 'borderStyle', 'borderWidth', 'wordWrap', 'fontSize', 'lineHeight', 'overflowX'];
23
+ Mirror.prototype.css_attr = ["overflowY", "height", "width", "paddingTop", "paddingLeft", "paddingRight", "paddingBottom", "marginTop", "marginLeft", "marginRight", "marginBottom", "fontFamily", "borderStyle", "borderWidth", "wordWrap", "fontSize", "lineHeight", "overflowX", "text-align"];
24
24
 
25
25
  function Mirror($inputor) {
26
26
  this.$inputor = $inputor;
@@ -75,6 +75,9 @@
75
75
  };
76
76
  DEFAULT_CALLBACKS = {
77
77
  data_refactor: function(data) {
78
+ if (!$.isArray(data)) {
79
+ return data;
80
+ }
78
81
  return $.map(data, function(item, k) {
79
82
  if (!$.isPlainObject(item)) {
80
83
  item = {
@@ -115,8 +118,9 @@
115
118
  sorter: function(query, items, search_key) {
116
119
  var item, results, text, _i, _len;
117
120
  if (!query) {
118
- items;
119
-
121
+ return items.sort(function(a, b) {
122
+ return a[search_key].toLowerCase() > b[search_key].toLowerCase();
123
+ });
120
124
  }
121
125
  results = [];
122
126
  for (_i = 0, _len = items.length; _i < _len; _i++) {
@@ -187,11 +191,7 @@
187
191
  current_settings = {};
188
192
  current_settings = $.isPlainObject(flag) ? this.common_settings = $.extend({}, this.common_settings, flag) : !this.settings[flag] ? this.settings[flag] = $.extend({}, settings) : this.settings[flag] = $.extend({}, this.settings[flag], settings);
189
193
  data = current_settings["data"];
190
- if (typeof data === "string") {
191
- current_settings["data"] = data;
192
- } else if (data) {
193
- current_settings["data"] = this.callbacks("data_refactor").call(this, data);
194
- }
194
+ current_settings["data"] = this.callbacks("data_refactor").call(this, data);
195
195
  return this;
196
196
  };
197
197
 
@@ -373,21 +373,33 @@
373
373
  return this.view.render(data);
374
374
  };
375
375
 
376
+ Controller.prototype.remote_call = function(data, query) {
377
+ var params, _callback;
378
+ params = {
379
+ q: query.text,
380
+ limit: this.get_opt("limit")
381
+ };
382
+ _callback = function(data) {
383
+ this.reg(this.current_flag, {
384
+ data: data
385
+ });
386
+ return this.render_view(this.data());
387
+ };
388
+ _callback = $.proxy(_callback, this);
389
+ return this.callbacks('remote_filter').call(this, params, data, _callback);
390
+ };
391
+
376
392
  Controller.prototype.look_up = function() {
377
- var data, origin_data, params, query, search_key;
393
+ var data, query, search_key;
378
394
  query = this.catch_query();
379
395
  if (!query) {
380
396
  return false;
381
397
  }
382
- origin_data = this.get_opt("data");
398
+ data = this.data();
383
399
  search_key = this.get_opt("search_key");
384
- if (typeof origin_data === "string") {
385
- params = {
386
- q: query.text,
387
- limit: this.get_opt("limit")
388
- };
389
- this.callbacks('remote_filter').call(this, params, origin_data, $.proxy(this.render_view, this));
390
- } else if ((data = this.callbacks('filter').call(this, query.text, origin_data, search_key))) {
400
+ if (typeof data === "string") {
401
+ this.remote_call(data, query);
402
+ } else if ((data = this.callbacks('filter').call(this, query.text, data, search_key))) {
391
403
  this.render_view(data);
392
404
  } else {
393
405
  this.view.hide();
@@ -1,5 +1,5 @@
1
1
  require "jquery-atwho-rails/version"
2
- require "ActiveSupport"
2
+ require "active_support"
3
3
 
4
4
  module Jquery
5
5
  module Atwho
@@ -1,7 +1,7 @@
1
1
  module Jquery
2
2
  module Atwho
3
3
  module Rails
4
- VERSION = "0.2.1"
4
+ VERSION = "0.2.2"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jquery-atwho-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-24 00:00:00.000000000 Z
12
+ date: 2013-03-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -77,7 +77,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
77
77
  version: '0'
78
78
  segments:
79
79
  - 0
80
- hash: -3411578706402898122
80
+ hash: -2700002809925972358
81
81
  required_rubygems_version: !ruby/object:Gem::Requirement
82
82
  none: false
83
83
  requirements:
@@ -86,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
86
86
  version: '0'
87
87
  segments:
88
88
  - 0
89
- hash: -3411578706402898122
89
+ hash: -2700002809925972358
90
90
  requirements: []
91
91
  rubyforge_project: jquery-atwho-rails
92
92
  rubygems_version: 1.8.24