actionview 7.1.3.4 → 7.1.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 +4 -4
- data/CHANGELOG.md +35 -0
- data/lib/action_view/base.rb +1 -2
- data/lib/action_view/gem_version.rb +2 -2
- data/lib/action_view/helpers/asset_tag_helper.rb +3 -3
- data/lib/action_view/helpers/cache_helper.rb +4 -4
- data/lib/action_view/helpers/url_helper.rb +5 -3
- data/lib/action_view/template.rb +10 -3
- data/lib/action_view/test_case.rb +5 -5
- data/lib/action_view/unbound_template.rb +4 -4
- data/lib/action_view.rb +1 -1
- metadata +15 -16
- 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: 81ab3c1fd87fbc6f3f4a09d1144364f7c86371f864de4f7b88a4a96964b91b2a
|
4
|
+
data.tar.gz: c09302122b22d24541386865a278ad1b72a988b08a9808375442470c674488ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df946293efa603d2e519d7acea52ea8565fac8b266aab767e2a5d655b4ed3235f5203f703fc7679323dab4137bc1087abaaeb26f77a5e4d0012a1ea9e03630d0
|
7
|
+
data.tar.gz: 01e8fd7e08c61c5463bbcafedd9813fcaa655b75b63406eefc6724fd78333ae2d0c943b7b651273d4edbd80b24efc82419976a38d103a62f6c4ae3cc37f2ce62
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,38 @@
|
|
1
|
+
## Rails 7.1.5.1 (December 10, 2024) ##
|
2
|
+
|
3
|
+
* No changes.
|
4
|
+
|
5
|
+
|
6
|
+
## Rails 7.1.5 (October 30, 2024) ##
|
7
|
+
|
8
|
+
* No changes.
|
9
|
+
|
10
|
+
|
11
|
+
## Rails 7.1.4.2 (October 23, 2024) ##
|
12
|
+
|
13
|
+
* No changes.
|
14
|
+
|
15
|
+
|
16
|
+
## Rails 7.1.4.1 (October 15, 2024) ##
|
17
|
+
|
18
|
+
* No changes.
|
19
|
+
|
20
|
+
|
21
|
+
## Rails 7.1.4 (August 22, 2024) ##
|
22
|
+
|
23
|
+
* Action View Test Case `rendered` memoization.
|
24
|
+
|
25
|
+
*Sean Doyle*
|
26
|
+
|
27
|
+
* Restore the ability for templates to return any kind of object and not just strings
|
28
|
+
|
29
|
+
*Jean Boussier*
|
30
|
+
|
31
|
+
* Fix threading issue with strict locals.
|
32
|
+
|
33
|
+
*Robert Fletcher*
|
34
|
+
|
35
|
+
|
1
36
|
## Rails 7.1.3.4 (June 04, 2024) ##
|
2
37
|
|
3
38
|
* No changes.
|
data/lib/action_view/base.rb
CHANGED
@@ -136,8 +136,7 @@ module ActionView # :nodoc:
|
|
136
136
|
# end
|
137
137
|
# end
|
138
138
|
#
|
139
|
-
# For more information on Builder please consult the {source
|
140
|
-
# code}[https://github.com/jimweirich/builder].
|
139
|
+
# For more information on Builder please consult the {source code}[https://github.com/rails/builder].
|
141
140
|
class Base
|
142
141
|
include Helpers, ::ERB::Util, Context
|
143
142
|
|
@@ -645,11 +645,11 @@ module ActionView
|
|
645
645
|
return if response_present && response.sending?
|
646
646
|
|
647
647
|
if respond_to?(:request) && request
|
648
|
-
request.send_early_hints("
|
648
|
+
request.send_early_hints("link" => preload_links.join(","))
|
649
649
|
end
|
650
650
|
|
651
651
|
if response_present
|
652
|
-
header = +response.headers["
|
652
|
+
header = +response.headers["link"].to_s
|
653
653
|
preload_links.each do |link|
|
654
654
|
break if header.bytesize + link.bytesize > max_header_size
|
655
655
|
|
@@ -660,7 +660,7 @@ module ActionView
|
|
660
660
|
end
|
661
661
|
end
|
662
662
|
|
663
|
-
response.headers["
|
663
|
+
response.headers["link"] = header
|
664
664
|
end
|
665
665
|
end
|
666
666
|
end
|
@@ -76,11 +76,11 @@ module ActionView
|
|
76
76
|
# render 'comments/comments'
|
77
77
|
# render('comments/comments')
|
78
78
|
#
|
79
|
-
# render "header" translates to render("comments/header")
|
79
|
+
# render "header" # translates to render("comments/header")
|
80
80
|
#
|
81
|
-
# render(@topic) translates to render("topics/topic")
|
82
|
-
# render(topics) translates to render("topics/topic")
|
83
|
-
# render(message.topics) translates to render("topics/topic")
|
81
|
+
# render(@topic) # translates to render("topics/topic")
|
82
|
+
# render(topics) # translates to render("topics/topic")
|
83
|
+
# render(message.topics) # translates to render("topics/topic")
|
84
84
|
#
|
85
85
|
# It's not possible to derive all render calls like that, though.
|
86
86
|
# Here are a few examples of things that can't be derived:
|
@@ -561,6 +561,8 @@ module ActionView
|
|
561
561
|
content_tag("a", name || email_address, html_options, &block)
|
562
562
|
end
|
563
563
|
|
564
|
+
RFC2396_PARSER = defined?(URI::RFC2396_PARSER) ? URI::RFC2396_PARSER : URI::RFC2396_Parser.new
|
565
|
+
|
564
566
|
# True if the current request URI was generated by the given +options+.
|
565
567
|
#
|
566
568
|
# ==== Examples
|
@@ -617,14 +619,14 @@ module ActionView
|
|
617
619
|
|
618
620
|
options ||= options_as_kwargs
|
619
621
|
check_parameters ||= options.is_a?(Hash) && options.delete(:check_parameters)
|
620
|
-
url_string =
|
622
|
+
url_string = RFC2396_PARSER.unescape(url_for(options)).force_encoding(Encoding::BINARY)
|
621
623
|
|
622
624
|
# We ignore any extra parameters in the request_uri if the
|
623
625
|
# submitted URL doesn't have any either. This lets the function
|
624
626
|
# work with things like ?order=asc
|
625
627
|
# the behavior can be disabled with check_parameters: true
|
626
628
|
request_uri = url_string.index("?") || check_parameters ? request.fullpath : request.path
|
627
|
-
request_uri =
|
629
|
+
request_uri = RFC2396_PARSER.unescape(request_uri).force_encoding(Encoding::BINARY)
|
628
630
|
|
629
631
|
if %r{^\w+://}.match?(url_string)
|
630
632
|
request_uri = +"#{request.protocol}#{request.host_with_port}#{request_uri}"
|
@@ -784,7 +786,7 @@ module ActionView
|
|
784
786
|
end
|
785
787
|
|
786
788
|
def add_method_to_attributes!(html_options, method)
|
787
|
-
if method_not_get_method?(method) && !html_options["rel"]
|
789
|
+
if method_not_get_method?(method) && !html_options["rel"].to_s.include?("nofollow")
|
788
790
|
if html_options["rel"].blank?
|
789
791
|
html_options["rel"] = "nofollow"
|
790
792
|
else
|
data/lib/action_view/template.rb
CHANGED
@@ -258,7 +258,8 @@ module ActionView
|
|
258
258
|
view._run(method_name, self, locals, buffer, add_to_stack: add_to_stack, has_strict_locals: strict_locals?, &block)
|
259
259
|
nil
|
260
260
|
else
|
261
|
-
view._run(method_name, self, locals, OutputBuffer.new, add_to_stack: add_to_stack, has_strict_locals: strict_locals?, &block)
|
261
|
+
result = view._run(method_name, self, locals, OutputBuffer.new, add_to_stack: add_to_stack, has_strict_locals: strict_locals?, &block)
|
262
|
+
result.is_a?(OutputBuffer) ? result.to_s : result
|
262
263
|
end
|
263
264
|
end
|
264
265
|
rescue => e
|
@@ -423,9 +424,13 @@ module ActionView
|
|
423
424
|
|
424
425
|
method_arguments =
|
425
426
|
if set_strict_locals
|
426
|
-
|
427
|
+
if set_strict_locals.include?("&")
|
428
|
+
"output_buffer, #{set_strict_locals}"
|
429
|
+
else
|
430
|
+
"output_buffer, #{set_strict_locals}, &_"
|
431
|
+
end
|
427
432
|
else
|
428
|
-
"local_assigns, output_buffer"
|
433
|
+
"local_assigns, output_buffer, &_"
|
429
434
|
end
|
430
435
|
|
431
436
|
# Make sure that the resulting String to be eval'd is in the
|
@@ -490,6 +495,8 @@ module ActionView
|
|
490
495
|
![:keyreq, :key, :keyrest, :nokey].include?(parameter[0])
|
491
496
|
end
|
492
497
|
|
498
|
+
non_kwarg_parameters.pop if non_kwarg_parameters.last == %i(block _)
|
499
|
+
|
493
500
|
unless non_kwarg_parameters.empty?
|
494
501
|
mod.undef_method(method_name)
|
495
502
|
|
@@ -60,7 +60,7 @@ module ActionView
|
|
60
60
|
include ActiveSupport::Testing::ConstantLookup
|
61
61
|
|
62
62
|
delegate :lookup_context, to: :controller
|
63
|
-
attr_accessor :controller, :request, :output_buffer
|
63
|
+
attr_accessor :controller, :request, :output_buffer, :rendered
|
64
64
|
|
65
65
|
module ClassMethods
|
66
66
|
def inherited(descendant) # :nodoc:
|
@@ -224,7 +224,7 @@ module ActionView
|
|
224
224
|
@request = @controller.request
|
225
225
|
@view_flow = ActionView::OutputFlow.new
|
226
226
|
@output_buffer = ActionView::OutputBuffer.new
|
227
|
-
@rendered = +""
|
227
|
+
@rendered = self.class.content_class.new(+"")
|
228
228
|
|
229
229
|
test_case_instance = self
|
230
230
|
controller_class.define_method(:_test_case) { test_case_instance }
|
@@ -244,6 +244,9 @@ module ActionView
|
|
244
244
|
@_rendered_views ||= RenderedViewsCollection.new
|
245
245
|
end
|
246
246
|
|
247
|
+
##
|
248
|
+
# :method: rendered
|
249
|
+
#
|
247
250
|
# Returns the content rendered by the last +render+ call.
|
248
251
|
#
|
249
252
|
# The returned object behaves like a string but also exposes a number of methods
|
@@ -291,9 +294,6 @@ module ActionView
|
|
291
294
|
#
|
292
295
|
# assert_pattern { rendered.json => { title: "Hello, world" } }
|
293
296
|
# end
|
294
|
-
def rendered
|
295
|
-
@_rendered ||= self.class.content_class.new(@rendered)
|
296
|
-
end
|
297
297
|
|
298
298
|
def _routes
|
299
299
|
@controller._routes if @controller.respond_to?(:_routes)
|
@@ -26,15 +26,15 @@ module ActionView
|
|
26
26
|
# while holding the lock.
|
27
27
|
template = (@templates[normalized_locals] ||= build_template(normalized_locals))
|
28
28
|
|
29
|
-
# This may have already been assigned, but we've already de-dup'd so
|
30
|
-
# reassignment is fine.
|
31
|
-
@templates[locals.dup] = template
|
32
|
-
|
33
29
|
if template.strict_locals?
|
34
30
|
# Under strict locals, we only need one template.
|
35
31
|
# This replaces the @templates Concurrent::Map with a hash which
|
36
32
|
# returns this template for every key.
|
37
33
|
@templates = Hash.new(template).freeze
|
34
|
+
else
|
35
|
+
# This may have already been assigned, but we've already de-dup'd so
|
36
|
+
# reassignment is fine.
|
37
|
+
@templates[locals.dup] = template
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|
data/lib/action_view.rb
CHANGED
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.1.
|
4
|
+
version: 7.1.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Heinemeier Hansson
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-12-10 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.1.
|
19
|
+
version: 7.1.5.1
|
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.1.
|
26
|
+
version: 7.1.5.1
|
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.1.
|
89
|
+
version: 7.1.5.1
|
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.1.
|
96
|
+
version: 7.1.5.1
|
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.1.
|
103
|
+
version: 7.1.5.1
|
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.1.
|
110
|
+
version: 7.1.5.1
|
111
111
|
description: Simple, battle-tested conventions and helpers for building web pages.
|
112
112
|
email: david@loudthinking.com
|
113
113
|
executables: []
|
@@ -240,18 +240,17 @@ files:
|
|
240
240
|
- lib/action_view/unbound_template.rb
|
241
241
|
- lib/action_view/version.rb
|
242
242
|
- lib/action_view/view_paths.rb
|
243
|
-
- lib/assets/compiled/rails-ujs.js
|
244
243
|
homepage: https://rubyonrails.org
|
245
244
|
licenses:
|
246
245
|
- MIT
|
247
246
|
metadata:
|
248
247
|
bug_tracker_uri: https://github.com/rails/rails/issues
|
249
|
-
changelog_uri: https://github.com/rails/rails/blob/v7.1.
|
250
|
-
documentation_uri: https://api.rubyonrails.org/v7.1.
|
248
|
+
changelog_uri: https://github.com/rails/rails/blob/v7.1.5.1/actionview/CHANGELOG.md
|
249
|
+
documentation_uri: https://api.rubyonrails.org/v7.1.5.1/
|
251
250
|
mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
|
252
|
-
source_code_uri: https://github.com/rails/rails/tree/v7.1.
|
251
|
+
source_code_uri: https://github.com/rails/rails/tree/v7.1.5.1/actionview
|
253
252
|
rubygems_mfa_required: 'true'
|
254
|
-
post_install_message:
|
253
|
+
post_install_message:
|
255
254
|
rdoc_options: []
|
256
255
|
require_paths:
|
257
256
|
- lib
|
@@ -267,8 +266,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
267
266
|
version: '0'
|
268
267
|
requirements:
|
269
268
|
- none
|
270
|
-
rubygems_version: 3.
|
271
|
-
signing_key:
|
269
|
+
rubygems_version: 3.5.22
|
270
|
+
signing_key:
|
272
271
|
specification_version: 4
|
273
272
|
summary: Rendering framework putting the V in MVC (part of Rails).
|
274
273
|
test_files: []
|
@@ -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);
|