Skip to content
Snippets Groups Projects
Commit 78c5a256 authored by Praveen Arimbrathodiyil's avatar Praveen Arimbrathodiyil
Browse files

New upstream version 4.2.1

parent 11c14dfb
Branches
Tags upstream/4.2.1
No related merge requests found
Showing
with 15544 additions and 4131 deletions
sudo: false
cache: bundler
language: ruby
rvm:
- 1.9.3
- 2.0.0
- 2.1
- 2.2
- 2.2.5
- 2.3.0
- jruby
- ruby-head
matrix:
fast_finish: true
allow_failures:
- rvm: jruby
notifications:
email: false
irc:
......@@ -18,4 +24,4 @@ notifications:
on_success: change
on_failure: always
rooms:
- secure: ""
- secure: "p58t43P+64c1g0Av88DNM9XxMnmXM/PzRFU4yeo53i7lDY77PqKOVY+swc8eibn6cMgfyw2vqI7UFri4WLxwdN5jN5QaByHtXT2STFaJV4ORyyOBqQLuJTFWzMn8+Zil3rW/0Xv6tHoeAjsToZyYFefyjM3qemAmUqI8jLqU1sM="
## 4.2.0
- Update jQuery to 3.1.0
## 4.2.0
- Support jQuery 3.x
- Update jquery-ujs to 1.2.2
- Update jQuery to 1.12.4 and 2.2.4
## 4.1.1
- Update jQuery to 1.12.1 and 2.2.1
- Update jquery-ujs to 1.2.1
## 4.1.0
- Update jQuery to 1.12.0 and 2.2.0
- Update jquery-ujs to 1.2.0
## 4.0.5
- Specify that Ruby version 1.9.3+ is required
- Test on Ruby 2.2
- Update jquery-ujs from 1.0.4 to 1.1.0
## 4.0.4
- Fix CSP bypass vulnerability. CVE-2015-1840
......
Thanks for taking the time to contribute to jquery-rails! Please
take a moment to read the following brief guidelines to help streamline
the merging process.
Contributing to jquery-rails
=====================
## Updating jQuery
[![Build Status](https://travis-ci.org/rails/jquery-rails.svg?branch=master)](https://travis-ci.org/rails/jquery-rails)
jquery-rails is work of [many contributors](https://github.com/rails/jquery-rails/graphs/contributors). You're encouraged to submit [pull requests](https://github.com/rails/jquery-rails/pulls), [propose features and discuss issues](https://github.com/rails/jquery-rails/issues).
#### Updating jQuery
If the jquery or jquery-ui scripts are outdated (i.e. maybe a new version of jquery was released yesterday), feel free to open an issue and prod us to get that thing updated. However, for security reasons, we won't be accepting pull requests with updated jquery or jquery-ui scripts.
## Changes to jquery_ujs.js
#### Changes to jquery_ujs.js
**If it's an issue pertaining to the jquery-ujs javascript, please
report it to the [rails/jquery-ujs project](https://github.com/rails/jquery-ujs/issues).**
## Tests
#### Fork the Project
Fork the [project on Github](https://github.com/rails/jquery-rails) and check out your copy.
```
git clone https://github.com/contributor/jquery-rails.git
cd jquery-rails
git remote add upstream https://github.com/rails/jquery-rails.git
```
#### Create a Topic Branch
Make sure your fork is up-to-date and create a topic branch for your feature or bug fix.
```
git checkout master
git pull upstream master
git checkout -b my-feature-branch
```
#### Bundle Install and Test
Ensure that you can build the project and run tests.
```
bundle install
bundle exec rake test
```
#### Write Tests
Try to write a test that reproduces the problem you're trying to fix or describes a feature that you want to build. Add to [test](test).
#### Testing
This is a gem that simply includes jQuery and jQuery UJS into the Rails
asset pipeline. The asset pipeline functionality is well tested within the
......@@ -29,8 +65,68 @@ If you're making changes to the actual gem, run the tests as follows:
2. Install the gems: `bundle install`
3. Change the jquery-rails gem in the Gemfile to use your local
version of the gem with your updates: `gem 'rspec-rails', :path => '../path/to/jquery-rails'`
version of the gem with your updates: `gem 'jquery-rails', :path => '../path/to/jquery-rails'`
4. Update your bundled jquery-rails gem: `bundle update jquery-rails`
5. Run the tests: `bundle exec rspec spec/`
We definitely appreciate pull requests that highlight or reproduce a problem, even without a fix.
#### Write Code
Implement your feature or bug fix.
Make sure that `bundle exec rake test` completes without errors.
#### Write Documentation
Document any external behavior in the [README](README.md).
#### Commit Changes
Make sure git knows your name and email address:
```
git config --global user.name "Your Name"
git config --global user.email "contributor@example.com"
```
Writing good commit logs is important. A commit log should describe what changed and why.
```
git add ...
git commit
```
#### Push
```
git push origin my-feature-branch
```
#### Make a Pull Request
Go to https://github.com/contributor/jquery-rails and select your feature branch. Click the 'Pull Request' button and fill out the form. Pull requests are usually reviewed within a few days.
#### Rebase
If you've been working on a change for a while, rebase with upstream/master.
```
git fetch upstream
git rebase upstream/master
git push origin my-feature-branch -f
```
#### Check on Your Pull Request
Go back to your pull request after a few minutes and see whether it passed muster with Travis-CI. Everything should look green, otherwise fix issues and amend your commit as described above.
#### Be Patient
It's likely that your change will not be merged and that the nitpicky maintainers will ask you to do more, or fix seemingly benign problems. Hang on there!
#### Thank You
Please do know that we really appreciate and value your time and work. We love you, really.
The MIT License
Copyright (c) 2010-2015 Andre Arko
Copyright (c) 2010-2016 Andre Arko
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
......
......@@ -4,7 +4,7 @@ jQuery! For Rails! So great.
This gem provides:
* jQuery 1 and jQuery 2
* jQuery 1, 2 and 3
* the jQuery UJS adapter
* assert_select_jquery to test jQuery responses in Ruby tests
......@@ -38,21 +38,32 @@ If you want to use jQuery 2, you can require `jquery2` instead:
//= require jquery_ujs
```
And if you want to use jQuery 3, you can require `jquery3`:
```js
//= require jquery3
//= require jquery_ujs
```
For jQuery UI, we recommend the [jquery-ui-rails](https://github.com/joliss/jquery-ui-rails) gem, as it includes the jquery-ui css and allows easier customization.
*As of v3.0, jquery-rails no longer includes jQuery UI. Use the
jquery-ui-rails gem above.*
## Contributing
## Contributing to jquery-rails
Feel free to open an issue ticket if you find something that could be improved. A couple notes:
jquery-rails is work of many contributors. You're encouraged to submit pull requests, propose
features and discuss issues.
* If it's an issue pertaining to the jquery-ujs javascript, please report it to the [jquery-ujs project](https://github.com/rails/jquery-ujs).
* If the jQuery scripts are outdated (i.e. maybe a new version of jquery was released yesterday), feel free to open an issue and prod us to get that thing updated. However, for security reasons, we won't be accepting pull requests with updated jQuery scripts.
See [CONTRIBUTING](CONTRIBUTING.md).
## License
jquery-rails is released under the [MIT License](MIT-LICENSE).
## Acknowledgements
Many thanks are due to all of [the jquery-rails contributors](https://github.com/rails/jquery-rails/graphs/contributors). Special thanks to [JangoSteve](http://github.com/JangoSteve) for tirelessly answering questions and accepting patches, and the [Rails Core Team](https://github.com/organizations/rails/teams/617) for making jquery-rails an official part of Rails 3.1.
Copyright [André Arko](http://arko.net), released under the MIT License.
......@@ -29,6 +29,7 @@ task :guard_version do
check_version('jquery.js', /jQuery JavaScript Library v([\S]+)/, 'JQUERY_VERSION')
check_version('jquery2.js', /jQuery JavaScript Library v([\S]+)/, 'JQUERY_2_VERSION')
check_version('jquery3.js', /jQuery JavaScript Library v([\S]+)/, 'JQUERY_3_VERSION')
end
desc "Update jQuery versions"
......@@ -37,15 +38,16 @@ task :update_jquery do
suffix = "-#{version}"
puts "Downloading #{filename}.js"
puts `curl -o vendor/assets/javascripts/#{filename}.js http://code.jquery.com/jquery#{suffix}.js`
puts `curl -o vendor/assets/javascripts/#{filename}.js https://code.jquery.com/jquery#{suffix}.js`
puts "Downloading #{filename}.min.js"
puts `curl -o vendor/assets/javascripts/#{filename}.min.js http://code.jquery.com/jquery#{suffix}.min.js`
puts `curl -o vendor/assets/javascripts/#{filename}.min.js https://code.jquery.com/jquery#{suffix}.min.js`
puts "Downloading #{filename}.min.map"
puts `curl -o vendor/assets/javascripts/#{filename}.min.map http://code.jquery.com/jquery#{suffix}.min.map`
puts `curl -o vendor/assets/javascripts/#{filename}.min.map https://code.jquery.com/jquery#{suffix}.min.map`
end
download_jquery('jquery', Jquery::Rails::JQUERY_VERSION)
download_jquery('jquery2', Jquery::Rails::JQUERY_2_VERSION)
download_jquery('jquery3', Jquery::Rails::JQUERY_3_VERSION)
puts "\e[32mDone!\e[0m"
end
......
......@@ -2,6 +2,10 @@
| Gem | jQuery | jQuery UJS | jQuery UI |
|--------|--------|------------| ----------|
| 4.2.1 | 1.12.4 & 2.2.4 & 3.1.0 | 1.2.2 | - |
| 4.2.0 | 1.12.4 & 2.2.4 & 3.0.0 | 1.2.2 | - |
| 4.1.1 | 1.12.1 & 2.2.1 | 1.2.1 | - |
| 4.1.0 | 1.12.0 & 2.2.0 | 1.2.0 | - |
| 4.0.5 | 1.11.3 & 2.1.4 | 1.1.0 | - |
| 4.0.4 | 1.11.2 & 2.1.3 | 1.0.4 | - |
| 4.0.3 | 1.11.2 & 2.1.3 | 1.0.3 | - |
......
......@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.authors = ["André Arko"]
s.email = ["andre@arko.net"]
s.homepage = "http://rubygems.org/gems/jquery-rails"
s.homepage = "https://github.com/rails/jquery-rails"
s.summary = "Use jQuery with Rails 4+"
s.description = "This gem provides jQuery and the jQuery-ujs driver for your Rails 4+ application."
s.license = "MIT"
......@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
s.add_dependency "railties", ">= 4.2.0"
s.add_dependency "thor", ">= 0.14", "< 2.0"
s.add_dependency "rails-dom-testing", "~> 1.0"
s.add_dependency "rails-dom-testing", ">= 1", "< 3"
s.files = `git ls-files`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
......
module Jquery
module Rails
VERSION = "4.0.5"
JQUERY_VERSION = "1.11.3"
JQUERY_2_VERSION = "2.1.4"
JQUERY_UJS_VERSION = "1.1.0"
VERSION = "4.2.1"
JQUERY_VERSION = "1.12.4"
JQUERY_2_VERSION = "2.2.4"
JQUERY_3_VERSION = "3.1.0"
JQUERY_UJS_VERSION = "1.2.2"
end
end
--- !ruby/object:Gem::Specification
name: jquery-rails
version: !ruby/object:Gem::Version
version: 4.0.5
platform: ruby
authors:
- André Arko
autorequire:
bindir: bin
cert_chain: []
date: 2015-09-01 00:00:00.000000000 Z
dependencies:
- !ruby/object:Gem::Dependency
name: railties
requirement: !ruby/object:Gem::Requirement
requirements:
- - ">="
- !ruby/object:Gem::Version
version: 4.2.0
type: :runtime
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
requirements:
- - ">="
- !ruby/object:Gem::Version
version: 4.2.0
- !ruby/object:Gem::Dependency
name: thor
requirement: !ruby/object:Gem::Requirement
requirements:
- - ">="
- !ruby/object:Gem::Version
version: '0.14'
- - "<"
- !ruby/object:Gem::Version
version: '2.0'
type: :runtime
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
requirements:
- - ">="
- !ruby/object:Gem::Version
version: '0.14'
- - "<"
- !ruby/object:Gem::Version
version: '2.0'
- !ruby/object:Gem::Dependency
name: rails-dom-testing
requirement: !ruby/object:Gem::Requirement
requirements:
- - "~>"
- !ruby/object:Gem::Version
version: '1.0'
type: :runtime
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
requirements:
- - "~>"
- !ruby/object:Gem::Version
version: '1.0'
description: This gem provides jQuery and the jQuery-ujs driver for your Rails 4+
application.
email:
- andre@arko.net
executables: []
extensions: []
extra_rdoc_files: []
files:
- ".gitignore"
- ".travis.yml"
- CHANGELOG.md
- CONTRIBUTING.md
- Gemfile
- LICENSE
- README.md
- Rakefile
- VERSIONS.md
- jquery-rails.gemspec
- lib/jquery-rails.rb
- lib/jquery/assert_select.rb
- lib/jquery/rails.rb
- lib/jquery/rails/engine.rb
- lib/jquery/rails/version.rb
- test/assert_select_jquery_test.rb
- test/test_helper.rb
- vendor/assets/javascripts/jquery.js
- vendor/assets/javascripts/jquery.min.js
- vendor/assets/javascripts/jquery.min.map
- vendor/assets/javascripts/jquery2.js
- vendor/assets/javascripts/jquery2.min.js
- vendor/assets/javascripts/jquery2.min.map
- vendor/assets/javascripts/jquery_ujs.js
homepage: http://rubygems.org/gems/jquery-rails
licenses:
- MIT
metadata: {}
post_install_message:
rdoc_options: []
require_paths:
- lib
required_ruby_version: !ruby/object:Gem::Requirement
requirements:
- - ">="
- !ruby/object:Gem::Version
version: 1.9.3
required_rubygems_version: !ruby/object:Gem::Requirement
requirements:
- - ">="
- !ruby/object:Gem::Version
version: 1.3.6
requirements: []
rubyforge_project:
rubygems_version: 2.4.7
signing_key:
specification_version: 4
summary: Use jQuery with Rails 4+
test_files: []
has_rdoc:
This diff is collapsed.
This diff is collapsed.
Source diff could not be displayed: it is too large. Options to address this: view the blob.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -24,10 +24,10 @@
$.rails = rails = {
// Link elements bound by jquery-ujs
linkClickSelector: 'a[data-confirm], a[data-method], a[data-remote], a[data-disable-with], a[data-disable]',
linkClickSelector: 'a[data-confirm], a[data-method], a[data-remote]:not([disabled]), a[data-disable-with], a[data-disable]',
// Button elements bound by jquery-ujs
buttonClickSelector: 'button[data-remote]:not(form button), button[data-confirm]:not(form button)',
buttonClickSelector: 'button[data-remote]:not([form]):not(form button), button[data-confirm]:not([form]):not(form button)',
// Select elements bound by jquery-ujs
inputChangeSelector: 'select[data-remote], input[data-remote], textarea[data-remote]',
......@@ -45,10 +45,10 @@
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',
// Form required input elements
requiredInputSelector: 'input[name][required]:not([disabled]),textarea[name][required]:not([disabled])',
requiredInputSelector: 'input[name][required]:not([disabled]), textarea[name][required]:not([disabled])',
// Form file input elements
fileInputSelector: 'input[type=file]:not([disabled])',
fileInputSelector: 'input[name][type=file]:not([disabled])',
// Link onClick disable selector with possible reenable after remote submission
linkDisableSelector: 'a[data-disable-with], a[data-disable]',
......@@ -72,7 +72,7 @@
if (token) xhr.setRequestHeader('X-CSRF-Token', token);
},
// making sure that all forms have actual up-to-date token(cached forms contain old one)
// Make sure that all forms have actual up-to-date tokens (cached forms contain old ones)
refreshCSRFTokens: function(){
$('form input[name="' + rails.csrfParam() + '"]').val(rails.csrfToken());
},
......@@ -113,15 +113,17 @@
dataType = element.data('type') || ($.ajaxSettings && $.ajaxSettings.dataType);
if (element.is('form')) {
method = element.attr('method');
url = element.attr('action');
data = element.serializeArray();
method = element.data('ujs:submit-button-formmethod') || element.attr('method');
url = element.data('ujs:submit-button-formaction') || element.attr('action');
data = $(element[0]).serializeArray();
// memoized value from clicked submit button
var button = element.data('ujs:submit-button');
if (button) {
data.push(button);
element.data('ujs:submit-button', null);
}
element.data('ujs:submit-button-formmethod', null);
element.data('ujs:submit-button-formaction', null);
} else if (element.is(rails.inputChangeSelector)) {
method = element.data('method');
url = element.data('url');
......@@ -250,12 +252,13 @@
method = element.is('button') ? 'html' : 'val';
replacement = element.data('disable-with');
element.data('ujs:enable-with', element[method]());
if (replacement !== undefined) {
element.data('ujs:enable-with', element[method]());
element[method](replacement);
}
element.prop('disabled', true);
element.data('ujs:disabled', true);
},
/* Re-enables disabled form elements:
......@@ -270,8 +273,12 @@
enableFormElement: function(element) {
var method = element.is('button') ? 'html' : 'val';
if (typeof element.data('ujs:enable-with') !== 'undefined') element[method](element.data('ujs:enable-with'));
if (element.data('ujs:enable-with') !== undefined) {
element[method](element.data('ujs:enable-with'));
element.removeData('ujs:enable-with'); // clean up cache
}
element.prop('disabled', false);
element.removeData('ujs:disabled');
},
/* For 'data-confirm' attribute:
......@@ -302,24 +309,45 @@
// Helper function which checks for blank inputs in a form that match the specified CSS selector
blankInputs: function(form, specifiedSelector, nonBlank) {
var inputs = $(), input, valueToCheck,
selector = specifiedSelector || 'input,textarea',
allInputs = form.find(selector);
allInputs.each(function() {
var foundInputs = $(),
input,
valueToCheck,
radiosForNameWithNoneSelected,
radioName,
selector = specifiedSelector || 'input,textarea',
requiredInputs = form.find(selector),
checkedRadioButtonNames = {};
requiredInputs.each(function() {
input = $(this);
valueToCheck = input.is('input[type=checkbox],input[type=radio]') ? input.is(':checked') : !!input.val();
if (valueToCheck === nonBlank) {
if (input.is('input[type=radio]')) {
// Don't count unchecked required radio if other radio with same name is checked
if (input.is('input[type=radio]') && allInputs.filter('input[type=radio]:checked[name="' + input.attr('name') + '"]').length) {
return true; // Skip to next input
}
// Don't count unchecked required radio as blank if other radio with same name is checked,
// regardless of whether same-name radio input has required attribute or not. The spec
// states https://www.w3.org/TR/html5/forms.html#the-required-attribute
radioName = input.attr('name');
// Skip if we've already seen the radio with this name.
if (!checkedRadioButtonNames[radioName]) {
// If none checked
if (form.find('input[type=radio]:checked[name="' + radioName + '"]').length === 0) {
radiosForNameWithNoneSelected = form.find(
'input[type=radio][name="' + radioName + '"]');
foundInputs = foundInputs.add(radiosForNameWithNoneSelected);
}
inputs = inputs.add(input);
// We only need to check each name once.
checkedRadioButtonNames[radioName] = radioName;
}
} else {
valueToCheck = input.is('input[type=checkbox],input[type=radio]') ? input.is(':checked') : !!input.val();
if (valueToCheck === nonBlank) {
foundInputs = foundInputs.add(input);
}
}
});
return inputs.length ? inputs : false;
return foundInputs.length ? foundInputs : false;
},
// Helper function which checks for non-blank inputs in a form that match the specified CSS selector
......@@ -334,28 +362,30 @@
return false;
},
// replace element's html with the 'data-disable-with' after storing original html
// Replace element's html with the 'data-disable-with' after storing original html
// and prevent clicking on it
disableElement: function(element) {
var replacement = element.data('disable-with');
element.data('ujs:enable-with', element.html()); // store enabled state
if (replacement !== undefined) {
element.data('ujs:enable-with', element.html()); // store enabled state
element.html(replacement);
}
element.bind('click.railsDisable', function(e) { // prevent further clicking
return rails.stopEverything(e);
});
element.data('ujs:disabled', true);
},
// restore element to its original state which was disabled by 'disableElement' above
// Restore element to its original state which was disabled by 'disableElement' above
enableElement: function(element) {
if (element.data('ujs:enable-with') !== undefined) {
element.html(element.data('ujs:enable-with')); // set to old enabled state
element.removeData('ujs:enable-with'); // clean up cache
}
element.unbind('click.railsDisable'); // enable element
element.removeData('ujs:disabled');
}
};
......@@ -372,7 +402,7 @@
$($.rails.enableSelector).each(function () {
var element = $(this);
if (element.data('ujs:enable-with')) {
if (element.data('ujs:disabled')) {
$.rails.enableFormElement(element);
}
});
......@@ -380,21 +410,21 @@
$($.rails.linkDisableSelector).each(function () {
var element = $(this);
if (element.data('ujs:enable-with')) {
if (element.data('ujs:disabled')) {
$.rails.enableElement(element);
}
});
});
$document.delegate(rails.linkDisableSelector, 'ajax:complete', function() {
$document.on('ajax:complete', rails.linkDisableSelector, function() {
rails.enableElement($(this));
});
$document.delegate(rails.buttonDisableSelector, 'ajax:complete', function() {
$document.on('ajax:complete', rails.buttonDisableSelector, function() {
rails.enableFormElement($(this));
});
$document.delegate(rails.linkClickSelector, 'click.rails', function(e) {
$document.on('click.rails', rails.linkClickSelector, function(e) {
var link = $(this), method = link.data('method'), data = link.data('params'), metaClick = e.metaKey || e.ctrlKey;
if (!rails.allowAction(link)) return rails.stopEverything(e);
......@@ -404,7 +434,7 @@
if (metaClick && (!method || method === 'GET') && !data) { return true; }
var handleRemote = rails.handleRemote(link);
// response from rails.handleRemote() will either be false or a deferred object promise.
// Response from rails.handleRemote() will either be false or a deferred object promise.
if (handleRemote === false) {
rails.enableElement(link);
} else {
......@@ -418,7 +448,7 @@
}
});
$document.delegate(rails.buttonClickSelector, 'click.rails', function(e) {
$document.on('click.rails', rails.buttonClickSelector, function(e) {
var button = $(this);
if (!rails.allowAction(button) || !rails.isRemote(button)) return rails.stopEverything(e);
......@@ -426,7 +456,7 @@
if (button.is(rails.buttonDisableSelector)) rails.disableFormElement(button);
var handleRemote = rails.handleRemote(button);
// response from rails.handleRemote() will either be false or a deferred object promise.
// Response from rails.handleRemote() will either be false or a deferred object promise.
if (handleRemote === false) {
rails.enableFormElement(button);
} else {
......@@ -435,7 +465,7 @@
return false;
});
$document.delegate(rails.inputChangeSelector, 'change.rails', function(e) {
$document.on('change.rails', rails.inputChangeSelector, function(e) {
var link = $(this);
if (!rails.allowAction(link) || !rails.isRemote(link)) return rails.stopEverything(e);
......@@ -443,7 +473,7 @@
return false;
});
$document.delegate(rails.formSubmitSelector, 'submit.rails', function(e) {
$document.on('submit.rails', rails.formSubmitSelector, function(e) {
var form = $(this),
remote = rails.isRemote(form),
blankRequiredInputs,
......@@ -451,23 +481,29 @@
if (!rails.allowAction(form)) return rails.stopEverything(e);
// skip other logic when required values are missing or file upload is present
// Skip other logic when required values are missing or file upload is present
if (form.attr('novalidate') === undefined) {
blankRequiredInputs = rails.blankInputs(form, rails.requiredInputSelector, false);
if (blankRequiredInputs && rails.fire(form, 'ajax:aborted:required', [blankRequiredInputs])) {
return rails.stopEverything(e);
if (form.data('ujs:formnovalidate-button') === undefined) {
blankRequiredInputs = rails.blankInputs(form, rails.requiredInputSelector, false);
if (blankRequiredInputs && rails.fire(form, 'ajax:aborted:required', [blankRequiredInputs])) {
return rails.stopEverything(e);
}
} else {
// Clear the formnovalidate in case the next button click is not on a formnovalidate button
// Not strictly necessary to do here, since it is also reset on each button click, but just to be certain
form.data('ujs:formnovalidate-button', undefined);
}
}
if (remote) {
nonBlankFileInputs = rails.nonBlankInputs(form, rails.fileInputSelector);
if (nonBlankFileInputs) {
// slight timeout so that the submit button gets properly serialized
// Slight timeout so that the submit button gets properly serialized
// (make it easy for event handler to serialize form without disabled values)
setTimeout(function(){ rails.disableFormElements(form); }, 13);
var aborted = rails.fire(form, 'ajax:aborted:file', [nonBlankFileInputs]);
// re-enable form elements if event bindings return false (canceling normal form submission)
// Re-enable form elements if event bindings return false (canceling normal form submission)
if (!aborted) { setTimeout(function(){ rails.enableFormElements(form); }, 13); }
return aborted;
......@@ -477,28 +513,37 @@
return false;
} else {
// slight timeout so that the submit button gets properly serialized
// Slight timeout so that the submit button gets properly serialized
setTimeout(function(){ rails.disableFormElements(form); }, 13);
}
});
$document.delegate(rails.formInputClickSelector, 'click.rails', function(event) {
$document.on('click.rails', rails.formInputClickSelector, function(event) {
var button = $(this);
if (!rails.allowAction(button)) return rails.stopEverything(event);
// register the pressed submit button
// Register the pressed submit button
var name = button.attr('name'),
data = name ? {name:name, value:button.val()} : null;
button.closest('form').data('ujs:submit-button', data);
var form = button.closest('form');
if (form.length === 0) {
form = $('#' + button.attr('form'));
}
form.data('ujs:submit-button', data);
// Save attributes from button
form.data('ujs:formnovalidate-button', button.attr('formnovalidate'));
form.data('ujs:submit-button-formaction', button.attr('formaction'));
form.data('ujs:submit-button-formmethod', button.attr('formmethod'));
});
$document.delegate(rails.formSubmitSelector, 'ajax:send.rails', function(event) {
$document.on('ajax:send.rails', rails.formSubmitSelector, function(event) {
if (this === event.target) rails.disableFormElements($(this));
});
$document.delegate(rails.formSubmitSelector, 'ajax:complete.rails', function(event) {
$document.on('ajax:complete.rails', rails.formSubmitSelector, function(event) {
if (this === event.target) rails.enableFormElements($(this));
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment