|
14 | 14 | var defaultStack = false;
|
15 | 15 |
|
16 | 16 | var initHash = function(stackName) {
|
| 17 | + |
17 | 18 | var hash = angular.copy(settings);
|
18 | 19 |
|
19 | 20 | if ((stackName || (stackName = defaultStack)) && stackName in stacks) {
|
| 21 | + |
20 | 22 | hash.stack = stacks[stackName].stack;
|
21 | 23 |
|
22 | 24 | if (stacks[stackName].addclass) {
|
23 |
| - hash.addclass = 'addclass' in hash ? hash.addclass + ' ' + stacks[stackName].addclass : stacks[stackName].addclass; |
| 25 | + |
| 26 | + hash.addclass = 'addclass' in hash |
| 27 | + ? hash.addclass + ' ' + stacks[stackName].addclass |
| 28 | + : stacks[stackName].addclass; |
| 29 | + |
24 | 30 | }
|
25 | 31 | }
|
26 | 32 |
|
27 | 33 | return hash;
|
| 34 | + |
28 | 35 | };
|
29 | 36 |
|
30 | 37 | this.setDefaults = function(defaults) {
|
| 38 | + |
31 | 39 | settings = defaults;
|
32 | 40 | return this;
|
| 41 | + |
33 | 42 | };
|
34 | 43 |
|
35 | 44 | this.setStack = function(name, addclass, stack) {
|
| 45 | + |
36 | 46 | if (angular.isObject(addclass)) {
|
37 | 47 | stack = addclass;
|
38 | 48 | addclass = false;
|
|
42 | 52 | stack: stack,
|
43 | 53 | addclass: addclass
|
44 | 54 | };
|
| 55 | + |
45 | 56 | return this;
|
| 57 | + |
46 | 58 | };
|
47 | 59 |
|
48 | 60 | this.setDefaultStack = function(name) {
|
| 61 | + |
49 | 62 | defaultStack = name;
|
| 63 | + |
50 | 64 | return this;
|
| 65 | + |
51 | 66 | };
|
52 | 67 |
|
53 | 68 | this.$get = [ function() {
|
|
57 | 72 | /* ========== SETTINGS RELATED METHODS =============*/
|
58 | 73 |
|
59 | 74 | getSettings: function() {
|
| 75 | + |
60 | 76 | return settings;
|
| 77 | + |
61 | 78 | },
|
62 | 79 |
|
63 | 80 | /* ============== NOTIFICATION METHODS ==============*/
|
64 | 81 |
|
65 | 82 | notice: function(content, stack) {
|
| 83 | + |
66 | 84 | var hash = initHash(stack);
|
67 | 85 | hash.type = 'notice';
|
68 | 86 | hash.text = content;
|
69 | 87 | return this.notify(hash);
|
| 88 | + |
70 | 89 | },
|
71 | 90 |
|
72 | 91 | info: function(content, stack) {
|
| 92 | + |
73 | 93 | var hash = initHash(stack);
|
74 | 94 | hash.type = 'info';
|
75 | 95 | hash.text = content;
|
76 | 96 | return this.notify(hash);
|
| 97 | + |
77 | 98 | },
|
78 | 99 |
|
79 | 100 | success: function(content, stack) {
|
| 101 | + |
80 | 102 | var hash = initHash(stack);
|
81 | 103 | hash.type = 'success';
|
82 | 104 | hash.text = content;
|
83 | 105 | return this.notify(hash);
|
| 106 | + |
84 | 107 | },
|
85 | 108 |
|
86 | 109 | error: function(content, stack) {
|
| 110 | + |
87 | 111 | var hash = initHash(stack);
|
88 | 112 | hash.type = 'error';
|
89 | 113 | hash.text = content;
|
90 | 114 | return this.notify(hash);
|
| 115 | + |
91 | 116 | },
|
92 | 117 |
|
93 | 118 | notifyWithDefaults: function(options, stack) {
|
| 119 | + |
94 | 120 | var defaults = initHash(stack);
|
95 | 121 | var combined = angular.extend(defaults, options);
|
96 | 122 | return this.notify(combined);
|
| 123 | + |
97 | 124 | },
|
98 | 125 |
|
99 | 126 | notify: function(hash) {
|
| 127 | + |
100 | 128 | return new PNotify(hash);
|
| 129 | + |
101 | 130 | },
|
102 |
| - |
| 131 | + |
103 | 132 | removeNotifications: function() {
|
| 133 | + |
104 | 134 | return PNotify.removeAll();
|
| 135 | + |
105 | 136 | }
|
106 | 137 |
|
107 | 138 | };
|
|
0 commit comments