recordselect 3.2.0 → 3.2.1
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.
@@ -102,7 +102,7 @@ if (typeof(jQuery.fn.delayedObserver) === 'undefined') {
|
|
102
102
|
|
103
103
|
jQuery.fn.extend({
|
104
104
|
delayedObserver:function(delay, callback){
|
105
|
-
$this =
|
105
|
+
$this = jQuery(this);
|
106
106
|
|
107
107
|
delayedObserverStack.push({
|
108
108
|
obj: $this, timer: null, delay: delay,
|
@@ -122,10 +122,10 @@ if (typeof(jQuery.fn.delayedObserver) === 'undefined') {
|
|
122
122
|
})();
|
123
123
|
};
|
124
124
|
|
125
|
-
|
125
|
+
jQuery(document).ready(function() {
|
126
126
|
RecordSelect.document_loaded = true;
|
127
|
-
|
128
|
-
var link =
|
127
|
+
jQuery('div.record-select * li.record a').live('ajax:before', function(event) {
|
128
|
+
var link = jQuery(this);
|
129
129
|
if (link) {
|
130
130
|
if (RecordSelect.notify(link) == false) {
|
131
131
|
return false;
|
@@ -139,7 +139,7 @@ $(document).ready(function() {
|
|
139
139
|
|
140
140
|
/**
|
141
141
|
Form.Element.AfterActivity = function(element, callback, delay) {
|
142
|
-
element =
|
142
|
+
element = jQuery(element);
|
143
143
|
if (!delay) delay = 0.25;
|
144
144
|
new Form.Element.Observer(element, delay, function(element, value) {
|
145
145
|
// TODO: display loading indicator
|
@@ -161,7 +161,7 @@ RecordSelect.notify = function(item) {
|
|
161
161
|
if (onselect)
|
162
162
|
{
|
163
163
|
try {
|
164
|
-
var label =
|
164
|
+
var label = jQuery.trim(item.find('label').first().text());
|
165
165
|
if (!label) label = item.text();
|
166
166
|
onselect(item.parent().attr('id').substr(2), label, e);
|
167
167
|
} catch(e) {
|
@@ -173,7 +173,7 @@ RecordSelect.notify = function(item) {
|
|
173
173
|
}
|
174
174
|
|
175
175
|
RecordSelect.render_page = function(record_select_id, page) {
|
176
|
-
|
176
|
+
jQuery('#' + record_select_id + ' ol').first().replaceWith(page);
|
177
177
|
};
|
178
178
|
|
179
179
|
RecordSelect.Abstract = Class.extend({
|
@@ -184,7 +184,7 @@ RecordSelect.Abstract = Class.extend({
|
|
184
184
|
*/
|
185
185
|
init: function(obj, url, options) {
|
186
186
|
if (typeof(obj) == 'string') obj = '#' + obj;
|
187
|
-
this.obj =
|
187
|
+
this.obj = jQuery(obj);
|
188
188
|
this.url = url;
|
189
189
|
this.options = options;
|
190
190
|
this.container;
|
@@ -195,7 +195,7 @@ RecordSelect.Abstract = Class.extend({
|
|
195
195
|
if (RecordSelect.document_loaded) {
|
196
196
|
this.onload();
|
197
197
|
} else {
|
198
|
-
var _this = this;
|
198
|
+
var _this = this; jQuery(document).ready(function() { _this.onload(); })
|
199
199
|
}
|
200
200
|
},
|
201
201
|
|
@@ -219,7 +219,7 @@ RecordSelect.Abstract = Class.extend({
|
|
219
219
|
open: function() {
|
220
220
|
if (this.is_open()) return;
|
221
221
|
var _this = this;
|
222
|
-
|
222
|
+
jQuery.ajax({
|
223
223
|
url: this.url,
|
224
224
|
//type: "POST",
|
225
225
|
//data: options['params'],
|
@@ -227,7 +227,7 @@ RecordSelect.Abstract = Class.extend({
|
|
227
227
|
success: function(data){
|
228
228
|
_this.container.html(data);
|
229
229
|
_this.show();
|
230
|
-
|
230
|
+
jQuery(document.body).mousedown(jQuery.proxy(_this, "onbodyclick"));
|
231
231
|
}
|
232
232
|
});
|
233
233
|
},
|
@@ -239,8 +239,8 @@ RecordSelect.Abstract = Class.extend({
|
|
239
239
|
var offset = this.obj.offset(), top = this.obj.height() + offset.top;
|
240
240
|
this.container.show();
|
241
241
|
this.container.css('left', offset.left);
|
242
|
-
if (top + this.container.height() >
|
243
|
-
this.container.css('bottom',
|
242
|
+
if (top + this.container.height() > jQuery(window).height())
|
243
|
+
this.container.css('bottom', jQuery(window).height() - offset.top);
|
244
244
|
else this.container.css('top', top);
|
245
245
|
|
246
246
|
if (this._use_iframe_mask()) {
|
@@ -274,7 +274,7 @@ RecordSelect.Abstract = Class.extend({
|
|
274
274
|
* returns true/false for whether the recordselect is open
|
275
275
|
*/
|
276
276
|
is_open: function() {
|
277
|
-
return (!(
|
277
|
+
return (!(jQuery.trim(this.container.html()).length == 0))
|
278
278
|
},
|
279
279
|
|
280
280
|
/**
|
@@ -282,7 +282,7 @@ RecordSelect.Abstract = Class.extend({
|
|
282
282
|
*/
|
283
283
|
onbodyclick: function(event) {
|
284
284
|
if (!this.is_open()) return;
|
285
|
-
if (this.container.has(
|
285
|
+
if (this.container.has(jQuery(event.target)).length > 0) {
|
286
286
|
return;
|
287
287
|
} else if (!this.obj.is(event.target)) {
|
288
288
|
this.close();
|
@@ -293,10 +293,10 @@ RecordSelect.Abstract = Class.extend({
|
|
293
293
|
* creates and initializes (and returns) the recordselect container
|
294
294
|
*/
|
295
295
|
create_container: function() {
|
296
|
-
var e =
|
296
|
+
var e = jQuery("<div />", {'class': "record-select-container record-select-handler"});
|
297
297
|
e.css('display', 'none')
|
298
|
-
|
299
|
-
e.get(0).onselect =
|
298
|
+
jQuery(document.body).append(e);
|
299
|
+
e.get(0).onselect = jQuery.proxy(this, "onselect")
|
300
300
|
return e;
|
301
301
|
},
|
302
302
|
|
@@ -310,14 +310,14 @@ RecordSelect.Abstract = Class.extend({
|
|
310
310
|
*/
|
311
311
|
_respond_to_text_field: function(text_field) {
|
312
312
|
// attach the events to start this party
|
313
|
-
text_field.focus(
|
313
|
+
text_field.focus(jQuery.proxy(this, 'open'));
|
314
314
|
|
315
315
|
// the autosearch event - needs to happen slightly late (keyup is later than keypress)
|
316
|
-
text_field.keyup(
|
316
|
+
text_field.keyup(jQuery.proxy(this, 'onkeyup'));
|
317
317
|
|
318
318
|
// keyboard navigation, if available
|
319
319
|
if (this.onkeydown) {
|
320
|
-
text_field.keydown(
|
320
|
+
text_field.keydown(jQuery.proxy(this, "onkeydown"));
|
321
321
|
}
|
322
322
|
},
|
323
323
|
|
@@ -331,7 +331,7 @@ RecordSelect.Abstract = Class.extend({
|
|
331
331
|
/**
|
332
332
|
* Adds keyboard navigation to RecordSelect objects
|
333
333
|
*/
|
334
|
-
|
334
|
+
jQuery.extend(RecordSelect.Abstract.prototype, {
|
335
335
|
current: null,
|
336
336
|
|
337
337
|
/**
|
@@ -341,12 +341,12 @@ $.extend(RecordSelect.Abstract.prototype, {
|
|
341
341
|
var elem;
|
342
342
|
switch (ev.keyCode) {
|
343
343
|
case 38: //Event.KEY_UP
|
344
|
-
if (this.current && this.current.closest('
|
344
|
+
if (this.current && this.current.closest('html').length) elem = this.current.prev();
|
345
345
|
if (!elem) elem = this.container.find('ol li.record').last();
|
346
346
|
this.highlight(elem);
|
347
347
|
break;
|
348
348
|
case 40: //Event.KEY_DOWN
|
349
|
-
if (this.current && this.current.closest('
|
349
|
+
if (this.current && this.current.closest('html').length) elem = this.current.next();
|
350
350
|
if (!elem) elem = this.container.find('ol li.record').first();
|
351
351
|
this.highlight(elem);
|
352
352
|
break;
|
@@ -375,7 +375,7 @@ $.extend(RecordSelect.Abstract.prototype, {
|
|
375
375
|
*/
|
376
376
|
highlight: function(obj) {
|
377
377
|
if (this.current) this.current.removeClass('current');
|
378
|
-
this.current =
|
378
|
+
this.current = jQuery(obj);
|
379
379
|
obj.addClass('current');
|
380
380
|
}
|
381
381
|
});
|
@@ -387,8 +387,8 @@ $.extend(RecordSelect.Abstract.prototype, {
|
|
387
387
|
RecordSelect.Dialog = RecordSelect.Abstract.extend({
|
388
388
|
onload: function() {
|
389
389
|
this.container = this.create_container();
|
390
|
-
this.obj.click(
|
391
|
-
if (this.onkeypress) this.obj.keypress(
|
390
|
+
this.obj.click(jQuery.proxy(this, "toggle"));
|
391
|
+
if (this.onkeypress) this.obj.keypress(jQuery.proxy(this, 'onkeypress'));
|
392
392
|
},
|
393
393
|
|
394
394
|
onselect: function(id, value) {
|
@@ -506,7 +506,7 @@ RecordSelect.Multiple = RecordSelect.Abstract.extend({
|
|
506
506
|
this.container.addClass('record-select-autocomplete');
|
507
507
|
|
508
508
|
// decide where the <li> entries should be placed
|
509
|
-
if (this.options.list) this.list_container =
|
509
|
+
if (this.options.list) this.list_container = jQuery(this.options.list);
|
510
510
|
else this.list_container = this.obj.next('ul');
|
511
511
|
|
512
512
|
// take the input name from the text input, and store it for this.add()
|
@@ -534,7 +534,7 @@ RecordSelect.Multiple = RecordSelect.Abstract.extend({
|
|
534
534
|
if (this.list_container.has('input[value=' + id + ']').length > 0) return;
|
535
535
|
|
536
536
|
var entry = '<li>'
|
537
|
-
+ '<a href="#" onclick="
|
537
|
+
+ '<a href="#" onclick="jQuery(this).parent().remove(); return false;" class="remove">remove</a>'
|
538
538
|
+ '<input type="hidden" name="' + this.input_name + '" value="' + id + '" />'
|
539
539
|
+ '<label>' + label + '</label>'
|
540
540
|
+ '</li>';
|
@@ -316,8 +316,8 @@ RecordSelect.Abstract = Class.extend({
|
|
316
316
|
text_field.keyup($.proxy(this, 'onkeyup'));
|
317
317
|
|
318
318
|
// keyboard navigation, if available
|
319
|
-
if (this.
|
320
|
-
text_field.
|
319
|
+
if (this.onkeydown) {
|
320
|
+
text_field.keydown($.proxy(this, "onkeydown"));
|
321
321
|
}
|
322
322
|
},
|
323
323
|
|
@@ -337,16 +337,16 @@ $.extend(RecordSelect.Abstract.prototype, {
|
|
337
337
|
/**
|
338
338
|
* keyboard navigation - where to intercept the keys is up to the concrete class
|
339
339
|
*/
|
340
|
-
|
340
|
+
onkeydown: function(ev) {
|
341
341
|
var elem;
|
342
342
|
switch (ev.keyCode) {
|
343
343
|
case 38: //Event.KEY_UP
|
344
|
-
if (this.current && this.current.closest('.record-select')) elem = this.current.prev();
|
344
|
+
if (this.current && this.current.closest('.record-select').length && this.current.closest('html').length) elem = this.current.prev();
|
345
345
|
if (!elem) elem = this.container.find('ol li.record').last();
|
346
346
|
this.highlight(elem);
|
347
347
|
break;
|
348
348
|
case 40: //Event.KEY_DOWN
|
349
|
-
if (this.current && this.current.closest('.record-select')) elem = this.current.next();
|
349
|
+
if (this.current && this.current.closest('.record-select').length && this.current.closest('html').length) elem = this.current.next();
|
350
350
|
if (!elem) elem = this.container.find('ol li.record').first();
|
351
351
|
this.highlight(elem);
|
352
352
|
break;
|
@@ -12,8 +12,8 @@
|
|
12
12
|
$(<%= record_select_search_id.to_json.html_safe -%>).down('input.search_submit').click();
|
13
13
|
}, 0.35);
|
14
14
|
<% elsif RecordSelect::Config.js_framework == :jquery %>
|
15
|
-
|
16
|
-
|
15
|
+
jQuery(<%= "##{record_select_search_id}".to_json.html_safe %>).find('input.text-input').delayedObserver(0.35, function() {
|
16
|
+
jQuery(<%= "##{record_select_search_id}".to_json.html_safe %>).trigger("submit");});
|
17
17
|
<% end %>
|
18
18
|
//]]>
|
19
19
|
</script>
|
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:
|
4
|
+
hash: 13
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 3
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 3.2.
|
9
|
+
- 1
|
10
|
+
version: 3.2.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Sergio Cambra
|
@@ -17,7 +17,7 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2012-02-
|
20
|
+
date: 2012-02-24 00:00:00 Z
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
23
23
|
version_requirements: &id001 !ruby/object:Gem::Requirement
|