summaryrefslogtreecommitdiff
path: root/www/lib/videogular-cuepoints/cuepoints.js
diff options
context:
space:
mode:
authorBoskSpb <bosk@mail.ru>2016-12-15 01:05:35 +0300
committerGitHub <noreply@github.com>2016-12-15 01:05:35 +0300
commitebf2e82f9687110b0237245169f2ae20f18382c0 (patch)
treeffd2f53566b2351e8c345124c47fe5a7f4509908 /www/lib/videogular-cuepoints/cuepoints.js
parente2f15230ac9c4c90b483914398886c70f7d6dd04 (diff)
parent1d9625d30bec5929164fb53b237fa4995f6991f5 (diff)
Merge pull request #1 from pliablepixels/master
updating
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>'
+ );
+ }]);
+})();