angular-turbolinks 0.0.4 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 36dbb7b58a7c8bacd11b185dfeda4b89d6cfe4bc
4
- data.tar.gz: 28185ce5a0343fe6d36c5da8428149eeb14c16e4
3
+ metadata.gz: 7044fc3c84ed045ac09b1789a7d6550a33134484
4
+ data.tar.gz: 5707b915713b6358526d78c69c43e1e7c85b7c4b
5
5
  SHA512:
6
- metadata.gz: aa00aba2bd9948ce2e4d2b8b4f147e32e7f8988efdb479517c22eeea489fbcfd7ba6cc43fc6e170d263975808580b1d2f0f761143b29e03d234b6ac7c3e4f5bb
7
- data.tar.gz: 911f8342208a72a2b973d3ed377d944f970311f3a9611b9aeed8d76cc566bc84da9fb6bb9570d724bb780b8746e645c291f49f15c78e264148c1e7075b2bbfeb
6
+ metadata.gz: 7c2587261f9f1a0a2f41b63db7871afddebe6ccb0858582e0e238d5ee3379ccac3cd11fa0bb6f439c54a683986b57ed5ddb309745a9b2aeb631318897ed085a6
7
+ data.tar.gz: e137af08d915c7daff6f40f604b0616ede803af52f80ec64b9580d81f4276ce8d060664119e280c411d6af57c029b03fcd1289daa83a33445dbe2fa89cfd3f9c
data/README.md CHANGED
@@ -6,8 +6,9 @@ gem "turbolinks"
6
6
  gem "angular-turbolinks"
7
7
  ```
8
8
 
9
- ##### Add angular-turbolinks to your sprockets
9
+ ##### Add angular-route and angular-turbolinks to your sprockets
10
10
  ```sh
11
+ //= require angular-route
11
12
  //= require angular-turbolinks
12
13
  ```
13
14
 
@@ -24,25 +25,24 @@ app.config([
24
25
  }
25
26
  ]);
26
27
  ```
28
+ ##### Add ng-app to the html element
29
+ <html ng-app='myapp'>
27
30
 
28
- ##### Move angular bootstrapping to turbolinks event
31
+ ##### (optional) Broadcast angular $destroy for you to remove any global listeners (window, pending http, etc)
29
32
  ```sh
30
- $(document).on('ready page:load', ->
31
- angular.bootstrap($("body"), ['app'])
32
- ).on('page:before-change', ->
33
+ $(document).on('page:before-change', ->
33
34
  angular.element("body").scope().$broadcast("$destroy")
34
35
  )
35
36
  ```
36
37
 
37
- ##### TODO
38
- * add support for turbolinks redirection logic
39
- * referer not working properly (ie. redirect_to :back)
40
-
41
- ##### Caveats
42
- * This is a first stab just to try to get around the '10 $digest() iterations reached using $locationWatch' errors I was receiving when using turbolinks with angular
38
+ ##### Notes
39
+ * This is a first stab just to try to get around the '10 $digest() iterations reached using $locationWatch' errors I was receiving when using turbolinks with angular when using the approach of re-bootstrapping the ng-app on turbolinks page:load
43
40
  * https://github.com/angular/angular.js/issues/3915
44
41
  * https://github.com/angular/angular.js/issues/2815 (among others)
45
42
  * none of the suggested fixes worked for me and this was happening on chrome
46
43
  * This approach uses the angular $location/$locationProvider services for click tracking and pushState, steals the $locationChangeStart event and runs the changed url through turbolinks methods
47
44
  * Does not support any of the turbolinks caching
48
45
  * Eventually im hoping angular $locationWatch can play nice with external plugins using pushState...
46
+
47
+ ##### TODO
48
+ * add support for turbolinks redirection logic (referer not working properly (ie. redirect_to :back))
@@ -1,5 +1,5 @@
1
1
  module Angular
2
2
  module Turbolinks
3
- VERSION = "0.0.4"
3
+ VERSION = "0.1.0"
4
4
  end
5
5
  end
@@ -3,6 +3,7 @@ angular.module('ngTurbolinks', []).run(($location, $rootScope, $http, $q, $compi
3
3
  loadedAssets = null
4
4
  createDocument = null
5
5
  xhr_req = null
6
+ referer = null
6
7
 
7
8
  triggerEvent = (name, data) ->
8
9
  event = document.createEvent 'Events'
@@ -16,7 +17,7 @@ angular.module('ngTurbolinks', []).run(($location, $rootScope, $http, $q, $compi
16
17
  value
17
18
 
18
19
  rememberReferer = ->
19
- window.referer = document.location.href
20
+ referer = document.location.href
20
21
 
21
22
  processResponse = (responseText, status, headers)->
22
23
  clientOrServerError = ->
@@ -96,7 +97,10 @@ angular.module('ngTurbolinks', []).run(($location, $rootScope, $http, $q, $compi
96
97
 
97
98
  changePage = (title, body, csrfToken, runScripts) ->
98
99
  document.title = title
99
- angular.element("body").html($compile("<div id=\"turbolinks_content\">"+body.innerHTML+"</div>")($rootScope))
100
+
101
+ angular.element("body").replaceWith(body)
102
+ $compile(body)($rootScope)
103
+
100
104
  CSRFToken.update csrfToken if csrfToken?
101
105
  executeScriptTags() if runScripts
102
106
  currentState = window.history.state
@@ -130,7 +134,7 @@ angular.module('ngTurbolinks', []).run(($location, $rootScope, $http, $q, $compi
130
134
  method: 'GET',
131
135
  headers: {
132
136
  'Accept' : 'text/html, application/xhtml+xml, application/xml',
133
- 'X-XHR-Referer' : window.referer
137
+ 'X-XHR-Referer' : referer
134
138
  },
135
139
  timeout: xhr_req.promise
136
140
  }).success((data, status, headers)->
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: angular-turbolinks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cary Dunn
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-02 00:00:00.000000000 Z
11
+ date: 2014-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler