jquery-rails 3.1.4 → 4.5.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.
- checksums.yaml +5 -5
- data/.travis.yml +32 -0
- data/CHANGELOG.md +87 -0
- data/CONTRIBUTING.md +103 -7
- data/Gemfile +18 -0
- data/{LICENSE → MIT-LICENSE} +2 -2
- data/README.md +34 -39
- data/Rakefile +32 -21
- data/VERSIONS.md +20 -1
- data/jquery-rails.gemspec +7 -5
- data/lib/jquery/assert_select.rb +141 -89
- data/lib/jquery/rails/version.rb +5 -3
- data/lib/jquery/rails.rb +1 -3
- data/test/assert_select_jquery_test.rb +91 -0
- data/test/test_helper.rb +6 -0
- data/vendor/assets/javascripts/jquery.js +2706 -2006
- data/vendor/assets/javascripts/jquery.min.js +5 -5
- data/vendor/assets/javascripts/jquery.min.map +1 -1
- data/vendor/assets/javascripts/jquery2.js +9814 -0
- data/vendor/assets/javascripts/jquery2.min.js +4 -0
- data/vendor/assets/javascripts/jquery2.min.map +1 -0
- data/vendor/assets/javascripts/jquery3.js +10909 -0
- data/vendor/assets/javascripts/jquery3.min.js +2 -0
- data/vendor/assets/javascripts/jquery3.min.map +1 -0
- data/vendor/assets/javascripts/jquery_ujs.js +173 -77
- metadata +42 -23
- data/lib/generators/jquery/install/install_generator.rb +0 -50
- data/lib/jquery/rails/railtie.rb +0 -18
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
/* jshint node: true */
|
2
2
|
|
3
3
|
/**
|
4
4
|
* Unobtrusive scripting adapter for jQuery
|
@@ -10,6 +10,11 @@
|
|
10
10
|
*
|
11
11
|
*/
|
12
12
|
|
13
|
+
(function() {
|
14
|
+
'use strict';
|
15
|
+
|
16
|
+
var jqueryUjsInit = function($, undefined) {
|
17
|
+
|
13
18
|
// Cut down on the number of issues from people inadvertently including jquery_ujs twice
|
14
19
|
// by detecting and raising an error when it happens.
|
15
20
|
if ( $.rails !== undefined ) {
|
@@ -22,19 +27,19 @@
|
|
22
27
|
|
23
28
|
$.rails = rails = {
|
24
29
|
// Link elements bound by jquery-ujs
|
25
|
-
linkClickSelector: 'a[data-confirm], a[data-method], a[data-remote], a[data-disable-with], a[data-disable]',
|
30
|
+
linkClickSelector: 'a[data-confirm], a[data-method], a[data-remote]:not([disabled]), a[data-disable-with], a[data-disable]',
|
26
31
|
|
27
32
|
// Button elements bound by jquery-ujs
|
28
|
-
buttonClickSelector: 'button[data-remote]:not(form button), button[data-confirm]:not(form button)',
|
33
|
+
buttonClickSelector: 'button[data-remote]:not([form]):not(form button), button[data-confirm]:not([form]):not(form button)',
|
29
34
|
|
30
35
|
// Select elements bound by jquery-ujs
|
31
36
|
inputChangeSelector: 'select[data-remote], input[data-remote], textarea[data-remote]',
|
32
37
|
|
33
38
|
// Form elements bound by jquery-ujs
|
34
|
-
formSubmitSelector: 'form',
|
39
|
+
formSubmitSelector: 'form:not([data-turbo=true])',
|
35
40
|
|
36
41
|
// Form input elements bound by jquery-ujs
|
37
|
-
formInputClickSelector: 'form input[type=submit], form input[type=image], form button[type=submit], form button:not([type]), input[type=submit][form], input[type=image][form], button[type=submit][form], button[form]:not([type])',
|
42
|
+
formInputClickSelector: 'form:not([data-turbo=true]) input[type=submit], form:not([data-turbo=true]) input[type=image], form:not([data-turbo=true]) button[type=submit], form:not([data-turbo=true]) button:not([type]), input[type=submit][form], input[type=image][form], button[type=submit][form], button[form]:not([type])',
|
38
43
|
|
39
44
|
// Form input elements disabled during form submission
|
40
45
|
disableSelector: 'input[data-disable-with]:enabled, button[data-disable-with]:enabled, textarea[data-disable-with]:enabled, input[data-disable]:enabled, button[data-disable]:enabled, textarea[data-disable]:enabled',
|
@@ -43,10 +48,10 @@
|
|
43
48
|
enableSelector: 'input[data-disable-with]:disabled, button[data-disable-with]:disabled, textarea[data-disable-with]:disabled, input[data-disable]:disabled, button[data-disable]:disabled, textarea[data-disable]:disabled',
|
44
49
|
|
45
50
|
// Form required input elements
|
46
|
-
requiredInputSelector: 'input[name][required]:not([disabled]),textarea[name][required]:not([disabled])',
|
51
|
+
requiredInputSelector: 'input[name][required]:not([disabled]), textarea[name][required]:not([disabled])',
|
47
52
|
|
48
53
|
// Form file input elements
|
49
|
-
fileInputSelector: 'input[type=file]',
|
54
|
+
fileInputSelector: 'input[name][type=file]:not([disabled])',
|
50
55
|
|
51
56
|
// Link onClick disable selector with possible reenable after remote submission
|
52
57
|
linkDisableSelector: 'a[data-disable-with], a[data-disable]',
|
@@ -54,17 +59,25 @@
|
|
54
59
|
// Button onClick disable selector with possible reenable after remote submission
|
55
60
|
buttonDisableSelector: 'button[data-remote][data-disable-with], button[data-remote][data-disable]',
|
56
61
|
|
62
|
+
// Up-to-date Cross-Site Request Forgery token
|
63
|
+
csrfToken: function() {
|
64
|
+
return $('meta[name=csrf-token]').attr('content');
|
65
|
+
},
|
66
|
+
|
67
|
+
// URL param that must contain the CSRF token
|
68
|
+
csrfParam: function() {
|
69
|
+
return $('meta[name=csrf-param]').attr('content');
|
70
|
+
},
|
71
|
+
|
57
72
|
// Make sure that every Ajax request sends the CSRF token
|
58
73
|
CSRFProtection: function(xhr) {
|
59
|
-
var token =
|
74
|
+
var token = rails.csrfToken();
|
60
75
|
if (token) xhr.setRequestHeader('X-CSRF-Token', token);
|
61
76
|
},
|
62
77
|
|
63
|
-
//
|
78
|
+
// Make sure that all forms have actual up-to-date tokens (cached forms contain old ones)
|
64
79
|
refreshCSRFTokens: function(){
|
65
|
-
|
66
|
-
var csrfParam = $('meta[name=csrf-param]').attr('content');
|
67
|
-
$('form input[name="' + csrfParam + '"]').val(csrfToken);
|
80
|
+
$('form input[name="' + rails.csrfParam() + '"]').val(rails.csrfToken());
|
68
81
|
},
|
69
82
|
|
70
83
|
// Triggers an event on an element and returns false if the event result is false
|
@@ -89,6 +102,11 @@
|
|
89
102
|
return element[0].href;
|
90
103
|
},
|
91
104
|
|
105
|
+
// Checks "data-remote" if true to handle the request through a XHR request.
|
106
|
+
isRemote: function(element) {
|
107
|
+
return element.data('remote') !== undefined && element.data('remote') !== false;
|
108
|
+
},
|
109
|
+
|
92
110
|
// Submits "remote" forms and links with ajax
|
93
111
|
handleRemote: function(element) {
|
94
112
|
var method, url, data, withCredentials, dataType, options;
|
@@ -98,25 +116,27 @@
|
|
98
116
|
dataType = element.data('type') || ($.ajaxSettings && $.ajaxSettings.dataType);
|
99
117
|
|
100
118
|
if (element.is('form')) {
|
101
|
-
method = element.attr('method');
|
102
|
-
url = element.attr('action');
|
103
|
-
data = element.serializeArray();
|
119
|
+
method = element.data('ujs:submit-button-formmethod') || element.attr('method');
|
120
|
+
url = element.data('ujs:submit-button-formaction') || element.attr('action');
|
121
|
+
data = $(element[0]).serializeArray();
|
104
122
|
// memoized value from clicked submit button
|
105
123
|
var button = element.data('ujs:submit-button');
|
106
124
|
if (button) {
|
107
125
|
data.push(button);
|
108
126
|
element.data('ujs:submit-button', null);
|
109
127
|
}
|
128
|
+
element.data('ujs:submit-button-formmethod', null);
|
129
|
+
element.data('ujs:submit-button-formaction', null);
|
110
130
|
} else if (element.is(rails.inputChangeSelector)) {
|
111
131
|
method = element.data('method');
|
112
132
|
url = element.data('url');
|
113
133
|
data = element.serialize();
|
114
|
-
if (element.data('params')) data = data +
|
134
|
+
if (element.data('params')) data = data + '&' + element.data('params');
|
115
135
|
} else if (element.is(rails.buttonClickSelector)) {
|
116
136
|
method = element.data('method') || 'get';
|
117
137
|
url = element.data('url');
|
118
138
|
data = element.serialize();
|
119
|
-
if (element.data('params')) data = data +
|
139
|
+
if (element.data('params')) data = data + '&' + element.data('params');
|
120
140
|
} else {
|
121
141
|
method = element.data('method');
|
122
142
|
url = rails.href(element);
|
@@ -167,9 +187,9 @@
|
|
167
187
|
|
168
188
|
// Determines if the request is a cross domain request.
|
169
189
|
isCrossDomain: function(url) {
|
170
|
-
var originAnchor = document.createElement(
|
190
|
+
var originAnchor = document.createElement('a');
|
171
191
|
originAnchor.href = location.href;
|
172
|
-
var urlAnchor = document.createElement(
|
192
|
+
var urlAnchor = document.createElement('a');
|
173
193
|
|
174
194
|
try {
|
175
195
|
urlAnchor.href = url;
|
@@ -180,10 +200,10 @@
|
|
180
200
|
// *and* host are false, assume it is not a cross-domain request
|
181
201
|
// (should only be the case for IE7 and IE compatibility mode).
|
182
202
|
// Otherwise, evaluate protocol and host of the URL against the origin
|
183
|
-
// protocol and host
|
203
|
+
// protocol and host.
|
184
204
|
return !(((!urlAnchor.protocol || urlAnchor.protocol === ':') && !urlAnchor.host) ||
|
185
|
-
(originAnchor.protocol +
|
186
|
-
urlAnchor.protocol +
|
205
|
+
(originAnchor.protocol + '//' + originAnchor.host ===
|
206
|
+
urlAnchor.protocol + '//' + urlAnchor.host));
|
187
207
|
} catch (e) {
|
188
208
|
// If there is an error parsing the URL, assume it is crossDomain.
|
189
209
|
return true;
|
@@ -196,8 +216,8 @@
|
|
196
216
|
var href = rails.href(link),
|
197
217
|
method = link.data('method'),
|
198
218
|
target = link.attr('target'),
|
199
|
-
csrfToken =
|
200
|
-
csrfParam =
|
219
|
+
csrfToken = rails.csrfToken(),
|
220
|
+
csrfParam = rails.csrfParam(),
|
201
221
|
form = $('<form method="post" action="' + href + '"></form>'),
|
202
222
|
metadataInput = '<input name="_method" value="' + method + '" type="hidden" />';
|
203
223
|
|
@@ -235,12 +255,13 @@
|
|
235
255
|
method = element.is('button') ? 'html' : 'val';
|
236
256
|
replacement = element.data('disable-with');
|
237
257
|
|
238
|
-
element.data('ujs:enable-with', element[method]());
|
239
258
|
if (replacement !== undefined) {
|
259
|
+
element.data('ujs:enable-with', element[method]());
|
240
260
|
element[method](replacement);
|
241
261
|
}
|
242
262
|
|
243
263
|
element.prop('disabled', true);
|
264
|
+
element.data('ujs:disabled', true);
|
244
265
|
},
|
245
266
|
|
246
267
|
/* Re-enables disabled form elements:
|
@@ -255,8 +276,12 @@
|
|
255
276
|
|
256
277
|
enableFormElement: function(element) {
|
257
278
|
var method = element.is('button') ? 'html' : 'val';
|
258
|
-
if (element.data('ujs:enable-with'))
|
279
|
+
if (element.data('ujs:enable-with') !== undefined) {
|
280
|
+
element[method](element.data('ujs:enable-with'));
|
281
|
+
element.removeData('ujs:enable-with'); // clean up cache
|
282
|
+
}
|
259
283
|
element.prop('disabled', false);
|
284
|
+
element.removeData('ujs:disabled');
|
260
285
|
},
|
261
286
|
|
262
287
|
/* For 'data-confirm' attribute:
|
@@ -275,7 +300,11 @@
|
|
275
300
|
if (!message) { return true; }
|
276
301
|
|
277
302
|
if (rails.fire(element, 'confirm')) {
|
278
|
-
|
303
|
+
try {
|
304
|
+
answer = rails.confirm(message);
|
305
|
+
} catch (e) {
|
306
|
+
(console.error || console.log).call(console, e.stack || e);
|
307
|
+
}
|
279
308
|
callback = rails.fire(element, 'confirm:complete', [answer]);
|
280
309
|
}
|
281
310
|
return answer && callback;
|
@@ -283,25 +312,45 @@
|
|
283
312
|
|
284
313
|
// Helper function which checks for blank inputs in a form that match the specified CSS selector
|
285
314
|
blankInputs: function(form, specifiedSelector, nonBlank) {
|
286
|
-
var
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
315
|
+
var foundInputs = $(),
|
316
|
+
input,
|
317
|
+
valueToCheck,
|
318
|
+
radiosForNameWithNoneSelected,
|
319
|
+
radioName,
|
320
|
+
selector = specifiedSelector || 'input,textarea',
|
321
|
+
requiredInputs = form.find(selector),
|
322
|
+
checkedRadioButtonNames = {};
|
323
|
+
|
324
|
+
requiredInputs.each(function() {
|
291
325
|
input = $(this);
|
292
|
-
|
293
|
-
// If nonBlank and valueToCheck are both truthy, or nonBlank and valueToCheck are both falsey
|
294
|
-
if (!valueToCheck === !nonBlank) {
|
326
|
+
if (input.is('input[type=radio]')) {
|
295
327
|
|
296
|
-
// Don't count unchecked required radio if other radio with same name is checked
|
297
|
-
|
298
|
-
|
299
|
-
|
328
|
+
// Don't count unchecked required radio as blank if other radio with same name is checked,
|
329
|
+
// regardless of whether same-name radio input has required attribute or not. The spec
|
330
|
+
// states https://www.w3.org/TR/html5/forms.html#the-required-attribute
|
331
|
+
radioName = input.attr('name');
|
300
332
|
|
301
|
-
|
333
|
+
// Skip if we've already seen the radio with this name.
|
334
|
+
if (!checkedRadioButtonNames[radioName]) {
|
335
|
+
|
336
|
+
// If none checked
|
337
|
+
if (form.find('input[type=radio]:checked[name="' + radioName + '"]').length === 0) {
|
338
|
+
radiosForNameWithNoneSelected = form.find(
|
339
|
+
'input[type=radio][name="' + radioName + '"]');
|
340
|
+
foundInputs = foundInputs.add(radiosForNameWithNoneSelected);
|
341
|
+
}
|
342
|
+
|
343
|
+
// We only need to check each name once.
|
344
|
+
checkedRadioButtonNames[radioName] = radioName;
|
345
|
+
}
|
346
|
+
} else {
|
347
|
+
valueToCheck = input.is('input[type=checkbox],input[type=radio]') ? input.is(':checked') : !!input.val();
|
348
|
+
if (valueToCheck === nonBlank) {
|
349
|
+
foundInputs = foundInputs.add(input);
|
350
|
+
}
|
302
351
|
}
|
303
352
|
});
|
304
|
-
return
|
353
|
+
return foundInputs.length ? foundInputs : false;
|
305
354
|
},
|
306
355
|
|
307
356
|
// Helper function which checks for non-blank inputs in a form that match the specified CSS selector
|
@@ -316,28 +365,30 @@
|
|
316
365
|
return false;
|
317
366
|
},
|
318
367
|
|
319
|
-
//
|
368
|
+
// Replace element's html with the 'data-disable-with' after storing original html
|
320
369
|
// and prevent clicking on it
|
321
370
|
disableElement: function(element) {
|
322
371
|
var replacement = element.data('disable-with');
|
323
372
|
|
324
|
-
element.data('ujs:enable-with', element.html()); // store enabled state
|
325
373
|
if (replacement !== undefined) {
|
374
|
+
element.data('ujs:enable-with', element.html()); // store enabled state
|
326
375
|
element.html(replacement);
|
327
376
|
}
|
328
377
|
|
329
|
-
element.
|
378
|
+
element.on('click.railsDisable', function(e) { // prevent further clicking
|
330
379
|
return rails.stopEverything(e);
|
331
380
|
});
|
381
|
+
element.data('ujs:disabled', true);
|
332
382
|
},
|
333
383
|
|
334
|
-
//
|
384
|
+
// Restore element to its original state which was disabled by 'disableElement' above
|
335
385
|
enableElement: function(element) {
|
336
386
|
if (element.data('ujs:enable-with') !== undefined) {
|
337
387
|
element.html(element.data('ujs:enable-with')); // set to old enabled state
|
338
388
|
element.removeData('ujs:enable-with'); // clean up cache
|
339
389
|
}
|
340
|
-
element.
|
390
|
+
element.off('click.railsDisable'); // enable element
|
391
|
+
element.removeData('ujs:disabled');
|
341
392
|
}
|
342
393
|
};
|
343
394
|
|
@@ -345,88 +396,117 @@
|
|
345
396
|
|
346
397
|
$.ajaxPrefilter(function(options, originalOptions, xhr){ if ( !options.crossDomain ) { rails.CSRFProtection(xhr); }});
|
347
398
|
|
348
|
-
|
399
|
+
// This event works the same as the load event, except that it fires every
|
400
|
+
// time the page is loaded.
|
401
|
+
//
|
402
|
+
// See https://github.com/rails/jquery-ujs/issues/357
|
403
|
+
// See https://developer.mozilla.org/en-US/docs/Using_Firefox_1.5_caching
|
404
|
+
$(window).on('pageshow.rails', function () {
|
405
|
+
$($.rails.enableSelector).each(function () {
|
406
|
+
var element = $(this);
|
407
|
+
|
408
|
+
if (element.data('ujs:disabled')) {
|
409
|
+
$.rails.enableFormElement(element);
|
410
|
+
}
|
411
|
+
});
|
412
|
+
|
413
|
+
$($.rails.linkDisableSelector).each(function () {
|
414
|
+
var element = $(this);
|
415
|
+
|
416
|
+
if (element.data('ujs:disabled')) {
|
417
|
+
$.rails.enableElement(element);
|
418
|
+
}
|
419
|
+
});
|
420
|
+
});
|
421
|
+
|
422
|
+
$document.on('ajax:complete', rails.linkDisableSelector, function() {
|
349
423
|
rails.enableElement($(this));
|
350
424
|
});
|
351
425
|
|
352
|
-
$document.
|
426
|
+
$document.on('ajax:complete', rails.buttonDisableSelector, function() {
|
353
427
|
rails.enableFormElement($(this));
|
354
428
|
});
|
355
429
|
|
356
|
-
$document.
|
430
|
+
$document.on('click.rails', rails.linkClickSelector, function(e) {
|
357
431
|
var link = $(this), method = link.data('method'), data = link.data('params'), metaClick = e.metaKey || e.ctrlKey;
|
358
432
|
if (!rails.allowAction(link)) return rails.stopEverything(e);
|
359
433
|
|
360
434
|
if (!metaClick && link.is(rails.linkDisableSelector)) rails.disableElement(link);
|
361
435
|
|
362
|
-
if (
|
436
|
+
if (rails.isRemote(link)) {
|
363
437
|
if (metaClick && (!method || method === 'GET') && !data) { return true; }
|
364
438
|
|
365
439
|
var handleRemote = rails.handleRemote(link);
|
366
|
-
//
|
440
|
+
// Response from rails.handleRemote() will either be false or a deferred object promise.
|
367
441
|
if (handleRemote === false) {
|
368
442
|
rails.enableElement(link);
|
369
443
|
} else {
|
370
|
-
handleRemote.
|
444
|
+
handleRemote.fail( function() { rails.enableElement(link); } );
|
371
445
|
}
|
372
446
|
return false;
|
373
447
|
|
374
|
-
} else if (
|
448
|
+
} else if (method) {
|
375
449
|
rails.handleMethod(link);
|
376
450
|
return false;
|
377
451
|
}
|
378
452
|
});
|
379
453
|
|
380
|
-
$document.
|
454
|
+
$document.on('click.rails', rails.buttonClickSelector, function(e) {
|
381
455
|
var button = $(this);
|
382
456
|
|
383
|
-
if (!rails.allowAction(button)) return rails.stopEverything(e);
|
457
|
+
if (!rails.allowAction(button) || !rails.isRemote(button)) return rails.stopEverything(e);
|
384
458
|
|
385
459
|
if (button.is(rails.buttonDisableSelector)) rails.disableFormElement(button);
|
386
460
|
|
387
461
|
var handleRemote = rails.handleRemote(button);
|
388
|
-
//
|
462
|
+
// Response from rails.handleRemote() will either be false or a deferred object promise.
|
389
463
|
if (handleRemote === false) {
|
390
464
|
rails.enableFormElement(button);
|
391
465
|
} else {
|
392
|
-
handleRemote.
|
466
|
+
handleRemote.fail( function() { rails.enableFormElement(button); } );
|
393
467
|
}
|
394
468
|
return false;
|
395
469
|
});
|
396
470
|
|
397
|
-
$document.
|
471
|
+
$document.on('change.rails', rails.inputChangeSelector, function(e) {
|
398
472
|
var link = $(this);
|
399
|
-
if (!rails.allowAction(link)) return rails.stopEverything(e);
|
473
|
+
if (!rails.allowAction(link) || !rails.isRemote(link)) return rails.stopEverything(e);
|
400
474
|
|
401
475
|
rails.handleRemote(link);
|
402
476
|
return false;
|
403
477
|
});
|
404
478
|
|
405
|
-
$document.
|
479
|
+
$document.on('submit.rails', rails.formSubmitSelector, function(e) {
|
406
480
|
var form = $(this),
|
407
|
-
remote =
|
481
|
+
remote = rails.isRemote(form),
|
408
482
|
blankRequiredInputs,
|
409
483
|
nonBlankFileInputs;
|
410
484
|
|
411
485
|
if (!rails.allowAction(form)) return rails.stopEverything(e);
|
412
486
|
|
413
|
-
//
|
414
|
-
if (form.attr('novalidate')
|
415
|
-
|
416
|
-
|
417
|
-
|
487
|
+
// Skip other logic when required values are missing or file upload is present
|
488
|
+
if (form.attr('novalidate') === undefined) {
|
489
|
+
if (form.data('ujs:formnovalidate-button') === undefined) {
|
490
|
+
blankRequiredInputs = rails.blankInputs(form, rails.requiredInputSelector, false);
|
491
|
+
if (blankRequiredInputs && rails.fire(form, 'ajax:aborted:required', [blankRequiredInputs])) {
|
492
|
+
return rails.stopEverything(e);
|
493
|
+
}
|
494
|
+
} else {
|
495
|
+
// Clear the formnovalidate in case the next button click is not on a formnovalidate button
|
496
|
+
// Not strictly necessary to do here, since it is also reset on each button click, but just to be certain
|
497
|
+
form.data('ujs:formnovalidate-button', undefined);
|
418
498
|
}
|
419
499
|
}
|
420
500
|
|
421
501
|
if (remote) {
|
422
502
|
nonBlankFileInputs = rails.nonBlankInputs(form, rails.fileInputSelector);
|
423
503
|
if (nonBlankFileInputs) {
|
424
|
-
//
|
504
|
+
// Slight timeout so that the submit button gets properly serialized
|
425
505
|
// (make it easy for event handler to serialize form without disabled values)
|
426
506
|
setTimeout(function(){ rails.disableFormElements(form); }, 13);
|
427
507
|
var aborted = rails.fire(form, 'ajax:aborted:file', [nonBlankFileInputs]);
|
428
508
|
|
429
|
-
//
|
509
|
+
// Re-enable form elements if event bindings return false (canceling normal form submission)
|
430
510
|
if (!aborted) { setTimeout(function(){ rails.enableFormElements(form); }, 13); }
|
431
511
|
|
432
512
|
return aborted;
|
@@ -436,29 +516,38 @@
|
|
436
516
|
return false;
|
437
517
|
|
438
518
|
} else {
|
439
|
-
//
|
519
|
+
// Slight timeout so that the submit button gets properly serialized
|
440
520
|
setTimeout(function(){ rails.disableFormElements(form); }, 13);
|
441
521
|
}
|
442
522
|
});
|
443
523
|
|
444
|
-
$document.
|
524
|
+
$document.on('click.rails', rails.formInputClickSelector, function(event) {
|
445
525
|
var button = $(this);
|
446
526
|
|
447
527
|
if (!rails.allowAction(button)) return rails.stopEverything(event);
|
448
528
|
|
449
|
-
//
|
529
|
+
// Register the pressed submit button
|
450
530
|
var name = button.attr('name'),
|
451
531
|
data = name ? {name:name, value:button.val()} : null;
|
452
532
|
|
453
|
-
button.closest('form')
|
533
|
+
var form = button.closest('form');
|
534
|
+
if (form.length === 0) {
|
535
|
+
form = $('#' + button.attr('form'));
|
536
|
+
}
|
537
|
+
form.data('ujs:submit-button', data);
|
538
|
+
|
539
|
+
// Save attributes from button
|
540
|
+
form.data('ujs:formnovalidate-button', button.attr('formnovalidate'));
|
541
|
+
form.data('ujs:submit-button-formaction', button.attr('formaction'));
|
542
|
+
form.data('ujs:submit-button-formmethod', button.attr('formmethod'));
|
454
543
|
});
|
455
544
|
|
456
|
-
$document.
|
457
|
-
if (this
|
545
|
+
$document.on('ajax:send.rails', rails.formSubmitSelector, function(event) {
|
546
|
+
if (this === event.target) rails.disableFormElements($(this));
|
458
547
|
});
|
459
548
|
|
460
|
-
$document.
|
461
|
-
if (this
|
549
|
+
$document.on('ajax:complete.rails', rails.formSubmitSelector, function(event) {
|
550
|
+
if (this === event.target) rails.enableFormElements($(this));
|
462
551
|
});
|
463
552
|
|
464
553
|
$(function(){
|
@@ -466,4 +555,11 @@
|
|
466
555
|
});
|
467
556
|
}
|
468
557
|
|
469
|
-
}
|
558
|
+
};
|
559
|
+
|
560
|
+
if (window.jQuery) {
|
561
|
+
jqueryUjsInit(jQuery);
|
562
|
+
} else if (typeof exports === 'object' && typeof module === 'object') {
|
563
|
+
module.exports = jqueryUjsInit;
|
564
|
+
}
|
565
|
+
})();
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jquery-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- André Arko
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-11-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -16,20 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
20
|
-
- - "<"
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: '5.0'
|
19
|
+
version: 4.2.0
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
24
|
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
30
|
-
- - "<"
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: '5.0'
|
26
|
+
version: 4.2.0
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
28
|
name: thor
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -50,7 +44,27 @@ dependencies:
|
|
50
44
|
- - "<"
|
51
45
|
- !ruby/object:Gem::Version
|
52
46
|
version: '2.0'
|
53
|
-
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rails-dom-testing
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '1'
|
54
|
+
- - "<"
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '3'
|
57
|
+
type: :runtime
|
58
|
+
prerelease: false
|
59
|
+
version_requirements: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '1'
|
64
|
+
- - "<"
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '3'
|
67
|
+
description: This gem provides jQuery and the jQuery-ujs driver for your Rails 4+
|
54
68
|
application.
|
55
69
|
email:
|
56
70
|
- andre@arko.net
|
@@ -59,30 +73,37 @@ extensions: []
|
|
59
73
|
extra_rdoc_files: []
|
60
74
|
files:
|
61
75
|
- ".gitignore"
|
76
|
+
- ".travis.yml"
|
62
77
|
- CHANGELOG.md
|
63
78
|
- CONTRIBUTING.md
|
64
79
|
- Gemfile
|
65
|
-
- LICENSE
|
80
|
+
- MIT-LICENSE
|
66
81
|
- README.md
|
67
82
|
- Rakefile
|
68
83
|
- VERSIONS.md
|
69
84
|
- jquery-rails.gemspec
|
70
|
-
- lib/generators/jquery/install/install_generator.rb
|
71
85
|
- lib/jquery-rails.rb
|
72
86
|
- lib/jquery/assert_select.rb
|
73
87
|
- lib/jquery/rails.rb
|
74
88
|
- lib/jquery/rails/engine.rb
|
75
|
-
- lib/jquery/rails/railtie.rb
|
76
89
|
- lib/jquery/rails/version.rb
|
90
|
+
- test/assert_select_jquery_test.rb
|
91
|
+
- test/test_helper.rb
|
77
92
|
- vendor/assets/javascripts/jquery.js
|
78
93
|
- vendor/assets/javascripts/jquery.min.js
|
79
94
|
- vendor/assets/javascripts/jquery.min.map
|
95
|
+
- vendor/assets/javascripts/jquery2.js
|
96
|
+
- vendor/assets/javascripts/jquery2.min.js
|
97
|
+
- vendor/assets/javascripts/jquery2.min.map
|
98
|
+
- vendor/assets/javascripts/jquery3.js
|
99
|
+
- vendor/assets/javascripts/jquery3.min.js
|
100
|
+
- vendor/assets/javascripts/jquery3.min.map
|
80
101
|
- vendor/assets/javascripts/jquery_ujs.js
|
81
|
-
homepage:
|
102
|
+
homepage: https://github.com/rails/jquery-rails
|
82
103
|
licenses:
|
83
104
|
- MIT
|
84
105
|
metadata: {}
|
85
|
-
post_install_message:
|
106
|
+
post_install_message:
|
86
107
|
rdoc_options: []
|
87
108
|
require_paths:
|
88
109
|
- lib
|
@@ -90,17 +111,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
90
111
|
requirements:
|
91
112
|
- - ">="
|
92
113
|
- !ruby/object:Gem::Version
|
93
|
-
version:
|
114
|
+
version: 1.9.3
|
94
115
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
116
|
requirements:
|
96
117
|
- - ">="
|
97
118
|
- !ruby/object:Gem::Version
|
98
119
|
version: 1.3.6
|
99
120
|
requirements: []
|
100
|
-
|
101
|
-
|
102
|
-
signing_key:
|
121
|
+
rubygems_version: 3.2.33
|
122
|
+
signing_key:
|
103
123
|
specification_version: 4
|
104
|
-
summary: Use jQuery with Rails
|
124
|
+
summary: Use jQuery with Rails 4+
|
105
125
|
test_files: []
|
106
|
-
has_rdoc:
|