jquery-rails 2.2.1 → 2.2.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of jquery-rails might be problematic. Click here for more details.

data/.gitignore CHANGED
@@ -2,7 +2,7 @@ pkg/*
2
2
  tmp
3
3
  spec/support/*/Gemfile.lock
4
4
  spec/support/*/public/javascripts
5
- .rvmrc
5
+ .ruby-version
6
6
  .bundle
7
7
  imports/*
8
8
  Gemfile.lock
@@ -1,3 +1,7 @@
1
+ ## 2.2.2 (29 May 2013)
2
+
3
+ - Updated to latest jquery-ujs
4
+
1
5
  ## 2.2.1 (08 February 2013)
2
6
 
3
7
  - Updated to jQuery 1.9.1
data/Rakefile CHANGED
@@ -1,2 +1,22 @@
1
1
  require 'bundler'
2
2
  Bundler::GemHelper.install_tasks
3
+
4
+ # Check if versions are correct between VERSION constants and .js files
5
+ #
6
+ task :release => [:guard_version]
7
+
8
+ task :guard_version do
9
+ def check_version(file, pattern, constant)
10
+ body = File.read("vendor/assets/javascripts/#{file}")
11
+ match = body.match(pattern) or abort "Version check failed: no pattern matched in #{file}"
12
+ file_version = body.match(pattern)[1]
13
+ constant_version = Jquery::Rails.const_get(constant)
14
+
15
+ unless constant_version == file_version
16
+ abort "Jquery::Rails::#{constant} was #{constant_version} but it should be #{file_version}"
17
+ end
18
+ end
19
+
20
+ check_version('jquery.js', /jQuery JavaScript Library v([\S]+)/, 'JQUERY_VERSION')
21
+ check_version('jquery-ui.js', /jQuery UI - v([\S]+)/, 'JQUERY_UI_VERSION')
22
+ end
@@ -1,8 +1,8 @@
1
1
  module Jquery
2
2
  module Rails
3
- VERSION = "2.2.1"
3
+ VERSION = "2.2.2"
4
4
  JQUERY_VERSION = "1.9.1"
5
5
  JQUERY_UI_VERSION = "1.9.2"
6
- JQUERY_UJS_VERSION = "aab2251d90afbdfc808d8031312d063b1ccf8f6f"
6
+ JQUERY_UJS_VERSION = "87587d476054e9869865f53c1b78cb8164619a05"
7
7
  end
8
8
  end
@@ -10,14 +10,9 @@
10
10
  *
11
11
  */
12
12
 
13
- // Cut down on the number if issues from people inadvertently including jquery_ujs twice
13
+ // Cut down on the number of issues from people inadvertently including jquery_ujs twice
14
14
  // by detecting and raising an error when it happens.
15
- var alreadyInitialized = function() {
16
- var events = $._data(document, 'events');
17
- return events && events.click && $.grep(events.click, function(e) { return e.namespace === 'rails'; }).length;
18
- }
19
-
20
- if ( alreadyInitialized() ) {
15
+ if ( $.rails !== undefined ) {
21
16
  $.error('jquery-ujs has already been loaded!');
22
17
  }
23
18
 
@@ -28,6 +23,9 @@
28
23
  // Link elements bound by jquery-ujs
29
24
  linkClickSelector: 'a[data-confirm], a[data-method], a[data-remote], a[data-disable-with]',
30
25
 
26
+ // Button elements boud jquery-ujs
27
+ buttonClickSelector: 'button[data-remote]',
28
+
31
29
  // Select elements bound by jquery-ujs
32
30
  inputChangeSelector: 'select[data-remote], input[data-remote], textarea[data-remote]',
33
31
 
@@ -105,6 +103,11 @@
105
103
  url = element.data('url');
106
104
  data = element.serialize();
107
105
  if (element.data('params')) data = data + "&" + element.data('params');
106
+ } else if (element.is(rails.buttonClickSelector)) {
107
+ method = element.data('method') || 'get';
108
+ url = element.data('url');
109
+ data = element.serialize();
110
+ if (element.data('params')) data = data + "&" + element.data('params');
108
111
  } else {
109
112
  method = element.data('method');
110
113
  url = rails.href(element);
@@ -255,18 +258,6 @@
255
258
  return false;
256
259
  },
