recordselect 3.2.10 → 3.2.11

Sign up to get free protection for your applications and to get access to all the features.
@@ -213,6 +213,8 @@ RecordSelect.Abstract = Class.extend({
213
213
  if (this.is_open()) return;
214
214
  var _this = this;
215
215
  jQuery.rails.fire(_this.obj, 'rs:before');
216
+ _this.container.html('');
217
+ _this.container.show();
216
218
  jQuery.ajax({
217
219
  url: this.url,
218
220
  //type: "POST",
@@ -220,8 +222,11 @@ RecordSelect.Abstract = Class.extend({
220
222
  //dataType: options.ajax_data_type,
221
223
  success: function(data){
222
224
  _this.container.html(data);
223
- _this.show();
224
- jQuery(document.body).mousedown(jQuery.proxy(_this, "onbodyclick"));
225
+ if (!_this.container.is(':visible')) _this.close();
226
+ else {
227
+ _this.show();
228
+ jQuery(document.body).mousedown(jQuery.proxy(_this, "onbodyclick"));
229
+ }
225
230
  }
226
231
  });
227
232
  },
@@ -233,9 +238,13 @@ RecordSelect.Abstract = Class.extend({
233
238
  var offset = this.obj.offset(), top = this.obj.height() + offset.top;
234
239
  this.container.show();
235
240
  this.container.css('left', offset.left);
236
- if (top + this.container.height() > jQuery(window).height())
241
+ if (top + this.container.height() > jQuery(window).height()) {
237
242
  this.container.css('bottom', jQuery(window).height() - offset.top);
238
- else this.container.css('top', top);
243
+ this.container.css('top', '');
244
+ } else {
245
+ this.container.css('top', top);
246
+ this.container.css('bottom', '');
247
+ }
239
248
 
240
249
  if (this._use_iframe_mask()) {
241
250
  this.container.after('<iframe src="javascript:false;" class="record-select-mask" />');
@@ -355,7 +364,8 @@ jQuery.extend(RecordSelect.Abstract.prototype, {
355
364
  elem = this.container.find('li.pagination.previous');
356
365
  if (elem) elem.find('a').click();
357
366
  break;
358
- case 27, 9: // Event.KEY_ESC, Event.KEY_TAB
367
+ case 27: // Event.KEY_ESC
368
+ case 9: // Event.KEY_TAB
359
369
  this.close();
360
370
  break;
361
371
  default:
@@ -94,14 +94,19 @@ Object.extend(RecordSelect.Abstract.prototype, {
94
94
  open: function() {
95
95
  if (this.is_open()) return;
96
96
 
97
+ this.container.update('');
98
+ this.container.show();
97
99
  new Ajax.Updater(this.container, this.url, {
98
100
  method: 'get',
99
101
  evalScripts: true,
100
102
  asynchronous: true,
101
103
  onComplete: function() {
102
- this.show();
103
104
  // needs to be mousedown so the event doesn't get canceled by other code (see issue #26)
104
- Element.observe(document.body, 'mousedown', this.onbodyclick.bindAsEventListener(this));
105
+ if (!this.container.visible()) this.close();
106
+ else {
107
+ this.show();
108
+ Element.observe(document.body, 'mousedown', this.onbodyclick.bindAsEventListener(this));
109
+ }
105
110
  }.bind(this)
106
111
  });
107
112
  },
@@ -114,9 +119,13 @@ Object.extend(RecordSelect.Abstract.prototype, {
114
119
  top = Element.getHeight(this.obj) + offset[1],
115
120
  window_height = document.viewport.getHeight();
116
121
  this.container.style.left = offset[0] + 'px';
117
- if (top + Element.getHeight(this.container) > window_height)
122
+ if (top + Element.getHeight(this.container) > window_height) {
118
123
  this.container.style.bottom = (window_height - offset[1]) + 'px';
119
- else this.container.style.top = top + 'px';
124
+ this.container.style.top = '';
125
+ } else {
126
+ this.container.style.top = top + 'px';
127
+ this.container.style.bottom = '';
128
+ }
120
129
 
121
130
  if (this._use_iframe_mask()) {
122
131
  this.container.insertAdjacentHTML('afterEnd', '<iframe src="javascript:false;" class="record-select-mask" />');
@@ -236,7 +245,8 @@ Object.extend(RecordSelect.Abstract.prototype, {
236
245
  elem = this.container.down('li.pagination.previous');
237
246
  if (elem) elem.down('a').onclick();
238
247
  break;
239
- case Event.KEY_ESC, Event.KEY_TAB:
248
+ case Event.KEY_ESC:
249
+ case Event.KEY_TAB:
240
250
  this.close();
241
251
  break;
242
252
  default:
@@ -2,7 +2,7 @@ module RecordSelect
2
2
  module Version
3
3
  MAJOR = 3
4
4
  MINOR = 2
5
- PATCH = 10
5
+ PATCH = 11
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: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 3
8
8
  - 2
9
- - 10
10
- version: 3.2.10
9
+ - 11
10
+ version: 3.2.11
11
11
  platform: ruby
12
12
  authors:
13
13
  - Sergio Cambra
@@ -17,11 +17,12 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2013-07-04 00:00:00 Z
20
+ date: 2013-07-11 00:00:00 Z
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
23
+ prerelease: false
23
24
  type: :development
24
- requirement: &id001 !ruby/object:Gem::Requirement
25
+ version_requirements: &id001 !ruby/object:Gem::Requirement
25
26
  none: false
26
27
  requirements:
27
28
  - - ">="
@@ -30,12 +31,12 @@ dependencies:
30
31
  segments:
31
32
  - 0
32
33
  version: "0"
33
- version_requirements: *id001
34
- prerelease: false
34
+ requirement: *id001
35
35
  name: shoulda
36
36
  - !ruby/object:Gem::Dependency
37
+ prerelease: false
37
38
  type: :development
38
- requirement: &id002 !ruby/object:Gem::Requirement
39
+ version_requirements: &id002 !ruby/object:Gem::Requirement
39
40
  none: false
40
41
  requirements:
41
42
  - - ~>
@@ -46,12 +47,12 @@ dependencies:
46
47
  - 0
47
48
  - 0
48
49
  version: 1.0.0
49
- version_requirements: *id002
50
- prerelease: false
50
+ requirement: *id002
51
51
  name: bundler
52
52
  - !ruby/object:Gem::Dependency
53
+ prerelease: false
53
54
  type: :runtime
54
- requirement: &id003 !ruby/object:Gem::Requirement
55
+ version_requirements: &id003 !ruby/object:Gem::Requirement
55
56
  none: false
56
57
  requirements:
57
58
  - - ">="
@@ -62,8 +63,7 @@ dependencies:
62
63
  - 1
63
64
  - 3
64
65
  version: 3.1.3
65
- version_requirements: *id003
66
- prerelease: false
66
+ requirement: *id003
67
67
  name: rails
68
68
  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
69
69
  email: activescaffold@googlegroups.com