From c30462003c41175acf7337536b036a47645cf742 Mon Sep 17 00:00:00 2001
From: ingeniarius
Date: Wed, 20 Feb 2013 15:22:34 +0400
Subject: [PATCH 001/122] Supporting button[data-remote] as replacement of
button_to helper
---
src/rails.js | 16 ++++++++++++++++
test/public/test/data-remote.js | 31 +++++++++++++++++++++++++------
2 files changed, 41 insertions(+), 6 deletions(-)
diff --git a/src/rails.js b/src/rails.js
index a1661f31..2cb26b53 100644
--- a/src/rails.js
+++ b/src/rails.js
@@ -23,6 +23,9 @@
// Link elements bound by jquery-ujs
linkClickSelector: 'a[data-confirm], a[data-method], a[data-remote], a[data-disable-with]',
+ // Button elements boud jquery-ujs
+ buttonClickSelector: 'button[data-remote]',
+
// Select elements bound by jquery-ujs
inputChangeSelector: 'select[data-remote], input[data-remote], textarea[data-remote]',
@@ -100,6 +103,11 @@
url = element.data('url');
data = element.serialize();
if (element.data('params')) data = data + "&" + element.data('params');
+ } else if (element.is(rails.buttonClickSelector)) {
+ method = element.data('method') || 'post';
+ url = element.data('url');
+ data = element.serialize();
+ if (element.data('params')) data = data + "&" + element.data('params');
} else {
method = element.data('method');
url = rails.href(element);
@@ -315,6 +323,14 @@
}
});
+ $(document).delegate(rails.buttonClickSelector, 'click.rails', function(e) {
+ var button = $(this);
+ if (!rails.allowAction(button)) return rails.stopEverything(e);
+
+ rails.handleRemote(button);
+ return false;
+ });
+
$(document).delegate(rails.inputChangeSelector, 'change.rails', function(e) {
var link = $(this);
if (!rails.allowAction(link)) return rails.stopEverything(e);
diff --git a/test/public/test/data-remote.js b/test/public/test/data-remote.js
index d9c2f6d7..1ce113e9 100644
--- a/test/public/test/data-remote.js
+++ b/test/public/test/data-remote.js
@@ -7,6 +7,12 @@ module('data-remote', {
'data-params': 'data1=value1&data2=value2',
text: 'my address'
}))
+ .append($('', {
+ 'data-url': '/echo',
+ 'data-remote': 'true',
+ 'data-params': 'data1=value1&data2=value2',
+ text: 'my button'
+ }))
.append($('', {
action: '/echo',
'data-remote': 'true',
@@ -67,12 +73,25 @@ asyncTest('ctrl-clicking on a link still fires ajax for non-GET links and for li
asyncTest('clicking on a link with data-remote attribute', 5, function() {
$('a[data-remote]')
- .bind('ajax:success', function(e, data, status, xhr) {
+ .bind('ajax:success', function(e, data, status, xhr) {
+ App.assert_callback_invoked('ajax:success');
+ App.assert_request_path(data, '/echo');
+ equal(data.params.data1, 'value1', 'ajax arguments should have key data1 with right value');
+ equal(data.params.data2, 'value2', 'ajax arguments should have key data2 with right value');
+ App.assert_get_request(data);
+ })
+ .bind('ajax:complete', function() { start() })
+ .trigger('click');
+});
+
+asyncTest('clicking on a button with data-remote attribute', 5, function() {
+ $('button[data-remote]')
+ .bind('ajax:success', function(e, data, status, xhr) {
App.assert_callback_invoked('ajax:success');
App.assert_request_path(data, '/echo');
equal(data.params.data1, 'value1', 'ajax arguments should have key data1 with right value');
equal(data.params.data2, 'value2', 'ajax arguments should have key data2 with right value');
- App.assert_get_request(data);
+ App.assert_post_request(data);
})
.bind('ajax:complete', function() { start() })
.trigger('click');
@@ -92,12 +111,12 @@ asyncTest('changing a select option with data-remote attribute', 5, function() {
);
$('select[data-remote]')
- .bind('ajax:success', function(e, data, status, xhr) {
+ .bind('ajax:success', function(e, data, status, xhr) {
App.assert_callback_invoked('ajax:success');
App.assert_request_path(data, '/echo');
equal(data.params.user_data, 'optionValue2', 'ajax arguments should have key term with right value');
equal(data.params.data1, 'value1', 'ajax arguments should have key data1 with right value');
- App.assert_get_request(data);
+ App.assert_get_request(data);
})
.bind('ajax:complete', function() { start() })
.val('optionValue2')
@@ -106,11 +125,11 @@ asyncTest('changing a select option with data-remote attribute', 5, function() {
asyncTest('submitting form with data-remote attribute', 4, function() {
$('form[data-remote]')
- .bind('ajax:success', function(e, data, status, xhr) {
+ .bind('ajax:success', function(e, data, status, xhr) {
App.assert_callback_invoked('ajax:success');
App.assert_request_path(data, '/echo');
equal(data.params.user_name, 'john', 'ajax arguments should have key user_name with right value');
- App.assert_post_request(data);
+ App.assert_post_request(data);
})
.bind('ajax:complete', function() { start() })
.trigger('submit');
From fa80b2e3740e8497d3cc05b0ec60d1c8b79388e1 Mon Sep 17 00:00:00 2001
From: Adam Krebs
Date: Sun, 3 Mar 2013 13:08:18 -0500
Subject: [PATCH 002/122] fix typo in opening comment
---
src/rails.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/rails.js b/src/rails.js
index a1661f31..6f85a328 100644
--- a/src/rails.js
+++ b/src/rails.js
@@ -10,7 +10,7 @@
*
*/
- // Cut down on the number if issues from people inadvertently including jquery_ujs twice
+ // Cut down on the number of issues from people inadvertently including jquery_ujs twice
// by detecting and raising an error when it happens.
if ( $.rails !== undefined ) {
$.error('jquery-ujs has already been loaded!');
From 6184e4dbd3afecd115960fd071ba0159291584df Mon Sep 17 00:00:00 2001
From: Steve Schwartz
Date: Tue, 28 May 2013 23:37:52 -0400
Subject: [PATCH 003/122] Removed formSubmitBinding function needed for
incorrect for submit event bubbling in IE before jQuery 1.7.
---
src/rails.js | 16 ----------------
1 file changed, 16 deletions(-)
diff --git a/src/rails.js b/src/rails.js
index a1661f31..7dad9387 100644
--- a/src/rails.js
+++ b/src/rails.js
@@ -250,18 +250,6 @@
return false;
},
- // find all the submit events directly bound to the form and
- // manually invoke them. If anyone returns false then stop the loop
- callFormSubmitBindings: function(form, event) {
- var events = form.data('events'), continuePropagation = true;
- if (events !== undefined && events['submit'] !== undefined) {
- $.each(events['submit'], function(i, obj){
- if (typeof obj.handler === 'function') return continuePropagation = obj.handler(event);
- });
- }
- return continuePropagation;
- },
-
// replace element's html with the 'data-disable-with' after storing original html
// and prevent clicking on it
disableElement: function(element) {
@@ -349,10 +337,6 @@
return aborted;
}
- // If browser does not support submit bubbling, then this live-binding will be called before direct
- // bindings. Therefore, we should directly call any direct bindings before remotely submitting form.
- if (!$.support.submitBubbles && $().jquery < '1.7' && rails.callFormSubmitBindings(form, e) === false) return rails.stopEverything(e);
-
rails.handleRemote(form);
return false;
From 87587d476054e9869865f53c1b78cb8164619a05 Mon Sep 17 00:00:00 2001
From: Steve Schwartz
Date: Wed, 29 May 2013 01:43:33 -0400
Subject: [PATCH 004/122] Changed button remote default request type to GET.
---
src/rails.js | 2 +-
test/public/test/data-remote.js | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/rails.js b/src/rails.js
index 3fe5f4f5..50121d6e 100644
--- a/src/rails.js
+++ b/src/rails.js
@@ -104,7 +104,7 @@
data = element.serialize();
if (element.data('params')) data = data + "&" + element.data('params');
} else if (element.is(rails.buttonClickSelector)) {
- method = element.data('method') || 'post';
+ method = element.data('method') || 'get';
url = element.data('url');
data = element.serialize();
if (element.data('params')) data = data + "&" + element.data('params');
diff --git a/test/public/test/data-remote.js b/test/public/test/data-remote.js
index 1ce113e9..3f5c551c 100644
--- a/test/public/test/data-remote.js
+++ b/test/public/test/data-remote.js
@@ -91,7 +91,7 @@ asyncTest('clicking on a button with data-remote attribute', 5, function() {
App.assert_request_path(data, '/echo');
equal(data.params.data1, 'value1', 'ajax arguments should have key data1 with right value');
equal(data.params.data2, 'value2', 'ajax arguments should have key data2 with right value');
- App.assert_post_request(data);
+ App.assert_get_request(data);
})
.bind('ajax:complete', function() { start() })
.trigger('click');
From 56841249206f58e14863653b747f2279727a5052 Mon Sep 17 00:00:00 2001
From: Steve Schwartz
Date: Wed, 29 May 2013 02:17:20 -0400
Subject: [PATCH 005/122] Added jquery 1.10.0 support.
---
test/server.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/test/server.rb b/test/server.rb
index 5ed58ec3..2c9bbb36 100644
--- a/test/server.rb
+++ b/test/server.rb
@@ -1,7 +1,7 @@
require 'sinatra'
require 'json'
-JQUERY_VERSIONS = %w[ 1.7 1.7.1 1.7.2 1.8.0 1.8.1 1.8.2 1.8.3 1.9.0 1.9.1 ].freeze
+JQUERY_VERSIONS = %w[ 1.7 1.7.1 1.7.2 1.8.0 1.8.1 1.8.2 1.8.3 1.9.0 1.9.1 1.10.0 ].freeze
use Rack::Static, :urls => ["/src"], :root => File.expand_path('..', settings.root)
From 846a91a8f408c15c8dcfa9f767ee561be66c6d58 Mon Sep 17 00:00:00 2001
From: Steve Schwartz
Date: Fri, 7 Jun 2013 22:14:33 -0400
Subject: [PATCH 006/122] Added jquery 1.10.1 support.
---
test/server.rb | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/test/server.rb b/test/server.rb
index 2c9bbb36..270999a2 100644
--- a/test/server.rb
+++ b/test/server.rb
@@ -1,7 +1,7 @@
require 'sinatra'
require 'json'
-JQUERY_VERSIONS = %w[ 1.7 1.7.1 1.7.2 1.8.0 1.8.1 1.8.2 1.8.3 1.9.0 1.9.1 1.10.0 ].freeze
+JQUERY_VERSIONS = %w[ 1.7 1.7.1 1.7.2 1.8.0 1.8.1 1.8.2 1.8.3 1.9.0 1.9.1 1.10.0 1.10.1 ].freeze
use Rack::Static, :urls => ["/src"], :root => File.expand_path('..', settings.root)
@@ -48,7 +48,7 @@ def jquery_versions
end
get '/' do
- params[:version] ||= '1.9.1'
+ params[:version] ||= '1.10.1'
params[:cdn] ||= 'jquery'
erb :index
end
From a8f36f70bba744fa9f127dd5c41a65985d8ddef7 Mon Sep 17 00:00:00 2001
From: Michael Nikitochkin
Date: Sun, 30 Jun 2013 00:14:26 +0300
Subject: [PATCH 007/122] Cached the jQuery document element.
---
src/rails.js | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/src/rails.js b/src/rails.js
index 50121d6e..84f9e6bc 100644
--- a/src/rails.js
+++ b/src/rails.js
@@ -18,6 +18,7 @@
// Shorthand to make it a little easier to call public rails functions from within rails.js
var rails;
+ var $document = $(document);
$.rails = rails = {
// Link elements bound by jquery-ujs
@@ -279,15 +280,15 @@
};
- if (rails.fire($(document), 'rails:attachBindings')) {
+ if (rails.fire($document, 'rails:attachBindings')) {
$.ajaxPrefilter(function(options, originalOptions, xhr){ if ( !options.crossDomain ) { rails.CSRFProtection(xhr); }});
- $(document).delegate(rails.linkDisableSelector, 'ajax:complete', function() {
+ $document.delegate(rails.linkDisableSelector, 'ajax:complete', function() {
rails.enableElement($(this));
});
- $(document).delegate(rails.linkClickSelector, 'click.rails', function(e) {
+ $document.delegate(rails.linkClickSelector, 'click.rails', function(e) {
var link = $(this), method = link.data('method'), data = link.data('params');
if (!rails.allowAction(link)) return rails.stopEverything(e);
@@ -311,7 +312,7 @@
}
});
- $(document).delegate(rails.buttonClickSelector, 'click.rails', function(e) {
+ $document.delegate(rails.buttonClickSelector, 'click.rails', function(e) {
var button = $(this);
if (!rails.allowAction(button)) return rails.stopEverything(e);
@@ -319,7 +320,7 @@
return false;
});
- $(document).delegate(rails.inputChangeSelector, 'change.rails', function(e) {
+ $document.delegate(rails.inputChangeSelector, 'change.rails', function(e) {
var link = $(this);
if (!rails.allowAction(link)) return rails.stopEverything(e);
@@ -327,7 +328,7 @@
return false;
});
- $(document).delegate(rails.formSubmitSelector, 'submit.rails', function(e) {
+ $document.delegate(rails.formSubmitSelector, 'submit.rails', function(e) {
var form = $(this),
remote = form.data('remote') !== undefined,
blankRequiredInputs = rails.blankInputs(form, rails.requiredInputSelector),
@@ -362,7 +363,7 @@
}
});
- $(document).delegate(rails.formInputClickSelector, 'click.rails', function(event) {
+ $document.delegate(rails.formInputClickSelector, 'click.rails', function(event) {
var button = $(this);
if (!rails.allowAction(button)) return rails.stopEverything(event);
@@ -374,11 +375,11 @@
button.closest('form').data('ujs:submit-button', data);
});
- $(document).delegate(rails.formSubmitSelector, 'ajax:beforeSend.rails', function(event) {
+ $document.delegate(rails.formSubmitSelector, 'ajax:beforeSend.rails', function(event) {
if (this == event.target) rails.disableFormElements($(this));
});
- $(document).delegate(rails.formSubmitSelector, 'ajax:complete.rails', function(event) {
+ $document.delegate(rails.formSubmitSelector, 'ajax:complete.rails', function(event) {
if (this == event.target) rails.enableFormElements($(this));
});
From 470486de27522e60e9b660e7810db2f20842f487 Mon Sep 17 00:00:00 2001
From: Junya Ogura
Date: Sun, 4 Aug 2013 12:12:26 +0900
Subject: [PATCH 008/122] Update a URL for HTML5 Spec
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 758a1a20..802c44d5 100644
--- a/README.md
+++ b/README.md
@@ -58,7 +58,7 @@ How to run tests
Follow [this wiki](https://github.com/rails/jquery-ujs/wiki/Running-Tests-and-Contributing) to run tests .
-[data]: http://dev.w3.org/html5/spec/elements.html#embedding-custom-non-visible-data-with-the-data-attributes "Embedding custom non-visible data with the data-* attributes"
+[data]: http://www.w3.org/TR/html5/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes "Embedding custom non-visible data with the data-* attributes"
[wiki]: https://github.com/rails/jquery-ujs/wiki
[events]: https://github.com/rails/jquery-ujs/wiki/ajax
[jquery]: http://docs.jquery.com/Downloading_jQuery
From f3785e4d2368e3f67c844d8523b429e67cd3abfc Mon Sep 17 00:00:00 2001
From: Espen Antonsen
Date: Sat, 24 Aug 2013 16:10:32 +0200
Subject: [PATCH 009/122] jquery-rails does not include jquery-ui anymore
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 802c44d5..bc488b72 100644
--- a/README.md
+++ b/README.md
@@ -42,7 +42,7 @@ a. For Rails 3.1, add these lines to the top of your app/assets/javascripts/appl
//= require jquery_ujs
```
-b. For Rails 3.0, run this command (add `--ui` if you want jQuery UI):
+b. For Rails 3.0, run this command:
*Be sure to get rid of the rails.js file if it exists, and instead use
the new jquery_ujs.js file that gets copied to the public directory.
From cb7d4df9fe433477a8bf4797403518f7d3e6db66 Mon Sep 17 00:00:00 2001
From: Jason Moon
Date: Tue, 27 Aug 2013 22:09:56 -0500
Subject: [PATCH 010/122] Wait to do the form DOM scans until absolutely
necessary
---
src/rails.js | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/src/rails.js b/src/rails.js
index 84f9e6bc..2b1e9b4b 100644
--- a/src/rails.js
+++ b/src/rails.js
@@ -331,17 +331,21 @@
$document.delegate(rails.formSubmitSelector, 'submit.rails', function(e) {
var form = $(this),
remote = form.data('remote') !== undefined,
- blankRequiredInputs = rails.blankInputs(form, rails.requiredInputSelector),
- nonBlankFileInputs = rails.nonBlankInputs(form, rails.fileInputSelector);
+ blankRequiredInputs,
+ nonBlankFileInputs;
if (!rails.allowAction(form)) return rails.stopEverything(e);
// skip other logic when required values are missing or file upload is present
- if (blankRequiredInputs && form.attr("novalidate") == undefined && rails.fire(form, 'ajax:aborted:required', [blankRequiredInputs])) {
- return rails.stopEverything(e);
+ if (form.attr('novalidate') == undefined) {
+ blankRequiredInputs = rails.blankInputs(form, rails.requiredInputSelector);
+ if (blankRequiredInputs && rails.fire(form, 'ajax:aborted:required', [blankRequiredInputs])) {
+ return rails.stopEverything(e);
+ }
}
if (remote) {
+ nonBlankFileInputs = rails.nonBlankInputs(form, rails.fileInputSelector);
if (nonBlankFileInputs) {
// slight timeout so that the submit button gets properly serialized
// (make it easy for event handler to serialize form without disabled values)
From 031eb86a23a1065a6ae19e09f95497b0f6a44667 Mon Sep 17 00:00:00 2001
From: Paul Sweeney
Date: Fri, 20 Sep 2013 15:32:07 -0700
Subject: [PATCH 011/122] Adding bower.json
---
bower.json | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
create mode 100644 bower.json
diff --git a/bower.json b/bower.json
new file mode 100644
index 00000000..a65510a8
--- /dev/null
+++ b/bower.json
@@ -0,0 +1,16 @@
+{
+ name: 'jquery-ujs',
+ version: '3.0.4',
+ homepage: 'https://github.com/rails/jquery-ujs',
+ authors: [],
+ description: 'Ruby on Rails unobtrusive scripting adapter for jQuery',
+ main: 'src/rails.js',
+ license: 'MIT',
+ ignore: [
+ '**/.*',
+ 'Gemfile.*',
+ 'Rakefile',
+ 'bower_components',
+ 'test',
+ ]
+}
From ec574b3f76530493af3cf087ce786e3fc3f6b9bf Mon Sep 17 00:00:00 2001
From: Paul Sweeney
Date: Fri, 20 Sep 2013 15:34:29 -0700
Subject: [PATCH 012/122] Valid JSON is nice
---
bower.json | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/bower.json b/bower.json
index a65510a8..bf16ce86 100644
--- a/bower.json
+++ b/bower.json
@@ -1,16 +1,16 @@
{
- name: 'jquery-ujs',
- version: '3.0.4',
- homepage: 'https://github.com/rails/jquery-ujs',
- authors: [],
- description: 'Ruby on Rails unobtrusive scripting adapter for jQuery',
- main: 'src/rails.js',
- license: 'MIT',
- ignore: [
- '**/.*',
- 'Gemfile.*',
- 'Rakefile',
- 'bower_components',
- 'test',
+ "name": "jquery-ujs",
+ "version": "3.0.4",
+ "homepage": "https://github.com/rails/jquery-ujs",
+ "authors": [],
+ "description": "Ruby on Rails unobtrusive scripting adapter for jQuery",
+ "main": "src/rails.js",
+ "license": "MIT",
+ "ignore": [
+ "**/.*",
+ "Gemfile.*",
+ "Rakefile",
+ "bower_components",
+ "test"
]
}
From 04cb0623ba77e59974e9555abdf8b56aa5fb858f Mon Sep 17 00:00:00 2001
From: Paul Sweeney
Date: Fri, 20 Sep 2013 15:35:54 -0700
Subject: [PATCH 013/122] Omitting Gemfile as well as Gemfile.lock
---
bower.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/bower.json b/bower.json
index bf16ce86..991d2684 100644
--- a/bower.json
+++ b/bower.json
@@ -8,7 +8,7 @@
"license": "MIT",
"ignore": [
"**/.*",
- "Gemfile.*",
+ "Gemfile*",
"Rakefile",
"bower_components",
"test"
From 97588668ec13526ea5832763a20682876c661660 Mon Sep 17 00:00:00 2001
From: Paul Sweeney
Date: Fri, 20 Sep 2013 15:37:54 -0700
Subject: [PATCH 014/122] Adding jquery as a dependency
---
bower.json | 3 +++
1 file changed, 3 insertions(+)
diff --git a/bower.json b/bower.json
index 991d2684..c96d9bd3 100644
--- a/bower.json
+++ b/bower.json
@@ -6,6 +6,9 @@
"description": "Ruby on Rails unobtrusive scripting adapter for jQuery",
"main": "src/rails.js",
"license": "MIT",
+ "dependencies": {
+ "jquery": "~1.10.2"
+ },
"ignore": [
"**/.*",
"Gemfile*",
From 9a55173e6727d874ed2880d005b3e1949b3f251f Mon Sep 17 00:00:00 2001
From: Lucas Mazza
Date: Thu, 31 Oct 2013 17:35:26 -0200
Subject: [PATCH 015/122] Update rubygems.org URL and remove json gem
dependency.
---
Gemfile | 3 +--
Gemfile.lock | 4 +---
2 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/Gemfile b/Gemfile
index e32e523b..8d6aa8d1 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,6 +1,5 @@
-source 'http://rubygems.org'
+source 'https://rubygems.org'
gem 'sinatra', '~> 1.0'
gem 'shotgun', :group => :reloadable
gem 'thin', :group => :reloadable
-gem 'json'
diff --git a/Gemfile.lock b/Gemfile.lock
index 42460e58..f4f2623d 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,9 +1,8 @@
GEM
- remote: http://rubygems.org/
+ remote: https://rubygems.org/
specs:
daemons (1.1.0)
eventmachine (0.12.10)
- json (1.4.6)
rack (1.2.1)
shotgun (0.8)
rack (>= 1.0)
@@ -20,7 +19,6 @@ PLATFORMS
ruby
DEPENDENCIES
- json
shotgun
sinatra (~> 1.0)
thin
From f6fa5a5dd8985f636d8419f8eeb0a4fdfef91ecf Mon Sep 17 00:00:00 2001
From: Lucas Mazza
Date: Thu, 31 Oct 2013 18:10:08 -0200
Subject: [PATCH 016/122] Do not disable elements on ctrl/cmd clicks.
Closes #310.
---
src/rails.js | 6 +++---
test/public/test/data-disable.js | 18 ++++++++++++++++++
2 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/src/rails.js b/src/rails.js
index 84f9e6bc..0786ab12 100644
--- a/src/rails.js
+++ b/src/rails.js
@@ -289,13 +289,13 @@
});
$document.delegate(rails.linkClickSelector, 'click.rails', function(e) {
- var link = $(this), method = link.data('method'), data = link.data('params');
+ var link = $(this), method = link.data('method'), data = link.data('params'), metaClick = e.metaKey || e.ctrlKey;
if (!rails.allowAction(link)) return rails.stopEverything(e);
- if (link.is(rails.linkDisableSelector)) rails.disableElement(link);
+ if (!metaClick && link.is(rails.linkDisableSelector)) rails.disableElement(link);
if (link.data('remote') !== undefined) {
- if ( (e.metaKey || e.ctrlKey) && (!method || method === 'GET') && !data ) { return true; }
+ 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.
diff --git a/test/public/test/data-disable.js b/test/public/test/data-disable.js
index 6c973dfd..0f58214a 100644
--- a/test/public/test/data-disable.js
+++ b/test/public/test/data-disable.js
@@ -245,3 +245,21 @@ asyncTest('form[data-remote] input|button|textarea[data-disable-with] does not d
start();
});
+
+asyncTest('ctrl-clicking on a link does not disables the link', 0, function() {
+ var link = $('a[data-disable-with]'), e;
+ e = $.Event('click');
+ e.metaKey = true;
+
+ checkEnabledState(link, 'Click me');
+
+ link.trigger(e);
+ checkEnabledState(link, 'Click me');
+
+ e = $.Event('click');
+ e.ctrlKey = true;
+
+ link.trigger(e);
+ checkEnabledState(link, 'Click me');
+ start();
+});
From 2e6a440cbff8da7b2f4f2e5b82723c5ca6516093 Mon Sep 17 00:00:00 2001
From: Paul Sweeney
Date: Thu, 31 Oct 2013 22:21:05 -0700
Subject: [PATCH 017/122] Swapping to starred minor and patch versions
---
bower.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/bower.json b/bower.json
index c96d9bd3..1f70fa63 100644
--- a/bower.json
+++ b/bower.json
@@ -7,7 +7,7 @@
"main": "src/rails.js",
"license": "MIT",
"dependencies": {
- "jquery": "~1.10.2"
+ "jquery": "1.*.*"
},
"ignore": [
"**/.*",
From 6b3d3fbea6f9aaf7761c314b866922fa7fe80b30 Mon Sep 17 00:00:00 2001
From: Paul Sweeney
Date: Thu, 31 Oct 2013 22:23:40 -0700
Subject: [PATCH 018/122] jQuery greater than 1.7, less than 2.0
---
bower.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/bower.json b/bower.json
index 1f70fa63..a5f1c5aa 100644
--- a/bower.json
+++ b/bower.json
@@ -7,7 +7,7 @@
"main": "src/rails.js",
"license": "MIT",
"dependencies": {
- "jquery": "1.*.*"
+ "jquery": ">1.7.* <2.0.0"
},
"ignore": [
"**/.*",
From 20ca9086030966d75efa8593a7af8ba666aacb6a Mon Sep 17 00:00:00 2001
From: Lucas Mazza
Date: Fri, 1 Nov 2013 10:51:30 -0200
Subject: [PATCH 019/122] Change snake_case usage to camelCase
The majority of the source code on this repo follows this convention
so the rest should look like the same.
---
src/rails.js | 18 +++++------
test/public/test/call-remote-callbacks.js | 6 ++--
test/public/test/call-remote.js | 38 +++++++++++------------
test/public/test/data-confirm.js | 22 ++++++-------
test/public/test/data-remote.js | 24 +++++++-------
test/public/test/settings.js | 24 +++++++-------
6 files changed, 66 insertions(+), 66 deletions(-)
diff --git a/src/rails.js b/src/rails.js
index 0786ab12..4659b03c 100644
--- a/src/rails.js
+++ b/src/rails.js
@@ -161,18 +161,18 @@
var href = rails.href(link),
method = link.data('method'),
target = link.attr('target'),
- csrf_token = $('meta[name=csrf-token]').attr('content'),
- csrf_param = $('meta[name=csrf-param]').attr('content'),
+ csrfToken = $('meta[name=csrf-token]').attr('content'),
+ csrfParam = $('meta[name=csrf-param]').attr('content'),
form = $(''),
- metadata_input = '';
+ metadataInput = '';
- if (csrf_param !== undefined && csrf_token !== undefined) {
- metadata_input += '';
+ if (csrfParam !== undefined && csrfToken !== undefined) {
+ metadataInput += '';
}
if (target) { form.attr('target', target); }
- form.hide().append(metadata_input).appendTo('body');
+ form.hide().append(metadataInput).appendTo('body');
form.submit();
},
@@ -385,9 +385,9 @@
$(function(){
// making sure that all forms have actual up-to-date token(cached forms contain old one)
- var csrf_token = $('meta[name=csrf-token]').attr('content');
- var csrf_param = $('meta[name=csrf-param]').attr('content');
- $('form input[name="' + csrf_param + '"]').val(csrf_token);
+ var csrfToken = $('meta[name=csrf-token]').attr('content');
+ var csrfParam = $('meta[name=csrf-param]').attr('content');
+ $('form input[name="' + csrfParam + '"]').val(csrfToken);
});
}
diff --git a/test/public/test/call-remote-callbacks.js b/test/public/test/call-remote-callbacks.js
index 60bff422..b4c4c7c7 100644
--- a/test/public/test/call-remote-callbacks.js
+++ b/test/public/test/call-remote-callbacks.js
@@ -53,7 +53,7 @@ asyncTest('modifying data("type") with "ajax:before" requests new dataType in re
$('form[data-remote]').data('type','html')
.bind('ajax:before', function() {
var form = $(this);
- form.data('type','xml')
+ form.data('type','xml');
});
submit(function(form) {
@@ -67,7 +67,7 @@ asyncTest('setting data("cross-domain",true) with "ajax:before" uses new setting
$('form[data-remote]').data('cross-domain',false)
.bind('ajax:before', function() {
var form = $(this);
- form.data('cross-domain',true)
+ form.data('cross-domain',true);
});
submit(function(form) {
@@ -94,7 +94,7 @@ asyncTest('setting data("with-credentials",true) with "ajax:before" uses new set
asyncTest('stopping the "ajax:beforeSend" event aborts the request', 1, function() {
submit(function(form) {
form.bind('ajax:beforeSend', function() {
- ok(true, 'aborting request in ajax:beforeSend')
+ ok(true, 'aborting request in ajax:beforeSend');
return false;
});
form.unbind('ajax:complete').bind('ajax:complete', function() {
diff --git a/test/public/test/call-remote.js b/test/public/test/call-remote.js
index ef998a8b..d78ce565 100644
--- a/test/public/test/call-remote.js
+++ b/test/public/test/call-remote.js
@@ -1,6 +1,6 @@
(function(){
-function build_form(attrs) {
+function buildForm(attrs) {
attrs = $.extend({ action: '/echo', 'data-remote': 'true' }, attrs);
$('#qunit-fixture').append($('', attrs))
@@ -17,47 +17,47 @@ function submit(fn) {
}
asyncTest('form method is read from "method" and not from "data-method"', 1, function() {
- build_form({ method: 'post', 'data-method': 'get' });
+ buildForm({ method: 'post', 'data-method': 'get' });
submit(function(e, data, status, xhr) {
- App.assert_post_request(data);
+ App.assertPostRequest(data);
});
});
asyncTest('form method is not read from "data-method" attribute in case of missing "method"', 1, function() {
- build_form({ 'data-method': 'put' });
+ buildForm({ 'data-method': 'put' });
submit(function(e, data, status, xhr) {
- App.assert_get_request(data);
+ App.assertGetRequest(data);
});
});
asyncTest('form default method is GET', 1, function() {
- build_form();
+ buildForm();
submit(function(e, data, status, xhr) {
- App.assert_get_request(data);
+ App.assertGetRequest(data);
});
});
asyncTest('form url is picked up from "action"', 1, function() {
- build_form({ method: 'post' });
+ buildForm({ method: 'post' });
submit(function(e, data, status, xhr) {
- App.assert_request_path(data, '/echo');
+ App.assertRequestPath(data, '/echo');
});
});
asyncTest('form url is read from "action" not "href"', 1, function() {
- build_form({ method: 'post', href: '/echo2' });
+ buildForm({ method: 'post', href: '/echo2' });
submit(function(e, data, status, xhr) {
- App.assert_request_path(data, '/echo');
+ App.assertRequestPath(data, '/echo');
});
});
asyncTest('prefer JS, but accept any format', 1, function() {
- build_form({ method: 'post' });
+ buildForm({ method: 'post' });
submit(function(e, data, status, xhr) {
var accept = data.HTTP_ACCEPT;
@@ -66,7 +66,7 @@ asyncTest('prefer JS, but accept any format', 1, function() {
});
asyncTest('accept application/json if "data-type" is json', 1, function() {
- build_form({ method: 'post', 'data-type': 'json' });
+ buildForm({ method: 'post', 'data-type': 'json' });
submit(function(e, data, status, xhr) {
equal(data.HTTP_ACCEPT, 'application/json, text/javascript, */*; q=0.01');
@@ -75,7 +75,7 @@ asyncTest('accept application/json if "data-type" is json', 1, function() {
asyncTest('allow empty "data-remote" attribute', 1, function() {
var form = $('#qunit-fixture').append($('')).find('form');
-
+
submit(function() {
ok(true, 'form with empty "data-remote" attribute is also allowed');
});
@@ -84,7 +84,7 @@ asyncTest('allow empty "data-remote" attribute', 1, function() {
asyncTest('allow empty form "action"', 1, function() {
var currentLocation, ajaxLocation;
- build_form({ action: '' });
+ buildForm({ action: '' });
$('#qunit-fixture').find('form')
.bind('ajax:beforeSend', function(e, xhr, settings) {
@@ -114,7 +114,7 @@ asyncTest('allow empty form "action"', 1, function() {
});
asyncTest('sends CSRF token in custom header', 1, function() {
- build_form({ method: 'post' });
+ buildForm({ method: 'post' });
$('#qunit-fixture').append('');
submit(function(e, data, status, xhr) {
@@ -123,7 +123,7 @@ asyncTest('sends CSRF token in custom header', 1, function() {
});
asyncTest('does not send CSRF token in custom header if crossDomain', 1, function() {
- build_form({ 'data-cross-domain': 'true' });
+ buildForm({ 'data-cross-domain': 'true' });
$('#qunit-fixture').append('');
// Manually set request header to be XHR, since setting crossDomain: true in .ajax()
@@ -141,7 +141,7 @@ asyncTest('does not send CSRF token in custom header if crossDomain', 1, functio
asyncTest('intelligently guesses crossDomain behavior when target URL is a different domain', 1, function(e, xhr) {
// Don't set data-cross-domain here, just set action to be a different domain than localhost
- build_form({ action: 'http://www.alfajango.com' });
+ buildForm({ action: 'http://www.alfajango.com' });
$('#qunit-fixture').append('');
$('#qunit-fixture').find('form')
@@ -158,7 +158,7 @@ asyncTest('intelligently guesses crossDomain behavior when target URL is a diffe
});
asyncTest('does not set crossDomain if explicitly set to false on element', 1, function() {
- build_form({ action: 'http://www.alfajango.com', 'data-cross-domain': false });
+ buildForm({ action: 'http://www.alfajango.com', 'data-cross-domain': false });
$('#qunit-fixture').append('');
$('#qunit-fixture').find('form')
diff --git a/test/public/test/data-confirm.js b/test/public/test/data-confirm.js
index 68784b84..50735e17 100644
--- a/test/public/test/data-confirm.js
+++ b/test/public/test/data-confirm.js
@@ -21,13 +21,13 @@ asyncTest('clicking on a link with data-confirm attribute. Confirm yes.', 6, fun
$('a[data-confirm]')
.bind('confirm:complete', function(e, data) {
- App.assert_callback_invoked('confirm:complete');
+ App.assertCallbackInvoked('confirm:complete');
ok(data == true, 'confirm:complete passes in confirm answer (true)');
})
- .bind('ajax:success', function(e, data, status, xhr) {
- App.assert_callback_invoked('ajax:success');
- App.assert_request_path(data, '/echo');
- App.assert_get_request(data);
+ .bind('ajax:success', function(e, data, status, xhr) {
+ App.assertCallbackInvoked('ajax:success');
+ App.assertRequestPath(data, '/echo');
+ App.assertGetRequest(data);
equal(message, 'Are you absolutely sure?');
start();
@@ -42,11 +42,11 @@ asyncTest('clicking on a link with data-confirm attribute. Confirm No.', 3, func
$('a[data-confirm]')
.bind('confirm:complete', function(e, data) {
- App.assert_callback_invoked('confirm:complete');
+ App.assertCallbackInvoked('confirm:complete');
ok(data == false, 'confirm:complete passes in confirm answer (false)');
})
.bind('ajax:beforeSend', function(e, data, status, xhr) {
- App.assert_callback_not_invoked('ajax:beforeSend');
+ App.assertCallbackNotInvoked('ajax:beforeSend');
})
.trigger('click');
@@ -65,11 +65,11 @@ asyncTest('binding to confirm event and returning false', 1, function() {
$('a[data-confirm]')
.bind('confirm', function() {
- App.assert_callback_invoked('confirm');
+ App.assertCallbackInvoked('confirm');
return false;
})
.bind('confirm:complete', function() {
- App.assert_callback_not_invoked('confirm:complete')
+ App.assertCallbackNotInvoked('confirm:complete');
})
.trigger('click');
@@ -87,11 +87,11 @@ asyncTest('binding to confirm:complete event and returning false', 2, function()
$('a[data-confirm]')
.bind('confirm:complete', function() {
- App.assert_callback_invoked('confirm:complete');
+ App.assertCallbackInvoked('confirm:complete');
return false;
})
.bind('ajax:beforeSend', function() {
- App.assert_callback_not_invoked('ajax:beforeSend');
+ App.assertCallbackNotInvoked('ajax:beforeSend');
})
.trigger('click');
diff --git a/test/public/test/data-remote.js b/test/public/test/data-remote.js
index 3f5c551c..f8c6b2a8 100644
--- a/test/public/test/data-remote.js
+++ b/test/public/test/data-remote.js
@@ -74,11 +74,11 @@ asyncTest('ctrl-clicking on a link still fires ajax for non-GET links and for li
asyncTest('clicking on a link with data-remote attribute', 5, function() {
$('a[data-remote]')
.bind('ajax:success', function(e, data, status, xhr) {
- App.assert_callback_invoked('ajax:success');
- App.assert_request_path(data, '/echo');
+ App.assertCallbackInvoked('ajax:success');
+ App.assertRequestPath(data, '/echo');
equal(data.params.data1, 'value1', 'ajax arguments should have key data1 with right value');
equal(data.params.data2, 'value2', 'ajax arguments should have key data2 with right value');
- App.assert_get_request(data);
+ App.assertGetRequest(data);
})
.bind('ajax:complete', function() { start() })
.trigger('click');
@@ -87,11 +87,11 @@ asyncTest('clicking on a link with data-remote attribute', 5, function() {
asyncTest('clicking on a button with data-remote attribute', 5, function() {
$('button[data-remote]')
.bind('ajax:success', function(e, data, status, xhr) {
- App.assert_callback_invoked('ajax:success');
- App.assert_request_path(data, '/echo');
+ App.assertCallbackInvoked('ajax:success');
+ App.assertRequestPath(data, '/echo');
equal(data.params.data1, 'value1', 'ajax arguments should have key data1 with right value');
equal(data.params.data2, 'value2', 'ajax arguments should have key data2 with right value');
- App.assert_get_request(data);
+ App.assertGetRequest(data);
})
.bind('ajax:complete', function() { start() })
.trigger('click');
@@ -112,11 +112,11 @@ asyncTest('changing a select option with data-remote attribute', 5, function() {
$('select[data-remote]')
.bind('ajax:success', function(e, data, status, xhr) {
- App.assert_callback_invoked('ajax:success');
- App.assert_request_path(data, '/echo');
+ App.assertCallbackInvoked('ajax:success');
+ App.assertRequestPath(data, '/echo');
equal(data.params.user_data, 'optionValue2', 'ajax arguments should have key term with right value');
equal(data.params.data1, 'value1', 'ajax arguments should have key data1 with right value');
- App.assert_get_request(data);
+ App.assertGetRequest(data);
})
.bind('ajax:complete', function() { start() })
.val('optionValue2')
@@ -126,10 +126,10 @@ asyncTest('changing a select option with data-remote attribute', 5, function() {
asyncTest('submitting form with data-remote attribute', 4, function() {
$('form[data-remote]')
.bind('ajax:success', function(e, data, status, xhr) {
- App.assert_callback_invoked('ajax:success');
- App.assert_request_path(data, '/echo');
+ App.assertCallbackInvoked('ajax:success');
+ App.assertRequestPath(data, '/echo');
equal(data.params.user_name, 'john', 'ajax arguments should have key user_name with right value');
- App.assert_post_request(data);
+ App.assertPostRequest(data);
})
.bind('ajax:complete', function() { start() })
.trigger('submit');
diff --git a/test/public/test/settings.js b/test/public/test/settings.js
index e23bf7ed..1eddc251 100644
--- a/test/public/test/settings.js
+++ b/test/public/test/settings.js
@@ -1,23 +1,23 @@
var App = App || {};
-App.assert_callback_invoked = function(callback_name) {
- ok(true, callback_name + ' callback should have been invoked');
+App.assertCallbackInvoked = function(callbackName) {
+ ok(true, callbackName + ' callback should have been invoked');
};
-App.assert_callback_not_invoked = function(callback_name) {
- ok(false, callback_name + ' callback should not have been invoked');
+App.assertCallbackNotInvoked = function(callbackName) {
+ ok(false, callbackName + ' callback should not have been invoked');
};
-App.assert_get_request = function(request_env){
- equal(request_env['REQUEST_METHOD'], 'GET', 'request type should be GET');
+App.assertGetRequest = function(requestEnv){
+ equal(requestEnv['REQUEST_METHOD'], 'GET', 'request type should be GET');
};
-App.assert_post_request = function(request_env){
- equal(request_env['REQUEST_METHOD'], 'POST', 'request type should be POST');
+App.assertPostRequest = function(requestEnv){
+ equal(requestEnv['REQUEST_METHOD'], 'POST', 'request type should be POST');
};
-App.assert_request_path = function(request_env, path) {
- equal(request_env['PATH_INFO'], path, 'request should be sent to right url');
+App.assertRequestPath = function(requestEnv, path) {
+ equal(requestEnv['PATH_INFO'], path, 'request should be sent to right url');
};
// hijacks normal form submit; lets it submit to an iframe to prevent
@@ -27,10 +27,10 @@ $(document).bind('submit', function(e) {
var form = $(e.target), action = form.attr('action'),
name = 'form-frame' + jQuery.guid++,
iframe = $('