@angular-wave/angular.ts 0.0.1
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/.eslintignore +1 -0
- package/.eslintrc.cjs +29 -0
- package/.github/workflows/playwright.yml +27 -0
- package/CHANGELOG.md +17974 -0
- package/CODE_OF_CONDUCT.md +3 -0
- package/CONTRIBUTING.md +246 -0
- package/DEVELOPERS.md +488 -0
- package/LICENSE +22 -0
- package/Makefile +31 -0
- package/README.md +115 -0
- package/RELEASE.md +98 -0
- package/SECURITY.md +16 -0
- package/TRIAGING.md +135 -0
- package/css/angular.css +22 -0
- package/dist/angular-ts.cjs.js +36843 -0
- package/dist/angular-ts.esm.js +36841 -0
- package/dist/angular-ts.umd.js +36848 -0
- package/dist/build/angular-animate.js +4272 -0
- package/dist/build/angular-aria.js +426 -0
- package/dist/build/angular-message-format.js +1072 -0
- package/dist/build/angular-messages.js +829 -0
- package/dist/build/angular-mocks.js +3757 -0
- package/dist/build/angular-parse-ext.js +1275 -0
- package/dist/build/angular-resource.js +911 -0
- package/dist/build/angular-route.js +1266 -0
- package/dist/build/angular-sanitize.js +891 -0
- package/dist/build/angular-touch.js +368 -0
- package/dist/build/angular.js +36600 -0
- package/e2e/unit.spec.ts +15 -0
- package/images/android-chrome-192x192.png +0 -0
- package/images/android-chrome-512x512.png +0 -0
- package/images/apple-touch-icon.png +0 -0
- package/images/favicon-16x16.png +0 -0
- package/images/favicon-32x32.png +0 -0
- package/images/favicon.ico +0 -0
- package/images/site.webmanifest +1 -0
- package/index.html +104 -0
- package/package.json +47 -0
- package/playwright.config.ts +78 -0
- package/public/circle.html +1 -0
- package/public/my_child_directive.html +1 -0
- package/public/my_directive.html +1 -0
- package/public/my_other_directive.html +1 -0
- package/public/test.html +1 -0
- package/rollup.config.js +31 -0
- package/src/animations/animateCache.js +55 -0
- package/src/animations/animateChildrenDirective.js +105 -0
- package/src/animations/animateCss.js +1139 -0
- package/src/animations/animateCssDriver.js +291 -0
- package/src/animations/animateJs.js +367 -0
- package/src/animations/animateJsDriver.js +67 -0
- package/src/animations/animateQueue.js +851 -0
- package/src/animations/animation.js +506 -0
- package/src/animations/module.js +779 -0
- package/src/animations/ngAnimateSwap.js +119 -0
- package/src/animations/rafScheduler.js +50 -0
- package/src/animations/shared.js +378 -0
- package/src/constants.js +20 -0
- package/src/core/animate.js +845 -0
- package/src/core/animateCss.js +73 -0
- package/src/core/animateRunner.js +195 -0
- package/src/core/attributes.js +199 -0
- package/src/core/cache.js +45 -0
- package/src/core/compile.js +4727 -0
- package/src/core/controller.js +225 -0
- package/src/core/exceptionHandler.js +63 -0
- package/src/core/filter.js +146 -0
- package/src/core/interpolate.js +442 -0
- package/src/core/interval.js +188 -0
- package/src/core/intervalFactory.js +57 -0
- package/src/core/location.js +1086 -0
- package/src/core/parser/parse.js +2562 -0
- package/src/core/parser/parse.md +13 -0
- package/src/core/q.js +746 -0
- package/src/core/rootScope.js +1596 -0
- package/src/core/sanitizeUri.js +85 -0
- package/src/core/sce.js +1161 -0
- package/src/core/taskTrackerFactory.js +125 -0
- package/src/core/timeout.js +121 -0
- package/src/core/urlUtils.js +187 -0
- package/src/core/utils.js +1349 -0
- package/src/directive/a.js +37 -0
- package/src/directive/attrs.js +283 -0
- package/src/directive/bind.js +51 -0
- package/src/directive/bind.md +142 -0
- package/src/directive/change.js +12 -0
- package/src/directive/change.md +25 -0
- package/src/directive/cloak.js +12 -0
- package/src/directive/cloak.md +24 -0
- package/src/directive/events.js +75 -0
- package/src/directive/events.md +166 -0
- package/src/directive/form.js +725 -0
- package/src/directive/init.js +15 -0
- package/src/directive/init.md +41 -0
- package/src/directive/input.js +1783 -0
- package/src/directive/list.js +46 -0
- package/src/directive/list.md +22 -0
- package/src/directive/ngClass.js +249 -0
- package/src/directive/ngController.js +64 -0
- package/src/directive/ngCsp.js +82 -0
- package/src/directive/ngIf.js +134 -0
- package/src/directive/ngInclude.js +217 -0
- package/src/directive/ngModel.js +1356 -0
- package/src/directive/ngModelOptions.js +509 -0
- package/src/directive/ngOptions.js +670 -0
- package/src/directive/ngRef.js +90 -0
- package/src/directive/ngRepeat.js +650 -0
- package/src/directive/ngShowHide.js +255 -0
- package/src/directive/ngSwitch.js +178 -0
- package/src/directive/ngTransclude.js +98 -0
- package/src/directive/non-bindable.js +11 -0
- package/src/directive/non-bindable.md +17 -0
- package/src/directive/script.js +30 -0
- package/src/directive/select.js +624 -0
- package/src/directive/style.js +25 -0
- package/src/directive/style.md +23 -0
- package/src/directive/validators.js +329 -0
- package/src/exts/aria.js +544 -0
- package/src/exts/messages.js +852 -0
- package/src/filters/filter.js +207 -0
- package/src/filters/filter.md +69 -0
- package/src/filters/filters.js +239 -0
- package/src/filters/json.md +16 -0
- package/src/filters/limit-to.js +43 -0
- package/src/filters/limit-to.md +19 -0
- package/src/filters/order-by.js +183 -0
- package/src/filters/order-by.md +83 -0
- package/src/index.js +13 -0
- package/src/injector.js +1034 -0
- package/src/jqLite.js +1117 -0
- package/src/loader.js +1320 -0
- package/src/public.js +215 -0
- package/src/routeToRegExp.js +41 -0
- package/src/services/anchorScroll.js +135 -0
- package/src/services/browser.js +321 -0
- package/src/services/cacheFactory.js +398 -0
- package/src/services/cookieReader.js +72 -0
- package/src/services/document.js +64 -0
- package/src/services/http.js +1537 -0
- package/src/services/httpBackend.js +206 -0
- package/src/services/log.js +160 -0
- package/src/services/templateRequest.js +139 -0
- package/test/angular.spec.js +2153 -0
- package/test/aria/aria.spec.js +1245 -0
- package/test/binding.spec.js +504 -0
- package/test/build-test.html +14 -0
- package/test/injector.spec.js +2327 -0
- package/test/jasmine/jasmine-5.1.2/boot0.js +65 -0
- package/test/jasmine/jasmine-5.1.2/boot1.js +133 -0
- package/test/jasmine/jasmine-5.1.2/jasmine-html.js +963 -0
- package/test/jasmine/jasmine-5.1.2/jasmine.css +320 -0
- package/test/jasmine/jasmine-5.1.2/jasmine.js +10824 -0
- package/test/jasmine/jasmine-5.1.2/jasmine_favicon.png +0 -0
- package/test/jasmine/jasmine-browser.json +17 -0
- package/test/jasmine/jasmine.json +9 -0
- package/test/jqlite.spec.js +2133 -0
- package/test/loader.spec.js +219 -0
- package/test/messages/messages.spec.js +1146 -0
- package/test/min-err.spec.js +174 -0
- package/test/mock-test.html +13 -0
- package/test/module-test.html +15 -0
- package/test/ng/anomate.spec.js +606 -0
- package/test/ng/cache-factor.spec.js +334 -0
- package/test/ng/compile.spec.js +17956 -0
- package/test/ng/controller-provider.spec.js +227 -0
- package/test/ng/cookie-reader.spec.js +98 -0
- package/test/ng/directive/a.spec.js +192 -0
- package/test/ng/directive/bind.spec.js +334 -0
- package/test/ng/directive/boolean.spec.js +136 -0
- package/test/ng/directive/change.spec.js +71 -0
- package/test/ng/directive/class.spec.js +858 -0
- package/test/ng/directive/click.spec.js +38 -0
- package/test/ng/directive/cloak.spec.js +44 -0
- package/test/ng/directive/constoller.spec.js +194 -0
- package/test/ng/directive/element-style.spec.js +92 -0
- package/test/ng/directive/event.spec.js +282 -0
- package/test/ng/directive/form.spec.js +1518 -0
- package/test/ng/directive/href.spec.js +143 -0
- package/test/ng/directive/if.spec.js +402 -0
- package/test/ng/directive/include.spec.js +828 -0
- package/test/ng/directive/init.spec.js +68 -0
- package/test/ng/directive/input.spec.js +3810 -0
- package/test/ng/directive/list.spec.js +170 -0
- package/test/ng/directive/model-options.spec.js +1008 -0
- package/test/ng/directive/model.spec.js +1905 -0
- package/test/ng/directive/non-bindable.spec.js +55 -0
- package/test/ng/directive/options.spec.js +3583 -0
- package/test/ng/directive/ref.spec.js +575 -0
- package/test/ng/directive/repeat.spec.js +1675 -0
- package/test/ng/directive/script.spec.js +52 -0
- package/test/ng/directive/scrset.spec.js +67 -0
- package/test/ng/directive/select.spec.js +2541 -0
- package/test/ng/directive/show-hide.spec.js +253 -0
- package/test/ng/directive/src.spec.js +157 -0
- package/test/ng/directive/style.spec.js +178 -0
- package/test/ng/directive/switch.spec.js +647 -0
- package/test/ng/directive/validators.spec.js +717 -0
- package/test/ng/document.spec.js +52 -0
- package/test/ng/filter/filter.spec.js +714 -0
- package/test/ng/filter/filters.spec.js +35 -0
- package/test/ng/filter/limit-to.spec.js +251 -0
- package/test/ng/filter/order-by.spec.js +891 -0
- package/test/ng/filter.spec.js +149 -0
- package/test/ng/http-backend.spec.js +398 -0
- package/test/ng/http.spec.js +4071 -0
- package/test/ng/interpolate.spec.js +642 -0
- package/test/ng/interval.spec.js +343 -0
- package/test/ng/location.spec.js +3488 -0
- package/test/ng/on.spec.js +229 -0
- package/test/ng/parse.spec.js +4655 -0
- package/test/ng/prop.spec.js +805 -0
- package/test/ng/q.spec.js +2904 -0
- package/test/ng/root-element.spec.js +16 -0
- package/test/ng/sanitize-uri.spec.js +249 -0
- package/test/ng/sce.spec.js +660 -0
- package/test/ng/scope.spec.js +3442 -0
- package/test/ng/template-request.spec.js +236 -0
- package/test/ng/timeout.spec.js +351 -0
- package/test/ng/url-utils.spec.js +156 -0
- package/test/ng/utils.spec.js +144 -0
- package/test/original-test.html +21 -0
- package/test/public.spec.js +34 -0
- package/test/sanitize/bing-html.spec.js +36 -0
- package/test/server/express.js +158 -0
- package/test/test-utils.js +11 -0
- package/tsconfig.json +17 -0
- package/types/angular.d.ts +138 -0
- package/types/global.d.ts +9 -0
- package/types/index.d.ts +2357 -0
- package/types/jqlite.d.ts +558 -0
- package/vite.config.js +14 -0
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
const NG_HIDE_CLASS = "ng-hide";
|
|
2
|
+
const NG_HIDE_IN_PROGRESS_CLASS = "ng-hide-animate";
|
|
3
|
+
/**
|
|
4
|
+
* @ngdoc directive
|
|
5
|
+
* @name ngShow
|
|
6
|
+
* @multiElement
|
|
7
|
+
*
|
|
8
|
+
* @description
|
|
9
|
+
* The `ngShow` directive shows or hides the given HTML element based on the expression provided to
|
|
10
|
+
* the `ngShow` attribute.
|
|
11
|
+
*
|
|
12
|
+
* The element is shown or hidden by removing or adding the `.ng-hide` CSS class onto the element.
|
|
13
|
+
* The `.ng-hide` CSS class is predefined in AngularJS and sets the display style to none (using an
|
|
14
|
+
* `!important` flag). For CSP mode please add `angular-csp.css` to your HTML file (see
|
|
15
|
+
* {@link ng.directive:ngCsp ngCsp}).
|
|
16
|
+
*
|
|
17
|
+
* ```html
|
|
18
|
+
* <!-- when $scope.myValue is truthy (element is visible) -->
|
|
19
|
+
* <div ng-show="myValue"></div>
|
|
20
|
+
*
|
|
21
|
+
* <!-- when $scope.myValue is falsy (element is hidden) -->
|
|
22
|
+
* <div ng-show="myValue" class="ng-hide"></div>
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* When the `ngShow` expression evaluates to a falsy value then the `.ng-hide` CSS class is added
|
|
26
|
+
* to the class attribute on the element causing it to become hidden. When truthy, the `.ng-hide`
|
|
27
|
+
* CSS class is removed from the element causing the element not to appear hidden.
|
|
28
|
+
*
|
|
29
|
+
* ## Why is `!important` used?
|
|
30
|
+
*
|
|
31
|
+
* You may be wondering why `!important` is used for the `.ng-hide` CSS class. This is because the
|
|
32
|
+
* `.ng-hide` selector can be easily overridden by heavier selectors. For example, something as
|
|
33
|
+
* simple as changing the display style on a HTML list item would make hidden elements appear
|
|
34
|
+
* visible. This also becomes a bigger issue when dealing with CSS frameworks.
|
|
35
|
+
*
|
|
36
|
+
* By using `!important`, the show and hide behavior will work as expected despite any clash between
|
|
37
|
+
* CSS selector specificity (when `!important` isn't used with any conflicting styles). If a
|
|
38
|
+
* developer chooses to override the styling to change how to hide an element then it is just a
|
|
39
|
+
* matter of using `!important` in their own CSS code.
|
|
40
|
+
*
|
|
41
|
+
* ### Overriding `.ng-hide`
|
|
42
|
+
*
|
|
43
|
+
* By default, the `.ng-hide` class will style the element with `display: none !important`. If you
|
|
44
|
+
* wish to change the hide behavior with `ngShow`/`ngHide`, you can simply overwrite the styles for
|
|
45
|
+
* the `.ng-hide` CSS class. Note that the selector that needs to be used is actually
|
|
46
|
+
* `.ng-hide:not(.ng-hide-animate)` to cope with extra animation classes that can be added.
|
|
47
|
+
*
|
|
48
|
+
* ```css
|
|
49
|
+
* .ng-hide:not(.ng-hide-animate) {
|
|
50
|
+
* /* These are just alternative ways of hiding an element */
|
|
51
|
+
* display: block!important;
|
|
52
|
+
* position: absolute;
|
|
53
|
+
* top: -9999px;
|
|
54
|
+
* left: -9999px;
|
|
55
|
+
* }
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* By default you don't need to override anything in CSS and the animations will work around the
|
|
59
|
+
* display style.
|
|
60
|
+
*
|
|
61
|
+
* @animations
|
|
62
|
+
* | Animation | Occurs |
|
|
63
|
+
* |-----------------------------------------------------|---------------------------------------------------------------------------------------------------------------|
|
|
64
|
+
* | {@link $animate#addClass addClass} `.ng-hide` | After the `ngShow` expression evaluates to a non truthy value and just before the contents are set to hidden. |
|
|
65
|
+
* | {@link $animate#removeClass removeClass} `.ng-hide` | After the `ngShow` expression evaluates to a truthy value and just before contents are set to visible. |
|
|
66
|
+
*
|
|
67
|
+
* Animations in `ngShow`/`ngHide` work with the show and hide events that are triggered when the
|
|
68
|
+
* directive expression is true and false. This system works like the animation system present with
|
|
69
|
+
* `ngClass` except that you must also include the `!important` flag to override the display
|
|
70
|
+
* property so that the elements are not actually hidden during the animation.
|
|
71
|
+
*
|
|
72
|
+
* ```css
|
|
73
|
+
* /* A working example can be found at the bottom of this page. */
|
|
74
|
+
* .my-element.ng-hide-add, .my-element.ng-hide-remove {
|
|
75
|
+
* transition: all 0.5s linear;
|
|
76
|
+
* }
|
|
77
|
+
*
|
|
78
|
+
* .my-element.ng-hide-add { ... }
|
|
79
|
+
* .my-element.ng-hide-add.ng-hide-add-active { ... }
|
|
80
|
+
* .my-element.ng-hide-remove { ... }
|
|
81
|
+
* .my-element.ng-hide-remove.ng-hide-remove-active { ... }
|
|
82
|
+
* ```
|
|
83
|
+
*
|
|
84
|
+
* Keep in mind that, as of AngularJS version 1.3, there is no need to change the display property
|
|
85
|
+
* to block during animation states - ngAnimate will automatically handle the style toggling for you.
|
|
86
|
+
*
|
|
87
|
+
* @element ANY
|
|
88
|
+
* @param {string} ngShow If the {@link guide/expression expression} is truthy/falsy then the
|
|
89
|
+
* element is shown/hidden respectively.
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* A simple example, animating the element's opacity:
|
|
93
|
+
|
|
94
|
+
* <hr />
|
|
95
|
+
*
|
|
96
|
+
* @knownIssue
|
|
97
|
+
*
|
|
98
|
+
* ### Flickering when using ngShow to toggle between elements
|
|
99
|
+
*
|
|
100
|
+
* When using {@link ngShow} and / or {@link ngHide} to toggle between elements, it can
|
|
101
|
+
* happen that both the element to show and the element to hide are visible for a very short time.
|
|
102
|
+
*
|
|
103
|
+
* This usually happens when the {@link ngAnimate ngAnimate module} is included, but no actual animations
|
|
104
|
+
* are defined for {@link ngShow} / {@link ngHide}.
|
|
105
|
+
*
|
|
106
|
+
* There are several way to mitigate this problem:
|
|
107
|
+
*
|
|
108
|
+
* - {@link guide/animations#how-to-selectively-enable-disable-and-skip-animations Disable animations on the affected elements}.
|
|
109
|
+
* - Use {@link ngIf} or {@link ngSwitch} instead of {@link ngShow} / {@link ngHide}.
|
|
110
|
+
* - Use the special CSS selector `ng-hide.ng-hide-animate` to set `{display: none}` or similar on the affected elements.
|
|
111
|
+
* - Use `ng-class="{'ng-hide': expression}` instead of instead of {@link ngShow} / {@link ngHide}.
|
|
112
|
+
* - Define an animation on the affected elements.
|
|
113
|
+
*/
|
|
114
|
+
export const ngShowDirective = [
|
|
115
|
+
"$animate",
|
|
116
|
+
($animate) => ({
|
|
117
|
+
restrict: "A",
|
|
118
|
+
multiElement: true,
|
|
119
|
+
link(scope, element, attr) {
|
|
120
|
+
scope.$watch(attr.ngShow, (value) => {
|
|
121
|
+
// we're adding a temporary, animation-specific class for ng-hide since this way
|
|
122
|
+
// we can control when the element is actually displayed on screen without having
|
|
123
|
+
// to have a global/greedy CSS selector that breaks when other animations are run.
|
|
124
|
+
// Read: https://github.com/angular/angular.js/issues/9103#issuecomment-58335845
|
|
125
|
+
$animate[value ? "removeClass" : "addClass"](element, NG_HIDE_CLASS, {
|
|
126
|
+
tempClasses: NG_HIDE_IN_PROGRESS_CLASS,
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
},
|
|
130
|
+
}),
|
|
131
|
+
];
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* @ngdoc directive
|
|
135
|
+
* @name ngHide
|
|
136
|
+
* @multiElement
|
|
137
|
+
*
|
|
138
|
+
* @description
|
|
139
|
+
* The `ngHide` directive shows or hides the given HTML element based on the expression provided to
|
|
140
|
+
* the `ngHide` attribute.
|
|
141
|
+
*
|
|
142
|
+
* The element is shown or hidden by removing or adding the `.ng-hide` CSS class onto the element.
|
|
143
|
+
* The `.ng-hide` CSS class is predefined in AngularJS and sets the display style to none (using an
|
|
144
|
+
* `!important` flag). For CSP mode please add `angular-csp.css` to your HTML file (see
|
|
145
|
+
* {@link ng.directive:ngCsp ngCsp}).
|
|
146
|
+
*
|
|
147
|
+
* ```html
|
|
148
|
+
* <!-- when $scope.myValue is truthy (element is hidden) -->
|
|
149
|
+
* <div ng-hide="myValue" class="ng-hide"></div>
|
|
150
|
+
*
|
|
151
|
+
* <!-- when $scope.myValue is falsy (element is visible) -->
|
|
152
|
+
* <div ng-hide="myValue"></div>
|
|
153
|
+
* ```
|
|
154
|
+
*
|
|
155
|
+
* When the `ngHide` expression evaluates to a truthy value then the `.ng-hide` CSS class is added
|
|
156
|
+
* to the class attribute on the element causing it to become hidden. When falsy, the `.ng-hide`
|
|
157
|
+
* CSS class is removed from the element causing the element not to appear hidden.
|
|
158
|
+
*
|
|
159
|
+
* ## Why is `!important` used?
|
|
160
|
+
*
|
|
161
|
+
* You may be wondering why `!important` is used for the `.ng-hide` CSS class. This is because the
|
|
162
|
+
* `.ng-hide` selector can be easily overridden by heavier selectors. For example, something as
|
|
163
|
+
* simple as changing the display style on a HTML list item would make hidden elements appear
|
|
164
|
+
* visible. This also becomes a bigger issue when dealing with CSS frameworks.
|
|
165
|
+
*
|
|
166
|
+
* By using `!important`, the show and hide behavior will work as expected despite any clash between
|
|
167
|
+
* CSS selector specificity (when `!important` isn't used with any conflicting styles). If a
|
|
168
|
+
* developer chooses to override the styling to change how to hide an element then it is just a
|
|
169
|
+
* matter of using `!important` in their own CSS code.
|
|
170
|
+
*
|
|
171
|
+
* ### Overriding `.ng-hide`
|
|
172
|
+
*
|
|
173
|
+
* By default, the `.ng-hide` class will style the element with `display: none !important`. If you
|
|
174
|
+
* wish to change the hide behavior with `ngShow`/`ngHide`, you can simply overwrite the styles for
|
|
175
|
+
* the `.ng-hide` CSS class. Note that the selector that needs to be used is actually
|
|
176
|
+
* `.ng-hide:not(.ng-hide-animate)` to cope with extra animation classes that can be added.
|
|
177
|
+
*
|
|
178
|
+
* ```css
|
|
179
|
+
* .ng-hide:not(.ng-hide-animate) {
|
|
180
|
+
* /* These are just alternative ways of hiding an element */
|
|
181
|
+
* display: block!important;
|
|
182
|
+
* position: absolute;
|
|
183
|
+
* top: -9999px;
|
|
184
|
+
* left: -9999px;
|
|
185
|
+
* }
|
|
186
|
+
* ```
|
|
187
|
+
*
|
|
188
|
+
* By default you don't need to override in CSS anything and the animations will work around the
|
|
189
|
+
* display style.
|
|
190
|
+
*
|
|
191
|
+
* @animations
|
|
192
|
+
* | Animation | Occurs |
|
|
193
|
+
* |-----------------------------------------------------|------------------------------------------------------------------------------------------------------------|
|
|
194
|
+
* | {@link $animate#addClass addClass} `.ng-hide` | After the `ngHide` expression evaluates to a truthy value and just before the contents are set to hidden. |
|
|
195
|
+
* | {@link $animate#removeClass removeClass} `.ng-hide` | After the `ngHide` expression evaluates to a non truthy value and just before contents are set to visible. |
|
|
196
|
+
*
|
|
197
|
+
* Animations in `ngShow`/`ngHide` work with the show and hide events that are triggered when the
|
|
198
|
+
* directive expression is true and false. This system works like the animation system present with
|
|
199
|
+
* `ngClass` except that you must also include the `!important` flag to override the display
|
|
200
|
+
* property so that the elements are not actually hidden during the animation.
|
|
201
|
+
*
|
|
202
|
+
* ```css
|
|
203
|
+
* /* A working example can be found at the bottom of this page. */
|
|
204
|
+
* .my-element.ng-hide-add, .my-element.ng-hide-remove {
|
|
205
|
+
* transition: all 0.5s linear;
|
|
206
|
+
* }
|
|
207
|
+
*
|
|
208
|
+
* .my-element.ng-hide-add { ... }
|
|
209
|
+
* .my-element.ng-hide-add.ng-hide-add-active { ... }
|
|
210
|
+
* .my-element.ng-hide-remove { ... }
|
|
211
|
+
* .my-element.ng-hide-remove.ng-hide-remove-active { ... }
|
|
212
|
+
* ```
|
|
213
|
+
*
|
|
214
|
+
* Keep in mind that, as of AngularJS version 1.3, there is no need to change the display property
|
|
215
|
+
* to block during animation states - ngAnimate will automatically handle the style toggling for you.
|
|
216
|
+
*
|
|
217
|
+
* @element ANY
|
|
218
|
+
* @param {string} ngHide If the {@link guide/expression expression} is truthy/falsy then the
|
|
219
|
+
* element is hidden/shown respectively.
|
|
220
|
+
*
|
|
221
|
+
* @knownIssue
|
|
222
|
+
*
|
|
223
|
+
* ### Flickering when using ngHide to toggle between elements
|
|
224
|
+
*
|
|
225
|
+
* When using {@link ngShow} and / or {@link ngHide} to toggle between elements, it can
|
|
226
|
+
* happen that both the element to show and the element to hide are visible for a very short time.
|
|
227
|
+
*
|
|
228
|
+
* This usually happens when the {@link ngAnimate ngAnimate module} is included, but no actual animations
|
|
229
|
+
* are defined for {@link ngShow} / {@link ngHide}. Internet Explorer is affected more often than
|
|
230
|
+
* other browsers.
|
|
231
|
+
*
|
|
232
|
+
* There are several way to mitigate this problem:
|
|
233
|
+
*
|
|
234
|
+
* - {@link guide/animations#how-to-selectively-enable-disable-and-skip-animations Disable animations on the affected elements}.
|
|
235
|
+
* - Use {@link ngIf} or {@link ngSwitch} instead of {@link ngShow} / {@link ngHide}.
|
|
236
|
+
* - Use the special CSS selector `ng-hide.ng-hide-animate` to set `{display: none}` or similar on the affected elements.
|
|
237
|
+
* - Use `ng-class="{'ng-hide': expression}` instead of instead of {@link ngShow} / {@link ngHide}.
|
|
238
|
+
* - Define an animation on the affected elements.
|
|
239
|
+
*/
|
|
240
|
+
export const ngHideDirective = [
|
|
241
|
+
"$animate",
|
|
242
|
+
($animate) => ({
|
|
243
|
+
restrict: "A",
|
|
244
|
+
multiElement: true,
|
|
245
|
+
link(scope, element, attr) {
|
|
246
|
+
scope.$watch(attr.ngHide, (value) => {
|
|
247
|
+
// The comment inside of the ngShowDirective explains why we add and
|
|
248
|
+
// remove a temporary class for the show/hide animation
|
|
249
|
+
$animate[value ? "addClass" : "removeClass"](element, NG_HIDE_CLASS, {
|
|
250
|
+
tempClasses: NG_HIDE_IN_PROGRESS_CLASS,
|
|
251
|
+
});
|
|
252
|
+
});
|
|
253
|
+
},
|
|
254
|
+
}),
|
|
255
|
+
];
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { forEach } from "../core/utils";
|
|
2
|
+
import { getBlockNodes } from "../jqLite";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @ngdoc directive
|
|
6
|
+
* @name ngSwitch
|
|
7
|
+
* @restrict EA
|
|
8
|
+
*
|
|
9
|
+
* @description
|
|
10
|
+
* The `ngSwitch` directive is used to conditionally swap DOM structure on your template based on a scope expression.
|
|
11
|
+
* Elements within `ngSwitch` but without `ngSwitchWhen` or `ngSwitchDefault` directives will be preserved at the location
|
|
12
|
+
* as specified in the template.
|
|
13
|
+
*
|
|
14
|
+
* The directive itself works similar to ngInclude, however, instead of downloading template code (or loading it
|
|
15
|
+
* from the template cache), `ngSwitch` simply chooses one of the nested elements and makes it visible based on which element
|
|
16
|
+
* matches the value obtained from the evaluated expression. In other words, you define a container element
|
|
17
|
+
* (where you place the directive), place an expression on the **`on="..."` attribute**
|
|
18
|
+
* (or the **`ng-switch="..."` attribute**), define any inner elements inside of the directive and place
|
|
19
|
+
* a when attribute per element. The when attribute is used to inform ngSwitch which element to display when the on
|
|
20
|
+
* expression is evaluated. If a matching expression is not found via a when attribute then an element with the default
|
|
21
|
+
* attribute is displayed.
|
|
22
|
+
*
|
|
23
|
+
* <div class="alert alert-info">
|
|
24
|
+
* Be aware that the attribute values to match against cannot be expressions. They are interpreted
|
|
25
|
+
* as literal string values to match against.
|
|
26
|
+
* For example, **`ng-switch-when="someVal"`** will match against the string `"someVal"` not against the
|
|
27
|
+
* value of the expression `$scope.someVal`.
|
|
28
|
+
* </div>
|
|
29
|
+
|
|
30
|
+
* @animations
|
|
31
|
+
* | Animation | Occurs |
|
|
32
|
+
* |----------------------------------|-------------------------------------|
|
|
33
|
+
* | {@link ng.$animate#enter enter} | after the ngSwitch contents change and the matched child element is placed inside the container |
|
|
34
|
+
* | {@link ng.$animate#leave leave} | after the ngSwitch contents change and just before the former contents are removed from the DOM |
|
|
35
|
+
*
|
|
36
|
+
* @usage
|
|
37
|
+
*
|
|
38
|
+
* ```
|
|
39
|
+
* <ANY ng-switch="expression">
|
|
40
|
+
* <ANY ng-switch-when="matchValue1">...</ANY>
|
|
41
|
+
* <ANY ng-switch-when="matchValue2">...</ANY>
|
|
42
|
+
* <ANY ng-switch-default>...</ANY>
|
|
43
|
+
* </ANY>
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
*
|
|
47
|
+
* @scope
|
|
48
|
+
* @priority 1200
|
|
49
|
+
* @param {*} ngSwitch|on expression to match against <code>ng-switch-when</code>.
|
|
50
|
+
* On child elements add:
|
|
51
|
+
*
|
|
52
|
+
* * `ngSwitchWhen`: the case statement to match against. If match then this
|
|
53
|
+
* case will be displayed. If the same match appears multiple times, all the
|
|
54
|
+
* elements will be displayed. It is possible to associate multiple values to
|
|
55
|
+
* the same `ngSwitchWhen` by defining the optional attribute
|
|
56
|
+
* `ngSwitchWhenSeparator`. The separator will be used to split the value of
|
|
57
|
+
* the `ngSwitchWhen` attribute into multiple tokens, and the element will show
|
|
58
|
+
* if any of the `ngSwitch` evaluates to any of these tokens.
|
|
59
|
+
* * `ngSwitchDefault`: the default case when no other case match. If there
|
|
60
|
+
* are multiple default cases, all of them will be displayed when no other
|
|
61
|
+
* case match.
|
|
62
|
+
*
|
|
63
|
+
*/
|
|
64
|
+
export const ngSwitchDirective = [
|
|
65
|
+
"$animate",
|
|
66
|
+
"$compile",
|
|
67
|
+
($animate, $compile) => ({
|
|
68
|
+
require: "ngSwitch",
|
|
69
|
+
|
|
70
|
+
// asks for $scope to fool the BC controller module
|
|
71
|
+
controller: [
|
|
72
|
+
"$scope",
|
|
73
|
+
function NgSwitchController() {
|
|
74
|
+
this.cases = {};
|
|
75
|
+
},
|
|
76
|
+
],
|
|
77
|
+
link(scope, element, attr, ngSwitchController) {
|
|
78
|
+
const watchExpr = attr.ngSwitch || attr.on;
|
|
79
|
+
let selectedTranscludes = [];
|
|
80
|
+
const selectedElements = [];
|
|
81
|
+
const previousLeaveAnimations = [];
|
|
82
|
+
const selectedScopes = [];
|
|
83
|
+
|
|
84
|
+
const spliceFactory = function (array, index) {
|
|
85
|
+
return function (response) {
|
|
86
|
+
if (response !== false) array.splice(index, 1);
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
scope.$watch(watchExpr, (value) => {
|
|
91
|
+
let i;
|
|
92
|
+
let ii;
|
|
93
|
+
|
|
94
|
+
// Start with the last, in case the array is modified during the loop
|
|
95
|
+
while (previousLeaveAnimations.length) {
|
|
96
|
+
$animate.cancel(previousLeaveAnimations.pop());
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
for (i = 0, ii = selectedScopes.length; i < ii; ++i) {
|
|
100
|
+
const selected = getBlockNodes(selectedElements[i].clone);
|
|
101
|
+
selectedScopes[i].$destroy();
|
|
102
|
+
const runner = (previousLeaveAnimations[i] =
|
|
103
|
+
$animate.leave(selected));
|
|
104
|
+
runner.done(spliceFactory(previousLeaveAnimations, i));
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
selectedElements.length = 0;
|
|
108
|
+
selectedScopes.length = 0;
|
|
109
|
+
|
|
110
|
+
if (
|
|
111
|
+
(selectedTranscludes =
|
|
112
|
+
ngSwitchController.cases[`!${value}`] ||
|
|
113
|
+
ngSwitchController.cases["?"])
|
|
114
|
+
) {
|
|
115
|
+
forEach(selectedTranscludes, (selectedTransclude) => {
|
|
116
|
+
selectedTransclude.transclude((caseElement, selectedScope) => {
|
|
117
|
+
selectedScopes.push(selectedScope);
|
|
118
|
+
const anchor = selectedTransclude.element;
|
|
119
|
+
caseElement[caseElement.length++] =
|
|
120
|
+
$compile.$$createComment("end ngSwitchWhen");
|
|
121
|
+
const block = { clone: caseElement };
|
|
122
|
+
|
|
123
|
+
selectedElements.push(block);
|
|
124
|
+
$animate.enter(caseElement, anchor.parent(), anchor);
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
},
|
|
130
|
+
}),
|
|
131
|
+
];
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* @returns {angular.IDirective}
|
|
135
|
+
*/
|
|
136
|
+
export function ngSwitchWhenDirective() {
|
|
137
|
+
return {
|
|
138
|
+
transclude: "element",
|
|
139
|
+
priority: 1200,
|
|
140
|
+
restrict: "EA",
|
|
141
|
+
require: "^ngSwitch",
|
|
142
|
+
multiElement: true,
|
|
143
|
+
link(scope, element, attrs, ctrl, $transclude) {
|
|
144
|
+
const cases = attrs.ngSwitchWhen
|
|
145
|
+
.split(attrs.ngSwitchWhenSeparator)
|
|
146
|
+
.sort()
|
|
147
|
+
.filter(
|
|
148
|
+
// Filter duplicate cases
|
|
149
|
+
(element, index, array) => array[index - 1] !== element,
|
|
150
|
+
);
|
|
151
|
+
|
|
152
|
+
cases.forEach((whenCase) => {
|
|
153
|
+
ctrl.cases[`!${whenCase}`] = ctrl.cases[`!${whenCase}`] || [];
|
|
154
|
+
ctrl.cases[`!${whenCase}`].push({
|
|
155
|
+
transclude: $transclude,
|
|
156
|
+
element,
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
},
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* @returns {angular.IDirective}
|
|
165
|
+
*/
|
|
166
|
+
export function ngSwitchDefaultDirective() {
|
|
167
|
+
return {
|
|
168
|
+
restrict: "EA",
|
|
169
|
+
transclude: "element",
|
|
170
|
+
priority: 1200,
|
|
171
|
+
require: "^ngSwitch",
|
|
172
|
+
multiElement: true,
|
|
173
|
+
link(_scope, element, _attr, ctrl, $transclude) {
|
|
174
|
+
ctrl.cases["?"] = ctrl.cases["?"] || [];
|
|
175
|
+
ctrl.cases["?"].push({ transclude: $transclude, element });
|
|
176
|
+
},
|
|
177
|
+
};
|
|
178
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { minErr } from "../core/utils";
|
|
2
|
+
import { startingTag } from "../jqLite";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @ngdoc directive
|
|
6
|
+
* @name ngTransclude
|
|
7
|
+
* @restrict EAC
|
|
8
|
+
*
|
|
9
|
+
* @description
|
|
10
|
+
* Directive that marks the insertion point for the transcluded DOM of the nearest parent directive that uses transclusion.
|
|
11
|
+
*
|
|
12
|
+
* You can specify that you want to insert a named transclusion slot, instead of the default slot, by providing the slot name
|
|
13
|
+
* as the value of the `ng-transclude` or `ng-transclude-slot` attribute.
|
|
14
|
+
*
|
|
15
|
+
* If the transcluded content is not empty (i.e. contains one or more DOM nodes, including whitespace text nodes), any existing
|
|
16
|
+
* content of this element will be removed before the transcluded content is inserted.
|
|
17
|
+
* If the transcluded content is empty (or only whitespace), the existing content is left intact. This lets you provide fallback
|
|
18
|
+
* content in the case that no transcluded content is provided.
|
|
19
|
+
*
|
|
20
|
+
* @element ANY
|
|
21
|
+
*
|
|
22
|
+
* @param {string} ngTransclude|ngTranscludeSlot the name of the slot to insert at this point. If this is not provided, is empty
|
|
23
|
+
* or its value is the same as the name of the attribute then the default slot is used.
|
|
24
|
+
*/
|
|
25
|
+
const ngTranscludeMinErr = minErr("ngTransclude");
|
|
26
|
+
export const ngTranscludeDirective = [
|
|
27
|
+
"$compile",
|
|
28
|
+
function ($compile) {
|
|
29
|
+
return {
|
|
30
|
+
restrict: "EAC",
|
|
31
|
+
compile: function ngTranscludeCompile(tElement) {
|
|
32
|
+
// Remove and cache any original content to act as a fallback
|
|
33
|
+
const fallbackLinkFn = $compile(tElement[0].childNodes);
|
|
34
|
+
tElement.empty();
|
|
35
|
+
|
|
36
|
+
return function ngTranscludePostLink(
|
|
37
|
+
$scope,
|
|
38
|
+
$element,
|
|
39
|
+
$attrs,
|
|
40
|
+
controller,
|
|
41
|
+
$transclude,
|
|
42
|
+
) {
|
|
43
|
+
if (!$transclude) {
|
|
44
|
+
throw ngTranscludeMinErr(
|
|
45
|
+
"orphan",
|
|
46
|
+
"Illegal use of ngTransclude directive in the template! " +
|
|
47
|
+
"No parent directive that requires a transclusion found. " +
|
|
48
|
+
"Element: {0}",
|
|
49
|
+
startingTag($element),
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// If the attribute is of the form: `ng-transclude="ng-transclude"` then treat it like the default
|
|
54
|
+
if ($attrs.ngTransclude === $attrs.$attr.ngTransclude) {
|
|
55
|
+
$attrs.ngTransclude = "";
|
|
56
|
+
}
|
|
57
|
+
const slotName = $attrs.ngTransclude || $attrs.ngTranscludeSlot;
|
|
58
|
+
|
|
59
|
+
// If the slot is required and no transclusion content is provided then this call will throw an error
|
|
60
|
+
$transclude(ngTranscludeCloneAttachFn, null, slotName);
|
|
61
|
+
|
|
62
|
+
// If the slot is optional and no transclusion content is provided then use the fallback content
|
|
63
|
+
if (slotName && !$transclude.isSlotFilled(slotName)) {
|
|
64
|
+
useFallbackContent();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function ngTranscludeCloneAttachFn(clone, transcludedScope) {
|
|
68
|
+
if (clone.length && notWhitespace(clone)) {
|
|
69
|
+
$element.append(clone);
|
|
70
|
+
} else {
|
|
71
|
+
useFallbackContent();
|
|
72
|
+
// There is nothing linked against the transcluded scope since no content was available,
|
|
73
|
+
// so it should be safe to clean up the generated scope.
|
|
74
|
+
transcludedScope.$destroy();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function useFallbackContent() {
|
|
79
|
+
// Since this is the fallback content rather than the transcluded content,
|
|
80
|
+
// we link against the scope of this directive rather than the transcluded scope
|
|
81
|
+
fallbackLinkFn($scope, (clone) => {
|
|
82
|
+
$element.append(clone);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function notWhitespace(nodes) {
|
|
87
|
+
for (let i = 0, ii = nodes.length; i < ii; i++) {
|
|
88
|
+
const node = nodes[i];
|
|
89
|
+
if (node.nodeType !== Node.TEXT_NODE || node.nodeValue.trim()) {
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
},
|
|
98
|
+
];
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
## `ngNonBindable` Directive
|
|
2
|
+
|
|
3
|
+
### Restrict
|
|
4
|
+
|
|
5
|
+
`AC`
|
|
6
|
+
|
|
7
|
+
### Priority
|
|
8
|
+
|
|
9
|
+
1000
|
|
10
|
+
|
|
11
|
+
### Element
|
|
12
|
+
|
|
13
|
+
`ANY`
|
|
14
|
+
|
|
15
|
+
### Description
|
|
16
|
+
|
|
17
|
+
The `ngNonBindable` directive tells AngularJS not to compile or bind the contents of the current DOM element, including directives on the element itself that have a lower priority than `ngNonBindable`. This is useful if the element contains what appears to be AngularJS directives and bindings but which should be ignored by AngularJS. This could be the case if you have a site that displays snippets of code, for instance.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @ngdoc directive
|
|
3
|
+
* @name script
|
|
4
|
+
* @restrict E
|
|
5
|
+
*
|
|
6
|
+
* @description
|
|
7
|
+
* Load the content of a `<script>` element into {@link ng.$templateCache `$templateCache`}, so that the
|
|
8
|
+
* template can be used by {@link ng.directive:ngInclude `ngInclude`},
|
|
9
|
+
* {@link ngRoute.directive:ngView `ngView`}, or {@link guide/directive directives}. The type of the
|
|
10
|
+
* `<script>` element must be specified as `text/ng-template`, and a cache name for the template must be
|
|
11
|
+
* assigned through the element's `id`, which can then be used as a directive's `templateUrl`.
|
|
12
|
+
*
|
|
13
|
+
* @param {string} type Must be set to `'text/ng-template'`.
|
|
14
|
+
* @param {string} id Cache name of the template.
|
|
15
|
+
*/
|
|
16
|
+
export const scriptDirective = [
|
|
17
|
+
"$templateCache",
|
|
18
|
+
($templateCache) => ({
|
|
19
|
+
restrict: "E",
|
|
20
|
+
terminal: true,
|
|
21
|
+
compile(element, attr) {
|
|
22
|
+
if (attr.type === "text/ng-template") {
|
|
23
|
+
const templateUrl = attr.id;
|
|
24
|
+
const { text } = element[0];
|
|
25
|
+
|
|
26
|
+
$templateCache.put(templateUrl, text);
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
}),
|
|
30
|
+
];
|