-
Notifications
You must be signed in to change notification settings - Fork 1
/
client.js
42 lines (39 loc) · 1.52 KB
/
client.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
Spiderable = {
makeSpiderable: function(angularApp) {
var app = null;
if (typeof(angularApp) === 'string') { // app name
app = angular.module(angularApp);
} else if (typeof(angularApp) === 'object') { // app object
app = angularApp;
}
if (app === null) {
throw new Error('spiderable-ui-router: invalid angular app');
}
app.run(['$rootScope', '$state'
function ($rootScope, $state) {
var numberOfSubstates = Infinity;
var timesViewContentLoadedFired = 0;
$rootScope.$on('$stateChangeSuccess', function(event, state) {
numberOfSubstates = state.name.split('.').length + 1;
if (timesViewContentLoadedFired >= numberOfSubstates) {
// Set a global flag when DOM is rendered.
window.__ui_router_dom_ready__ = true;
}
});
$rootScope.$on('$viewContentLoaded', function(event) {
timesViewContentLoadedFired++;
if (timesViewContentLoadedFired >= numberOfSubstates) {
// Set a global flag when DOM is rendered.
window.__ui_router_dom_ready__ = true;
}
});
}
]);
}
};
// Hook into angular bridges.
Meteor.startup(function() {
if (typeof(ngMeteor) !== 'undefined') {
Spiderable.makeSpiderable(ngMeteor);
}
});