jquery-rails 4.0.3 → 4.6.0
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 +29 -6
- data/Rakefile +16 -4
- data/VERSIONS.md +18 -0
- data/jquery-rails.gemspec +3 -3
- data/lib/jquery/assert_select.rb +70 -15
- data/lib/jquery/rails/version.rb +5 -4
- data/test/assert_select_jquery_test.rb +91 -0
- data/test/test_helper.rb +6 -0
- data/vendor/assets/javascripts/jquery.js +2632 -1970
- data/vendor/assets/javascripts/jquery.min.js +5 -4
- data/vendor/assets/javascripts/jquery.min.map +1 -1
- data/vendor/assets/javascripts/jquery2.js +2570 -1961
- data/vendor/assets/javascripts/jquery2.min.js +4 -4
- data/vendor/assets/javascripts/jquery2.min.map +1 -1
- data/vendor/assets/javascripts/jquery3.js +10704 -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 +174 -78
- metadata +25 -14
@@ -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
|
@@ -86,39 +99,44 @@
|
|
86
99
|
|
87
100
|
// Default way to get an element's href. May be overridden at $.rails.href.
|
88
101
|
href: function(element) {
|
89
|
-
return element.
|
102
|
+
return element[0].href;
|
103
|
+
},
|
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;
|
90
108
|
},
|
91
109
|
|
92
110
|
// Submits "remote" forms and links with ajax
|
93
111
|
handleRemote: function(element) {
|
94
|
-
var method, url, data,
|
112
|
+
var method, url, data, withCredentials, dataType, options;
|
95
113
|
|
96
114
|
if (rails.fire(element, 'ajax:before')) {
|
97
|
-
elCrossDomain = element.data('cross-domain');
|
98
|
-
crossDomain = elCrossDomain === undefined ? null : elCrossDomain;
|
99
115
|
withCredentials = element.data('with-credentials') || null;
|
100
116
|
dataType = element.data('type') || ($.ajaxSettings && $.ajaxSettings.dataType);
|
101
117
|
|
102
118
|
if (element.is('form')) {
|
103
|
-
method = element.attr('method');
|
104
|
-
url = element.attr('action');
|
105
|
-
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();
|
106
122
|
// memoized value from clicked submit button
|
107
123
|
var button = element.data('ujs:submit-button');
|
108
124
|
if (button) {
|
109
125
|
data.push(button);
|
110
126
|
element.data('ujs:submit-button', null);
|
111
127
|
}
|
128
|
+
element.data('ujs:submit-button-formmethod', null);
|
129
|
+
element.data('ujs:submit-button-formaction', null);
|
112
130
|
} else if (element.is(rails.inputChangeSelector)) {
|
113
131
|
method = element.data('method');
|
114
132
|
url = element.data('url');
|
115
133
|
data = element.serialize();
|
116
|
-
if (element.data('params')) data = data +
|
134
|
+
if (element.data('params')) data = data + '&' + element.data('params');
|
117
135
|
} else if (element.is(rails.buttonClickSelector)) {
|
118
136
|
method = element.data('method') || 'get';
|
119
137
|
url = element.data('url');
|
120
138
|
data = element.serialize();
|
121
|
-
if (element.data('params')) data = data +
|
139
|
+
if (element.data('params')) data = data + '&' + element.data('params');
|
122
140
|
} else {
|
123
141
|
method = element.data('method');
|
124
142
|
url = rails.href(element);
|
@@ -147,7 +165,7 @@
|
|
147
165
|
error: function(xhr, status, error) {
|
148
166
|
element.trigger('ajax:error', [xhr, status, error]);
|
149
167
|
},
|
150
|
-
crossDomain:
|
168
|
+
crossDomain: rails.isCrossDomain(url)
|
151
169
|
};
|
152
170
|
|
153
171
|
// There is no withCredentials for IE6-8 when
|
@@ -167,18 +185,43 @@
|
|
167
185
|
}
|
168
186
|
},
|
169
187
|
|
188
|
+
// Determines if the request is a cross domain request.
|
189
|
+
isCrossDomain: function(url) {
|
190
|
+
var originAnchor = document.createElement('a');
|
191
|
+
originAnchor.href = location.href;
|
192
|
+
var urlAnchor = document.createElement('a');
|
193
|
+
|
194
|
+
try {
|
195
|
+
urlAnchor.href = url;
|
196
|
+
// This is a workaround to a IE bug.
|
197
|
+
urlAnchor.href = urlAnchor.href;
|
198
|
+
|
199
|
+
// If URL protocol is false or is a string containing a single colon
|
200
|
+
// *and* host are false, assume it is not a cross-domain request
|
201
|
+
// (should only be the case for IE7 and IE compatibility mode).
|
202
|
+
// Otherwise, evaluate protocol and host of the URL against the origin
|
203
|
+
// protocol and host.
|
204
|
+
return !(((!urlAnchor.protocol || urlAnchor.protocol === ':') && !urlAnchor.host) ||
|
205
|
+
(originAnchor.protocol + '//' + originAnchor.host ===
|
206
|
+
urlAnchor.protocol + '//' + urlAnchor.host));
|
207
|
+
} catch (e) {
|
208
|
+
// If there is an error parsing the URL, assume it is crossDomain.
|
209
|
+
return true;
|
210
|
+
}
|
211
|
+
},
|
212
|
+
|
170
213
|
// Handles "data-method" on links such as:
|
171
214
|
// <a href="/users/5" data-method="delete" rel="nofollow" data-confirm="Are you sure?">Delete</a>
|
172
215
|
handleMethod: function(link) {
|
173
216
|
var href = rails.href(link),
|
174
217
|
method = link.data('method'),
|
175
218
|
target = link.attr('target'),
|
176
|
-
csrfToken =
|
177
|
-
csrfParam =
|
219
|
+
csrfToken = rails.csrfToken(),
|
220
|
+
csrfParam = rails.csrfParam(),
|
178
221
|
form = $('<form method="post" action="' + href + '"></form>'),
|
179
222
|
metadataInput = '<input name="_method" value="' + method + '" type="hidden" />';
|
180
223
|
|
181
|
-
if (csrfParam !== undefined && csrfToken !== undefined) {
|
224
|
+
if (csrfParam !== undefined && csrfToken !== undefined && !rails.isCrossDomain(href)) {
|
182
225
|
metadataInput += '<input name="' + csrfParam + '" value="' + csrfToken + '" type="hidden" />';
|
183
226
|
}
|
184
227
|
|
@@ -212,12 +255,13 @@
|
|
212
255
|
method = element.is('button') ? 'html' : 'val';
|
213
256
|
replacement = element.data('disable-with');
|
214
257
|
|
215
|
-
element.data('ujs:enable-with', element[method]());
|
216
258
|
if (replacement !== undefined) {
|
259
|
+
element.data('ujs:enable-with', element[method]());
|
217
260
|
element[method](replacement);
|
218
261
|
}
|
219
262
|
|
220
263
|
element.prop('disabled', true);
|
264
|
+
element.data('ujs:disabled', true);
|
221
265
|
},
|
222
266
|
|
223
267
|
/* Re-enables disabled form elements:
|
@@ -232,8 +276,12 @@
|
|
232
276
|
|
233
277
|
enableFormElement: function(element) {
|
234
278
|
var method = element.is('button') ? 'html' : 'val';
|
235
|
-
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
|
+
}
|
236
283
|
element.prop('disabled', false);
|
284
|
+
element.removeData('ujs:disabled');
|
237
285
|
},
|
238
286
|
|
239
287
|
/* For 'data-confirm' attribute:
|
@@ -252,7 +300,11 @@
|
|
252
300
|
if (!message) { return true; }
|
253
301
|
|
254
302
|
if (rails.fire(element, 'confirm')) {
|
255
|
-
|
303
|
+
try {
|
304
|
+
answer = rails.confirm(message);
|
305
|
+
} catch (e) {
|
306
|
+
(console.error || console.log).call(console, e.stack || e);
|
307
|
+
}
|
256
308
|
callback = rails.fire(element, 'confirm:complete', [answer]);
|
257
309
|
}
|
258
310
|
return answer && callback;
|
@@ -260,25 +312,45 @@
|
|
260
312
|
|
261
313
|
// Helper function which checks for blank inputs in a form that match the specified CSS selector
|
262
314
|
blankInputs: function(form, specifiedSelector, nonBlank) {
|
263
|
-
var
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
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() {
|
268
325
|
input = $(this);
|
269
|
-
|
270
|
-
// If nonBlank and valueToCheck are both truthy, or nonBlank and valueToCheck are both falsey
|
271
|
-
if (!valueToCheck === !nonBlank) {
|
326
|
+
if (input.is('input[type=radio]')) {
|
272
327
|
|
273
|
-
// Don't count unchecked required radio if other radio with same name is checked
|
274
|
-
|
275
|
-
|
276
|
-
|
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');
|
332
|
+
|
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
|
+
}
|
277
342
|
|
278
|
-
|
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
|
+
}
|
279
351
|
}
|
280
352
|
});
|
281
|
-
return
|
353
|
+
return foundInputs.length ? foundInputs : false;
|
282
354
|
},
|
283
355
|
|
284
356
|
// Helper function which checks for non-blank inputs in a form that match the specified CSS selector
|
@@ -293,28 +365,30 @@
|
|
293
365
|
return false;
|
294
366
|
},
|
295
367
|
|
296
|
-
//
|
368
|
+
// Replace element's html with the 'data-disable-with' after storing original html
|
297
369
|
// and prevent clicking on it
|
298
370
|
disableElement: function(element) {
|
299
371
|
var replacement = element.data('disable-with');
|
300
372
|
|
301
|
-
element.data('ujs:enable-with', element.html()); // store enabled state
|
302
373
|
if (replacement !== undefined) {
|
374
|
+
element.data('ujs:enable-with', element.html()); // store enabled state
|
303
375
|
element.html(replacement);
|
304
376
|
}
|
305
377
|
|
306
|
-
element.
|
378
|
+
element.on('click.railsDisable', function(e) { // prevent further clicking
|
307
379
|
return rails.stopEverything(e);
|
308
380
|
});
|
381
|
+
element.data('ujs:disabled', true);
|
309
382
|
},
|
310
383
|
|
311
|
-
//
|
384
|
+
// Restore element to its original state which was disabled by 'disableElement' above
|
312
385
|
enableElement: function(element) {
|
313
386
|
if (element.data('ujs:enable-with') !== undefined) {
|
314
387
|
element.html(element.data('ujs:enable-with')); // set to old enabled state
|
315
388
|
element.removeData('ujs:enable-with'); // clean up cache
|
316
389
|
}
|
317
|
-
element.
|
390
|
+
element.off('click.railsDisable'); // enable element
|
391
|
+
element.removeData('ujs:disabled');
|
318
392
|
}
|
319
393
|
};
|
320
394
|
|
@@ -327,11 +401,11 @@
|
|
327
401
|
//
|
328
402
|
// See https://github.com/rails/jquery-ujs/issues/357
|
329
403
|
// See https://developer.mozilla.org/en-US/docs/Using_Firefox_1.5_caching
|
330
|
-
$(window).on(
|
404
|
+
$(window).on('pageshow.rails', function () {
|
331
405
|
$($.rails.enableSelector).each(function () {
|
332
406
|
var element = $(this);
|
333
407
|
|
334
|
-
if (element.data(
|
408
|
+
if (element.data('ujs:disabled')) {
|
335
409
|
$.rails.enableFormElement(element);
|
336
410
|
}
|
337
411
|
});
|
@@ -339,31 +413,31 @@
|
|
339
413
|
$($.rails.linkDisableSelector).each(function () {
|
340
414
|
var element = $(this);
|
341
415
|
|
342
|
-
if (element.data(
|
416
|
+
if (element.data('ujs:disabled')) {
|
343
417
|
$.rails.enableElement(element);
|
344
418
|
}
|
345
419
|
});
|
346
420
|
});
|
347
421
|
|
348
|
-
$document.
|
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 {
|
@@ -377,15 +451,15 @@
|
|
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 {
|
@@ -394,39 +468,45 @@
|
|
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.0
|
4
|
+
version: 4.6.0
|
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: 2023-06-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -48,16 +48,22 @@ dependencies:
|
|
48
48
|
name: rails-dom-testing
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
|
-
- - "
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '1'
|
54
|
+
- - "<"
|
52
55
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
56
|
+
version: '3'
|
54
57
|
type: :runtime
|
55
58
|
prerelease: false
|
56
59
|
version_requirements: !ruby/object:Gem::Requirement
|
57
60
|
requirements:
|
58
|
-
- - "
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '1'
|
64
|
+
- - "<"
|
59
65
|
- !ruby/object:Gem::Version
|
60
|
-
version: '
|
66
|
+
version: '3'
|
61
67
|
description: This gem provides jQuery and the jQuery-ujs driver for your Rails 4+
|
62
68
|
application.
|
63
69
|
email:
|
@@ -67,10 +73,11 @@ extensions: []
|
|
67
73
|
extra_rdoc_files: []
|
68
74
|
files:
|
69
75
|
- ".gitignore"
|
76
|
+
- ".travis.yml"
|
70
77
|
- CHANGELOG.md
|
71
78
|
- CONTRIBUTING.md
|
72
79
|
- Gemfile
|
73
|
-
- LICENSE
|
80
|
+
- MIT-LICENSE
|
74
81
|
- README.md
|
75
82
|
- Rakefile
|
76
83
|
- VERSIONS.md
|
@@ -80,18 +87,23 @@ files:
|
|
80
87
|
- lib/jquery/rails.rb
|
81
88
|
- lib/jquery/rails/engine.rb
|
82
89
|
- lib/jquery/rails/version.rb
|
90
|
+
- test/assert_select_jquery_test.rb
|
91
|
+
- test/test_helper.rb
|
83
92
|
- vendor/assets/javascripts/jquery.js
|
84
93
|
- vendor/assets/javascripts/jquery.min.js
|
85
94
|
- vendor/assets/javascripts/jquery.min.map
|
86
95
|
- vendor/assets/javascripts/jquery2.js
|
87
96
|
- vendor/assets/javascripts/jquery2.min.js
|
88
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
|
89
101
|
- vendor/assets/javascripts/jquery_ujs.js
|
90
|
-
homepage:
|
102
|
+
homepage: https://github.com/rails/jquery-rails
|
91
103
|
licenses:
|
92
104
|
- MIT
|
93
105
|
metadata: {}
|
94
|
-
post_install_message:
|
106
|
+
post_install_message:
|
95
107
|
rdoc_options: []
|
96
108
|
require_paths:
|
97
109
|
- lib
|
@@ -99,16 +111,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
99
111
|
requirements:
|
100
112
|
- - ">="
|
101
113
|
- !ruby/object:Gem::Version
|
102
|
-
version:
|
114
|
+
version: 1.9.3
|
103
115
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
116
|
requirements:
|
105
117
|
- - ">="
|
106
118
|
- !ruby/object:Gem::Version
|
107
119
|
version: 1.3.6
|
108
120
|
requirements: []
|
109
|
-
|
110
|
-
|
111
|
-
signing_key:
|
121
|
+
rubygems_version: 3.4.6
|
122
|
+
signing_key:
|
112
123
|
specification_version: 4
|
113
124
|
summary: Use jQuery with Rails 4+
|
114
125
|
test_files: []
|