-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathjw-plangular.js
More file actions
42 lines (37 loc) · 1.06 KB
/
jw-plangular.js
File metadata and controls
42 lines (37 loc) · 1.06 KB
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
'use strict';
angular.module('JwPlangular', [])
.controller('JwPlangularCtrl', ['$scope', '$stateParams', '$state', function($scope, $stateParams, $state){
$scope.setupVideo = function(id, options) {
var playerId = id;
if($('#' + playerId).length > 0) {
jwplayer(playerId).setup(options);
}
}
}])
.directive("jwPlangular", function() {
return {
restrict: 'EC'
, scope: {
watchMe: '='
, playerId: '@'
, options: '='
, fetchedOptions: '&'
}
, transclude: true
, template: "<div class='video-box' id='{{playerId}}'> loading player... </div>"
, controller: 'JwPlangularCtrl'
, link: function(scope, element, attrs) {
scope.$watch('watchMe', function(newVal, oldVal){
if(newVal) {
if(scope.options) {
scope.setupVideo(scope.playerId, scope.options);
} else {
scope.setupVideo(scope.playerId, scope.fetchedOptions());
}
}
});
}
}
})
// end of the file
;