recordselect 3.1.6 → 3.1.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -79,7 +79,7 @@ if (typeof(jQuery.fn.delayedObserver) === 'undefined') {
79
79
 
80
80
  function delayedObserverCallback(stackPos) {
81
81
  observed = delayedObserverStack[stackPos];
82
- if (observed.timer) return;
82
+ if (observed.timer) clearTimeout(observed.timer);
83
83
 
84
84
  observed.timer = setTimeout(function(){
85
85
  observed.timer = null;
@@ -284,7 +284,7 @@ RecordSelect.Abstract = Class.extend({
284
284
  if (!this.is_open()) return;
285
285
  if (this.container.has($(event.target)).length > 0) {
286
286
  return;
287
- } else {
287
+ } else if (!this.obj.is(event.target)) {
288
288
  this.close();
289
289
  }
290
290
  },
@@ -79,7 +79,7 @@ if (typeof(jQuery.fn.delayedObserver) === 'undefined') {
79
79
 
80
80
  function delayedObserverCallback(stackPos) {
81
81
  observed = delayedObserverStack[stackPos];
82
- if (observed.timer) return;
82
+ if (observed.timer) clearTimeout(observed.timer);
83
83
 
84
84
  observed.timer = setTimeout(function(){
85
85
  observed.timer = null;
@@ -161,11 +161,8 @@ RecordSelect.notify = function(item) {
161
161
  if (onselect)
162
162
  {
163
163
  try {
164
- // .unescapeHTML() not implemented so far
165
- var label = $.trim(item.find('label').first().html());
166
- if (label.length == 0) {
167
- label = item.html();
168
- }
164
+ var label = $.trim(item.find('label').first().text());
165
+ if (!label) label = item.text();
169
166
  onselect(item.parent().attr('id').substr(2), label, e);
170
167
  } catch(e) {
171
168
  alert(e);
@@ -191,6 +188,9 @@ RecordSelect.Abstract = Class.extend({
191
188
  this.url = url;
192
189
  this.options = options;
193
190
  this.container;
191
+ if (this.options.onchange && typeof this.options.onchange != 'function') {
192
+ this.options.onchange = eval(this.options.onchange);
193
+ }
194
194
 
195
195
  if (RecordSelect.document_loaded) {
196
196
  this.onload();
@@ -284,7 +284,7 @@ RecordSelect.Abstract = Class.extend({
284
284
  if (!this.is_open()) return;
285
285
  if (this.container.has($(event.target)).length > 0) {
286
286
  return;
287
- } else {
287
+ } else if (!this.obj.is(event.target)) {
288
288
  this.close();
289
289
  }
290
290
  },
@@ -438,6 +438,8 @@ RecordSelect.Single = RecordSelect.Abstract.extend({
438
438
  onselect: function(id, value) {
439
439
  this.set(id, value);
440
440
  if (this.options.onchange) this.options.onchange.call(this, id, value);
441
+ var _this = this;
442
+ this.obj.trigger("recordselect:change", [id, value]);
441
443
  this.close();
442
444
  },
443
445
 
@@ -471,7 +473,7 @@ RecordSelect.Autocomplete = RecordSelect.Abstract.extend({
471
473
 
472
474
  close: function() {
473
475
  // if they close the dialog with the text field empty, then delete the id value
474
- if (this.obj.val() == '') this.set('', '');
476
+ if (this.obj.val() == '') this.set('');
475
477
 
476
478
  RecordSelect.Abstract.prototype.close.call(this);
477
479
  },
@@ -479,6 +481,7 @@ RecordSelect.Autocomplete = RecordSelect.Abstract.extend({
479
481
  onselect: function(id, value) {
480
482
  this.set(value);
481
483
  if (this.options.onchange) this.options.onchange.call(this, id, value);
484
+ this.obj.trigger("recordselect:change", [id, value]);
482
485
  this.close();
483
486
  },
484
487
 
@@ -2,7 +2,7 @@ module RecordSelect
2
2
  module Version
3
3
  MAJOR = 3
4
4
  MINOR = 1
5
- PATCH = 6
5
+ PATCH = 7
6
6
 
7
7
  STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: recordselect
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 13
5
5
  prerelease:
6
6
  segments:
7
7
  - 3
8
8
  - 1
9
- - 6
10
- version: 3.1.6
9
+ - 7
10
+ version: 3.1.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - Sergio Cambra
@@ -17,10 +17,10 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2011-11-14 00:00:00 Z
20
+ date: 2011-12-19 00:00:00 Z
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
23
- requirement: &id001 !ruby/object:Gem::Requirement
23
+ version_requirements: &id001 !ruby/object:Gem::Requirement
24
24
  none: false
25
25
  requirements:
26
26
  - - ">="
@@ -29,12 +29,12 @@ dependencies:
29
29
  segments:
30
30
  - 0
31
31
  version: "0"
32
+ requirement: *id001
33
+ prerelease: false
32
34
  type: :development
33
35
  name: shoulda
34
- version_requirements: *id001
35
- prerelease: false
36
36
  - !ruby/object:Gem::Dependency
37
- requirement: &id002 !ruby/object:Gem::Requirement
37
+ version_requirements: &id002 !ruby/object:Gem::Requirement
38
38
  none: false
39
39
  requirements:
40
40
  - - ~>
@@ -45,12 +45,12 @@ dependencies:
45
45
  - 0
46
46
  - 0
47
47
  version: 1.0.0
48
+ requirement: *id002
49
+ prerelease: false
48
50
  type: :development
49
51
  name: bundler
50
- version_requirements: *id002
51
- prerelease: false
52
52
  - !ruby/object:Gem::Dependency
53
- requirement: &id003 !ruby/object:Gem::Requirement
53
+ version_requirements: &id003 !ruby/object:Gem::Requirement
54
54
  none: false
55
55
  requirements:
56
56
  - - ">="
@@ -59,12 +59,12 @@ dependencies:
59
59
  segments:
60
60
  - 0
61
61
  version: "0"
62
+ requirement: *id003
63
+ prerelease: false
62
64
  type: :development
63
65
  name: rcov
64
- version_requirements: *id003
65
- prerelease: false
66
66
  - !ruby/object:Gem::Dependency
67
- requirement: &id004 !ruby/object:Gem::Requirement
67
+ version_requirements: &id004 !ruby/object:Gem::Requirement
68
68
  none: false
69
69
  requirements:
70
70
  - - ~>
@@ -75,10 +75,10 @@ dependencies:
75
75
  - 1
76
76
  - 0
77
77
  version: 3.1.0
78
+ requirement: *id004
79
+ prerelease: false
78
80
  type: :runtime
79
81
  name: rails
80
- version_requirements: *id004
81
- prerelease: false
82
82
  description: RecordSelect is a Rails widget to help you pick one record out of many. I designed it as a more usable and performant alternative to generating a massive dropdown list
83
83
  email: activescaffold@googlegroups.com
84
84
  executables: []