-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathdirectives.js
199 lines (178 loc) · 5.88 KB
/
directives.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
(function () {
'use strict';
/**
* @namespace storytools.core.time.directives
*/
var module = angular.module('storytools.core.time.directives', []);
/**
* @ngdoc directive
* @name stPlaybackControls
* @memberOf storytools.core.time.directives
* @description
* Directive that presents playback controls to manipulate the provided
* TimeController instance.
*
* @param {TimeController} time-controls attribute
*/
module.directive('stPlaybackControls', function () {
return {
restrict: 'E',
templateUrl: 'time/playback-controls.html',
scope: {
timeControls: '=',
playbackOptions: '='
},
link: function (scope, elem) {
scope.playbackState = "Play";
scope.loopText = 'Loop Chapter';
scope.loopStoryEnabled = false;
scope.loopChapterEnabled = false;
scope.showTimeLine = false;
scope.next = function () {
scope.timeControls.next();
};
scope.prev = function () {
scope.timeControls.prev();
};
scope.$watch('timeControls', function (neu, old) {
if (neu !== old) {
neu.on('stateChange', function () {
var started = scope.timeControls.isStarted();
scope.started = started;
scope.playbackState = started ? "Pause" : "Play";
scope.$apply();
});
neu.on('rangeChange', function (range) {
scope.currentRange = range;
scope.$apply();
});
}
});
scope.$on('pausePlayback', function () {
var tc = scope.timeControls;
var started = tc.isStarted();
if (started) {
tc.stop();
}
});
scope.play = function () {
var tc = scope.timeControls;
var started = tc.isStarted();
if (started) {
tc.stop();
} else {
tc.start();
}
};
/**
* Check if window is in full screen mode.
* @return {Boolean} full screen mode
*/
scope.isInFullScreen = function (doc) {
if (doc.fullScreenElement !== undefined) {
return !!doc.fullScreenElement;
}
if (doc.mozFullScreen !== undefined) {
return !!doc.mozFullScreen;
}
if (doc.webkitIsFullScreen !== undefined) {
return !!doc.webkitIsFullScreen;
}
if (window.fullScreen !== undefined) {
return !!window.fullScreen;
}
if (window.navigator.standalone !== undefined) {
return !!window.navigator.standalone;
}
};
scope.toggleFullScreen = function () {
var elem = window.parent.document.getElementById('embedded_map');
if (!this.isInFullScreen(document) && !this.isInFullScreen(parent.document)) {
if (!document.webkitFullScreen || !document.mozFullScreen || !document.msFullscreenElement || !document.fullscreenElement) {
if (elem.requestFullscreen) {
elem.requestFullscreen();
} else if (elem.msRequestFullscreen) {
elem.msRequestFullscreen();
} else if (elem.mozRequestFullScreen) {
elem.mozRequestFullScreen();
} else if (elem.webkitRequestFullScreen) {
elem.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
}
}
} else {
if (document.mozCancelFullScreen) {
parent.document.mozCancelFullScreen();
document.mozCancelFullScreen();
} else {
parent.document.webkitCancelFullScreen();
document.webkitCancelFullScreen();
}
}
};
scope.toggleLoop = function () {
var tc = scope.timeControls;
if (tc.loop === 'none') {
scope.loop = tc.loop = 'chapter';
scope.loopText = 'Loop Story';
scope.loopChapterEnabled = true;
} else if (tc.loop === 'chapter') {
scope.loop = tc.loop = 'story';
scope.loopText = 'Disable Loop';
scope.loopStoryEnabled = true;
scope.loopChapterEnabled = false;
} else {
scope.loopText = 'Loop Chapter';
scope.loop = tc.loop = 'none';
scope.loopStoryEnabled = false;
scope.loopChapterEnabled = false; }
};
scope.getLoopButtonGlyph = function(){
if (scope.loop === 'story') {
return 'glyphicon glyphicon-refresh';
} else {
return 'glyphicon glyphicon-repeat';
}
};
scope.toggleTimeLine = function () {
var tc = scope.timeControls;
scope.showTimeLine = tc.showTimeLine = !tc.showTimeLine;
var element = $('#timeline');
if (tc.showTimeLine) {
element.show("slow");
} else {
element.hide("slow");
}
};
}
};
});
/**
* @ngdoc directive
* @name stPlaybackSettings
* @memberOf storytools.core.time.directives
* @description
* Directive that presents playback settings that manipulate the provided
* TimeController instance.
*
* @param {TimeController} time-controls attribute
* @param {object} playbackOptions (will go away)
*/
module.directive('stPlaybackSettings', function () {
return {
restrict: 'E',
templateUrl: 'time/playback-settings.html',
scope: {
timeControls: '=',
// @todo remove once timeControls properly exposes access to this
playbackOptions: '='
},
link: function (scope, elem) {
scope.optionsChanged = function () {
if (scope.timeControls) {
scope.timeControls.update(scope.playbackOptions);
}
};
}
};
});
})();