summaryrefslogtreecommitdiff
path: root/www/lib/videogular-cuepoints/cuepoints.js
diff options
context:
space:
mode:
authorPliable Pixels <pliablepixels@gmail.com>2017-09-21 12:49:18 -0400
committerPliable Pixels <pliablepixels@gmail.com>2017-09-21 12:49:18 -0400
commitb28028ac4082842143b0f528d6bc539da6ccb419 (patch)
tree1e26ea969a781ed8e323fca4e3c76345113fc694 /www/lib/videogular-cuepoints/cuepoints.js
parent676270d21beed31d767a06c89522198c77d5d865 (diff)
mega changes, including updates and X
Diffstat (limited to 'www/lib/videogular-cuepoints/cuepoints.js')
-rw-r--r--www/lib/videogular-cuepoints/cuepoints.js52
1 files changed, 52 insertions, 0 deletions
diff --git a/www/lib/videogular-cuepoints/cuepoints.js b/www/lib/videogular-cuepoints/cuepoints.js
new file mode 100644
index 00000000..6bfc3c6f
--- /dev/null
+++ b/www/lib/videogular-cuepoints/cuepoints.js
@@ -0,0 +1,52 @@
+(function(){
+'use strict';
+angular.module('uk.ac.soton.ecs.videogular.plugins.cuepoints', [])
+ .directive(
+ 'vgCuepoints',
+ [function() {
+ return {
+ restrict: 'E',
+ require: '^videogular',
+ templateUrl: function(element, attrs) {
+ return attrs.templateUrl || 'videogular-cuepoints/cuepoints.html';
+ },
+ scope: {
+ cuepoints: '=vgCuepointsConfig',
+ theme: '=vgCuepointsTheme',
+ },
+ link: function($scope, elem, attr, API) {
+ // shamelessly stolen from part of videogular's updateTheme function
+ function updateTheme(value) {
+ if (value) {
+ var headElem = angular.element(document).find("head");
+ headElem.append("<link rel='stylesheet' href='" + value + "'>");
+ }
+ }
+
+ var calcLeft = function(cuepoint) {
+ if (API.totalTime === 0) return '-1000';
+
+ var videoLength = API.totalTime / 1000;
+ return (cuepoint.time * 100 / videoLength).toString();
+ };
+
+ $scope.onCuepointClick = function(cuepoint){
+ API.seekTime(cuepoint.time);
+ };
+
+ $scope.cuepointStyle = function(cuepoint) {
+ return {
+ left: calcLeft(cuepoint) + '%'
+ };
+ }
+
+ updateTheme($scope.theme);
+ },
+ };
+ }])
+ .run(['$templateCache', function($templateCache) {
+ $templateCache.put('videogular-cuepoints/cuepoints.html',
+ '<vg-cuepoint ng-repeat="cuepoint in cuepoints.points" ng-click="onCuepointClick(cuepoint)" ng-style="cuepointStyle(cuepoint)"></vg-cuepoint>'
+ );
+ }]);
+})();