mootools-rails 1.0.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,9 +6,10 @@ license: MIT-style
6
6
 
7
7
  authors:
8
8
  - Kevin Valdek
9
+ - Oskar Krawczyk
9
10
 
10
11
  requires:
11
- core/1.3: '*'
12
+ core/1.4: '*'
12
13
 
13
14
  provides:
14
15
  - Rails 3 MooTools driver
@@ -16,37 +17,49 @@ provides:
16
17
  ...
17
18
  */
18
19
 
19
- (function($) {
20
+ window.addEvent('domready', function(){
21
+
22
+ rails.csrf = {
23
+ token: rails.getCsrf('token'),
24
+ param: rails.getCsrf('param')
25
+ };
26
+
27
+ rails.applyEvents();
28
+ });
20
29
 
30
+ (function($){
31
+
21
32
  window.rails = {
22
33
  /**
23
34
  * If el is passed as argument, events will only be applied to
24
35
  * elements within el. Otherwise applied to document body.
25
36
  */
26
- applyEvents: function(el) {
37
+ applyEvents: function(el){
27
38
  el = $(el || document.body);
28
- var apply = function(selector, action, callback) {
29
- el.getElements(selector).addEvent(action, callback);
39
+ var apply = function(selector, action, callback){
40
+ el.addEvent(action + ':relay(' + selector + ')', callback);
30
41
  };
31
-
42
+
32
43
  apply('form[data-remote="true"]', 'submit', rails.handleRemote);
33
44
  apply('a[data-remote="true"], input[data-remote="true"]', 'click', rails.handleRemote);
34
- apply('a[data-method][data-remote!=true]', 'click', function(e) {
35
- e.preventDefault();
36
- if(rails.confirmed(this)) {
37
- var form = new Element('form', {
45
+ apply('a[data-method][data-remote!=true]', 'click', function(event){
46
+ event.preventDefault();
47
+ if (rails.confirmed(this)){
48
+ var form = Element('form', {
38
49
  method: 'post',
39
50
  action: this.get('href'),
40
- styles: { display: 'none' }
51
+ styles: {
52
+ display: 'none'
53
+ }
41
54
  }).inject(this, 'after');
42
55
 
43
- var methodInput = new Element('input', {
56
+ var methodInput = Element('input', {
44
57
  type: 'hidden',
45
58
  name: '_method',
46
59
  value: this.get('data-method')
47
60
  });
48
61
 
49
- var csrfInput = new Element('input', {
62
+ var csrfInput = Element('input', {
50
63
  type: 'hidden',
51
64
  name: rails.csrf.param,
52
65
  value: rails.csrf.token
@@ -56,30 +69,29 @@ provides:
56
69
  }
57
70
  });
58
71
  var noMethodNorRemoteConfirm = ':not([data-method]):not([data-remote=true])[data-confirm]';
59
- apply('a' + noMethodNorRemoteConfirm + ',' + 'input' + noMethodNorRemoteConfirm, 'click', function() {
72
+ apply('a' + noMethodNorRemoteConfirm + ',' + 'input' + noMethodNorRemoteConfirm, 'click', function(){
60
73
  return rails.confirmed(this);
61
74
  });
62
75
  },
63
-
64
- getCsrf: function(name) {
76
+
77
+ getCsrf: function(name){
65
78
  var meta = document.getElement('meta[name=csrf-' + name + ']');
66
79
  return (meta ? meta.get('content') : null);
67
80
  },
68
-
69
- confirmed: function(el) {
81
+
82
+ confirmed: function(el){
70
83
  var confirmMessage = el.get('data-confirm');
71
- if(confirmMessage && !confirm(confirmMessage)) {
84
+ if(confirmMessage && !confirm(confirmMessage)){
72
85
  return false;
73
86
  }
74
87
  return true;
75
88
  },
76
-
77
- disable: function(el) {
89
+
90
+ disable: function(el){
78
91
  var button = el.get('data-disable-with') ? el : el.getElement('[data-disable-with]');
79
-
80
- if(button) {
92
+ if (button){
81
93
  var enableWith = button.get('value');
82
- el.addEvent('ajax:complete', function() {
94
+ el.addEvent('ajax:complete', function(){
83
95
  button.set({
84
96
  value: enableWith,
85
97
  disabled: false
@@ -91,70 +103,59 @@ provides:
91
103
  });
92
104
  }
93
105
  },
94
-
95
- handleRemote: function(e) {
96
- e.preventDefault();
97
-
98
- if(rails.confirmed(this)) {
106
+
107
+ handleRemote: function(event){
108
+ event.preventDefault();
109
+ if(rails.confirmed(this)){
99
110
  this.request = new Request.Rails(this);
100
111
  rails.disable(this);
101
112
  this.request.send();
102
113
  }
103
114
  }
104
115
  };
105
-
116
+
106
117
  Request.Rails = new Class({
107
-
118
+
108
119
  Extends: Request,
109
-
110
- initialize: function(element, options) {
120
+
121
+ initialize: function(element, options){
111
122
  this.el = element;
112
123
  this.parent(Object.merge({
113
124
  method: this.el.get('method') || this.el.get('data-method') || 'get',
114
125
  url: this.el.get('action') || this.el.get('href')
115
126
  }, options));
116
-
117
127
  this.addRailsEvents();
118
128
  },
119
-
129
+
120
130
  send: function(options) {
121
131
  this.el.fireEvent('ajax:before');
122
- if(this.el.get('tag') == 'form') {
132
+ if (this.el.get('tag') === 'form'){
123
133
  this.options.data = this.el;
124
134
  }
125
135
  this.parent(options);
126
136
  this.el.fireEvent('ajax:after', this.xhr);
127
137
  },
128
-
129
- addRailsEvents: function() {
130
- this.addEvent('request', function() {
138
+
139
+ addRailsEvents: function(){
140
+ this.addEvent('request', function(){
131
141
  this.el.fireEvent('ajax:loading', this.xhr);
132
142
  });
133
-
134
- this.addEvent('success', function() {
143
+
144
+ this.addEvent('success', function(){
135
145
  this.el.fireEvent('ajax:success', this.xhr);
136
146
  });
137
-
138
- this.addEvent('complete', function() {
147
+
148
+ this.addEvent('complete', function(){
139
149
  this.el.fireEvent('ajax:complete', this.xhr);
140
150
  this.el.fireEvent('ajax:loaded', this.xhr);
141
151
  });
142
-
143
- this.addEvent('failure', function() {
152
+
153
+ this.addEvent('failure', function(){
144
154
  this.el.fireEvent('ajax:failure', this.xhr);
145
155
  });
146
156
  }
147
-
157
+
148
158
  });
149
-
159
+
150
160
  })(document.id);
151
161
 
152
- window.addEvent('domready', function() {
153
-
154
- rails.csrf = {
155
- token: rails.getCsrf('token'),
156
- param: rails.getCsrf('param')
157
- };
158
-
159
- rails.applyEvents();
160
- });
metadata CHANGED
@@ -1,74 +1,95 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mootools-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
5
- prerelease:
4
+ version: 2.0.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Daniel Spangenberg
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2011-11-21 00:00:00.000000000Z
11
+ date: 2013-04-09 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: railties
16
- requirement: &70235211140580 !ruby/object:Gem::Requirement
17
- none: false
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
- - - ~>
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '3.0'
20
+ - - <
21
+ - !ruby/object:Gem::Version
22
+ version: '5.0'
22
23
  type: :runtime
23
24
  prerelease: false
24
- version_requirements: *70235211140580
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '3.0'
30
+ - - <
31
+ - !ruby/object:Gem::Version
32
+ version: '5.0'
25
33
  - !ruby/object:Gem::Dependency
26
34
  name: thor
27
- requirement: &70235211139840 !ruby/object:Gem::Requirement
28
- none: false
35
+ requirement: !ruby/object:Gem::Requirement
29
36
  requirements:
30
- - - ~>
37
+ - - '>='
31
38
  - !ruby/object:Gem::Version
32
39
  version: '0.14'
40
+ - - <
41
+ - !ruby/object:Gem::Version
42
+ version: '2.0'
33
43
  type: :runtime
34
44
  prerelease: false
35
- version_requirements: *70235211139840
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - '>='
48
+ - !ruby/object:Gem::Version
49
+ version: '0.14'
50
+ - - <
51
+ - !ruby/object:Gem::Version
52
+ version: '2.0'
36
53
  - !ruby/object:Gem::Dependency
37
54
  name: bundler
38
- requirement: &70235211131960 !ruby/object:Gem::Requirement
39
- none: false
55
+ requirement: !ruby/object:Gem::Requirement
40
56
  requirements:
41
- - - ~>
57
+ - - '>='
42
58
  - !ruby/object:Gem::Version
43
- version: 1.0.0
59
+ version: '0'
44
60
  type: :development
45
61
  prerelease: false
46
- version_requirements: *70235211131960
62
+ version_requirements: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - '>='
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
47
67
  - !ruby/object:Gem::Dependency
48
- name: rails
49
- requirement: &70235211131140 !ruby/object:Gem::Requirement
50
- none: false
68
+ name: rake
69
+ requirement: !ruby/object:Gem::Requirement
51
70
  requirements:
52
- - - ~>
71
+ - - '>='
53
72
  - !ruby/object:Gem::Version
54
- version: '3.0'
73
+ version: '0'
55
74
  type: :development
56
75
  prerelease: false
57
- version_requirements: *70235211131140
58
- description: This gem provides MooTools and the MooTools-ujs driver for your Rails
59
- 3 application.
60
- email:
61
- - daniel.spangenberg@parcydo.com
76
+ version_requirements: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - '>='
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ description: Use MooTools with Rails 3
82
+ email: danielsp@parcydo.com
62
83
  executables: []
63
84
  extensions: []
64
85
  extra_rdoc_files: []
65
86
  files:
66
87
  - .gitignore
67
88
  - Gemfile
68
- - Gemfile.lock
89
+ - LICENSE.txt
69
90
  - README.md
70
91
  - Rakefile
71
- - lib/generators/mootools/install/install_generator.rb
92
+ - lib/generators/mootools/install_generator.rb
72
93
  - lib/mootools-rails.rb
73
94
  - lib/mootools/assert_select.rb
74
95
  - lib/mootools/rails.rb
@@ -76,41 +97,32 @@ files:
76
97
  - lib/mootools/rails/railtie.rb
77
98
  - lib/mootools/rails/version.rb
78
99
  - mootools-rails.gemspec
79
- - pkg/mootools-rails-1.0.0.gem
80
- - spec/lib/mootools-rails_spec.rb
81
- - spec/spec_helper.rb
82
- - vendor/assets/javascripts/mootools-compat.js
83
- - vendor/assets/javascripts/mootools-more-compat.js
84
100
  - vendor/assets/javascripts/mootools-more.js
85
101
  - vendor/assets/javascripts/mootools-more.min.js
86
102
  - vendor/assets/javascripts/mootools.js
87
103
  - vendor/assets/javascripts/mootools.min.js
88
104
  - vendor/assets/javascripts/mootools_ujs.js
89
- homepage: http://rubygems.org/gems/mootools-rails
90
- licenses: []
105
+ homepage: http://github.com/neonlex/mootools-rails
106
+ licenses:
107
+ - MIT
108
+ metadata: {}
91
109
  post_install_message:
92
110
  rdoc_options: []
93
- require_paths:
94
- - lib
111
+ require_paths: lib
95
112
  required_ruby_version: !ruby/object:Gem::Requirement
96
- none: false
97
113
  requirements:
98
- - - ! '>='
114
+ - - '>='
99
115
  - !ruby/object:Gem::Version
100
116
  version: '0'
101
- segments:
102
- - 0
103
- hash: 2407732717676801997
104
117
  required_rubygems_version: !ruby/object:Gem::Requirement
105
- none: false
106
118
  requirements:
107
- - - ! '>='
119
+ - - '>='
108
120
  - !ruby/object:Gem::Version
109
- version: 1.3.6
121
+ version: '0'
110
122
  requirements: []
111
- rubyforge_project: mootools-rails
112
- rubygems_version: 1.8.10
123
+ rubyforge_project:
124
+ rubygems_version: 2.0.3
113
125
  signing_key:
114
- specification_version: 3
115
- summary: Use MooTools with Rails 3
126
+ specification_version: 4
127
+ summary: This gem provides MooTools and the MooTools-ujs driver for your Rails 3 application.
116
128
  test_files: []
data/Gemfile.lock DELETED
@@ -1,100 +0,0 @@
1
- GIT
2
- remote: git://github.com/rack/rack.git
3
- revision: a9beb476b27914794743d0677b327d5bafb5e8a3
4
- specs:
5
- rack (1.2.1)
6
-
7
- GIT
8
- remote: git://github.com/sstephenson/sprockets.git
9
- revision: c4800417792744c11eb1fb888bbe9a3a82859952
10
- specs:
11
- sprockets (2.0.0.beta.2)
12
- hike (~> 1.0)
13
- rack (~> 1.0)
14
- tilt (~> 1.0)
15
-
16
- PATH
17
- remote: .
18
- specs:
19
- mootools-rails (1.0.1)
20
- railties (~> 3.0)
21
- thor (~> 0.14)
22
-
23
- GEM
24
- remote: http://rubygems.org/
25
- specs:
26
- abstract (1.0.0)
27
- actionmailer (3.0.5)
28
- actionpack (= 3.0.5)
29
- mail (~> 2.2.15)
30
- actionpack (3.0.5)
31
- activemodel (= 3.0.5)
32
- activesupport (= 3.0.5)
33
- builder (~> 2.1.2)
34
- erubis (~> 2.6.6)
35
- i18n (~> 0.4)
36
- rack (~> 1.2.1)
37
- rack-mount (~> 0.6.13)
38
- rack-test (~> 0.5.7)
39
- tzinfo (~> 0.3.23)
40
- activemodel (3.0.5)
41
- activesupport (= 3.0.5)
42
- builder (~> 2.1.2)
43
- i18n (~> 0.4)
44
- activerecord (3.0.5)
45
- activemodel (= 3.0.5)
46
- activesupport (= 3.0.5)
47
- arel (~> 2.0.2)
48
- tzinfo (~> 0.3.23)
49
- activeresource (3.0.5)
50
- activemodel (= 3.0.5)
51
- activesupport (= 3.0.5)
52
- activesupport (3.0.5)
53
- arel (2.0.10)
54
- builder (2.1.2)
55
- erubis (2.6.6)
56
- abstract (>= 1.0.0)
57
- hike (1.0.0)
58
- i18n (0.6.0beta1)
59
- mail (2.2.19)
60
- activesupport (>= 2.3.6)
61
- i18n (>= 0.4.0)
62
- mime-types (~> 1.16)
63
- treetop (~> 1.4.8)
64
- mime-types (1.17.2)
65
- polyglot (0.3.3)
66
- rack-mount (0.6.14)
67
- rack (>= 1.0.0)
68
- rack-test (0.5.7)
69
- rack (>= 1.0)
70
- rails (3.0.5)
71
- actionmailer (= 3.0.5)
72
- actionpack (= 3.0.5)
73
- activerecord (= 3.0.5)
74
- activeresource (= 3.0.5)
75
- activesupport (= 3.0.5)
76
- bundler (~> 1.0)
77
- railties (= 3.0.5)
78
- railties (3.0.5)
79
- actionpack (= 3.0.5)
80
- activesupport (= 3.0.5)
81
- rake (>= 0.8.7)
82
- thor (~> 0.14.4)
83
- rake (0.9.2.2)
84
- thor (0.14.6)
85
- tilt (1.3)
86
- treetop (1.4.10)
87
- polyglot
88
- polyglot (>= 0.3.1)
89
- tzinfo (0.3.30)
90
-
91
- PLATFORMS
92
- ruby
93
-
94
- DEPENDENCIES
95
- bundler (~> 1.0.0)
96
- i18n (= 0.6.0beta1)
97
- mootools-rails!
98
- rack!
99
- rails (~> 3.0)
100
- sprockets!