turbograft 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0c249b4ccd0c6e283c8a5bf909ebdec4541b4f4d
4
- data.tar.gz: 16169d007d25ecc6ac97c05fb604047440a4ec78
3
+ metadata.gz: 9363a348161d11d97e367b31a33aa3bbef88b085
4
+ data.tar.gz: f97e93ef362b214d9878967583f1e4611496331a
5
5
  SHA512:
6
- metadata.gz: 1a843ee131ba65714567e500cba001ec560ac8459316c8f146bb30de45145eb9831a1f5ac69a102a573b667ddff50ead11e2b513b300ddc0487e977888418483
7
- data.tar.gz: 40ffcb9804a953630b2f58a4f7d909ba3616abdfcf391e3f742ff0bd181dc0e0c9e20e709732a5078b418e3f870ab6b14a7c6fe576884966a276e1c014e8b4a5
6
+ metadata.gz: af7f17cbeaea58085a590b55d5c71c80aa085d9344df499d06be82467a661cca1d3b63db9dff8879402a551671b5eadf9f58a9f756607ed5e8f80624b218f4c0
7
+ data.tar.gz: b8d5e300a0b964f6f2ef55e896e5ba2b34119dbe9e46f45820c851312a614a0e6397d7d73c507ae7cdc76f3a4d9e84929060de33f039562b1dc97fd73c842c90
@@ -1,3 +1,3 @@
1
1
  module TurboGraft
2
- VERSION = '0.0.6'
2
+ VERSION = '0.0.7'
3
3
  end
data/lib/turbograft.js CHANGED
@@ -131,7 +131,15 @@ window.TurboGraft = {
131
131
  };
132
132
 
133
133
  hasClass = function(node, search) {
134
- return node.classList.contains(search);
134
+ var className, _i, _len, _ref;
135
+ _ref = node.classList;
136
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
137
+ className = _ref[_i];
138
+ if (className === search) {
139
+ return true;
140
+ }
141
+ }
142
+ return false;
135
143
  };
136
144
 
137
145
  nodeIsDisabled = function(node) {
@@ -187,10 +195,7 @@ TurboGraft.handlers.remoteMethodHandler = function(ev) {
187
195
  refreshOnSuccess: target.getAttribute('refresh-on-success'),
188
196
  refreshOnError: target.getAttribute('refresh-on-error')
189
197
  };
190
- if (!options.refreshOnSuccess && !options.refreshOnError) {
191
- options.fullRefresh = true;
192
- }
193
- remote = new TurboGraft.Remote(options, null, target);
198
+ remote = new TurboGraft.Remote(options);
194
199
  };
195
200
 
