Otaku-Projects /
AngularJS-CRUD-PHP
| 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
Loading history...
|
|||
| 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 | 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()"); |
||
|
0 ignored issues
–
show
|
|||
| 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){ |
||
|
0 ignored issues
–
show
Comprehensibility
Documentation
Best Practice
introduced
by
|
|||
| 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()"); |
||
|
0 ignored issues
–
show
|
|||
| 97 | } |
||
| 98 | } |
||
| 99 | }, |
||
| 100 | }; |
||
| 101 | }]); |