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