196
201
  documentListenerForButtons = function(eventType, handler, useCapture) {
@@ -390,11 +395,14 @@ window.PageCache = (function() {
390
395
 
391
396
  },{}],8:[function(require,module,exports){
392
397
  TurboGraft.Remote = (function() {
393
- function Remote(opts, form, target) {
398
+ function Remote(opts, form) {
394
399
  var actualRequestType, formData, xhr;
395
400
  this.opts = opts;
396
- formData = form ? new FormData(form) : new FormData();
397
- this.initiator = target;
401
+ if (form) {
402
+ formData = new FormData(form);
403
+ } else {
404
+ formData = new FormData();
405
+ }
398
406
  actualRequestType = this.opts.httpRequestType.toLowerCase() === 'get' ? 'GET' : 'POST';
399
407
  formData.append("_method", this.opts.httpRequestType);
400
408
  if (this.opts.refreshOnSuccess) {
@@ -406,14 +414,9 @@ TurboGraft.Remote = (function() {
406
414
  xhr = new XMLHttpRequest;
407
415
  xhr.open(actualRequestType, this.opts.httpUrl, true);
408
416
  xhr.setRequestHeader('Accept', 'text/html, application/xhtml+xml, application/xml');
409
- xhr.addEventListener('loadstart', (function(_this) {
410
- return function() {
411
- return triggerEvent('turbograft:remote:start', {
412
- xhr: xhr,
413
- initiator: _this.initiator
414
- });
415
- };
416
- })(this));
417
+ xhr.addEventListener('loadstart', function() {
418
+ return triggerEvent('turbograft:remote:start', xhr);
419
+ });
417
420
  xhr.addEventListener('error', this.onError);
418
421
  xhr.addEventListener('load', (function(_this) {
419
422
  return function(event) {
@@ -424,14 +427,9 @@ TurboGraft.Remote = (function() {
424
427
  }
425
428
  };
426
429
  })(this));
427
- xhr.addEventListener('loadend', (function(_this) {
428
- return function() {
429
- return triggerEvent('turbograft:remote:always', {
430
- xhr: xhr,
431
- initiator: _this.initiator
432
- });
433
- };
434
- })(this));
430
+ xhr.addEventListener('loadend', function() {
431
+ return triggerEvent('turbograft:remote:always', xhr);
432
+ });
435
433
  xhr.send(formData);
436
434
  return xhr;
437
435
  }
@@ -439,22 +437,17 @@ TurboGraft.Remote = (function() {
439
437
  Remote.prototype.onSuccess = function(ev) {
440
438
  var redirect, xhr;
441
439
  xhr = ev.target;
442
- triggerEvent('turbograft:remote:success', {
443
- xhr: xhr,
444
- initiator: this.initiator
445
- });
440
+ triggerEvent('turbograft:remote:success', xhr);
446
441
  if (redirect = xhr.getResponseHeader('X-Next-Redirect')) {
447
442
  Page.visit(redirect, {
448
443
  reload: true
449
444
  });
450
445
  return;
451
446
  }
452
- if (this.opts.fullRefresh && this.refreshOnSuccess) {
447
+ if (this.opts.fullRefresh) {
453
448
  return Page.refresh({
454
449
  onlyKeys: this.refreshOnSuccess
455
450
  });
456
- } else if (this.opts.fullRefresh) {
457
- return Page.refresh();
458
451
  } else if (this.refreshOnSuccess) {
459
452
  return Page.refresh({
460
453
  response: xhr,
@@ -466,20 +459,14 @@ TurboGraft.Remote = (function() {
466
459
  Remote.prototype.onError = function(ev) {
467
460
  var xhr;
468
461
  xhr = ev.target;
469
- triggerEvent('turbograft:remote:fail', {
470
- xhr: xhr,
471
- initiator: this.initiator
472
- });
462
+ triggerEvent('turbograft:remote:fail', xhr);
473
463
  if (this.refreshOnError) {
474
464
  return Page.refresh({
475
465
  response: xhr,
476
466
  onlyKeys: this.refreshOnError
477
467
  });
478
468
  } else {
479
- return triggerEvent('turbograft:remote:fail:unhandled', {
480
- xhr: xhr,
481
- initiator: this.initiator
482
- });
469
+ return triggerEvent('turbograft:remote:fail:unhandled', xhr);
483
470
  }
484
471
  };
485
472
 
data/lib/turbograft.rb CHANGED
@@ -9,13 +9,21 @@ require "turbograft/x_domain_blocker"
9
9
  require "turbograft/redirection"
10
10
 
11
11
  module TurboGraft
12
+ class Config
13
+ cattr_accessor :controllers
14
+ self.controllers = ["ActionController::Base"]
15
+ end
16
+
12
17
  class Engine < ::Rails::Engine
18
+
13
19
  initializer :turbograft do |config|
14
20
  ActiveSupport.on_load(:action_controller) do
15
- ActionController::Base.class_eval do
16
- include XHRHeaders, Cookies, XDomainBlocker, Redirection
17
- before_filter :set_xhr_redirected_to, :set_request_method_cookie
18
- after_filter :abort_xdomain_redirect
21
+ Config.controllers.each do |klass|
22
+ klass.constantize.class_eval do
23
+ include XHRHeaders, Cookies, XDomainBlocker, Redirection
24
+ before_filter :set_xhr_redirected_to, :set_request_method_cookie
25
+ after_filter :abort_xdomain_redirect
26
+ end
19
27
  end
20
28
 
21
29
  ActionDispatch::Request.class_eval do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: turbograft
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kristian Plettenberg-Dussault
@@ -13,174 +13,174 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2014-10-05 00:00:00.000000000 Z
16
+ date: 2014-10-21 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: coffee-rails
20
20
  requirement: !ruby/object:Gem::Requirement
21
21
  requirements:
22
- - - ">="
22
+ - - '>='
23
23
  - !ruby/object:Gem::Version
24
24
  version: '0'
25
25
  type: :runtime
26
26
  prerelease: false
27
27
  version_requirements: !ruby/object:Gem::Requirement
28
28
  requirements:
29
- - - ">="
29
+ - - '>='
30
30
  - !ruby/object:Gem::Version
31
31
  version: '0'
32
32
  - !ruby/object:Gem::Dependency
33
33
  name: bundler
34
34
  requirement: !ruby/object:Gem::Requirement
35
35
  requirements:
36
- - - ">="
36
+ - - '>='
37
37
  - !ruby/object:Gem::Version
38
38
  version: '0'
39
39
  type: :development
40
40
  prerelease: false
41
41
  version_requirements: !ruby/object:Gem::Requirement
42
42
  requirements:
43
- - - ">="
43
+ - - '>='
44
44
  - !ruby/object:Gem::Version
45
45
  version: '0'
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: rake
48
48
  requirement: !ruby/object:Gem::Requirement
49
49
  requirements:
50
- - - ">="
50
+ - - '>='
51
51
  - !ruby/object:Gem::Version
52
52
  version: '0'
53
53
  type: :development
54
54
  prerelease: false
55
55
  version_requirements: !ruby/object:Gem::Requirement
56
56
  requirements:
57
- - - ">="
57
+ - - '>='
58
58
  - !ruby/object:Gem::Version
59
59
  version: '0'
60
60
  - !ruby/object:Gem::Dependency
61
61
  name: rails
62
62
  requirement: !ruby/object:Gem::Requirement
63
63
  requirements:
64
- - - ">="
64
+ - - '>='
65
65
  - !ruby/object:Gem::Version
66
66
  version: '0'
67
67
  type: :development
68
68
  prerelease: false
69
69
  version_requirements: !ruby/object:Gem::Requirement
70
70
  requirements:
71
- - - ">="
71
+ - - '>='
72
72
  - !ruby/object:Gem::Version
73
73
  version: '0'
74
74
  - !ruby/object:Gem::Dependency
75
75
  name: jquery-rails
76
76
  requirement: !ruby/object:Gem::Requirement
77
77
  requirements:
78
- - - ">="
78
+ - - '>='
79
79
  - !ruby/object:Gem::Version
80
80
  version: '0'
81
81
  type: :development
82
82
  prerelease: false
83
83
  version_requirements: !ruby/object:Gem::Requirement
84
84
  requirements:
85
- - - ">="
85
+ - - '>='
86
86
  - !ruby/object:Gem::Version
87
87
  version: '0'
88
88
  - !ruby/object:Gem::Dependency
89
89
  name: minitest-reporters
90
90
  requirement: !ruby/object:Gem::Requirement
91
91
  requirements:
92
- - - ">="
92
+ - - '>='
93
93
  - !ruby/object:Gem::Version
94
94
  version: '0'
95
95
  type: :development
96
96
  prerelease: false
97
97
  version_requirements: !ruby/object:Gem::Requirement
98
98
  requirements:
99
- - - ">="
99
+ - - '>='
100
100
  - !ruby/object:Gem::Version
101
101
  version: '0'
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: capybara
104
104
  requirement: !ruby/object:Gem::Requirement
105
105
  requirements:
106
- - - ">="
106
+ - - '>='
107
107
  - !ruby/object:Gem::Version
108
108
  version: '0'
109
109
  type: :development
110
110
  prerelease: false
111
111
  version_requirements: !ruby/object:Gem::Requirement
112
112
  requirements:
113
- - - ">="
113
+ - - '>='
114
114
  - !ruby/object:Gem::Version
115
115
  version: '0'
116
116
  - !ruby/object:Gem::Dependency
117
117
  name: selenium-webdriver
118
118
  requirement: !ruby/object:Gem::Requirement
119
119
  requirements:
120
- - - ">="
120
+ - - '>='
121
121
  - !ruby/object:Gem::Version
122
122
  version: '0'
123
123
  type: :development
124
124
  prerelease: false
125
125
  version_requirements: !ruby/object:Gem::Requirement
126
126
  requirements:
127
- - - ">="
127
+ - - '>='
128
128
  - !ruby/object:Gem::Version
129
129
  version: '0'
130
130
  - !ruby/object:Gem::Dependency
131
131
  name: teaspoon
132
132
  requirement: !ruby/object:Gem::Requirement
133
133
  requirements:
134
- - - ">="
134
+ - - '>='
135
135
  - !ruby/object:Gem::Version
136
136
  version: '0'
137
137
  type: :development
138
138
  prerelease: false
139
139
  version_requirements: !ruby/object:Gem::Requirement
140
140
  requirements:
141
- - - ">="
141
+ - - '>='
142
142
  - !ruby/object:Gem::Version
143
143
  version: '0'
144
144
  - !ruby/object:Gem::Dependency
145
145
  name: sqlite3
146
146
  requirement: !ruby/object:Gem::Requirement
147
147
  requirements:
148
- - - ">="
148
+ - - '>='
149
149
  - !ruby/object:Gem::Version
150
150
  version: '0'
151
151
  type: :development
152
152
  prerelease: false
153
153
  version_requirements: !ruby/object:Gem::Requirement
154
154
  requirements:
155
- - - ">="
155
+ - - '>='
156
156
  - !ruby/object:Gem::Version
157
157
  version: '0'
158
158
  - !ruby/object:Gem::Dependency
159
159
  name: thin
160
160
  requirement: !ruby/object:Gem::Requirement
161
161
  requirements:
162
- - - ">="
162
+ - - '>='
163
163
  - !ruby/object:Gem::Version
164
164
  version: '0'
165
165
  type: :development
166
166
  prerelease: false
167
167
  version_requirements: !ruby/object:Gem::Requirement
168
168
  requirements:
169
- - - ">="
169
+ - - '>='
170
170
  - !ruby/object:Gem::Version
171
171
  version: '0'
172
172
  - !ruby/object:Gem::Dependency
173
173
  name: byebug
174
174
  requirement: !ruby/object:Gem::Requirement
175
175
  requirements:
176
- - - ">="
176
+ - - '>='
177
177
  - !ruby/object:Gem::Version
178
178
  version: '0'
179
179
  type: :development
180
180
  prerelease: false
181
181
  version_requirements: !ruby/object:Gem::Requirement
182
182
  requirements:
183
- - - ">="
183
+ - - '>='
184
184
  - !ruby/object:Gem::Version
185
185
  version: '0'
186
186
  description: It's like turbolinks, but with partial page replacement and tests
@@ -190,8 +190,6 @@ executables: []
190
190
  extensions: []
191
191
  extra_rdoc_files: []
192
192
  files:
193
- - MIT-LICENSE
194
- - README.md
195
193
  - lib/assets/javascripts/click.coffee
196
194
  - lib/assets/javascripts/component_url.coffee
197
195
  - lib/assets/javascripts/csrf_token.coffee
@@ -201,14 +199,16 @@ files:
201
199
  - lib/assets/javascripts/page_cache.coffee
202
200
  - lib/assets/javascripts/turbograft.coffee
203
201
  - lib/assets/javascripts/turbolinks.coffee
204
- - lib/turbograft.js
205
- - lib/turbograft.rb
206
202
  - lib/turbograft/cookies.rb
207
203
  - lib/turbograft/redirection.rb
208
204
  - lib/turbograft/version.rb
209
205
  - lib/turbograft/x_domain_blocker.rb
210
206
  - lib/turbograft/xhr_headers.rb
211
207
  - lib/turbograft/xhr_url_for.rb
208
+ - lib/turbograft.js
209
+ - lib/turbograft.rb
210
+ - README.md
211
+ - MIT-LICENSE
212
212
  homepage: https://github.com/Shopify/turbograft
213
213
  licenses:
214
214
  - MIT
@@ -219,17 +219,17 @@ require_paths:
219
219
  - lib
220
220
  required_ruby_version: !ruby/object:Gem::Requirement
221
221
  requirements:
222
- - - ">="
222
+ - - '>='
223
223
  - !ruby/object:Gem::Version
224
224
  version: '0'
225
225
  required_rubygems_version: !ruby/object:Gem::Requirement
226
226
  requirements:
227
- - - ">="
227
+ - - '>='
228
228
  - !ruby/object:Gem::Version
229
229
  version: '0'
230
230
  requirements: []
231
231
  rubyforge_project:
232
- rubygems_version: 2.2.2
232
+ rubygems_version: 2.0.14
233
233
  signing_key:
234
234
  specification_version: 4
235
235
  summary: turbolinks with partial page replacement