angular-turbolinks 0.0.4 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -11
- data/lib/angular/turbolinks/version.rb +1 -1
- data/lib/assets/javascripts/angular-turbolinks.js.coffee +7 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7044fc3c84ed045ac09b1789a7d6550a33134484
|
4
|
+
data.tar.gz: 5707b915713b6358526d78c69c43e1e7c85b7c4b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
#####
|
31
|
+
##### (optional) Broadcast angular $destroy for you to remove any global listeners (window, pending http, etc)
|
29
32
|
```sh
|
30
|
-
$(document).on('
|
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
|
-
#####
|
38
|
-
*
|
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))
|
@@ -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
|
-
|
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
|
-
|
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' :
|
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
|
+
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-
|
11
|
+
date: 2014-02-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|