From 9c8fc791a1e6b370ac53c5071ae5008432734968 Mon Sep 17 00:00:00 2001
From: Steve Schwartz
Date: Sat, 18 Aug 2012 02:36:25 -0400
Subject: [PATCH 001/155] Compare boolean values for non-blank file field to
fire ajax:aborted:file. Fixes #271.
---
src/rails.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/rails.js b/src/rails.js
index baac8b9a..af4bf18b 100644
--- a/src/rails.js
+++ b/src/rails.js
@@ -257,7 +257,7 @@
input = $(this);
valueToCheck = input.is(':checkbox,:radio') ? input.is(':checked') : input.val();
// If nonBlank and valueToCheck are both truthy, or nonBlank and valueToCheck are both falsey
- if (valueToCheck == !!nonBlank) {
+ if (!valueToCheck === !nonBlank) {
inputs = inputs.add(input);
}
});
From 8b147fb023f0d13deebea750e7e9827b6d3bc8ba Mon Sep 17 00:00:00 2001
From: Steve Schwartz
Date: Sat, 18 Aug 2012 02:36:56 -0400
Subject: [PATCH 002/155] Re-enable form fields if ajax:aborted:file handler
returns false.
---
src/rails.js | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/rails.js b/src/rails.js
index af4bf18b..8de1faaa 100644
--- a/src/rails.js
+++ b/src/rails.js
@@ -366,8 +366,15 @@
if (remote) {
if (nonBlankFileInputs) {
+ // 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);
- return rails.fire(form, 'ajax:aborted:file', [nonBlankFileInputs]);
+ var aborted = rails.fire(form, 'ajax:aborted:file', [nonBlankFileInputs]);
+
+ // re-enable form elements if event bindings return false (canceling normal form submission)
+ if (!aborted) { setTimeout(function(){ rails.enableFormElements(form); }, 13); }
+
+ return aborted;
}
// If browser does not support submit bubbling, then this live-binding will be called before direct
From 688ffdceef5308396b9555492b0f3667ec3507d5 Mon Sep 17 00:00:00 2001
From: Steve Schwartz
Date: Thu, 6 Sep 2012 19:30:37 -0400
Subject: [PATCH 003/155] Only require one required radio input in set to be
checked.
---
src/rails.js | 11 +++++++++--
test/public/test/call-remote-callbacks.js | 20 ++++++++++++++++++++
2 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/src/rails.js b/src/rails.js
index 8de1faaa..0a7cf58c 100644
--- a/src/rails.js
+++ b/src/rails.js
@@ -252,12 +252,19 @@
// 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';
- form.find(selector).each(function() {
+ selector = specifiedSelector || 'input,textarea',
+ $allInputs = form.find(selector);
+ $allInputs.each(function() {
input = $(this);
valueToCheck = input.is(':checkbox,:radio') ? input.is(':checked') : input.val();
// If nonBlank and valueToCheck are both truthy, or nonBlank and valueToCheck are both falsey
if (!valueToCheck === !nonBlank) {
+
+ // Don't count unchecked required radio if other radio with same name is checked
+ if (input.is(':radio') && $allInputs.filter('input:radio:checked[name="' + input.attr('name') + '"]').length) {
+ return true; // Skip to next input
+ }
+
inputs = inputs.add(input);
}
});
diff --git a/test/public/test/call-remote-callbacks.js b/test/public/test/call-remote-callbacks.js
index adb5a86c..ecba5013 100644
--- a/test/public/test/call-remote-callbacks.js
+++ b/test/public/test/call-remote-callbacks.js
@@ -234,6 +234,26 @@ asyncTest('unchecked required radio should abort form submission', 1, function()
}, 13);
});
+asyncTest('required radio should only require one to be checked', 1, function() {
+ var form = $('form[data-remote]')
+ .append($(''))
+ .append($(''))
+ .removeAttr('data-remote')
+ .bind('iframe:loading', function() {
+ ok(true, 'form should get submitted');
+ })
+ .bind('ujs:everythingStopped', function() {
+ ok(false, 'ujs:everythingStopped should not run');
+ })
+ .find('#checkme').prop('checked', true)
+ .end()
+ .trigger('submit');
+
+ setTimeout(function() {
+ start();
+ }, 13);
+});
+
function skipIt() {
// This test cannot work due to the security feature in browsers which makes the value
// attribute of file input fields readonly, so it cannot be set with default value.
From faeb0ad734ff6867149b8522f9a29081734442e6 Mon Sep 17 00:00:00 2001
From: Steve Schwartz
Date: Thu, 6 Sep 2012 19:32:20 -0400
Subject: [PATCH 004/155] Added support for jquery 1.8.1
---
test/server.rb | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/test/server.rb b/test/server.rb
index b76864f6..fb129c14 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 ].freeze
+JQUERY_VERSIONS = %w[ 1.7 1.7.1 1.7.2 1.8.0 1.8.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.8.0'
+ params[:version] ||= '1.8.1'
params[:cdn] ||= 'jquery'
erb :index
end
From 015061adccb2bfff9232b902e2a15b37868213bf Mon Sep 17 00:00:00 2001
From: Steve Schwartz
Date: Thu, 6 Sep 2012 19:34:53 -0400
Subject: [PATCH 005/155] Updated changelog and readme
---
CHANGELOG.md | 1 +
README.md | 4 ++--
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9a46db32..cfff7571 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -38,3 +38,4 @@ to newest):
ajax requests
- [`4382f580766fcdd1`](https://github.com/rails/jquery-ujs/commit/4382f580766fcdd14201c204f43ca5aeb0928501) added support for `data-with-credentials`
- [`12da9fc2f175c8e4`](https://github.com/rails/jquery-ujs/commit/12da9fc2f175c8e445413b15cf6b685deb271d6e) added support for jQuery 1.8.0, removed support for jquery 1.6.x
+- [`faeb0ad734ff6867`](https://github.com/rails/jquery-ujs/commit/faeb0ad734ff6867149b8522f9a29081734442e6) added support for jQuery 1.8.1
diff --git a/README.md b/README.md
index 62426ffe..db3dff79 100644
--- a/README.md
+++ b/README.md
@@ -15,7 +15,7 @@ Full [documentation is on the wiki][wiki], including the [list of published Ajax
Requirements
------------
-- [jQuery 1.7.x or 1.8.0][jquery];
+- [jQuery 1.7.x or 1.8.x][jquery];
- HTML5 doctype (optional).
If you don't use HTML5, adding "data" attributes to your HTML4 or XHTML pages might make them fail [W3C markup validation][validator]. However, this shouldn't create any issues for web browsers or other user agents.
@@ -26,7 +26,7 @@ Installation
For automated installation in Rails, use the "jquery-rails" gem. Place this in your Gemfile:
```ruby
-gem 'jquery-rails', '~> 2.0'
+gem 'jquery-rails', '~> 2.1'
```
And run:
From bddff6a677edc54f00e48bde740b0b22d68deef6 Mon Sep 17 00:00:00 2001
From: Steve Schwartz
Date: Thu, 6 Sep 2012 19:36:49 -0400
Subject: [PATCH 006/155] Change var naming convention for consistency
---
src/rails.js | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/rails.js b/src/rails.js
index 0a7cf58c..df9dc862 100644
--- a/src/rails.js
+++ b/src/rails.js
@@ -253,15 +253,16 @@
blankInputs: function(form, specifiedSelector, nonBlank) {
var inputs = $(), input, valueToCheck,
selector = specifiedSelector || 'input,textarea',
- $allInputs = form.find(selector);
- $allInputs.each(function() {
+ allInputs = form.find(selector);
+
+ allInputs.each(function() {
input = $(this);
valueToCheck = input.is(':checkbox,:radio') ? input.is(':checked') : input.val();
// If nonBlank and valueToCheck are both truthy, or nonBlank and valueToCheck are both falsey
if (!valueToCheck === !nonBlank) {
// Don't count unchecked required radio if other radio with same name is checked
- if (input.is(':radio') && $allInputs.filter('input:radio:checked[name="' + input.attr('name') + '"]').length) {
+ if (input.is(':radio') && allInputs.filter('input:radio:checked[name="' + input.attr('name') + '"]').length) {
return true; // Skip to next input
}
From b6dae4ef4a2d031a222627c7f6a4284602f99160 Mon Sep 17 00:00:00 2001
From: Steve Schwartz
Date: Mon, 24 Sep 2012 11:02:09 -0400
Subject: [PATCH 007/155] Added support for jquery 1.8.2
---
test/server.rb | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/test/server.rb b/test/server.rb
index fb129c14..afa1a19f 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 ].freeze
+JQUERY_VERSIONS = %w[ 1.7 1.7.1 1.7.2 1.8.0 1.8.1 1.8.2 ].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.8.1'
+ params[:version] ||= '1.8.2'
params[:cdn] ||= 'jquery'
erb :index
end
From a59f28f0a7e68214985c1fb591ea6766125d45c8 Mon Sep 17 00:00:00 2001
From: Javier Julio
Date: Mon, 19 Nov 2012 15:30:18 -0500
Subject: [PATCH 008/155] Replace deprecated input:file with input[type=file]
selector.
---
src/rails.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/rails.js b/src/rails.js
index df9dc862..ac4f7dc0 100644
--- a/src/rails.js
+++ b/src/rails.js
@@ -82,7 +82,7 @@
requiredInputSelector: 'input[name][required]:not([disabled]),textarea[name][required]:not([disabled])',
// Form file input elements
- fileInputSelector: 'input:file',
+ fileInputSelector: 'input[type=file]',
// Link onClick disable selector with possible reenable after remote submission
linkDisableSelector: 'a[data-disable-with]',
From 3014cd54a178c23fb2ecfe9c55ef258707988cb4 Mon Sep 17 00:00:00 2001
From: Javier Julio
Date: Mon, 19 Nov 2012 15:40:50 -0500
Subject: [PATCH 009/155] Replace deprecated :checkbox and :radio with
[type=checkbox] and [type=radio] selectors.
---
src/rails.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/rails.js b/src/rails.js
index ac4f7dc0..ec8d5d95 100644
--- a/src/rails.js
+++ b/src/rails.js
@@ -257,12 +257,12 @@
allInputs.each(function() {
input = $(this);
- valueToCheck = input.is(':checkbox,:radio') ? input.is(':checked') : input.val();
+ valueToCheck = input.is('input[type=checkbox],input[type=radio]') ? input.is(':checked') : input.val();
// If nonBlank and valueToCheck are both truthy, or nonBlank and valueToCheck are both falsey
if (!valueToCheck === !nonBlank) {
// Don't count unchecked required radio if other radio with same name is checked
- if (input.is(':radio') && allInputs.filter('input:radio:checked[name="' + input.attr('name') + '"]').length) {
+ if (input.is('input[type=radio]') && allInputs.filter('input[type=radio]:checked[name="' + input.attr('name') + '"]').length) {
return true; // Skip to next input
}
From b1c482f55c8674168720c1f886af63799f7eb809 Mon Sep 17 00:00:00 2001
From: Edgars Beigarts
Date: Thu, 3 Jan 2013 11:26:49 +0200
Subject: [PATCH 010/155] Avoid setting withCredentials to null. Fixes #295.
Fixes #279.
---
src/rails.js | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/src/rails.js b/src/rails.js
index df9dc862..05e369ac 100644
--- a/src/rails.js
+++ b/src/rails.js
@@ -164,11 +164,17 @@
error: function(xhr, status, error) {
element.trigger('ajax:error', [xhr, status, error]);
},
- xhrFields: {
- withCredentials: withCredentials
- },
crossDomain: crossDomain
};
+
+ // There is no withCredentials for IE6-8 when
+ // "Enable native XMLHTTP support" is disabled
+ if (withCredentials) {
+ options.xhrFields = {
+ withCredentials: withCredentials
+ };
+ }
+
// Only pass url to `ajax` options if not blank
if (url) { options.url = url; }
From 6927b82cadf3146c2b9ae3028e9b197af64011ca Mon Sep 17 00:00:00 2001
From: Steve Schwartz
Date: Fri, 18 Jan 2013 15:27:52 -0500
Subject: [PATCH 011/155] Added support for jquery 1.8.3
---
test/server.rb | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/test/server.rb b/test/server.rb
index afa1a19f..a9abe258 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 ].freeze
+JQUERY_VERSIONS = %w[ 1.7 1.7.1 1.7.2 1.8.0 1.8.1 1.8.2 1.8.3 ].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.8.2'
+ params[:version] ||= '1.8.3'
params[:cdn] ||= 'jquery'
erb :index
end
From f32a303d6baf8013320cba2f8b350c71266fdfc5 Mon Sep 17 00:00:00 2001
From: Steve Schwartz
Date: Fri, 18 Jan 2013 16:24:45 -0500
Subject: [PATCH 012/155] Added jquery 1.9.2 to test suite
---
test/server.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/test/server.rb b/test/server.rb
index a9abe258..0bf7052c 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 ].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 ].freeze
use Rack::Static, :urls => ["/src"], :root => File.expand_path('..', settings.root)
From 212e71ee3ae2d75b8a605565729e3fe2bb8b702c Mon Sep 17 00:00:00 2001
From: Steve Schwartz
Date: Fri, 18 Jan 2013 16:25:29 -0500
Subject: [PATCH 013/155] Fixed issue with binding to 'iframe:loaded' event on
form with jquery 1.9
---
test/public/test/data-disable.js | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/test/public/test/data-disable.js b/test/public/test/data-disable.js
index d80a5102..29faa888 100644
--- a/test/public/test/data-disable.js
+++ b/test/public/test/data-disable.js
@@ -21,6 +21,9 @@ module('data-disable', {
href: '/echo',
'data-disable-with': 'clicking...'
}));
+ },
+ teardown: function() {
+ $(document).unbind('iframe:loaded');
}
});
@@ -82,14 +85,15 @@ asyncTest('form input[type=submit][data-disable-with] disables', 6, function(){
checkEnabledState(input, 'Submit');
// WEEIRDD: attaching this handler makes the test work in IE7
- form.bind('iframe:loading', function(e, form) {});
+ $(document).bind('iframe:loading', function(e, form) {});
- form.bind('iframe:loaded', function(e, data) {
+ $(document).bind('iframe:loaded', function(e, data) {
setTimeout(function() {
checkDisabledState(input, 'submitting ...');
start();
}, 30);
- }).trigger('submit');
+ });
+ form.trigger('submit');
setTimeout(function() {
checkDisabledState(input, 'submitting ...');
From f22f74aae4fff766b321fc34244ff4acd61ddfa2 Mon Sep 17 00:00:00 2001
From: Steve Schwartz
Date: Fri, 18 Jan 2013 16:36:16 -0500
Subject: [PATCH 014/155] Removed all instances of .live() and .die() in docs
and test suite
---
src/rails.js | 4 +--
test/public/test/call-remote-callbacks.js | 32 +++++++++++------------
test/public/test/data-disable.js | 8 +++---
3 files changed, 23 insertions(+), 21 deletions(-)
diff --git a/src/rails.js b/src/rails.js
index df9dc862..087d5eb6 100644
--- a/src/rails.js
+++ b/src/rails.js
@@ -15,7 +15,7 @@
* The `ajax:aborted:file` event allows you to bind your own handler to process the form submission however you wish.
*
* Ex:
- * $('form').live('ajax:aborted:file', function(event, elements){
+ * $('form').bind('ajax:aborted:file', function(event, elements){
* // Implement own remote file-transfer handler here for non-blank file inputs passed in `elements`.
* // Returning false in this handler tells rails.js to disallow standard form submission
* return false;
@@ -38,7 +38,7 @@
* get fired in Opera. This event is what causes other browsers to exhibit the same submit-aborting behavior.
*
* Ex:
- * $('form').live('ajax:aborted:required', function(event, elements){
+ * $('form').bind('ajax:aborted:required', function(event, elements){
* // Returning false in this handler tells rails.js to submit the form anyway.
* // The blank required inputs are passed to this function in `elements`.
* return ! confirm("Would you like to submit the form with missing info?");
diff --git a/test/public/test/call-remote-callbacks.js b/test/public/test/call-remote-callbacks.js
index ecba5013..7536487c 100644
--- a/test/public/test/call-remote-callbacks.js
+++ b/test/public/test/call-remote-callbacks.js
@@ -7,10 +7,10 @@ module('call-remote-callbacks', {
}));
},
teardown: function() {
- $('form[data-remote]').die('ajax:beforeSend');
- $('form[data-remote]').die('ajax:before');
- $('form[data-remote]').die('ajax:complete');
- $('form[data-remote]').die('ajax:success');
+ $(document).undelegate('form[data-remote]', 'ajax:beforeSend');
+ $(document).undelegate('form[data-remote]', 'ajax:before');
+ $(document).undelegate('form[data-remote]', 'ajax:complete');
+ $(document).undelegate('form[data-remote]', 'ajax:success');
}
});
@@ -29,7 +29,7 @@ asyncTest('modifying form fields with "ajax:before" sends modified data in reque
$('form[data-remote]')
.append($(''))
.append($(''))
- .live('ajax:before', function() {
+ .bind('ajax:before', function() {
var form = $(this);
form
.append($('',{name: 'other_user_name',value: 'jonathan'}))
@@ -49,7 +49,7 @@ asyncTest('modifying form fields with "ajax:before" sends modified data in reque
asyncTest('modifying data("type") with "ajax:before" requests new dataType in request', 2, function(){
$('form[data-remote]').data('type','html')
- .live('ajax:before', function() {
+ .bind('ajax:before', function() {
var form = $(this);
form.data('type','xml')
});
@@ -63,7 +63,7 @@ asyncTest('modifying data("type") with "ajax:before" requests new dataType in re
asyncTest('setting data("cross-domain",true) with "ajax:before" uses new setting in request', 2, function(){
$('form[data-remote]').data('cross-domain',false)
- .live('ajax:before', function() {
+ .bind('ajax:before', function() {
var form = $(this);
form.data('cross-domain',true)
});
@@ -77,7 +77,7 @@ asyncTest('setting data("cross-domain",true) with "ajax:before" uses new setting
asyncTest('setting data("with-credentials",true) with "ajax:before" uses new setting in request', 2, function(){
$('form[data-remote]').data('with-credentials',false)
- .live('ajax:before', function() {
+ .bind('ajax:before', function() {
var form = $(this);
form.data('with-credentials',true);
});
@@ -304,7 +304,7 @@ function skipIt() {
}
asyncTest('"ajax:beforeSend" can be observed and stopped with event delegation', 1, function() {
- $('form[data-remote]').live('ajax:beforeSend', function() {
+ $(document).delegate('form[data-remote]', 'ajax:beforeSend', function() {
ok(true, 'ajax:beforeSend observed with event delegation');
return false;
});
@@ -353,18 +353,18 @@ asyncTest('"ajax:beforeSend", "ajax:error" and "ajax:complete" are triggered on
});
// IF THIS TEST IS FAILING, TRY INCREASING THE TIMEOUT AT THE BOTTOM TO > 100
-asyncTest('binding to ajax callbacks via .live() triggers handlers properly', 3, function() {
- $('form[data-remote]')
- .live('ajax:beforeSend', function() {
+asyncTest('binding to ajax callbacks via .delegate() triggers handlers properly', 3, function() {
+ $(document)
+ .delegate('form[data-remote]', 'ajax:beforeSend', function() {
ok(true, 'ajax:beforeSend handler is triggered');
})
- .live('ajax:complete', function() {
+ .delegate('form[data-remote]', 'ajax:complete', function() {
ok(true, 'ajax:complete handler is triggered');
})
- .live('ajax:success', function() {
+ .delegate('form[data-remote]', 'ajax:success', function() {
ok(true, 'ajax:success handler is triggered');
- })
- .trigger('submit');
+ });
+ $('form[data-remote]').trigger('submit');
setTimeout(function() {
start();
diff --git a/test/public/test/data-disable.js b/test/public/test/data-disable.js
index 29faa888..241c1583 100644
--- a/test/public/test/data-disable.js
+++ b/test/public/test/data-disable.js
@@ -162,9 +162,11 @@ asyncTest('a[data-remote][data-disable-with] disables and re-enables', 6, functi
.bind('ajax:beforeSend', function() {
checkDisabledState(link, 'clicking...');
})
- .live('ajax:complete', function() {
- checkEnabledState(link, 'Click me');
- start();
+ .bind('ajax:complete', function() {
+ setTimeout( function() {
+ checkEnabledState(link, 'Click me');
+ start();
+ }, 15);
})
.trigger('click');
});
From 8409edbdc937abe297f0cb972ab73fe7a57fdcd1 Mon Sep 17 00:00:00 2001
From: Steve Schwartz
Date: Fri, 18 Jan 2013 17:12:35 -0500
Subject: [PATCH 015/155] Rebound instances of ajaxStop to document, where
jquery 1.9 now only fires them
---
test/public/test/call-remote-callbacks.js | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/test/public/test/call-remote-callbacks.js b/test/public/test/call-remote-callbacks.js
index 7536487c..3b0ecade 100644
--- a/test/public/test/call-remote-callbacks.js
+++ b/test/public/test/call-remote-callbacks.js
@@ -11,6 +11,7 @@ module('call-remote-callbacks', {
$(document).undelegate('form[data-remote]', 'ajax:before');
$(document).undelegate('form[data-remote]', 'ajax:complete');
$(document).undelegate('form[data-remote]', 'ajax:success');
+ $(document).unbind('ajaxStop');
}
});
@@ -101,7 +102,7 @@ asyncTest('stopping the "ajax:beforeSend" event aborts the request', 1, function
form.bind('ajax:error', function(e, xhr, status, error) {
ok(false, 'ajax:error should not run');
});
- form.bind('ajaxStop', function() {
+ $(document).bind('ajaxStop', function() {
start();
});
});
@@ -313,7 +314,7 @@ asyncTest('"ajax:beforeSend" can be observed and stopped with event delegation',
form.unbind('ajax:complete').bind('ajax:complete', function() {
ok(false, 'ajax:complete should not run');
});
- form.bind('ajaxStop', function() {
+ $(document).bind('ajaxStop', function() {
start();
});
});
From a2caea88ec87e1cc0d064cc669d8f631954abe21 Mon Sep 17 00:00:00 2001
From: Steve Schwartz
Date: Fri, 18 Jan 2013 17:19:39 -0500
Subject: [PATCH 016/155] More iframe:loading fixes for jquery 1.9
---
test/public/test/call-remote-callbacks.js | 22 +++++++++++++---------
test/public/test/data-method.js | 14 +++++++++-----
2 files changed, 22 insertions(+), 14 deletions(-)
diff --git a/test/public/test/call-remote-callbacks.js b/test/public/test/call-remote-callbacks.js
index 3b0ecade..60bff422 100644
--- a/test/public/test/call-remote-callbacks.js
+++ b/test/public/test/call-remote-callbacks.js
@@ -12,6 +12,7 @@ module('call-remote-callbacks', {
$(document).undelegate('form[data-remote]', 'ajax:complete');
$(document).undelegate('form[data-remote]', 'ajax:success');
$(document).unbind('ajaxStop');
+ $(document).unbind('iframe:loading');
}
});
@@ -109,15 +110,16 @@ asyncTest('stopping the "ajax:beforeSend" event aborts the request', 1, function
});
asyncTest('blank required form input field should abort request and trigger "ajax:aborted:required" event', 5, function() {
+ $(document).bind('iframe:loading', function() {
+ ok(false, 'form should not get submitted');
+ });
+
var form = $('form[data-remote]')
.append($(''))
.append($(''))
.bind('ajax:beforeSend', function() {
ok(false, 'ajax:beforeSend should not run');
})
- .bind('iframe:loading', function() {
- ok(false, 'form should not get submitted');
- })
.bind('ajax:aborted:required', function(e,data){
ok(data.length == 2, 'ajax:aborted:required event is passed all blank required inputs (jQuery objects)');
ok(data.first().is('input[name="user_name"]') , 'ajax:aborted:required adds blank required input to data');
@@ -192,13 +194,14 @@ asyncTest('form should be submitted with blank required fields if it has the "no
});
asyncTest('blank required form input for non-remote form with "novalidate" attribute should not abort normal submission', 1, function() {
+ $(document).bind('iframe:loading', function() {
+ ok(true, 'form should get submitted');
+ });
+
var form = $('form[data-remote]')
.append($(''))
.removeAttr('data-remote')
.attr("novalidate","novalidate")
- .bind('iframe:loading', function() {
- ok(true, 'form should get submitted');
- })
.trigger('submit');
setTimeout(function() {
@@ -236,13 +239,14 @@ asyncTest('unchecked required radio should abort form submission', 1, function()
});
asyncTest('required radio should only require one to be checked', 1, function() {
+ $(document).bind('iframe:loading', function() {
+ ok(true, 'form should get submitted');
+ });
+
var form = $('form[data-remote]')
.append($(''))
.append($(''))
.removeAttr('data-remote')
- .bind('iframe:loading', function() {
- ok(true, 'form should get submitted');
- })
.bind('ujs:everythingStopped', function() {
ok(false, 'ujs:everythingStopped should not run');
})
diff --git a/test/public/test/data-method.js b/test/public/test/data-method.js
index 40e99210..c4426624 100644
--- a/test/public/test/data-method.js
+++ b/test/public/test/data-method.js
@@ -5,16 +5,20 @@ module('data-method', {
$('#qunit-fixture').append($('', {
href: '/echo', 'data-method': 'delete', text: 'destroy!'
}));
+ },
+ teardown: function() {
+ $(document).unbind('iframe:loaded');
}
});
function submit(fn, options) {
+ $(document).bind('iframe:loaded', function(e, data) {
+ fn(data);
+ start();
+ });
+
$('#qunit-fixture').find('a')
- .bind('iframe:loaded', function(e, data) {
- fn(data);
- start();
- })
- .trigger('click');
+ .trigger('click');
}
asyncTest('link with "data-method" set to "delete"', 3, function() {
From 22068f3913e3ca7e987c12a624f76dfce5ae7b96 Mon Sep 17 00:00:00 2001
From: Steve Schwartz
Date: Fri, 18 Jan 2013 19:03:07 -0500
Subject: [PATCH 017/155] Fixed click binding modifier test in IE
---
test/public/test/override.js | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/test/public/test/override.js b/test/public/test/override.js
index 92119ea2..6ce632d4 100644
--- a/test/public/test/override.js
+++ b/test/public/test/override.js
@@ -41,9 +41,11 @@ asyncTest("the getter for an element's href works normally if not overridden", 1
asyncTest("the event selector strings are overridable", 2, function() {
var documentClickBindings = $._data(document, 'events').click,
linkClickBinding = $.grep(documentClickBindings, function(a) {
- return a.selector.indexOf('a[data-remote]') != -1;
+ return a.selector && a.selector.indexOf('a[data-remote]') != -1;
})[0];
+ //var documentClickBindings = "", linkClickBinding = {selector: ""};
+
ok($.rails.linkClickSelector.indexOf(', a[data-custom-remote-link]') != -1, 'linkClickSelector contains custom selector');
ok(linkClickBinding.selector.indexOf(', a[data-custom-remote-link]') != -1, 'actual document binding contains custom selector');
From cc356656cc3edf1596fd685265187d2f75d1bc7c Mon Sep 17 00:00:00 2001
From: Steve Schwartz
Date: Fri, 18 Jan 2013 23:21:58 -0500
Subject: [PATCH 018/155] Official support for jquery 1.9.0
---
test/server.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/test/server.rb b/test/server.rb
index 0bf7052c..8a2412c9 100644
--- a/test/server.rb
+++ b/test/server.rb
@@ -48,7 +48,7 @@ def jquery_versions
end
get '/' do
- params[:version] ||= '1.8.3'
+ params[:version] ||= '1.9.0'
params[:cdn] ||= 'jquery'
erb :index
end
From fd9f043dae22c66e07cf9f470a77c3c458d40d31 Mon Sep 17 00:00:00 2001
From: Steve Schwartz
Date: Sat, 19 Jan 2013 12:18:56 -0500
Subject: [PATCH 019/155] Removed debugging comment from test suite.
---
test/public/test/override.js | 2 --
1 file changed, 2 deletions(-)
diff --git a/test/public/test/override.js b/test/public/test/override.js
index 6ce632d4..ba84b6dc 100644
--- a/test/public/test/override.js
+++ b/test/public/test/override.js
@@ -44,8 +44,6 @@ asyncTest("the event selector strings are overridable", 2, function() {
return a.selector && a.selector.indexOf('a[data-remote]') != -1;
})[0];
- //var documentClickBindings = "", linkClickBinding = {selector: ""};
-
ok($.rails.linkClickSelector.indexOf(', a[data-custom-remote-link]') != -1, 'linkClickSelector contains custom selector');
ok(linkClickBinding.selector.indexOf(', a[data-custom-remote-link]') != -1, 'actual document binding contains custom selector');
From f681221504a760d73acfe8cf76e1606e6a1e3202 Mon Sep 17 00:00:00 2001
From: Neeraj Singh
Date: Thu, 24 Jan 2013 00:34:39 -0500
Subject: [PATCH 020/155] jquery 1.6 is not being supported
---
src/rails.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/rails.js b/src/rails.js
index fd9415d4..fc33c2a1 100644
--- a/src/rails.js
+++ b/src/rails.js
@@ -3,7 +3,7 @@
/**
* Unobtrusive scripting adapter for jQuery
*
- * Requires jQuery 1.6.0 or later.
+ * Requires jQuery 1.7.0 or later.
* https://github.com/rails/jquery-ujs
* Uploading file using rails.js
From dff02f903822859a3b5021fadfb4b02b34ba8c55 Mon Sep 17 00:00:00 2001
From: Neeraj Singh
Date: Thu, 24 Jan 2013 00:45:42 -0500
Subject: [PATCH 021/155] moved the repo info closer to the top
---
src/rails.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/rails.js b/src/rails.js
index fc33c2a1..d9447713 100644
--- a/src/rails.js
+++ b/src/rails.js
@@ -2,10 +2,10 @@
/**
* Unobtrusive scripting adapter for jQuery
+ * https://github.com/rails/jquery-ujs
*
* Requires jQuery 1.7.0 or later.
- * https://github.com/rails/jquery-ujs
-
+ *
* Uploading file using rails.js
* =============================
*
From be8a59f60afc1c463bf9c13997d17c82fe123254 Mon Sep 17 00:00:00 2001
From: Neeraj Singh
Date: Thu, 24 Jan 2013 00:46:44 -0500
Subject: [PATCH 022/155] Added license information in the file. closes #292
---
src/rails.js | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/rails.js b/src/rails.js
index d9447713..17c2f539 100644
--- a/src/rails.js
+++ b/src/rails.js
@@ -6,6 +6,8 @@
*
* Requires jQuery 1.7.0 or later.
*
+ * Released under the MIT license
+ *
* Uploading file using rails.js
* =============================
*
From 0f094f7330da9dba0d15040cd31cd0fa9c6c808b Mon Sep 17 00:00:00 2001
From: Neeraj Singh
Date: Thu, 24 Jan 2013 00:49:39 -0500
Subject: [PATCH 023/155] moved instructions to wiki
https://github.com/rails/jquery-ujs/wiki/Uploading-file-using-rails.js
---
src/rails.js | 20 --------------------
1 file changed, 20 deletions(-)
diff --git a/src/rails.js b/src/rails.js
index 17c2f539..5e4b5126 100644
--- a/src/rails.js
+++ b/src/rails.js
@@ -8,26 +8,6 @@
*
* Released under the MIT license
*
- * Uploading file using rails.js
- * =============================
- *
- * By default, browsers do not allow files to be uploaded via AJAX. As a result, if there are any non-blank file fields
- * in the remote form, this adapter aborts the AJAX submission and allows the form to submit through standard means.
- *
- * The `ajax:aborted:file` event allows you to bind your own handler to process the form submission however you wish.
- *
- * Ex:
- * $('form').bind('ajax:aborted:file', function(event, elements){
- * // Implement own remote file-transfer handler here for non-blank file inputs passed in `elements`.
- * // Returning false in this handler tells rails.js to disallow standard form submission
- * return false;
- * });
- *
- * The `ajax:aborted:file` event is fired when a file-type input is detected with a non-blank value.
- *
- * Third-party tools can use this hook to detect when an AJAX file upload is attempted, and then use
- * techniques like the iframe method to upload the file instead.
- *
* Required fields in rails.js
* ===========================
*
From e96a1f6bc18561c31713742b4ab5418a184a854d Mon Sep 17 00:00:00 2001
From: Neeraj Singh
Date: Thu, 24 Jan 2013 00:52:13 -0500
Subject: [PATCH 024/155] moved instructions to wiki
https://github.com/rails/jquery-ujs/wiki/Required-fields-in-rails.js
---
src/rails.js | 17 -----------------
1 file changed, 17 deletions(-)
diff --git a/src/rails.js b/src/rails.js
index 5e4b5126..369ed9fe 100644
--- a/src/rails.js
+++ b/src/rails.js
@@ -8,23 +8,6 @@
*
* Released under the MIT license
*
- * Required fields in rails.js
- * ===========================
- *
- * If any blank required inputs (required="required") are detected in the remote form, the whole form submission
- * is canceled. Note that this is unlike file inputs, which still allow standard (non-AJAX) form submission.
- *
- * The `ajax:aborted:required` event allows you to bind your own handler to inform the user of blank required inputs.
- *
- * !! Note that Opera does not fire the form's submit event if there are blank required inputs, so this event may never
- * get fired in Opera. This event is what causes other browsers to exhibit the same submit-aborting behavior.
- *
- * Ex:
- * $('form').bind('ajax:aborted:required', function(event, elements){
- * // Returning false in this handler tells rails.js to submit the form anyway.
- * // The blank required inputs are passed to this function in `elements`.
- * return ! confirm("Would you like to submit the form with missing info?");
- * });
*/
// Cut down on the number if issues from people inadvertently including jquery_ujs twice
From 827b85f8b11a838bb3035fd79274f3203955dc43 Mon Sep 17 00:00:00 2001
From: Neeraj Singh
Date: Thu, 24 Jan 2013 01:00:27 -0500
Subject: [PATCH 025/155] Added missing var. closes #298
---
src/rails.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/rails.js b/src/rails.js
index 369ed9fe..f63fe049 100644
--- a/src/rails.js
+++ b/src/rails.js
@@ -391,8 +391,8 @@
$(function(){
// making sure that all forms have actual up-to-date token(cached forms contain old one)
- csrf_token = $('meta[name=csrf-token]').attr('content');
- csrf_param = $('meta[name=csrf-param]').attr('content');
+ 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);
});
}
From 1becac6b45762134835b33646e626b38a36b4df6 Mon Sep 17 00:00:00 2001
From: Neeraj Singh
Date: Thu, 24 Jan 2013 01:30:32 -0500
Subject: [PATCH 026/155] jquery 1.9 is also being supported
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index db3dff79..537eed7c 100644
--- a/README.md
+++ b/README.md
@@ -15,7 +15,7 @@ Full [documentation is on the wiki][wiki], including the [list of published Ajax
Requirements
------------
-- [jQuery 1.7.x or 1.8.x][jquery];
+- [jQuery 1.7.x or higher][jquery];
- HTML5 doctype (optional).
If you don't use HTML5, adding "data" attributes to your HTML4 or XHTML pages might make them fail [W3C markup validation][validator]. However, this shouldn't create any issues for web browsers or other user agents.
From 2f8ccdf26eac199a11aa1a893a8909bb4650d0fb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Trung=20L=C3=AA?=
Date: Wed, 6 Feb 2013 00:48:54 +1100
Subject: [PATCH 027/155] Support jQuery 1.9.1
---
test/server.rb | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/test/server.rb b/test/server.rb
index 8a2412c9..5ed58ec3 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 ].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 ].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.0'
+ params[:version] ||= '1.9.1'
params[:cdn] ||= 'jquery'
erb :index
end
From 35acdbd047c3069dffd6fa990fd7d61635a429f1 Mon Sep 17 00:00:00 2001
From: Neeraj Singh
Date: Tue, 5 Feb 2013 19:14:53 -0500
Subject: [PATCH 028/155] putting README on diet
---
README.md | 40 +---------------------------------------
1 file changed, 1 insertion(+), 39 deletions(-)
diff --git a/README.md b/README.md
index 537eed7c..f3b0d4f3 100644
--- a/README.md
+++ b/README.md
@@ -50,45 +50,7 @@ Choose to overwrite jquery_ujs.js if prompted.*
$ rails generate jquery:install
-
-### Manual installation (including Rails 2)
-
-[Download jQuery][jquery] and ["rails.js"][adapter] and place them in your "javascripts" directory.
-
-Configure the following in your application startup file (for Rails 3):
-
-```ruby
- config.action_view.javascript_expansions[:defaults] = %w(jquery rails)
-```
-
-Or create an initializer (for Rails 2):
-
-```ruby
-module ActionView::Helpers::AssetTagHelper
- remove_const :JAVASCRIPT_DEFAULT_SOURCES
- JAVASCRIPT_DEFAULT_SOURCES = %w(jquery.js rails.js)
-
- reset_javascript_include_default
-end
-```
-
-Now the template helper `javascript_include_tag :defaults` will generate SCRIPT tags to load jQuery and rails.js.
-
-For Rails 2, you will need to manually implement the `csrf_meta_tag` helper and include it inside the `` of your application layout.
-
-The `csrf_meta_tags` (Rails 3.1) and `csrf_meta_tag` (Rails 3.0) helpers generate two meta tags containing values necessary for the [cross-site request forgery protection][csrf] built into Rails. Here is how to implement that helper in Rails 2:
-
-```ruby
- # app/helpers/application_helper.rb
- def csrf_meta_tag
- if protect_against_forgery?
- out = %(\n)
- out << %()
- out % [ Rack::Utils.escape_html(request_forgery_protection_token),
- Rack::Utils.escape_html(form_authenticity_token) ]
- end
- end
-```
+c. For Rails 2.x and for manual installation follow [this wiki](https://github.com/rails/jquery-ujs/wiki/Manual-installing-and-Rails-2) .
[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"
[wiki]: https://github.com/rails/jquery-ujs/wiki
From e576b90e22270a80cc26e2227a794767523a9812 Mon Sep 17 00:00:00 2001
From: Neeraj Singh
Date: Tue, 5 Feb 2013 19:16:25 -0500
Subject: [PATCH 029/155] added instruction on README on how to run tests
---
README.md | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/README.md b/README.md
index f3b0d4f3..5abfd10a 100644
--- a/README.md
+++ b/README.md
@@ -52,6 +52,12 @@ Choose to overwrite jquery_ujs.js if prompted.*
c. For Rails 2.x and for manual installation follow [this wiki](https://github.com/rails/jquery-ujs/wiki/Manual-installing-and-Rails-2) .
+Requirements
+------------
+
+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"
[wiki]: https://github.com/rails/jquery-ujs/wiki
[events]: https://github.com/rails/jquery-ujs/wiki/ajax
From 5fa4791cb97461eec1063ab6ec13c1e91300e89b Mon Sep 17 00:00:00 2001
From: Neeraj Singh
Date: Tue, 5 Feb 2013 19:17:12 -0500
Subject: [PATCH 030/155] changed header to How to run tests
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 5abfd10a..758a1a20 100644
--- a/README.md
+++ b/README.md
@@ -52,7 +52,7 @@ Choose to overwrite jquery_ujs.js if prompted.*
c. For Rails 2.x and for manual installation follow [this wiki](https://github.com/rails/jquery-ujs/wiki/Manual-installing-and-Rails-2) .
-Requirements
+How to run tests
------------
Follow [this wiki](https://github.com/rails/jquery-ujs/wiki/Running-Tests-and-Contributing) to run tests .
From 1b861bb7032aac5621b60ac0620202a1780e0a48 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Trung=20L=C3=AA?=
Date: Thu, 7 Feb 2013 00:23:19 +1100
Subject: [PATCH 031/155] Update CHANGELOG.md
---
CHANGELOG.md | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index cfff7571..fe03033a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -22,16 +22,16 @@ to newest):
- [`8063d1d47ea6a08e`](https://github.com/rails/jquery-ujs/commit/8063d1d47ea6a08e545e9a6ba3e84af584200e41) made $.rails.confirm and $.rails.ajax functions available in $.rails object
- [`a96c4e9b074998c6`](https://github.com/rails/jquery-ujs/commit/a96c4e9b074998c6b6d102e4573b81c8a76f07a7) added support for jQuery 1.6.1
- [`dad6982dc5926866`](https://github.com/rails/jquery-ujs/commit/dad6982dc592686677e6845e681233c40d2ead27) added support for `data-params` attribute on remote links
-- [`5433841d01622345`](https://github.com/rails/jquery-ujs/commit/5433841d01622345f734f22f82394ac035c2f783) removed support for jquery 1.4.4 and 1.5.x, and added support for jquery 1.6.2
+- [`5433841d01622345`](https://github.com/rails/jquery-ujs/commit/5433841d01622345f734f22f82394ac035c2f783) removed support for jQuery 1.4.4 and 1.5.x, and added support for jQuery 1.6.2
- [`cd619df9f0daad33`](https://github.com/rails/jquery-ujs/commit/cd619df9f0daad3303aacd4f992fff19158b1e5d) added support for html5 `novalidate` attribute, so required fields validation is not enforced
-- [`840ab6ac76b2d5ab`](https://github.com/rails/jquery-ujs/commit/840ab6ac76b2d5ab931841bc3d8567e5b57f183e) added support for jquery 1.6.3
+- [`840ab6ac76b2d5ab`](https://github.com/rails/jquery-ujs/commit/840ab6ac76b2d5ab931841bc3d8567e5b57f183e) added support for jQuery 1.6.3
- [`ba5808e73111fb65`](https://github.com/rails/jquery-ujs/commit/ba5808e73111fb65e91610b078577bb014d9b6d8) added `data-remote` support for checkboxes
- [`6e9a06d45eaf2da1`](https://github.com/rails/jquery-ujs/commit/6e9a06d45eaf2da1036d4c2ead25ff57d0127d03) added `data-disable-with` support for links
- [`89396108ce574080`](https://github.com/rails/jquery-ujs/commit/89396108ce574080f9b877cad74573c5d1ae9aa2) added `data-remote` support for all input types
-- [`c01215c3d48ebb9f`](https://github.com/rails/jquery-ujs/commit/c01215c3d48ebb9f9f1059f26efa0c0c9092da2b) added support for jquery 1.6.4
-- [`17f4004310b6ece3`](https://github.com/rails/jquery-ujs/commit/17f4004310b6ece3cb240914932b4d6d46032c24) added support for jquery 1.7
-- [`cb54ae287f5c7320`](https://github.com/rails/jquery-ujs/commit/cb54ae287f5c73207aef2891cdf22212aea5fb86) added support for jquery 1.7.1
-- [`dbb1b5f72a62e59f`](https://github.com/rails/jquery-ujs/commit/dbb1b5f72a62e59f34f6b5be4bee291ee7f3318f) added support for jquery 1.7.2
+- [`c01215c3d48ebb9f`](https://github.com/rails/jquery-ujs/commit/c01215c3d48ebb9f9f1059f26efa0c0c9092da2b) added support for jQuery 1.6.4
+- [`17f4004310b6ece3`](https://github.com/rails/jquery-ujs/commit/17f4004310b6ece3cb240914932b4d6d46032c24) added support for jQuery 1.7
+- [`cb54ae287f5c7320`](https://github.com/rails/jquery-ujs/commit/cb54ae287f5c73207aef2891cdf22212aea5fb86) added support for jQuery 1.7.1
+- [`dbb1b5f72a62e59f`](https://github.com/rails/jquery-ujs/commit/dbb1b5f72a62e59f34f6b5be4bee291ee7f3318f) added support for jQuery 1.7.2
- [`8100cf3b2462f144`](https://github.com/rails/jquery-ujs/commit/8100cf3b2462f144e6a0bcef7cb78d05be41755d) created `rails:attachBindings` to allow for customization of
$.rails object settings
- [`e4ca2045b202cd7a`](https://github.com/rails/jquery-ujs/commit/e4ca2045b202cd7ade97d78c20caa2822c5c28da) created `ajax:send` event to provide access to jqXHR object from
@@ -39,3 +39,7 @@ to newest):
- [`4382f580766fcdd1`](https://github.com/rails/jquery-ujs/commit/4382f580766fcdd14201c204f43ca5aeb0928501) added support for `data-with-credentials`
- [`12da9fc2f175c8e4`](https://github.com/rails/jquery-ujs/commit/12da9fc2f175c8e445413b15cf6b685deb271d6e) added support for jQuery 1.8.0, removed support for jquery 1.6.x
- [`faeb0ad734ff6867`](https://github.com/rails/jquery-ujs/commit/faeb0ad734ff6867149b8522f9a29081734442e6) added support for jQuery 1.8.1
+- [`b6dae4ef4a2d031a`](https://github.com/rails/jquery-ujs/commit/b6dae4ef4a2d031a222627c7f6a4284602f99160) added support for jQuery 1.8.2
+- [`6927b82cadf3146c`](https://github.com/rails/jquery-ujs/commit/6927b82cadf3146c2b9ae3028e9b197af64011ca) added support for jQuery 1.8.3
+- [`cc356656cc3edf15`](https://github.com/rails/jquery-ujs/commit/cc356656cc3edf1596fd685265187d2f75d1bc7c) added support for jQuery 1.9.0
+- [`2f8ccdf26eac199a`](https://github.com/rails/jquery-ujs/commit/2f8ccdf26eac199a11aa1a893a8909bb4650d0fb) added support for jQuery 1.9.1
From 049d2039da7188783408a22294982f01330d1b38 Mon Sep 17 00:00:00 2001
From: Steve Schwartz
Date: Fri, 8 Feb 2013 00:44:20 -0500
Subject: [PATCH 032/155] Much simpler method of checking if rails.js has
already been loaded.
---
src/rails.js | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/src/rails.js b/src/rails.js
index f63fe049..69db1843 100644
--- a/src/rails.js
+++ b/src/rails.js
@@ -12,12 +12,7 @@
// Cut down on the number if issues from people inadvertently including jquery_ujs twice
// by detecting and raising an error when it happens.
- var alreadyInitialized = function() {
- var events = $._data(document, 'events');
- return events && events.click && $.grep(events.click, function(e) { return e.namespace === 'rails'; }).length;
- }
-
- if ( alreadyInitialized() ) {
+ if ( $.rails !== undefined ) {
$.error('jquery-ujs has already been loaded!');
}
From 610dfb8881377598b7e63ab2c152d73aa1d3632f Mon Sep 17 00:00:00 2001
From: Steve Schwartz
Date: Tue, 19 Feb 2013 00:28:38 -0500
Subject: [PATCH 033/155] Fixed bug where a[disable-with] got set to blank html
when ajax returned error, due to enableElement being triggered twice.
---
src/rails.js | 4 +---
test/public/test/data-disable.js | 17 +++++++++++++++++
2 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/src/rails.js b/src/rails.js
index 69db1843..a1661f31 100644
--- a/src/rails.js
+++ b/src/rails.js
@@ -276,9 +276,7 @@
enableElement: function(element) {
if (element.data('ujs:enable-with') !== undefined) {
element.html(element.data('ujs:enable-with')); // set to old enabled state
- // this should be element.removeData('ujs:enable-with')
- // but, there is currently a bug in jquery which makes hyphenated data attributes not get removed
- element.data('ujs:enable-with', false); // clean up cache
+ element.removeData('ujs:enable-with'); // clean up cache
}
element.unbind('click.railsDisable'); // enable element
}
diff --git a/test/public/test/data-disable.js b/test/public/test/data-disable.js
index 241c1583..6c973dfd 100644
--- a/test/public/test/data-disable.js
+++ b/test/public/test/data-disable.js
@@ -207,6 +207,23 @@ asyncTest('a[data-remote][data-disable-with] re-enables when `ajax:beforeSend` e
}, 30);
});
+asyncTest('a[data-remote][data-disable-with] re-enables when `ajax:error` event is triggered', 6, function() {
+ var link = $('a[data-disable-with]').attr('data-remote', true).attr('href', '/error');
+
+ checkEnabledState(link, 'Click me');
+
+ link
+ .bind('ajax:beforeSend', function() {
+ checkDisabledState(link, 'clicking...');
+ })
+ .trigger('click');
+
+ setTimeout(function() {
+ checkEnabledState(link, 'Click me');
+ start();
+ }, 30);
+});
+
asyncTest('form[data-remote] input|button|textarea[data-disable-with] does not disable when `ajax:beforeSend` event is cancelled', 8, function() {
var form = $('form[data-remote]'),
input = form.find('input:text'),
From c30462003c41175acf7337536b036a47645cf742 Mon Sep 17 00:00:00 2001
From: ingeniarius
Date: Wed, 20 Feb 2013 15:22:34 +0400
Subject: [PATCH 034/155] 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 035/155] 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 036/155] 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 037/155] 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 038/155] 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 039/155] 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 040/155] 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 041/155] 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 042/155] 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 043/155] 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 044/155] 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 045/155] 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 046/155] 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 047/155] 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 048/155] 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 049/155] 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 050/155] 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 051/155] 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 052/155] 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 = $('