|
1 |
| -'use strict'; |
2 |
| - |
3 | 1 | /*
|
4 | 2 | * Template for error/success message,
|
5 | 3 | * Show/hide error message when required,
|
6 | 4 | * Show/hide success message when required.
|
7 | 5 | */
|
8 | 6 |
|
9 |
| -angular.module('audioTaggedApp') |
10 |
| -.directive('awesomeError', function () { |
11 |
| - return { |
12 |
| - restrict: 'E', |
13 |
| - replace: true, |
14 |
| - scope : { |
15 |
| - msg : '=msg' |
16 |
| - }, |
17 |
| - template: '<div> \ |
18 |
| - <div ng-show="showerr"> \ |
19 |
| - <div class="alert fade in"> \ |
20 |
| - <button type="button" class="close" ng-click="hideError()">×</button> \ |
21 |
| - {{showMessage}} \ |
22 |
| - </div> \ |
23 |
| - </div> \ |
24 |
| - <div ng-show="showsucc"> \ |
25 |
| - <div class="alert fade in alert-success"> \ |
26 |
| - {{showMessage}} \ |
27 |
| - </div> \ |
28 |
| - </div> \ |
29 |
| - </div>', |
30 |
| - link: function(scope) { |
31 |
| - scope.errorMessage = { |
32 |
| - "USERNAME_OR_PASSWORD_NOT_CORRECT" : "Sorry, Username or Password is not correct.", |
33 |
| - "MISSING_PASSWORD" : "Sorry, Missing Password.", |
34 |
| - "MISSING_USERNAME" : "Sorry, Missing Username.", |
35 |
| - "INVALID_USERNAME" : "Sorry, Invalid Username.", |
36 |
| - "INVALID_PASSWORD" : "Sorry, Invalid Password.", |
37 |
| - "MISSING_EMAIL" : "Sorry, Missing Email.", |
38 |
| - "INVALID_EMAIL" : "Sorry, Invalid Email.", |
39 |
| - "USERNAME_NOT_AVAILABLE" : "Sorry, Username is not available.", |
40 |
| - "EMAIL_NOT_AVAILABE" : "Sorry, Email is not available", |
41 |
| - "FILE_NOT_VALID" : "Sorry, File is not valid", |
42 |
| - "Email_Confirm_Email_Not_Matching" : "Sorry, email and confirm email do not match.", |
43 |
| - "TAG_NOT_AVAILABLE" : "Sorry, tag not available.", |
44 |
| - "UPDATE_COMPLETE" : "Success, update complete.", |
45 |
| - "PASSWORD_UPDATE_COMPLETE" : "Success, password updated.", |
46 |
| - "file type is not audio/mp3" : "Sorry, file type is not in audio/mp3 format", |
47 |
| - "Uploading_Error" : "Uploading error", |
48 |
| - "PASSWORD_MODIFICATION_FAILED" : "Sorry, Password modification failed.", |
49 |
| - "Undefined" : "Sorry, we encounterned an Unknown problem" |
50 |
| - }; |
51 |
| - |
52 |
| - scope.$on('show error', function (args) { |
53 |
| - scope.showerr = true; |
54 |
| - }); |
| 7 | +(function(window, angular, undefined) { |
55 | 8 |
|
56 |
| - scope.$on('hide error', function (args) { |
57 |
| - scope.showerr = false; |
58 |
| - }); |
| 9 | + 'use strict'; |
| 10 | + angular.module('ngAngularError', ['ng']) |
| 11 | + .directive('awesomeError', function () { |
| 12 | + return { |
| 13 | + restrict: 'E', |
| 14 | + replace: true, |
| 15 | + scope : { |
| 16 | + msg : '=msg' |
| 17 | + }, |
| 18 | + template: '<div> \ |
| 19 | + <div ng-show="showerr"> \ |
| 20 | + <div class="alert fade in"> \ |
| 21 | + <button type="button" class="close" ng-click="hideError()">×</button> \ |
| 22 | + {{showMessage}} \ |
| 23 | + </div> \ |
| 24 | + </div> \ |
| 25 | + <div ng-show="showsucc"> \ |
| 26 | + <div class="alert fade in alert-success"> \ |
| 27 | + {{showMessage}} \ |
| 28 | + </div> \ |
| 29 | + </div> \ |
| 30 | + </div>', |
| 31 | + link: function(scope) { |
| 32 | + scope.errorMessage = { |
| 33 | + "USERNAME_OR_PASSWORD_NOT_CORRECT" : "Sorry, Username or Password is not correct.", |
| 34 | + "MISSING_PASSWORD" : "Sorry, Missing Password.", |
| 35 | + "MISSING_USERNAME" : "Sorry, Missing Username.", |
| 36 | + "INVALID_USERNAME" : "Sorry, Invalid Username.", |
| 37 | + "INVALID_PASSWORD" : "Sorry, Invalid Password.", |
| 38 | + "MISSING_EMAIL" : "Sorry, Missing Email.", |
| 39 | + "INVALID_EMAIL" : "Sorry, Invalid Email.", |
| 40 | + "USERNAME_NOT_AVAILABLE" : "Sorry, Username is not available.", |
| 41 | + "EMAIL_NOT_AVAILABE" : "Sorry, Email is not available", |
| 42 | + "FILE_NOT_VALID" : "Sorry, File is not valid", |
| 43 | + "Email_Confirm_Email_Not_Matching" : "Sorry, email and confirm email do not match.", |
| 44 | + "TAG_NOT_AVAILABLE" : "Sorry, tag not available.", |
| 45 | + "UPDATE_COMPLETE" : "Success, update complete.", |
| 46 | + "PASSWORD_UPDATE_COMPLETE" : "Success, password updated.", |
| 47 | + "file type is not audio/mp3" : "Sorry, file type is not in audio/mp3 format", |
| 48 | + "Uploading_Error" : "Uploading error", |
| 49 | + "PASSWORD_MODIFICATION_FAILED" : "Sorry, Password modification failed.", |
| 50 | + "Undefined" : "Sorry, we encounterned an Unknown problem" |
| 51 | + }; |
| 52 | + |
| 53 | + scope.$on('show error', function (args) { |
| 54 | + scope.showerr = true; |
| 55 | + }); |
59 | 56 |
|
60 |
| - scope.hideError = function () { |
61 |
| - scope.showerr = false; |
62 |
| - }; |
| 57 | + scope.$on('hide error', function (args) { |
| 58 | + scope.showerr = false; |
| 59 | + }); |
63 | 60 |
|
64 |
| - scope.$on('show success', function (args) { |
65 |
| - scope.showsucc = true; |
66 |
| - }); |
| 61 | + scope.hideError = function () { |
| 62 | + scope.showerr = false; |
| 63 | + }; |
67 | 64 |
|
68 |
| - scope.$on('hide success', function (args) { |
69 |
| - scope.showsucc = false; |
70 |
| - }); |
| 65 | + scope.$on('show success', function (args) { |
| 66 | + scope.showsucc = true; |
| 67 | + }); |
| 68 | + |
| 69 | + scope.$on('hide success', function (args) { |
| 70 | + scope.showsucc = false; |
| 71 | + }); |
| 72 | + |
| 73 | + scope.$watch(function() {return scope.msg}, function(value) { |
| 74 | + scope.showMessage = scope.errorMessage[scope.msg]; |
| 75 | + if (scope.showMessage === "undefined") { scope.showMessage = scope.errorMessage["Undefined"]; } |
| 76 | + }); |
| 77 | + } |
| 78 | + }; |
| 79 | + }); |
71 | 80 |
|
72 |
| - scope.$watch(function() {return scope.msg}, function(value) { |
73 |
| - scope.showMessage = scope.errorMessage[scope.msg]; |
74 |
| - if (scope.showMessage === "undefined") { scope.showMessage = scope.errorMessage["Undefined"]; } |
75 |
| - }); |
76 |
| - } |
77 |
| - }; |
78 |
| -}); |
| 81 | +})(window, window.angular); |
0 commit comments