forked from behavior3/behavior3editor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
62 lines (54 loc) · 1.52 KB
/
app.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
angular.module('app', [
'ui.router',
'ui.bootstrap',
'ngAnimate',
'templates'
])
.run(['$rootScope', '$window', '$state',
function Execute($rootScope, $window, $state) {
$rootScope.isDesktop = !!$window.process && !!$window.require;
$rootScope.go = function(state, params) {
$state.go(state, params);
};
}
])
.run(['$window', '$animate', '$location', '$document', '$timeout', 'settingsModel', 'projectModel',
function Execute($window,
$animate,
$location,
$document,
$timeout,
settingsModel,
projectModel) {
// reset path
$location.path('/');
// add drop to canvas
angular
.element($window.editor._game.canvas)
.attr('b3-drop-node', true);
// initialize editor
settingsModel.getSettings();
projectModel
.getRecentProjects()
.then(function(projects) {
function closePreload() {
$timeout(function() {
var element = angular.element(document.getElementById('page-preload'));
$animate.addClass(element, 'preload-fade')
.then(function() {
element.remove();
});
}, 500);
}
if (projects.length > 0 && projects[0].isOpen) {
projectModel
.openProject(projects[0].path)
.then(function() {
closePreload();
});
} else {
closePreload();
}
});
}
]);