@angular-wave/angular.ts 0.0.68 → 0.0.70
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/angular-ts.esm.js +2 -2
- package/dist/angular-ts.umd.js +2 -2
- package/package.json +1 -1
- package/src/animations/animate-swap.js +1 -1
- package/src/core/animate/animate.js +5 -5
- package/src/core/compile/compile.js +0 -1
- package/src/core/compile/compile.spec.js +4 -4
- package/src/core/controller/controller.js +5 -1
- package/src/core/cookie-reader.spec.js +1 -1
- package/src/core/di/injector.js +1 -1
- package/src/core/di/injector.spec.js +35 -35
- package/src/core/di/internal-injector.js +1 -1
- package/src/core/filter/filter.spec.js +15 -15
- package/src/core/interpolate/interpolate.spec.js +29 -29
- package/src/core/interval/interval.spec.js +1 -1
- package/src/core/location/location.spec.js +1 -1
- package/src/core/parser/lexer.spec.js +1 -1
- package/src/core/parser/parse.spec.js +1 -1
- package/src/core/q/q.js +1 -0
- package/src/core/q/q.spec.js +1 -1
- package/src/core/scope/scope.js +1 -2
- package/src/core/timeout/timeout.js +5 -21
- package/src/{exts → directive}/aria/aria.html +1 -1
- package/src/directive/aria/aria.js +382 -0
- package/src/{exts → directive}/aria/aria.spec.js +13 -13
- package/src/{exts → directive}/aria/aria.test.js +1 -1
- package/src/directive/attrs/boolean.spec.js +1 -1
- package/src/directive/bind/bind.js +2 -2
- package/src/directive/class/class.js +1 -1
- package/src/directive/form/form.js +1 -18
- package/src/directive/form/form.spec.js +2 -2
- package/src/directive/include/include.js +7 -0
- package/src/directive/input/input.js +1 -1
- package/src/{exts → directive}/messages/messages.html +4 -1
- package/src/directive/messages/messages.js +339 -0
- package/src/{exts → directive}/messages/messages.spec.js +7 -11
- package/src/{exts → directive}/messages/messages.test.js +1 -1
- package/src/directive/model-options/model-options.spec.js +1 -1
- package/src/directive/switch/switch.spec.js +1 -1
- package/src/filters/filter.js +2 -6
- package/src/filters/filter.spec.js +1 -1
- package/src/filters/filters.spec.js +1 -1
- package/src/filters/limit-to.js +0 -1
- package/src/filters/limit-to.spec.js +2 -2
- package/src/loader.js +1 -1
- package/src/loader.spec.js +1 -1
- package/src/public.js +39 -5
- package/src/router/common/glob.spec.js +1 -1
- package/src/router/params/param-factory.js +1 -1
- package/src/router/state/state-builder.spec.js +1 -1
- package/src/router/template-factory.js +6 -4
- package/src/router/view/view.spec.js +8 -11
- package/src/router/view-scroll.js +6 -1
- package/src/services/anchor-scroll.html +83 -0
- package/src/services/anchor-scroll.js +23 -6
- package/src/services/browser.js +1 -1
- package/src/services/http/http.spec.js +40 -40
- package/src/shared/jqlite/jqlite.js +3 -3
- package/src/shared/jqlite/jqlite.spec.js +4 -4
- package/src/shared/utils.js +1 -3
- package/types/core/q/q.d.ts +5 -0
- package/types/core/scope/scope.d.ts +2 -3
- package/types/core/timeout/timeout.d.ts +3 -7
- package/types/directive/aria/aria.d.ts +94 -0
- package/types/directive/form/form.d.ts +3 -20
- package/types/directive/include/include.d.ts +1 -1
- package/types/router/params/param-factory.d.ts +1 -1
- package/types/router/template-factory.d.ts +4 -4
- package/types/router/view-scroll.d.ts +1 -1
- package/types/services/anchor-scroll.d.ts +16 -1
- package/types/services/browser.d.ts +2 -2
- package/types/shared/utils.d.ts +0 -2
- package/src/exts/aria/aria.js +0 -415
- package/src/exts/messages/messages.js +0 -361
- package/types/exts/aria/aria.d.ts +0 -1
- package/types/exts/messages/messages.d.ts +0 -1
- /package/src/{exts → directive}/aria/aria.md +0 -0
- /package/src/{exts → directive}/messages/messages.md +0 -0
|
@@ -1,361 +0,0 @@
|
|
|
1
|
-
import { forEach, isString } from "../../shared/utils";
|
|
2
|
-
|
|
3
|
-
export function initMessageModule(angular) {
|
|
4
|
-
angular
|
|
5
|
-
.module("ngMessages", [])
|
|
6
|
-
|
|
7
|
-
.directive("ngMessages", [
|
|
8
|
-
"$animate",
|
|
9
|
-
function ($animate) {
|
|
10
|
-
const ACTIVE_CLASS = "ng-active";
|
|
11
|
-
const INACTIVE_CLASS = "ng-inactive";
|
|
12
|
-
return {
|
|
13
|
-
require: "ngMessages",
|
|
14
|
-
restrict: "AE",
|
|
15
|
-
controller: [
|
|
16
|
-
"$element",
|
|
17
|
-
"$scope",
|
|
18
|
-
"$attrs",
|
|
19
|
-
function NgMessagesCtrl($element, $scope, $attrs) {
|
|
20
|
-
const ctrl = this;
|
|
21
|
-
let latestKey = 0;
|
|
22
|
-
let nextAttachId = 0;
|
|
23
|
-
this.head = undefined;
|
|
24
|
-
this.default = undefined;
|
|
25
|
-
|
|
26
|
-
this.getAttachId = function getAttachId() {
|
|
27
|
-
return nextAttachId++;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const messages = (this.messages = {});
|
|
31
|
-
let renderLater;
|
|
32
|
-
let cachedCollection;
|
|
33
|
-
|
|
34
|
-
this.render = function (collection) {
|
|
35
|
-
collection = collection || {};
|
|
36
|
-
|
|
37
|
-
renderLater = false;
|
|
38
|
-
cachedCollection = collection;
|
|
39
|
-
|
|
40
|
-
// this is true if the attribute is empty or if the attribute value is truthy
|
|
41
|
-
const multiple =
|
|
42
|
-
isAttrTruthy($scope, $attrs.ngMessagesMultiple) ||
|
|
43
|
-
isAttrTruthy($scope, $attrs.multiple);
|
|
44
|
-
|
|
45
|
-
const unmatchedMessages = [];
|
|
46
|
-
const matchedKeys = {};
|
|
47
|
-
let truthyKeys = 0;
|
|
48
|
-
let messageItem = ctrl.head;
|
|
49
|
-
let messageFound = false;
|
|
50
|
-
let totalMessages = 0;
|
|
51
|
-
|
|
52
|
-
// we use != instead of !== to allow for both undefined and null values
|
|
53
|
-
while (messageItem != null) {
|
|
54
|
-
totalMessages++;
|
|
55
|
-
const messageCtrl = messageItem.message;
|
|
56
|
-
|
|
57
|
-
let messageUsed = false;
|
|
58
|
-
if (!messageFound) {
|
|
59
|
-
forEach(collection, (value, key) => {
|
|
60
|
-
if (truthy(value) && !messageUsed) {
|
|
61
|
-
truthyKeys++;
|
|
62
|
-
|
|
63
|
-
if (messageCtrl.test(key)) {
|
|
64
|
-
// this is to prevent the same error name from showing up twice
|
|
65
|
-
if (matchedKeys[key]) return;
|
|
66
|
-
matchedKeys[key] = true;
|
|
67
|
-
|
|
68
|
-
messageUsed = true;
|
|
69
|
-
messageCtrl.attach();
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
if (messageUsed) {
|
|
76
|
-
// unless we want to display multiple messages then we should
|
|
77
|
-
// set a flag here to avoid displaying the next message in the list
|
|
78
|
-
messageFound = !multiple;
|
|
79
|
-
} else {
|
|
80
|
-
unmatchedMessages.push(messageCtrl);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
messageItem = messageItem.next;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
forEach(unmatchedMessages, (messageCtrl) => {
|
|
87
|
-
messageCtrl.detach();
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
const messageMatched =
|
|
91
|
-
unmatchedMessages.length !== totalMessages;
|
|
92
|
-
const attachDefault =
|
|
93
|
-
ctrl.default && !messageMatched && truthyKeys > 0;
|
|
94
|
-
|
|
95
|
-
if (attachDefault) {
|
|
96
|
-
ctrl.default.attach();
|
|
97
|
-
} else if (ctrl.default) {
|
|
98
|
-
ctrl.default.detach();
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
if (messageMatched || attachDefault) {
|
|
102
|
-
$animate.setClass($element, ACTIVE_CLASS, INACTIVE_CLASS);
|
|
103
|
-
} else {
|
|
104
|
-
$animate.setClass($element, INACTIVE_CLASS, ACTIVE_CLASS);
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
$scope.$watchCollection(
|
|
109
|
-
$attrs.ngMessages || $attrs.for,
|
|
110
|
-
ctrl.render,
|
|
111
|
-
);
|
|
112
|
-
|
|
113
|
-
this.reRender = function () {
|
|
114
|
-
if (!renderLater) {
|
|
115
|
-
renderLater = true;
|
|
116
|
-
$scope.$evalAsync(() => {
|
|
117
|
-
if (renderLater && cachedCollection) {
|
|
118
|
-
ctrl.render(cachedCollection);
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
this.register = function (comment, messageCtrl, isDefault) {
|
|
125
|
-
if (isDefault) {
|
|
126
|
-
ctrl.default = messageCtrl;
|
|
127
|
-
} else {
|
|
128
|
-
const nextKey = latestKey.toString();
|
|
129
|
-
messages[nextKey] = {
|
|
130
|
-
message: messageCtrl,
|
|
131
|
-
};
|
|
132
|
-
insertMessageNode($element[0], comment, nextKey);
|
|
133
|
-
comment.$$ngMessageNode = nextKey;
|
|
134
|
-
latestKey++;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
ctrl.reRender();
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
this.deregister = function (comment, isDefault) {
|
|
141
|
-
if (isDefault) {
|
|
142
|
-
delete ctrl.default;
|
|
143
|
-
} else {
|
|
144
|
-
const key = comment.$$ngMessageNode;
|
|
145
|
-
delete comment.$$ngMessageNode;
|
|
146
|
-
removeMessageNode($element[0], comment, key);
|
|
147
|
-
delete messages[key];
|
|
148
|
-
}
|
|
149
|
-
ctrl.reRender();
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
function findPreviousMessage(parent, comment) {
|
|
153
|
-
let prevNode = comment;
|
|
154
|
-
const parentLookup = [];
|
|
155
|
-
|
|
156
|
-
while (prevNode && prevNode !== parent) {
|
|
157
|
-
const prevKey = prevNode.$$ngMessageNode;
|
|
158
|
-
if (prevKey && prevKey.length) {
|
|
159
|
-
return messages[prevKey];
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
// dive deeper into the DOM and examine its children for any ngMessage
|
|
163
|
-
// comments that may be in an element that appears deeper in the list
|
|
164
|
-
if (
|
|
165
|
-
prevNode.childNodes.length &&
|
|
166
|
-
parentLookup.indexOf(prevNode) === -1
|
|
167
|
-
) {
|
|
168
|
-
parentLookup.push(prevNode);
|
|
169
|
-
prevNode =
|
|
170
|
-
prevNode.childNodes[prevNode.childNodes.length - 1];
|
|
171
|
-
} else if (prevNode.previousSibling) {
|
|
172
|
-
prevNode = prevNode.previousSibling;
|
|
173
|
-
} else {
|
|
174
|
-
prevNode = prevNode.parentNode;
|
|
175
|
-
parentLookup.push(prevNode);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
function insertMessageNode(parent, comment, key) {
|
|
181
|
-
const messageNode = messages[key];
|
|
182
|
-
if (!ctrl.head) {
|
|
183
|
-
ctrl.head = messageNode;
|
|
184
|
-
} else {
|
|
185
|
-
const match = findPreviousMessage(parent, comment);
|
|
186
|
-
if (match) {
|
|
187
|
-
messageNode.next = match.next;
|
|
188
|
-
match.next = messageNode;
|
|
189
|
-
} else {
|
|
190
|
-
messageNode.next = ctrl.head;
|
|
191
|
-
ctrl.head = messageNode;
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
function removeMessageNode(parent, comment, key) {
|
|
197
|
-
const messageNode = messages[key];
|
|
198
|
-
|
|
199
|
-
// This message node may have already been removed by a call to deregister()
|
|
200
|
-
if (!messageNode) return;
|
|
201
|
-
|
|
202
|
-
const match = findPreviousMessage(parent, comment);
|
|
203
|
-
if (match) {
|
|
204
|
-
match.next = messageNode.next;
|
|
205
|
-
} else {
|
|
206
|
-
ctrl.head = messageNode.next;
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
},
|
|
210
|
-
],
|
|
211
|
-
};
|
|
212
|
-
|
|
213
|
-
function isAttrTruthy(scope, attr) {
|
|
214
|
-
return (
|
|
215
|
-
(isString(attr) && attr.length === 0) || // empty attribute
|
|
216
|
-
truthy(scope.$eval(attr))
|
|
217
|
-
);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
function truthy(val) {
|
|
221
|
-
return isString(val) ? val.length : !!val;
|
|
222
|
-
}
|
|
223
|
-
},
|
|
224
|
-
])
|
|
225
|
-
|
|
226
|
-
.directive("ngMessagesInclude", [
|
|
227
|
-
"$templateRequest",
|
|
228
|
-
"$compile",
|
|
229
|
-
function ($templateRequest, $compile) {
|
|
230
|
-
return {
|
|
231
|
-
restrict: "AE",
|
|
232
|
-
require: "^^ngMessages", // we only require this for validation sake
|
|
233
|
-
link($scope, element, attrs) {
|
|
234
|
-
const src = attrs.ngMessagesInclude || attrs.src;
|
|
235
|
-
$templateRequest(src).then((html) => {
|
|
236
|
-
if ($scope.$$destroyed) return;
|
|
237
|
-
if (isString(html) && !html.trim()) {
|
|
238
|
-
// Empty template - nothing to compile
|
|
239
|
-
} else {
|
|
240
|
-
// Non-empty template - compile and link
|
|
241
|
-
$compile(html)($scope, (contents) => {
|
|
242
|
-
element.after(contents);
|
|
243
|
-
});
|
|
244
|
-
}
|
|
245
|
-
});
|
|
246
|
-
},
|
|
247
|
-
};
|
|
248
|
-
},
|
|
249
|
-
])
|
|
250
|
-
|
|
251
|
-
.directive("ngMessage", ngMessageDirectiveFactory(false))
|
|
252
|
-
.directive("ngMessageExp", ngMessageDirectiveFactory(false))
|
|
253
|
-
.directive("ngMessageDefault", ngMessageDirectiveFactory(true));
|
|
254
|
-
|
|
255
|
-
function ngMessageDirectiveFactory(isDefault) {
|
|
256
|
-
return [
|
|
257
|
-
"$animate",
|
|
258
|
-
function ($animate) {
|
|
259
|
-
return {
|
|
260
|
-
restrict: "AE",
|
|
261
|
-
transclude: "element",
|
|
262
|
-
priority: 1, // must run before ngBind, otherwise the text is set on the comment
|
|
263
|
-
terminal: true,
|
|
264
|
-
require: "^^ngMessages",
|
|
265
|
-
link(scope, element, attrs, ngMessagesCtrl, $transclude) {
|
|
266
|
-
let commentNode;
|
|
267
|
-
let records;
|
|
268
|
-
let staticExp;
|
|
269
|
-
let dynamicExp;
|
|
270
|
-
|
|
271
|
-
if (!isDefault) {
|
|
272
|
-
commentNode = element[0];
|
|
273
|
-
staticExp = attrs.ngMessage || attrs.when;
|
|
274
|
-
dynamicExp = attrs.ngMessageExp || attrs.whenExp;
|
|
275
|
-
|
|
276
|
-
const assignRecords = function (items) {
|
|
277
|
-
records = items
|
|
278
|
-
? Array.isArray(items)
|
|
279
|
-
? items
|
|
280
|
-
: items.split(/[\s,]+/)
|
|
281
|
-
: null;
|
|
282
|
-
ngMessagesCtrl.reRender();
|
|
283
|
-
};
|
|
284
|
-
|
|
285
|
-
if (dynamicExp) {
|
|
286
|
-
assignRecords(scope.$eval(dynamicExp));
|
|
287
|
-
scope.$watchCollection(dynamicExp, assignRecords);
|
|
288
|
-
} else {
|
|
289
|
-
assignRecords(staticExp);
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
let currentElement;
|
|
294
|
-
let messageCtrl;
|
|
295
|
-
ngMessagesCtrl.register(
|
|
296
|
-
commentNode,
|
|
297
|
-
(messageCtrl = {
|
|
298
|
-
test(name) {
|
|
299
|
-
return contains(records, name);
|
|
300
|
-
},
|
|
301
|
-
attach() {
|
|
302
|
-
if (!currentElement) {
|
|
303
|
-
$transclude((elm, newScope) => {
|
|
304
|
-
$animate.enter(elm, null, element);
|
|
305
|
-
currentElement = elm;
|
|
306
|
-
|
|
307
|
-
// Each time we attach this node to a message we get a new id that we can match
|
|
308
|
-
// when we are destroying the node later.
|
|
309
|
-
const $$attachId = (currentElement.$$attachId =
|
|
310
|
-
ngMessagesCtrl.getAttachId());
|
|
311
|
-
|
|
312
|
-
// in the event that the element or a parent element is destroyed
|
|
313
|
-
// by another structural directive then it's time
|
|
314
|
-
// to deregister the message from the controller
|
|
315
|
-
currentElement.on("$destroy", () => {
|
|
316
|
-
// If the message element was removed via a call to `detach` then `currentElement` will be null
|
|
317
|
-
// So this handler only handles cases where something else removed the message element.
|
|
318
|
-
if (
|
|
319
|
-
currentElement &&
|
|
320
|
-
currentElement.$$attachId === $$attachId
|
|
321
|
-
) {
|
|
322
|
-
ngMessagesCtrl.deregister(commentNode, isDefault);
|
|
323
|
-
messageCtrl.detach();
|
|
324
|
-
}
|
|
325
|
-
newScope.$destroy();
|
|
326
|
-
});
|
|
327
|
-
});
|
|
328
|
-
}
|
|
329
|
-
},
|
|
330
|
-
detach() {
|
|
331
|
-
if (currentElement) {
|
|
332
|
-
const elm = currentElement;
|
|
333
|
-
currentElement = null;
|
|
334
|
-
$animate.leave(elm);
|
|
335
|
-
}
|
|
336
|
-
},
|
|
337
|
-
}),
|
|
338
|
-
isDefault,
|
|
339
|
-
);
|
|
340
|
-
|
|
341
|
-
// We need to ensure that this directive deregisters itself when it no longer exists
|
|
342
|
-
// Normally this is done when the attached element is destroyed; but if this directive
|
|
343
|
-
// gets removed before we attach the message to the DOM there is nothing to watch
|
|
344
|
-
// in which case we must deregister when the containing scope is destroyed.
|
|
345
|
-
scope.$on("$destroy", () => {
|
|
346
|
-
ngMessagesCtrl.deregister(commentNode, isDefault);
|
|
347
|
-
});
|
|
348
|
-
},
|
|
349
|
-
};
|
|
350
|
-
},
|
|
351
|
-
];
|
|
352
|
-
|
|
353
|
-
function contains(collection, key) {
|
|
354
|
-
if (collection) {
|
|
355
|
-
return Array.isArray(collection)
|
|
356
|
-
? collection.indexOf(key) >= 0
|
|
357
|
-
: Object.prototype.hasOwnProperty.call(collection, key);
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export function initAriaModule(angular: any): void;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export function initMessageModule(angular: any): void;
|
|
File without changes
|
|
File without changes
|