257
260
 
258
- // find all the submit events directly bound to the form and
259
- // manually invoke them. If anyone returns false then stop the loop
260
- callFormSubmitBindings: function(form, event) {
261
- var events = form.data('events'), continuePropagation = true;
262
- if (events !== undefined && events['submit'] !== undefined) {
263
- $.each(events['submit'], function(i, obj){
264
- if (typeof obj.handler === 'function') return continuePropagation = obj.handler(event);
265
- });
266
- }
267
- return continuePropagation;
268
- },
269
-
270
261
  // replace element's html with the 'data-disable-with' after storing original html
271
262
  // and prevent clicking on it
272
263
  disableElement: function(element) {
@@ -281,9 +272,7 @@
281
272
  enableElement: function(element) {
282
273
  if (element.data('ujs:enable-with') !== undefined) {
283
274
  element.html(element.data('ujs:enable-with')); // set to old enabled state
284
- // this should be element.removeData('ujs:enable-with')
285
- // but, there is currently a bug in jquery which makes hyphenated data attributes not get removed
286
- element.data('ujs:enable-with', false); // clean up cache
275
+ element.removeData('ujs:enable-with'); // clean up cache
287
276
  }
288
277
  element.unbind('click.railsDisable'); // enable element
289
278
  }
@@ -322,6 +311,14 @@
322
311
  }
323
312
  });
324
313
 
314
+ $(document).delegate(rails.buttonClickSelector, 'click.rails', function(e) {
315
+ var button = $(this);
316
+ if (!rails.allowAction(button)) return rails.stopEverything(e);
317
+
318
+ rails.handleRemote(button);
319
+ return false;
320
+ });
321
+
325
322
  $(document).delegate(rails.inputChangeSelector, 'change.rails', function(e) {
326
323
  var link = $(this);
327
324
  if (!rails.allowAction(link)) return rails.stopEverything(e);
@@ -356,10 +353,6 @@
356
353
  return aborted;
357
354
  }
358
355
 
359
- // If browser does not support submit bubbling, then this live-binding will be called before direct
360
- // bindings. Therefore, we should directly call any direct bindings before remotely submitting form.
361
- if (!$.support.submitBubbles && $().jquery < '1.7' && rails.callFormSubmitBindings(form, e) === false) return rails.stopEverything(e);
362
-
363
356
  rails.handleRemote(form);
364
357
  return false;
365
358
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jquery-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.1
4
+ version: 2.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-08 00:00:00.000000000Z
12
+ date: 2013-05-29 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: railties
16
- requirement: &70229904418740 !ruby/object:Gem::Requirement
16
+ requirement: &70343408106200 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -24,10 +24,10 @@ dependencies:
24
24
  version: '5.0'
25
25
  type: :runtime
26
26
  prerelease: false
27
- version_requirements: *70229904418740
27
+ version_requirements: *70343408106200
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: thor
30
- requirement: &70229904425240 !ruby/object:Gem::Requirement
30
+ requirement: &70343408105460 !ruby/object:Gem::Requirement
31
31
  none: false
32
32
  requirements:
33
33
  - - ! '>='
@@ -38,7 +38,7 @@ dependencies:
38
38
  version: '2.0'
39
39
  type: :runtime
40
40
  prerelease: false
41
- version_requirements: *70229904425240
41
+ version_requirements: *70343408105460
42
42
  description: This gem provides jQuery and the jQuery-ujs driver for your Rails 3 application.
43
43
  email:
44
44
  - andre@arko.net
@@ -79,9 +79,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
79
79
  - - ! '>='
80
80
  - !ruby/object:Gem::Version
81
81
  version: '0'
82
- segments:
83
- - 0
84
- hash: -3074731499898009030
85
82
  required_rubygems_version: !ruby/object:Gem::Requirement
86
83
  none: false
87
84
  requirements: