actionview 7.2.0.beta2 → 7.2.0.beta3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/lib/action_view/base.rb +1 -1
- data/lib/action_view/gem_version.rb +1 -1
- data/lib/action_view/template.rb +5 -4
- metadata +14 -15
- data/lib/assets/compiled/rails-ujs.js +0 -777
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1fcd9075f9b2406bb90cceebb50d8a9f7f1079aea3923f8a9bf5ae057d339cf1
|
4
|
+
data.tar.gz: 020e9ffc828b8986a76ec9ee5889addf9d1ac8665ccc4b565f0bbfc1f6dc7f3c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5178837985267d3877327374f5f138d4ed9a67e73b6b8ccc00edf325ada4d9e52e9c8193c1a429a7d45f106612c663dc757d37d2583fd60674183c8a261ab8d6
|
7
|
+
data.tar.gz: 78614d56787c24422599c743a5518dab064f5b850d70ff628f7df8d5b41ef84464d6b11218b42046a123a87130f76f51d28043b5a90d107ca9402c920a01e673
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
## Rails 7.2.0.beta3 (July 11, 2024) ##
|
2
|
+
|
3
|
+
* Fix templates with strict locals to also include `local_assigns`.
|
4
|
+
|
5
|
+
Previously templates defining strict locals wouldn't receive the `local_assigns`
|
6
|
+
hash.
|
7
|
+
|
8
|
+
*Jean Boussier*
|
9
|
+
|
1
10
|
## Rails 7.2.0.beta2 (June 04, 2024) ##
|
2
11
|
|
3
12
|
* No changes.
|
data/lib/action_view/base.rb
CHANGED
data/lib/action_view/template.rb
CHANGED
@@ -439,9 +439,9 @@ module ActionView
|
|
439
439
|
method_arguments =
|
440
440
|
if set_strict_locals
|
441
441
|
if set_strict_locals.include?("&")
|
442
|
-
"output_buffer, #{set_strict_locals}"
|
442
|
+
"local_assigns, output_buffer, #{set_strict_locals}"
|
443
443
|
else
|
444
|
-
"output_buffer, #{set_strict_locals}, &_"
|
444
|
+
"local_assigns, output_buffer, #{set_strict_locals}, &_"
|
445
445
|
end
|
446
446
|
else
|
447
447
|
"local_assigns, output_buffer, &_"
|
@@ -500,11 +500,12 @@ module ActionView
|
|
500
500
|
|
501
501
|
return unless strict_locals?
|
502
502
|
|
503
|
-
parameters = mod.instance_method(method_name).parameters
|
503
|
+
parameters = mod.instance_method(method_name).parameters
|
504
|
+
parameters -= [[:req, :local_assigns], [:req, :output_buffer]]
|
505
|
+
|
504
506
|
# Check compiled method parameters to ensure that only kwargs
|
505
507
|
# were provided as strict locals, preventing `locals: (foo, *foo)` etc
|
506
508
|
# and allowing `locals: (foo:)`.
|
507
|
-
|
508
509
|
non_kwarg_parameters = parameters.select do |parameter|
|
509
510
|
![:keyreq, :key, :keyrest, :nokey].include?(parameter[0])
|
510
511
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: actionview
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 7.2.0.
|
4
|
+
version: 7.2.0.beta3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Heinemeier Hansson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-07-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 7.2.0.
|
19
|
+
version: 7.2.0.beta3
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 7.2.0.
|
26
|
+
version: 7.2.0.beta3
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: builder
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,28 +86,28 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - '='
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 7.2.0.
|
89
|
+
version: 7.2.0.beta3
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - '='
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 7.2.0.
|
96
|
+
version: 7.2.0.beta3
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: activemodel
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - '='
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 7.2.0.
|
103
|
+
version: 7.2.0.beta3
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - '='
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 7.2.0.
|
110
|
+
version: 7.2.0.beta3
|
111
111
|
description: Simple, battle-tested conventions and helpers for building web pages.
|
112
112
|
email: david@loudthinking.com
|
113
113
|
executables: []
|
@@ -241,16 +241,15 @@ files:
|
|
241
241
|
- lib/action_view/unbound_template.rb
|
242
242
|
- lib/action_view/version.rb
|
243
243
|
- lib/action_view/view_paths.rb
|
244
|
-
- lib/assets/compiled/rails-ujs.js
|
245
244
|
homepage: https://rubyonrails.org
|
246
245
|
licenses:
|
247
246
|
- MIT
|
248
247
|
metadata:
|
249
248
|
bug_tracker_uri: https://github.com/rails/rails/issues
|
250
|
-
changelog_uri: https://github.com/rails/rails/blob/v7.2.0.
|
251
|
-
documentation_uri: https://api.rubyonrails.org/v7.2.0.
|
249
|
+
changelog_uri: https://github.com/rails/rails/blob/v7.2.0.beta3/actionview/CHANGELOG.md
|
250
|
+
documentation_uri: https://api.rubyonrails.org/v7.2.0.beta3/
|
252
251
|
mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
|
253
|
-
source_code_uri: https://github.com/rails/rails/tree/v7.2.0.
|
252
|
+
source_code_uri: https://github.com/rails/rails/tree/v7.2.0.beta3/actionview
|
254
253
|
rubygems_mfa_required: 'true'
|
255
254
|
post_install_message:
|
256
255
|
rdoc_options: []
|
@@ -263,12 +262,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
263
262
|
version: 3.1.0
|
264
263
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
265
264
|
requirements:
|
266
|
-
- - "
|
265
|
+
- - ">="
|
267
266
|
- !ruby/object:Gem::Version
|
268
|
-
version:
|
267
|
+
version: '0'
|
269
268
|
requirements:
|
270
269
|
- none
|
271
|
-
rubygems_version: 3.
|
270
|
+
rubygems_version: 3.5.11
|
272
271
|
signing_key:
|
273
272
|
specification_version: 4
|
274
273
|
summary: Rendering framework putting the V in MVC (part of Rails).
|
@@ -1,777 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
Unobtrusive JavaScript
|
3
|
-
https://github.com/rails/rails/blob/main/actionview/app/assets/javascripts
|
4
|
-
Released under the MIT license
|
5
|
-
*/;
|
6
|
-
|
7
|
-
(function() {
|
8
|
-
var context = this;
|
9
|
-
|
10
|
-
(function() {
|
11
|
-
(function() {
|
12
|
-
this.Rails = {
|
13
|
-
linkClickSelector: 'a[data-confirm], a[data-method], a[data-remote]:not([disabled]), a[data-disable-with], a[data-disable]',
|
14
|
-
buttonClickSelector: {
|
15
|
-
selector: 'button[data-remote]:not([form]), button[data-confirm]:not([form])',
|
16
|
-
exclude: 'form button'
|
17
|
-
},
|
18
|
-
inputChangeSelector: 'select[data-remote], input[data-remote], textarea[data-remote]',
|
19
|
-
formSubmitSelector: 'form:not([data-turbo=true])',
|
20
|
-
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])',
|
21
|
-
formDisableSelector: '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',
|
22
|
-
formEnableSelector: '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',
|
23
|
-
fileInputSelector: 'input[name][type=file]:not([disabled])',
|
24
|
-
linkDisableSelector: 'a[data-disable-with], a[data-disable]',
|
25
|
-
buttonDisableSelector: 'button[data-remote][data-disable-with], button[data-remote][data-disable]'
|
26
|
-
};
|
27
|
-
|
28
|
-
}).call(this);
|
29
|
-
}).call(context);
|
30
|
-
|
31
|
-
var Rails = context.Rails;
|
32
|
-
|
33
|
-
(function() {
|
34
|
-
(function() {
|
35
|
-
var nonce;
|
36
|
-
|
37
|
-
nonce = null;
|
38
|
-
|
39
|
-
Rails.loadCSPNonce = function() {
|
40
|
-
var ref;
|
41
|
-
return nonce = (ref = document.querySelector("meta[name=csp-nonce]")) != null ? ref.content : void 0;
|
42
|
-
};
|
43
|
-
|
44
|
-
Rails.cspNonce = function() {
|
45
|
-
return nonce != null ? nonce : Rails.loadCSPNonce();
|
46
|
-
};
|
47
|
-
|
48
|
-
}).call(this);
|
49
|
-
(function() {
|
50
|
-
var expando, m;
|
51
|
-
|
52
|
-
m = Element.prototype.matches || Element.prototype.matchesSelector || Element.prototype.mozMatchesSelector || Element.prototype.msMatchesSelector || Element.prototype.oMatchesSelector || Element.prototype.webkitMatchesSelector;
|
53
|
-
|
54
|
-
Rails.matches = function(element, selector) {
|
55
|
-
if (selector.exclude != null) {
|
56
|
-
return m.call(element, selector.selector) && !m.call(element, selector.exclude);
|
57
|
-
} else {
|
58
|
-
return m.call(element, selector);
|
59
|
-
}
|
60
|
-
};
|
61
|
-
|
62
|
-
expando = '_ujsData';
|
63
|
-
|
64
|
-
Rails.getData = function(element, key) {
|
65
|
-
var ref;
|
66
|
-
return (ref = element[expando]) != null ? ref[key] : void 0;
|
67
|
-
};
|
68
|
-
|
69
|
-
Rails.setData = function(element, key, value) {
|
70
|
-
if (element[expando] == null) {
|
71
|
-
element[expando] = {};
|
72
|
-
}
|
73
|
-
return element[expando][key] = value;
|
74
|
-
};
|
75
|
-
|
76
|
-
Rails.isContentEditable = function(element) {
|
77
|
-
var isEditable;
|
78
|
-
isEditable = false;
|
79
|
-
while (true) {
|
80
|
-
if (element.isContentEditable) {
|
81
|
-
isEditable = true;
|
82
|
-
break;
|
83
|
-
}
|
84
|
-
element = element.parentElement;
|
85
|
-
if (!element) {
|
86
|
-
break;
|
87
|
-
}
|
88
|
-
}
|
89
|
-
return isEditable;
|
90
|
-
};
|
91
|
-
|
92
|
-
Rails.$ = function(selector) {
|
93
|
-
return Array.prototype.slice.call(document.querySelectorAll(selector));
|
94
|
-
};
|
95
|
-
|
96
|
-
}).call(this);
|
97
|
-
(function() {
|
98
|
-
var $, csrfParam, csrfToken;
|
99
|
-
|
100
|
-
$ = Rails.$;
|
101
|
-
|
102
|
-
csrfToken = Rails.csrfToken = function() {
|
103
|
-
var meta;
|
104
|
-
meta = document.querySelector('meta[name=csrf-token]');
|
105
|
-
return meta && meta.content;
|
106
|
-
};
|
107
|
-
|
108
|
-
csrfParam = Rails.csrfParam = function() {
|
109
|
-
var meta;
|
110
|
-
meta = document.querySelector('meta[name=csrf-param]');
|
111
|
-
return meta && meta.content;
|
112
|
-
};
|
113
|
-
|
114
|
-
Rails.CSRFProtection = function(xhr) {
|
115
|
-
var token;
|
116
|
-
token = csrfToken();
|
117
|
-
if (token != null) {
|
118
|
-
return xhr.setRequestHeader('X-CSRF-Token', token);
|
119
|
-
}
|
120
|
-
};
|
121
|
-
|
122
|
-
Rails.refreshCSRFTokens = function() {
|
123
|
-
var param, token;
|
124
|
-
token = csrfToken();
|
125
|
-
param = csrfParam();
|
126
|
-
if ((token != null) && (param != null)) {
|
127
|
-
return $('form input[name="' + param + '"]').forEach(function(input) {
|
128
|
-
return input.value = token;
|
129
|
-
});
|
130
|
-
}
|
131
|
-
};
|
132
|
-
|
133
|
-
}).call(this);
|
134
|
-
(function() {
|
135
|
-
var CustomEvent, fire, matches, preventDefault;
|
136
|
-
|
137
|
-
matches = Rails.matches;
|
138
|
-
|
139
|
-
CustomEvent = window.CustomEvent;
|
140
|
-
|
141
|
-
if (typeof CustomEvent !== 'function') {
|
142
|
-
CustomEvent = function(event, params) {
|
143
|
-
var evt;
|
144
|
-
evt = document.createEvent('CustomEvent');
|
145
|
-
evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
|
146
|
-
return evt;
|
147
|
-
};
|
148
|
-
CustomEvent.prototype = window.Event.prototype;
|
149
|
-
preventDefault = CustomEvent.prototype.preventDefault;
|
150
|
-
CustomEvent.prototype.preventDefault = function() {
|
151
|
-
var result;
|
152
|
-
result = preventDefault.call(this);
|
153
|
-
if (this.cancelable && !this.defaultPrevented) {
|
154
|
-
Object.defineProperty(this, 'defaultPrevented', {
|
155
|
-
get: function() {
|
156
|
-
return true;
|
157
|
-
}
|
158
|
-
});
|
159
|
-
}
|
160
|
-
return result;
|
161
|
-
};
|
162
|
-
}
|
163
|
-
|
164
|
-
fire = Rails.fire = function(obj, name, data) {
|
165
|
-
var event;
|
166
|
-
event = new CustomEvent(name, {
|
167
|
-
bubbles: true,
|
168
|
-
cancelable: true,
|
169
|
-
detail: data
|
170
|
-
});
|
171
|
-
obj.dispatchEvent(event);
|
172
|
-
return !event.defaultPrevented;
|
173
|
-
};
|
174
|
-
|
175
|
-
Rails.stopEverything = function(e) {
|
176
|
-
fire(e.target, 'ujs:everythingStopped');
|
177
|
-
e.preventDefault();
|
178
|
-
e.stopPropagation();
|
179
|
-
return e.stopImmediatePropagation();
|
180
|
-
};
|
181
|
-
|
182
|
-
Rails.delegate = function(element, selector, eventType, handler) {
|
183
|
-
return element.addEventListener(eventType, function(e) {
|
184
|
-
var target;
|
185
|
-
target = e.target;
|
186
|
-
while (!(!(target instanceof Element) || matches(target, selector))) {
|
187
|
-
target = target.parentNode;
|
188
|
-
}
|
189
|
-
if (target instanceof Element && handler.call(target, e) === false) {
|
190
|
-
e.preventDefault();
|
191
|
-
return e.stopPropagation();
|
192
|
-
}
|
193
|
-
});
|
194
|
-
};
|
195
|
-
|
196
|
-
}).call(this);
|
197
|
-
(function() {
|
198
|
-
var AcceptHeaders, CSRFProtection, createXHR, cspNonce, fire, prepareOptions, processResponse;
|
199
|
-
|
200
|
-
cspNonce = Rails.cspNonce, CSRFProtection = Rails.CSRFProtection, fire = Rails.fire;
|
201
|
-
|
202
|
-
AcceptHeaders = {
|
203
|
-
'*': '*/*',
|
204
|
-
text: 'text/plain',
|
205
|
-
html: 'text/html',
|
206
|
-
xml: 'application/xml, text/xml',
|
207
|
-
json: 'application/json, text/javascript',
|
208
|
-
script: 'text/javascript, application/javascript, application/ecmascript, application/x-ecmascript'
|
209
|
-
};
|
210
|
-
|
211
|
-
Rails.ajax = function(options) {
|
212
|
-
var xhr;
|
213
|
-
options = prepareOptions(options);
|
214
|
-
xhr = createXHR(options, function() {
|
215
|
-
var ref, response;
|
216
|
-
response = processResponse((ref = xhr.response) != null ? ref : xhr.responseText, xhr.getResponseHeader('Content-Type'));
|
217
|
-
if (Math.floor(xhr.status / 100) === 2) {
|
218
|
-
if (typeof options.success === "function") {
|
219
|
-
options.success(response, xhr.statusText, xhr);
|
220
|
-
}
|
221
|
-
} else {
|
222
|
-
if (typeof options.error === "function") {
|
223
|
-
options.error(response, xhr.statusText, xhr);
|
224
|
-
}
|
225
|
-
}
|
226
|
-
return typeof options.complete === "function" ? options.complete(xhr, xhr.statusText) : void 0;
|
227
|
-
});
|
228
|
-
if ((options.beforeSend != null) && !options.beforeSend(xhr, options)) {
|
229
|
-
return false;
|
230
|
-
}
|
231
|
-
if (xhr.readyState === XMLHttpRequest.OPENED) {
|
232
|
-
return xhr.send(options.data);
|
233
|
-
}
|
234
|
-
};
|
235
|
-
|
236
|
-
prepareOptions = function(options) {
|
237
|
-
options.url = options.url || location.href;
|
238
|
-
options.type = options.type.toUpperCase();
|
239
|
-
if (options.type === 'GET' && options.data) {
|
240
|
-
if (options.url.indexOf('?') < 0) {
|
241
|
-
options.url += '?' + options.data;
|
242
|
-
} else {
|
243
|
-
options.url += '&' + options.data;
|
244
|
-
}
|
245
|
-
}
|
246
|
-
if (AcceptHeaders[options.dataType] == null) {
|
247
|
-
options.dataType = '*';
|
248
|
-
}
|
249
|
-
options.accept = AcceptHeaders[options.dataType];
|
250
|
-
if (options.dataType !== '*') {
|
251
|
-
options.accept += ', */*; q=0.01';
|
252
|
-
}
|
253
|
-
return options;
|
254
|
-
};
|
255
|
-
|
256
|
-
createXHR = function(options, done) {
|
257
|
-
var xhr;
|
258
|
-
xhr = new XMLHttpRequest();
|
259
|
-
xhr.open(options.type, options.url, true);
|
260
|
-
xhr.setRequestHeader('Accept', options.accept);
|
261
|
-
if (typeof options.data === 'string') {
|
262
|
-
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
|
263
|
-
}
|
264
|
-
if (!options.crossDomain) {
|
265
|
-
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
|
266
|
-
CSRFProtection(xhr);
|
267
|
-
}
|
268
|
-
xhr.withCredentials = !!options.withCredentials;
|
269
|
-
xhr.onreadystatechange = function() {
|
270
|
-
if (xhr.readyState === XMLHttpRequest.DONE) {
|
271
|
-
return done(xhr);
|
272
|
-
}
|
273
|
-
};
|
274
|
-
return xhr;
|
275
|
-
};
|
276
|
-
|
277
|
-
processResponse = function(response, type) {
|
278
|
-
var parser, script;
|
279
|
-
if (typeof response === 'string' && typeof type === 'string') {
|
280
|
-
if (type.match(/\bjson\b/)) {
|
281
|
-
try {
|
282
|
-
response = JSON.parse(response);
|
283
|
-
} catch (error) {}
|
284
|
-
} else if (type.match(/\b(?:java|ecma)script\b/)) {
|
285
|
-
script = document.createElement('script');
|
286
|
-
script.setAttribute('nonce', cspNonce());
|
287
|
-
script.text = response;
|
288
|
-
document.head.appendChild(script).parentNode.removeChild(script);
|
289
|
-
} else if (type.match(/\b(xml|html|svg)\b/)) {
|
290
|
-
parser = new DOMParser();
|
291
|
-
type = type.replace(/;.+/, '');
|
292
|
-
try {
|
293
|
-
response = parser.parseFromString(response, type);
|
294
|
-
} catch (error) {}
|
295
|
-
}
|
296
|
-
}
|
297
|
-
return response;
|
298
|
-
};
|
299
|
-
|
300
|
-
Rails.href = function(element) {
|
301
|
-
return element.href;
|
302
|
-
};
|
303
|
-
|
304
|
-
Rails.isCrossDomain = function(url) {
|
305
|
-
var e, originAnchor, urlAnchor;
|
306
|
-
originAnchor = document.createElement('a');
|
307
|
-
originAnchor.href = location.href;
|
308
|
-
urlAnchor = document.createElement('a');
|
309
|
-
try {
|
310
|
-
urlAnchor.href = url;
|
311
|
-
return !(((!urlAnchor.protocol || urlAnchor.protocol === ':') && !urlAnchor.host) || (originAnchor.protocol + '//' + originAnchor.host === urlAnchor.protocol + '//' + urlAnchor.host));
|
312
|
-
} catch (error) {
|
313
|
-
e = error;
|
314
|
-
return true;
|
315
|
-
}
|
316
|
-
};
|
317
|
-
|
318
|
-
}).call(this);
|
319
|
-
(function() {
|
320
|
-
var matches, toArray;
|
321
|
-
|
322
|
-
matches = Rails.matches;
|
323
|
-
|
324
|
-
toArray = function(e) {
|
325
|
-
return Array.prototype.slice.call(e);
|
326
|
-
};
|
327
|
-
|
328
|
-
Rails.serializeElement = function(element, additionalParam) {
|
329
|
-
var inputs, params;
|
330
|
-
inputs = [element];
|
331
|
-
if (matches(element, 'form')) {
|
332
|
-
inputs = toArray(element.elements);
|
333
|
-
}
|
334
|
-
params = [];
|
335
|
-
inputs.forEach(function(input) {
|
336
|
-
if (!input.name || input.disabled) {
|
337
|
-
return;
|
338
|
-
}
|
339
|
-
if (matches(input, 'fieldset[disabled] *')) {
|
340
|
-
return;
|
341
|
-
}
|
342
|
-
if (matches(input, 'select')) {
|
343
|
-
return toArray(input.options).forEach(function(option) {
|
344
|
-
if (option.selected) {
|
345
|
-
return params.push({
|
346
|
-
name: input.name,
|
347
|
-
value: option.value
|
348
|
-
});
|
349
|
-
}
|
350
|
-
});
|
351
|
-
} else if (input.checked || ['radio', 'checkbox', 'submit'].indexOf(input.type) === -1) {
|
352
|
-
return params.push({
|
353
|
-
name: input.name,
|
354
|
-
value: input.value
|
355
|
-
});
|
356
|
-
}
|
357
|
-
});
|
358
|
-
if (additionalParam) {
|
359
|
-
params.push(additionalParam);
|
360
|
-
}
|
361
|
-
return params.map(function(param) {
|
362
|
-
if (param.name != null) {
|
363
|
-
return (encodeURIComponent(param.name)) + "=" + (encodeURIComponent(param.value));
|
364
|
-
} else {
|
365
|
-
return param;
|
366
|
-
}
|
367
|
-
}).join('&');
|
368
|
-
};
|
369
|
-
|
370
|
-
Rails.formElements = function(form, selector) {
|
371
|
-
if (matches(form, 'form')) {
|
372
|
-
return toArray(form.elements).filter(function(el) {
|
373
|
-
return matches(el, selector);
|
374
|
-
});
|
375
|
-
} else {
|
376
|
-
return toArray(form.querySelectorAll(selector));
|
377
|
-
}
|
378
|
-
};
|
379
|
-
|
380
|
-
}).call(this);
|
381
|
-
(function() {
|
382
|
-
var allowAction, fire, stopEverything;
|
383
|
-
|
384
|
-
fire = Rails.fire, stopEverything = Rails.stopEverything;
|
385
|
-
|
386
|
-
Rails.handleConfirm = function(e) {
|
387
|
-
if (!allowAction(this)) {
|
388
|
-
return stopEverything(e);
|
389
|
-
}
|
390
|
-
};
|
391
|
-
|
392
|
-
Rails.confirm = function(message, element) {
|
393
|
-
return confirm(message);
|
394
|
-
};
|
395
|
-
|
396
|
-
allowAction = function(element) {
|
397
|
-
var answer, callback, message;
|
398
|
-
message = element.getAttribute('data-confirm');
|
399
|
-
if (!message) {
|
400
|
-
return true;
|
401
|
-
}
|
402
|
-
answer = false;
|
403
|
-
if (fire(element, 'confirm')) {
|
404
|
-
try {
|
405
|
-
answer = Rails.confirm(message, element);
|
406
|
-
} catch (error) {}
|
407
|
-
callback = fire(element, 'confirm:complete', [answer]);
|
408
|
-
}
|
409
|
-
return answer && callback;
|
410
|
-
};
|
411
|
-
|
412
|
-
}).call(this);
|
413
|
-
(function() {
|
414
|
-
var disableFormElement, disableFormElements, disableLinkElement, enableFormElement, enableFormElements, enableLinkElement, formElements, getData, isContentEditable, isXhrRedirect, matches, setData, stopEverything;
|
415
|
-
|
416
|
-
matches = Rails.matches, getData = Rails.getData, setData = Rails.setData, stopEverything = Rails.stopEverything, formElements = Rails.formElements, isContentEditable = Rails.isContentEditable;
|
417
|
-
|
418
|
-
Rails.handleDisabledElement = function(e) {
|
419
|
-
var element;
|
420
|
-
element = this;
|
421
|
-
if (element.disabled) {
|
422
|
-
return stopEverything(e);
|
423
|
-
}
|
424
|
-
};
|
425
|
-
|
426
|
-
Rails.enableElement = function(e) {
|
427
|
-
var element;
|
428
|
-
if (e instanceof Event) {
|
429
|
-
if (isXhrRedirect(e)) {
|
430
|
-
return;
|
431
|
-
}
|
432
|
-
element = e.target;
|
433
|
-
} else {
|
434
|
-
element = e;
|
435
|
-
}
|
436
|
-
if (isContentEditable(element)) {
|
437
|
-
return;
|
438
|
-
}
|
439
|
-
if (matches(element, Rails.linkDisableSelector)) {
|
440
|
-
return enableLinkElement(element);
|
441
|
-
} else if (matches(element, Rails.buttonDisableSelector) || matches(element, Rails.formEnableSelector)) {
|
442
|
-
return enableFormElement(element);
|
443
|
-
} else if (matches(element, Rails.formSubmitSelector)) {
|
444
|
-
return enableFormElements(element);
|
445
|
-
}
|
446
|
-
};
|
447
|
-
|
448
|
-
Rails.disableElement = function(e) {
|
449
|
-
var element;
|
450
|
-
element = e instanceof Event ? e.target : e;
|
451
|
-
if (isContentEditable(element)) {
|
452
|
-
return;
|
453
|
-
}
|
454
|
-
if (matches(element, Rails.linkDisableSelector)) {
|
455
|
-
return disableLinkElement(element);
|
456
|
-
} else if (matches(element, Rails.buttonDisableSelector) || matches(element, Rails.formDisableSelector)) {
|
457
|
-
return disableFormElement(element);
|
458
|
-
} else if (matches(element, Rails.formSubmitSelector)) {
|
459
|
-
return disableFormElements(element);
|
460
|
-
}
|
461
|
-
};
|
462
|
-
|
463
|
-
disableLinkElement = function(element) {
|
464
|
-
var replacement;
|
465
|
-
if (getData(element, 'ujs:disabled')) {
|
466
|
-
return;
|
467
|
-
}
|
468
|
-
replacement = element.getAttribute('data-disable-with');
|
469
|
-
if (replacement != null) {
|
470
|
-
setData(element, 'ujs:enable-with', element.innerHTML);
|
471
|
-
element.innerHTML = replacement;
|
472
|
-
}
|
473
|
-
element.addEventListener('click', stopEverything);
|
474
|
-
return setData(element, 'ujs:disabled', true);
|
475
|
-
};
|
476
|
-
|
477
|
-
enableLinkElement = function(element) {
|
478
|
-
var originalText;
|
479
|
-
originalText = getData(element, 'ujs:enable-with');
|
480
|
-
if (originalText != null) {
|
481
|
-
element.innerHTML = originalText;
|
482
|
-
setData(element, 'ujs:enable-with', null);
|
483
|
-
}
|
484
|
-
element.removeEventListener('click', stopEverything);
|
485
|
-
return setData(element, 'ujs:disabled', null);
|
486
|
-
};
|
487
|
-
|
488
|
-
disableFormElements = function(form) {
|
489
|
-
return formElements(form, Rails.formDisableSelector).forEach(disableFormElement);
|
490
|
-
};
|
491
|
-
|
492
|
-
disableFormElement = function(element) {
|
493
|
-
var replacement;
|
494
|
-
if (getData(element, 'ujs:disabled')) {
|
495
|
-
return;
|
496
|
-
}
|
497
|
-
replacement = element.getAttribute('data-disable-with');
|
498
|
-
if (replacement != null) {
|
499
|
-
if (matches(element, 'button')) {
|
500
|
-
setData(element, 'ujs:enable-with', element.innerHTML);
|
501
|
-
element.innerHTML = replacement;
|
502
|
-
} else {
|
503
|
-
setData(element, 'ujs:enable-with', element.value);
|
504
|
-
element.value = replacement;
|
505
|
-
}
|
506
|
-
}
|
507
|
-
element.disabled = true;
|
508
|
-
return setData(element, 'ujs:disabled', true);
|
509
|
-
};
|
510
|
-
|
511
|
-
enableFormElements = function(form) {
|
512
|
-
return formElements(form, Rails.formEnableSelector).forEach(enableFormElement);
|
513
|
-
};
|
514
|
-
|
515
|
-
enableFormElement = function(element) {
|
516
|
-
var originalText;
|
517
|
-
originalText = getData(element, 'ujs:enable-with');
|
518
|
-
if (originalText != null) {
|
519
|
-
if (matches(element, 'button')) {
|
520
|
-
element.innerHTML = originalText;
|
521
|
-
} else {
|
522
|
-
element.value = originalText;
|
523
|
-
}
|
524
|
-
setData(element, 'ujs:enable-with', null);
|
525
|
-
}
|
526
|
-
element.disabled = false;
|
527
|
-
return setData(element, 'ujs:disabled', null);
|
528
|
-
};
|
529
|
-
|
530
|
-
isXhrRedirect = function(event) {
|
531
|
-
var ref, xhr;
|
532
|
-
xhr = (ref = event.detail) != null ? ref[0] : void 0;
|
533
|
-
return (xhr != null ? xhr.getResponseHeader("X-Xhr-Redirect") : void 0) != null;
|
534
|
-
};
|
535
|
-
|
536
|
-
}).call(this);
|
537
|
-
(function() {
|
538
|
-
var isContentEditable, stopEverything;
|
539
|
-
|
540
|
-
stopEverything = Rails.stopEverything;
|
541
|
-
|
542
|
-
isContentEditable = Rails.isContentEditable;
|
543
|
-
|
544
|
-
Rails.handleMethod = function(e) {
|
545
|
-
var csrfParam, csrfToken, form, formContent, href, link, method;
|
546
|
-
link = this;
|
547
|
-
method = link.getAttribute('data-method');
|
548
|
-
if (!method) {
|
549
|
-
return;
|
550
|
-
}
|
551
|
-
if (isContentEditable(this)) {
|
552
|
-
return;
|
553
|
-
}
|
554
|
-
href = Rails.href(link);
|
555
|
-
csrfToken = Rails.csrfToken();
|
556
|
-
csrfParam = Rails.csrfParam();
|
557
|
-
form = document.createElement('form');
|
558
|
-
formContent = "<input name='_method' value='" + method + "' type='hidden' />";
|
559
|
-
if ((csrfParam != null) && (csrfToken != null) && !Rails.isCrossDomain(href)) {
|
560
|
-
formContent += "<input name='" + csrfParam + "' value='" + csrfToken + "' type='hidden' />";
|
561
|
-
}
|
562
|
-
formContent += '<input type="submit" />';
|
563
|
-
form.method = 'post';
|
564
|
-
form.action = href;
|
565
|
-
form.target = link.target;
|
566
|
-
form.innerHTML = formContent;
|
567
|
-
form.style.display = 'none';
|
568
|
-
document.body.appendChild(form);
|
569
|
-
form.querySelector('[type="submit"]').click();
|
570
|
-
return stopEverything(e);
|
571
|
-
};
|
572
|
-
|
573
|
-
}).call(this);
|
574
|
-
(function() {
|
575
|
-
var ajax, fire, getData, isContentEditable, isCrossDomain, isRemote, matches, serializeElement, setData, stopEverything,
|
576
|
-
slice = [].slice;
|
577
|
-
|
578
|
-
matches = Rails.matches, getData = Rails.getData, setData = Rails.setData, fire = Rails.fire, stopEverything = Rails.stopEverything, ajax = Rails.ajax, isCrossDomain = Rails.isCrossDomain, serializeElement = Rails.serializeElement, isContentEditable = Rails.isContentEditable;
|
579
|
-
|
580
|
-
isRemote = function(element) {
|
581
|
-
var value;
|
582
|
-
value = element.getAttribute('data-remote');
|
583
|
-
return (value != null) && value !== 'false';
|
584
|
-
};
|
585
|
-
|
586
|
-
Rails.handleRemote = function(e) {
|
587
|
-
var button, data, dataType, element, method, url, withCredentials;
|
588
|
-
element = this;
|
589
|
-
if (!isRemote(element)) {
|
590
|
-
return true;
|
591
|
-
}
|
592
|
-
if (!fire(element, 'ajax:before')) {
|
593
|
-
fire(element, 'ajax:stopped');
|
594
|
-
return false;
|
595
|
-
}
|
596
|
-
if (isContentEditable(element)) {
|
597
|
-
fire(element, 'ajax:stopped');
|
598
|
-
return false;
|
599
|
-
}
|
600
|
-
withCredentials = element.getAttribute('data-with-credentials');
|
601
|
-
dataType = element.getAttribute('data-type') || 'script';
|
602
|
-
if (matches(element, Rails.formSubmitSelector)) {
|
603
|
-
button = getData(element, 'ujs:submit-button');
|
604
|
-
method = getData(element, 'ujs:submit-button-formmethod') || element.method;
|
605
|
-
url = getData(element, 'ujs:submit-button-formaction') || element.getAttribute('action') || location.href;
|
606
|
-
if (method.toUpperCase() === 'GET') {
|
607
|
-
url = url.replace(/\?.*$/, '');
|
608
|
-
}
|
609
|
-
if (element.enctype === 'multipart/form-data') {
|
610
|
-
data = new FormData(element);
|
611
|
-
if (button != null) {
|
612
|
-
data.append(button.name, button.value);
|
613
|
-
}
|
614
|
-
} else {
|
615
|
-
data = serializeElement(element, button);
|
616
|
-
}
|
617
|
-
setData(element, 'ujs:submit-button', null);
|
618
|
-
setData(element, 'ujs:submit-button-formmethod', null);
|
619
|
-
setData(element, 'ujs:submit-button-formaction', null);
|
620
|
-
} else if (matches(element, Rails.buttonClickSelector) || matches(element, Rails.inputChangeSelector)) {
|
621
|
-
method = element.getAttribute('data-method');
|
622
|
-
url = element.getAttribute('data-url');
|
623
|
-
data = serializeElement(element, element.getAttribute('data-params'));
|
624
|
-
} else {
|
625
|
-
method = element.getAttribute('data-method');
|
626
|
-
url = Rails.href(element);
|
627
|
-
data = element.getAttribute('data-params');
|
628
|
-
}
|
629
|
-
ajax({
|
630
|
-
type: method || 'GET',
|
631
|
-
url: url,
|
632
|
-
data: data,
|
633
|
-
dataType: dataType,
|
634
|
-
beforeSend: function(xhr, options) {
|
635
|
-
if (fire(element, 'ajax:beforeSend', [xhr, options])) {
|
636
|
-
return fire(element, 'ajax:send', [xhr]);
|
637
|
-
} else {
|
638
|
-
fire(element, 'ajax:stopped');
|
639
|
-
return false;
|
640
|
-
}
|
641
|
-
},
|
642
|
-
success: function() {
|
643
|
-
var args;
|
644
|
-
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
645
|
-
return fire(element, 'ajax:success', args);
|
646
|
-
},
|
647
|
-
error: function() {
|
648
|
-
var args;
|
649
|
-
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
650
|
-
return fire(element, 'ajax:error', args);
|
651
|
-
},
|
652
|
-
complete: function() {
|
653
|
-
var args;
|
654
|
-
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
655
|
-
return fire(element, 'ajax:complete', args);
|
656
|
-
},
|
657
|
-
crossDomain: isCrossDomain(url),
|
658
|
-
withCredentials: (withCredentials != null) && withCredentials !== 'false'
|
659
|
-
});
|
660
|
-
return stopEverything(e);
|
661
|
-
};
|
662
|
-
|
663
|
-
Rails.formSubmitButtonClick = function(e) {
|
664
|
-
var button, form;
|
665
|
-
button = this;
|
666
|
-
form = button.form;
|
667
|
-
if (!form) {
|
668
|
-
return;
|
669
|
-
}
|
670
|
-
if (button.name) {
|
671
|
-
setData(form, 'ujs:submit-button', {
|
672
|
-
name: button.name,
|
673
|
-
value: button.value
|
674
|
-
});
|
675
|
-
}
|
676
|
-
setData(form, 'ujs:formnovalidate-button', button.formNoValidate);
|
677
|
-
setData(form, 'ujs:submit-button-formaction', button.getAttribute('formaction'));
|
678
|
-
return setData(form, 'ujs:submit-button-formmethod', button.getAttribute('formmethod'));
|
679
|
-
};
|
680
|
-
|
681
|
-
Rails.preventInsignificantClick = function(e) {
|
682
|
-
var data, insignificantMetaClick, link, metaClick, method, nonPrimaryMouseClick;
|
683
|
-
link = this;
|
684
|
-
method = (link.getAttribute('data-method') || 'GET').toUpperCase();
|
685
|
-
data = link.getAttribute('data-params');
|
686
|
-
metaClick = e.metaKey || e.ctrlKey;
|
687
|
-
insignificantMetaClick = metaClick && method === 'GET' && !data;
|
688
|
-
nonPrimaryMouseClick = (e.button != null) && e.button !== 0;
|
689
|
-
if (nonPrimaryMouseClick || insignificantMetaClick) {
|
690
|
-
return e.stopImmediatePropagation();
|
691
|
-
}
|
692
|
-
};
|
693
|
-
|
694
|
-
}).call(this);
|
695
|
-
(function() {
|
696
|
-
var $, CSRFProtection, delegate, disableElement, enableElement, fire, formSubmitButtonClick, getData, handleConfirm, handleDisabledElement, handleMethod, handleRemote, loadCSPNonce, preventInsignificantClick, refreshCSRFTokens;
|
697
|
-
|
698
|
-
fire = Rails.fire, delegate = Rails.delegate, getData = Rails.getData, $ = Rails.$, refreshCSRFTokens = Rails.refreshCSRFTokens, CSRFProtection = Rails.CSRFProtection, loadCSPNonce = Rails.loadCSPNonce, enableElement = Rails.enableElement, disableElement = Rails.disableElement, handleDisabledElement = Rails.handleDisabledElement, handleConfirm = Rails.handleConfirm, preventInsignificantClick = Rails.preventInsignificantClick, handleRemote = Rails.handleRemote, formSubmitButtonClick = Rails.formSubmitButtonClick, handleMethod = Rails.handleMethod;
|
699
|
-
|
700
|
-
if ((typeof jQuery !== "undefined" && jQuery !== null) && (jQuery.ajax != null)) {
|
701
|
-
if (jQuery.rails) {
|
702
|
-
throw new Error('If you load both jquery_ujs and rails-ujs, use rails-ujs only.');
|
703
|
-
}
|
704
|
-
jQuery.rails = Rails;
|
705
|
-
jQuery.ajaxPrefilter(function(options, originalOptions, xhr) {
|
706
|
-
if (!options.crossDomain) {
|
707
|
-
return CSRFProtection(xhr);
|
708
|
-
}
|
709
|
-
});
|
710
|
-
}
|
711
|
-
|
712
|
-
Rails.start = function() {
|
713
|
-
if (window._rails_loaded) {
|
714
|
-
throw new Error('rails-ujs has already been loaded!');
|
715
|
-
}
|
716
|
-
window.addEventListener('pageshow', function() {
|
717
|
-
$(Rails.formEnableSelector).forEach(function(el) {
|
718
|
-
if (getData(el, 'ujs:disabled')) {
|
719
|
-
return enableElement(el);
|
720
|
-
}
|
721
|
-
});
|
722
|
-
return $(Rails.linkDisableSelector).forEach(function(el) {
|
723
|
-
if (getData(el, 'ujs:disabled')) {
|
724
|
-
return enableElement(el);
|
725
|
-
}
|
726
|
-
});
|
727
|
-
});
|
728
|
-
delegate(document, Rails.linkDisableSelector, 'ajax:complete', enableElement);
|
729
|
-
delegate(document, Rails.linkDisableSelector, 'ajax:stopped', enableElement);
|
730
|
-
delegate(document, Rails.buttonDisableSelector, 'ajax:complete', enableElement);
|
731
|
-
delegate(document, Rails.buttonDisableSelector, 'ajax:stopped', enableElement);
|
732
|
-
delegate(document, Rails.linkClickSelector, 'click', preventInsignificantClick);
|
733
|
-
delegate(document, Rails.linkClickSelector, 'click', handleDisabledElement);
|
734
|
-
delegate(document, Rails.linkClickSelector, 'click', handleConfirm);
|
735
|
-
delegate(document, Rails.linkClickSelector, 'click', disableElement);
|
736
|
-
delegate(document, Rails.linkClickSelector, 'click', handleRemote);
|
737
|
-
delegate(document, Rails.linkClickSelector, 'click', handleMethod);
|
738
|
-
delegate(document, Rails.buttonClickSelector, 'click', preventInsignificantClick);
|
739
|
-
delegate(document, Rails.buttonClickSelector, 'click', handleDisabledElement);
|
740
|
-
delegate(document, Rails.buttonClickSelector, 'click', handleConfirm);
|
741
|
-
delegate(document, Rails.buttonClickSelector, 'click', disableElement);
|
742
|
-
delegate(document, Rails.buttonClickSelector, 'click', handleRemote);
|
743
|
-
delegate(document, Rails.inputChangeSelector, 'change', handleDisabledElement);
|
744
|
-
delegate(document, Rails.inputChangeSelector, 'change', handleConfirm);
|
745
|
-
delegate(document, Rails.inputChangeSelector, 'change', handleRemote);
|
746
|
-
delegate(document, Rails.formSubmitSelector, 'submit', handleDisabledElement);
|
747
|
-
delegate(document, Rails.formSubmitSelector, 'submit', handleConfirm);
|
748
|
-
delegate(document, Rails.formSubmitSelector, 'submit', handleRemote);
|
749
|
-
delegate(document, Rails.formSubmitSelector, 'submit', function(e) {
|
750
|
-
return setTimeout((function() {
|
751
|
-
return disableElement(e);
|
752
|
-
}), 13);
|
753
|
-
});
|
754
|
-
delegate(document, Rails.formSubmitSelector, 'ajax:send', disableElement);
|
755
|
-
delegate(document, Rails.formSubmitSelector, 'ajax:complete', enableElement);
|
756
|
-
delegate(document, Rails.formInputClickSelector, 'click', preventInsignificantClick);
|
757
|
-
delegate(document, Rails.formInputClickSelector, 'click', handleDisabledElement);
|
758
|
-
delegate(document, Rails.formInputClickSelector, 'click', handleConfirm);
|
759
|
-
delegate(document, Rails.formInputClickSelector, 'click', formSubmitButtonClick);
|
760
|
-
document.addEventListener('DOMContentLoaded', refreshCSRFTokens);
|
761
|
-
document.addEventListener('DOMContentLoaded', loadCSPNonce);
|
762
|
-
return window._rails_loaded = true;
|
763
|
-
};
|
764
|
-
|
765
|
-
if (window.Rails === Rails && fire(document, 'rails:attachBindings')) {
|
766
|
-
Rails.start();
|
767
|
-
}
|
768
|
-
|
769
|
-
}).call(this);
|
770
|
-
}).call(this);
|
771
|
-
|
772
|
-
if (typeof module === "object" && module.exports) {
|
773
|
-
module.exports = Rails;
|
774
|
-
} else if (typeof define === "function" && define.amd) {
|
775
|
-
define(Rails);
|
776
|
-
}
|
777
|
-
}).call(this);
|