1 | |||
2 | /** |
||
3 | * <screen> element to display a share html |
||
4 | * <screen |
||
5 | program-id="" |
||
6 | > |
||
7 | * @param {String} program-id - optional to define, default as parent scope.programId |
||
8 | */ |
||
9 | View Code Duplication | app.directive('screen', ['Core', 'Security', '$rootScope', '$timeout', function(Core, Security, $rootScope, $timeout) { |
|
10 | function ScreenConstructor($scope, $element, $attrs) { |
||
11 | if(Core.GetConfig().debugLog.DirectiveFlow) |
||
12 | console.log("1 screen - ScreenConstructor()"); |
||
0 ignored issues
–
show
Debugging Code
introduced
by
![]() |
|||
13 | |||
14 | function Initialize() { |
||
0 ignored issues
–
show
|
|||
15 | $scope.screenURL = ""; |
||
16 | } |
||
17 | |||
18 | } |
||
19 | function templateUrlFunction(tElement, tAttrs) { |
||
0 ignored issues
–
show
|
|||
20 | var templateURL = ""; |
||
21 | var programId = ""; |
||
22 | if(typeof(tAttrs.programId) != "undefined"){ |
||
23 | if(tAttrs.programId != ""){ |
||
24 | programId = tAttrs.programId; |
||
25 | } |
||
26 | } |
||
27 | |||
28 | templateURL = $rootScope.screenTemplate + programId.toLowerCase() + ".html"; |
||
29 | |||
30 | return templateURL; |
||
31 | } |
||
32 | function templateFunction(tElement, tAttrs){ |
||
33 | var template = "" + |
||
34 | "<div ng-include='screenURL'></div>"; |
||
35 | |||
36 | return template; |
||
37 | } |
||
38 | |||
39 | return { |
||
40 | require: ['?editbox', '?pageview', '^ngModel'], |
||
41 | restrict: 'E', |
||
42 | transclude: true, |
||
43 | scope: true, |
||
44 | |||
45 | controller: ScreenConstructor, |
||
46 | controllerAs: 'screenCtrl', |
||
47 | |||
48 | // bindToController: { |
||
49 | // ngModel: '=', |
||
50 | // }, |
||
51 | // templateUrl : templateUrlFunction, |
||
52 | template: templateFunction, |
||
53 | compile: function compile(tElement, tAttrs, transclude) { |
||
54 | return { |
||
55 | pre: function preLink(scope, iElement, iAttrs, controller) { |
||
56 | if(Core.GetConfig().debugLog.DirectiveFlow) |
||
57 | console.log("2 screen - ScreenConstructor()"); |
||
0 ignored issues
–
show
|
|||
58 | |||
59 | transclude(scope, function(clone, scope) { |
||
60 | var element = angular.element(iElement); |
||
61 | var programId = ""; |
||
62 | |||
63 | // find the attr programId |
||
64 | var isProgramIdFound = false; |
||
65 | if(typeof(iAttrs.programId) != undefined){ |
||
66 | if(iAttrs.programId != null && iAttrs.programId !=""){ |
||
67 | isProgramIdFound = true; |
||
68 | } |
||
69 | } |
||
70 | // assign parent programId if programId attribute not found |
||
71 | if(isProgramIdFound){ |
||
72 | programId = iAttrs.programId; |
||
73 | } |
||
74 | else |
||
75 | programId = scope.$parent.programId.toLowerCase(); |
||
76 | |||
77 | scope.screenURL = $rootScope.screenTemplate + programId.toLowerCase() + ".html"; |
||
78 | }); |
||
79 | }, |
||
80 | post: function postLink(scope, iElement, iAttrs, controller) { |
||
81 | if(Core.GetConfig().debugLog.DirectiveFlow) |
||
82 | console.log("3 screen - ScreenConstructor()"); |
||
0 ignored issues
–
show
|
|||
83 | } |
||
84 | } |
||
85 | }, |
||
86 | }; |
||
87 | }]); |