From 432191b799d9e7eaf8b98e77ca08dbed24651cee Mon Sep 17 00:00:00 2001 From: Matthew O'Riordan Date: Tue, 4 Mar 2014 14:13:17 +0000 Subject: [PATCH 01/75] Include instructions for installation via Bower --- README.md | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d2442a5e..31b2905c 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ Requirements 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. -Installation +Installation using the jQuery-Rails Gem ------------ For automated installation in Rails, use the "jquery-rails" gem. Place this in your Gemfile: @@ -52,6 +52,29 @@ 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) . +Installation using Bower +------------ + +Modify your bower.json file and add jQuery-UJS as a dependency as follows: + +```javascript +{ + "dependencies": { + /* include jQuery-UJS as below */ + "jquery-ujs": "git@github.com:rails/jquery-ujs.git" + } +} +``` + +Then run `bower install jquery-ujs` to install the jQuery-UJS package. + +For Rails 3.1 and above, add these lines to the top of your app/assets/javascripts/application.js file: + +```javascript +//= require jquery +//= require jquery-ujs/src/rails +``` + How to run tests ------------ From ca6526413e7e8534c0df70707c71148dfb395dfe Mon Sep 17 00:00:00 2001 From: Marnen Laibow-Koser Date: Mon, 9 Jun 2014 11:33:10 -0400 Subject: [PATCH 02/75] Form inputs can use the form attribute too. --- src/rails.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rails.js b/src/rails.js index 837f45a2..579d742c 100644 --- a/src/rails.js +++ b/src/rails.js @@ -34,7 +34,7 @@ formSubmitSelector: 'form', // Form input elements bound by jquery-ujs - formInputClickSelector: 'form input[type=submit], form input[type=image], form button[type=submit], form button:not([type])', + formInputClickSelector: 'form input[type=submit], form input[type=image], form button[type=submit], form button:not([type]), input[type=submit][form], input[type=image][form], button[type=submit][form], button[form]:not([type])', // Form input elements disabled during form submission disableSelector: 'input[data-disable-with]:enabled, button[data-disable-with]:enabled, textarea[data-disable-with]:enabled, input[data-disable]:enabled, button[data-disable]:enabled, textarea[data-disable]:enabled', From eb0e88537cd23208591c0426e8b06c1f0cfad39d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Wed, 18 Jun 2014 11:18:31 -0300 Subject: [PATCH 03/75] Release v1.0.0 --- bower.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bower.json b/bower.json index 02c4e9ed..ea9b1ab4 100644 --- a/bower.json +++ b/bower.json @@ -1,10 +1,11 @@ { "name": "jquery-ujs", "homepage": "https://github.com/rails/jquery-ujs", - "authors": [], + "authors": ["Stephen St. Martin", "Steve Schwartz"], "description": "Ruby on Rails unobtrusive scripting adapter for jQuery", "main": "src/rails.js", "license": "MIT", + "version": "1.0.0", "dependencies": { "jquery": ">1.8.*" }, From e2123e080f77e76748069a07ada04bdd7b4244b7 Mon Sep 17 00:00:00 2001 From: Lucas Mazza Date: Wed, 18 Jun 2014 11:21:32 -0300 Subject: [PATCH 04/75] Update jQuery requirement version inside rails.js. --- src/rails.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rails.js b/src/rails.js index 837f45a2..18194eb7 100644 --- a/src/rails.js +++ b/src/rails.js @@ -4,7 +4,7 @@ * Unobtrusive scripting adapter for jQuery * https://github.com/rails/jquery-ujs * - * Requires jQuery 1.7.0 or later. + * Requires jQuery 1.8.0 or later. * * Released under the MIT license * From 05c9fcab8e29c7c712f2661ccfd51fe73b3e9e60 Mon Sep 17 00:00:00 2001 From: Marnen Laibow-Koser Date: Tue, 8 Jul 2014 12:34:52 -0400 Subject: [PATCH 05/75] Add test case for input with form ID. --- test/public/test/data-confirm.js | 33 ++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/test/public/test/data-confirm.js b/test/public/test/data-confirm.js index b84dd280..d29735fa 100644 --- a/test/public/test/data-confirm.js +++ b/test/public/test/data-confirm.js @@ -14,6 +14,18 @@ module('data-confirm', { text: 'Click me' })); + $('#qunit-fixture').append($('
', { + id: 'confirm', + action: '/echo', + 'data-remote': 'true' + })); + + $('#qunit-fixture').append($('', { + type: 'submit', + form: 'confirm', + 'data-confirm': 'Are you absolutely sure?' + })); + this.windowConfirm = window.confirm; }, teardown: function() { @@ -105,6 +117,27 @@ asyncTest('clicking on a button with data-confirm attribute. Confirm No.', 3, fu }, 50); }); +asyncTest('clicking on a submit button with form and data-confirm attributes. Confirm No.', 3, function() { + var message; + // auto-decline: + window.confirm = function(msg) { message = msg; return false }; + + $('input[type=submit][form]') + .bind('confirm:complete', function(e, data) { + App.assertCallbackInvoked('confirm:complete'); + ok(data == false, 'confirm:complete passes in confirm answer (false)'); + }) + .bind('ajax:beforeSend', function(e, data, status, xhr) { + App.assertCallbackNotInvoked('ajax:beforeSend'); + }) + .trigger('click'); + + setTimeout(function() { + equal(message, 'Are you absolutely sure?'); + start(); + }, 50); +}); + asyncTest('binding to confirm event of a link and returning false', 1, function() { // redefine confirm function so we can make sure it's not called window.confirm = function(msg) { From 358b19d6adf5a939505f84fd91ea492a254412e6 Mon Sep 17 00:00:00 2001 From: Lucas Mazza Date: Wed, 6 Aug 2014 22:46:28 -0300 Subject: [PATCH 06/75] Do not crash the test suite if the form does not have an `action` attribute. --- test/public/test/settings.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/public/test/settings.js b/test/public/test/settings.js index 606f2900..85a33ac1 100644 --- a/test/public/test/settings.js +++ b/test/public/test/settings.js @@ -47,7 +47,7 @@ $(document).bind('submit', function(e) { iframe = $('