@angular-wave/angular.ts 0.0.68 → 0.0.69
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.spec.js +2 -2
- 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 -1
- package/src/core/timeout/timeout.js +5 -21
- 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 +346 -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/exts/aria/aria.spec.js +1 -1
- package/src/filters/filter.js +2 -3
- package/src/filters/filter.spec.js +1 -1
- package/src/filters/filters.spec.js +1 -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 +12 -2
- 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 -1
- package/types/core/q/q.d.ts +5 -0
- package/types/core/scope/scope.d.ts +1 -1
- package/types/core/timeout/timeout.d.ts +3 -7
- 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/src/exts/messages/messages.js +0 -361
- package/types/exts/messages/messages.d.ts +0 -1
- /package/src/{exts → directive}/messages/messages.md +0 -0
package/types/core/q/q.d.ts
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
* @property {function(((reason: any) => (QPromise<never>|QPromise<T>|T))|null): QPromise<T>|T} catch - Shorthand for promise.then(null, errorCallback).
|
|
16
16
|
* @property {function(function(): void): QPromise<T>} finally - Allows you to observe either the fulfillment or rejection of a promise, but to do so without modifying the final value.
|
|
17
17
|
* @property {number} [$$intervalId] - Internal id set by the $interval service for callback notifications
|
|
18
|
+
* @property {number} [$$timeoutId] - Timeout id set by the $timeout service for cancelations
|
|
18
19
|
*/
|
|
19
20
|
/**
|
|
20
21
|
*@template T
|
|
@@ -65,6 +66,10 @@ export type QPromise<T> = {
|
|
|
65
66
|
* - Internal id set by the $interval service for callback notifications
|
|
66
67
|
*/
|
|
67
68
|
$$intervalId?: number;
|
|
69
|
+
/**
|
|
70
|
+
* - Timeout id set by the $timeout service for cancelations
|
|
71
|
+
*/
|
|
72
|
+
$$timeoutId?: number;
|
|
68
73
|
};
|
|
69
74
|
export type Deferred<T> = {
|
|
70
75
|
/**
|
|
@@ -598,7 +598,7 @@ export class Scope {
|
|
|
598
598
|
*
|
|
599
599
|
* @param {(object)=} locals Local variables object, useful for overriding values in scope.
|
|
600
600
|
*/
|
|
601
|
-
$evalAsync(expr?: (string | ((arg0: any) => any)) | undefined, locals?: (object) | undefined):
|
|
601
|
+
$evalAsync(expr?: (string | ((arg0: any) => any)) | undefined, locals?: (object) | undefined): number;
|
|
602
602
|
/**
|
|
603
603
|
* @ngdoc method
|
|
604
604
|
* @name $rootScope.Scope#$applyAsync
|
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
export function $TimeoutProvider(): void;
|
|
2
2
|
export class $TimeoutProvider {
|
|
3
3
|
$get: (string | (($rootScope: import("../scope/scope").Scope, $browser: import("../../services/browser").Browser, $q: any, $$q: any, $exceptionHandler: import("../exception-handler").ErrorHandler) => {
|
|
4
|
-
(fn?: (() => any) | undefined, delay?: number | undefined, invokeApply?: boolean | undefined, ...args: any[]):
|
|
4
|
+
(fn?: (() => any) | undefined, delay?: number | undefined, invokeApply?: boolean | undefined, ...args: any[]): import("../q/q").QPromise<any>;
|
|
5
5
|
/**
|
|
6
|
-
* @ngdoc method
|
|
7
|
-
* @name $timeout#cancel
|
|
8
|
-
*
|
|
9
|
-
* @description
|
|
10
6
|
* Cancels a task associated with the `promise`. As a result of this, the promise will be
|
|
11
7
|
* resolved with a rejection.
|
|
12
8
|
*
|
|
13
|
-
* @param {
|
|
9
|
+
* @param {import("../q/q").QPromise<any>} promise Promise returned by the `$timeout` function.
|
|
14
10
|
* @returns {boolean} Returns `true` if the task hasn't executed yet and was successfully
|
|
15
11
|
* canceled.
|
|
16
12
|
*/
|
|
17
|
-
cancel(promise
|
|
13
|
+
cancel(promise: import("../q/q").QPromise<any>): boolean;
|
|
18
14
|
}))[];
|
|
19
15
|
}
|
|
@@ -49,12 +49,6 @@ export class FormController {
|
|
|
49
49
|
*/
|
|
50
50
|
$commitViewValue(): void;
|
|
51
51
|
/**
|
|
52
|
-
* @ngdoc method
|
|
53
|
-
* @name form.FormController#$addControl
|
|
54
|
-
* @param {object} control control object, either a {@link form.FormController} or an
|
|
55
|
-
* {@link ngModel.NgModelController}
|
|
56
|
-
*
|
|
57
|
-
* @description
|
|
58
52
|
* Register a control with the form. Input elements using ngModelController do this automatically
|
|
59
53
|
* when they are linked.
|
|
60
54
|
*
|
|
@@ -69,13 +63,8 @@ export class FormController {
|
|
|
69
63
|
* For example, if an input control is added that is already `$dirty` and has `$error` properties,
|
|
70
64
|
* calling `$setDirty()` and `$validate()` afterwards will propagate the state to the parent form.
|
|
71
65
|
*/
|
|
72
|
-
$addControl(control:
|
|
66
|
+
$addControl(control: any): void;
|
|
73
67
|
/**
|
|
74
|
-
* @ngdoc method
|
|
75
|
-
* @name form.FormController#$getControls
|
|
76
|
-
* @returns {Array} the controls that are currently part of this form
|
|
77
|
-
*
|
|
78
|
-
* @description
|
|
79
68
|
* This method returns a **shallow copy** of the controls that are currently part of this form.
|
|
80
69
|
* The controls can be instances of {@link form.FormController `FormController`}
|
|
81
70
|
* ({@link ngForm "child-forms"}) and of {@link ngModel.NgModelController `NgModelController`}.
|
|
@@ -90,15 +79,9 @@ export class FormController {
|
|
|
90
79
|
* in the shallow copy. That means you should get a fresh copy from `$getControls()` every time
|
|
91
80
|
* you need access to the controls.
|
|
92
81
|
*/
|
|
93
|
-
$getControls(): any
|
|
82
|
+
$getControls(): any;
|
|
94
83
|
$$renameControl(control: any, newName: any): void;
|
|
95
84
|
/**
|
|
96
|
-
* @ngdoc method
|
|
97
|
-
* @name form.FormController#$removeControl
|
|
98
|
-
* @param {object} control control object, either a {@link form.FormController} or an
|
|
99
|
-
* {@link ngModel.NgModelController}
|
|
100
|
-
*
|
|
101
|
-
* @description
|
|
102
85
|
* Deregister a control from the form.
|
|
103
86
|
*
|
|
104
87
|
* Input elements using ngModelController do this automatically when they are destroyed.
|
|
@@ -108,7 +91,7 @@ export class FormController {
|
|
|
108
91
|
* different from case to case. For example, removing the only `$dirty` control from a form may or
|
|
109
92
|
* may not mean that the form is still `$dirty`.
|
|
110
93
|
*/
|
|
111
|
-
$removeControl(control:
|
|
94
|
+
$removeControl(control: any): void;
|
|
112
95
|
/**
|
|
113
96
|
* @ngdoc method
|
|
114
97
|
* @name form.FormController#$setDirty
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const ngIncludeDirective: (string | (($templateRequest: any, $anchorScroll:
|
|
1
|
+
export const ngIncludeDirective: (string | (($templateRequest: any, $anchorScroll: import("../../services/anchor-scroll").AnchorScrollFunction, $animate: any) => {
|
|
2
2
|
restrict: string;
|
|
3
3
|
priority: number;
|
|
4
4
|
terminal: boolean;
|
|
@@ -59,20 +59,20 @@ export class TemplateFactory {
|
|
|
59
59
|
* Creates a template by invoking an injectable provider function.
|
|
60
60
|
*
|
|
61
61
|
* @param {import('../types').Injectable<any>} provider Function to invoke via `locals`
|
|
62
|
-
* @param {Function}
|
|
62
|
+
* @param {Function} params a function used to invoke the template provider
|
|
63
63
|
* @param {import("./resolve/resolve-context").ResolveContext} context
|
|
64
64
|
* @return {string|Promise.<string>} The template html as a string, or a promise
|
|
65
65
|
* for that string.
|
|
66
66
|
*/
|
|
67
|
-
fromProvider(provider: import("../types").Injectable<any>, params:
|
|
67
|
+
fromProvider(provider: import("../types").Injectable<any>, params: Function, context: import("./resolve/resolve-context").ResolveContext): string | Promise<string>;
|
|
68
68
|
/**
|
|
69
69
|
* Creates a component's template by invoking an injectable provider function.
|
|
70
70
|
*
|
|
71
71
|
* @param {import('../types').Injectable<any>} provider Function to invoke via `locals`
|
|
72
|
-
* @param {Function}
|
|
72
|
+
* @param {Function} params a function used to invoke the template provider
|
|
73
73
|
* @return {string} The template html as a string: "<component-name input1='::$resolve.foo'></component-name>".
|
|
74
74
|
*/
|
|
75
|
-
fromComponentProvider(provider: import("../types").Injectable<any>, params:
|
|
75
|
+
fromComponentProvider(provider: import("../types").Injectable<any>, params: Function, context: any): string;
|
|
76
76
|
/**
|
|
77
77
|
* Creates a template from a component's name
|
|
78
78
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export function $ViewScrollProvider(): void;
|
|
2
2
|
export class $ViewScrollProvider {
|
|
3
3
|
useAnchorScroll: () => void;
|
|
4
|
-
$get: (string | (($anchorScroll:
|
|
4
|
+
$get: (string | (($anchorScroll: import("../services/anchor-scroll").AnchorScrollObject, $timeout: any) => import("../services/anchor-scroll").AnchorScrollObject | Function))[];
|
|
5
5
|
}
|
|
@@ -1,5 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {Object} AnchorScrollObject
|
|
3
|
+
* @property {number|function|import("../shared/jqlite/jqlite").JQLite} yOffset
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @typedef {(string) => void} AnchorScrollFunction
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* @typedef {AnchorScrollFunction | AnchorScrollObject} AnchorScrollService
|
|
10
|
+
*/
|
|
1
11
|
export function AnchorScrollProvider(): void;
|
|
2
12
|
export class AnchorScrollProvider {
|
|
3
13
|
disableAutoScrolling: () => void;
|
|
4
|
-
$get: (string | (($location: import("../core/location/location").Location, $rootScope: import("../core/scope/scope").Scope) =>
|
|
14
|
+
$get: (string | (($location: import("../core/location/location").Location, $rootScope: import("../core/scope/scope").Scope) => AnchorScrollFunction))[];
|
|
5
15
|
}
|
|
16
|
+
export type AnchorScrollObject = {
|
|
17
|
+
yOffset: number | Function | import("../shared/jqlite/jqlite").JQLite;
|
|
18
|
+
};
|
|
19
|
+
export type AnchorScrollFunction = (string: any) => void;
|
|
20
|
+
export type AnchorScrollService = AnchorScrollFunction | AnchorScrollObject;
|
|
@@ -125,7 +125,7 @@ export class Browser {
|
|
|
125
125
|
* @param {function():any} fn A function, who's execution should be deferred.
|
|
126
126
|
* @param {number=} [delay=0] Number of milliseconds to defer the function execution.
|
|
127
127
|
* @param {string=} [taskType=DEFAULT_TASK_TYPE] The type of task that is deferred.
|
|
128
|
-
* @returns {
|
|
128
|
+
* @returns {number} DeferId that can be used to cancel the task via `$browser.cancel()`.
|
|
129
129
|
*
|
|
130
130
|
* @description
|
|
131
131
|
* Executes a fn asynchronously via `setTimeout(fn, delay)`.
|
|
@@ -135,7 +135,7 @@ export class Browser {
|
|
|
135
135
|
* via `$browser.defer.flush()`.
|
|
136
136
|
*
|
|
137
137
|
*/
|
|
138
|
-
defer: (fn: () => any, delay?: number | undefined, taskType?: string | undefined) =>
|
|
138
|
+
defer: (fn: () => any, delay?: number | undefined, taskType?: string | undefined) => number;
|
|
139
139
|
/**
|
|
140
140
|
* @name $browser#cancel
|
|
141
141
|
*
|
|
@@ -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 initMessageModule(angular: any): void;
|
|
File without changes
|