rails-angularjs 1.3.16 → 1.4.0.pre.rc.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -13
- data/lib/rails-angularjs/version.rb +1 -2
- data/vendor/assets/javascripts/angular-animate.js +3231 -1885
- data/vendor/assets/javascripts/angular-animate.min.js +45 -29
- data/vendor/assets/javascripts/angular-animate.min.js.map +3 -3
- data/vendor/assets/javascripts/angular-aria.js +89 -75
- data/vendor/assets/javascripts/angular-aria.min.js +9 -9
- data/vendor/assets/javascripts/angular-aria.min.js.map +2 -2
- data/vendor/assets/javascripts/angular-cookies.js +255 -141
- data/vendor/assets/javascripts/angular-cookies.min.js +5 -4
- data/vendor/assets/javascripts/angular-cookies.min.js.map +3 -3
- data/vendor/assets/javascripts/angular-loader.js +41 -17
- data/vendor/assets/javascripts/angular-loader.min.js +5 -5
- data/vendor/assets/javascripts/angular-loader.min.js.map +2 -2
- data/vendor/assets/javascripts/{unstable/angular-messageFormat.js → angular-message-format.js} +76 -18
- data/vendor/assets/javascripts/angular-message-format.min.js +26 -0
- data/vendor/assets/javascripts/angular-message-format.min.js.map +8 -0
- data/vendor/assets/javascripts/angular-messages.js +430 -153
- data/vendor/assets/javascripts/angular-messages.min.js +7 -6
- data/vendor/assets/javascripts/angular-messages.min.js.map +3 -3
- data/vendor/assets/javascripts/angular-mocks.js +76 -92
- data/vendor/assets/javascripts/angular-resource.js +4 -4
- data/vendor/assets/javascripts/angular-resource.min.js +3 -3
- data/vendor/assets/javascripts/angular-resource.min.js.map +1 -1
- data/vendor/assets/javascripts/angular-route.js +8 -6
- data/vendor/assets/javascripts/angular-route.min.js +2 -2
- data/vendor/assets/javascripts/angular-route.min.js.map +1 -1
- data/vendor/assets/javascripts/angular-sanitize.js +32 -28
- data/vendor/assets/javascripts/angular-sanitize.min.js +11 -11
- data/vendor/assets/javascripts/angular-sanitize.min.js.map +2 -2
- data/vendor/assets/javascripts/angular-scenario.js +4155 -2553
- data/vendor/assets/javascripts/angular-touch.js +15 -12
- data/vendor/assets/javascripts/angular-touch.min.js +9 -9
- data/vendor/assets/javascripts/angular-touch.min.js.map +2 -2
- data/vendor/assets/javascripts/angular.js +4092 -2529
- data/vendor/assets/javascripts/angular.min.js +283 -247
- data/vendor/assets/javascripts/angular.min.js.map +3 -3
- metadata +8 -39
- data/vendor/assets/javascripts/unstable/angular-animate.js +0 -3268
- data/vendor/assets/javascripts/unstable/angular-animate.min.js +0 -49
- data/vendor/assets/javascripts/unstable/angular-animate.min.js.map +0 -8
- data/vendor/assets/javascripts/unstable/angular-aria.js +0 -377
- data/vendor/assets/javascripts/unstable/angular-aria.min.js +0 -13
- data/vendor/assets/javascripts/unstable/angular-aria.min.js.map +0 -8
- data/vendor/assets/javascripts/unstable/angular-cookies.js +0 -320
- data/vendor/assets/javascripts/unstable/angular-cookies.min.js +0 -9
- data/vendor/assets/javascripts/unstable/angular-cookies.min.js.map +0 -8
- data/vendor/assets/javascripts/unstable/angular-loader.js +0 -429
- data/vendor/assets/javascripts/unstable/angular-loader.min.js +0 -9
- data/vendor/assets/javascripts/unstable/angular-loader.min.js.map +0 -8
- data/vendor/assets/javascripts/unstable/angular-messageFormat.min.js +0 -26
- data/vendor/assets/javascripts/unstable/angular-messageFormat.min.js.map +0 -8
- data/vendor/assets/javascripts/unstable/angular-messages.js +0 -667
- data/vendor/assets/javascripts/unstable/angular-messages.min.js +0 -11
- data/vendor/assets/javascripts/unstable/angular-messages.min.js.map +0 -8
- data/vendor/assets/javascripts/unstable/angular-mocks.js +0 -2452
- data/vendor/assets/javascripts/unstable/angular-resource.js +0 -668
- data/vendor/assets/javascripts/unstable/angular-resource.min.js +0 -13
- data/vendor/assets/javascripts/unstable/angular-resource.min.js.map +0 -8
- data/vendor/assets/javascripts/unstable/angular-route.js +0 -991
- data/vendor/assets/javascripts/unstable/angular-route.min.js +0 -15
- data/vendor/assets/javascripts/unstable/angular-route.min.js.map +0 -8
- data/vendor/assets/javascripts/unstable/angular-sanitize.js +0 -683
- data/vendor/assets/javascripts/unstable/angular-sanitize.min.js +0 -16
- data/vendor/assets/javascripts/unstable/angular-sanitize.min.js.map +0 -8
- data/vendor/assets/javascripts/unstable/angular-scenario.js +0 -39082
- data/vendor/assets/javascripts/unstable/angular-touch.js +0 -625
- data/vendor/assets/javascripts/unstable/angular-touch.min.js +0 -13
- data/vendor/assets/javascripts/unstable/angular-touch.min.js.map +0 -8
- data/vendor/assets/javascripts/unstable/angular.js +0 -27674
- data/vendor/assets/javascripts/unstable/angular.min.js +0 -286
- data/vendor/assets/javascripts/unstable/angular.min.js.map +0 -8
@@ -1,667 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* @license AngularJS v1.4.0-rc.0
|
3
|
-
* (c) 2010-2015 Google, Inc. http://angularjs.org
|
4
|
-
* License: MIT
|
5
|
-
*/
|
6
|
-
(function(window, angular, undefined) {'use strict';
|
7
|
-
|
8
|
-
/* jshint ignore:start */
|
9
|
-
// this code is in the core, but not in angular-messages.js
|
10
|
-
var isArray = angular.isArray;
|
11
|
-
var forEach = angular.forEach;
|
12
|
-
var isString = angular.isString;
|
13
|
-
var jqLite = angular.element;
|
14
|
-
/* jshint ignore:end */
|
15
|
-
|
16
|
-
/**
|
17
|
-
* @ngdoc module
|
18
|
-
* @name ngMessages
|
19
|
-
* @description
|
20
|
-
*
|
21
|
-
* The `ngMessages` module provides enhanced support for displaying messages within templates
|
22
|
-
* (typically within forms or when rendering message objects that return key/value data).
|
23
|
-
* Instead of relying on JavaScript code and/or complex ng-if statements within your form template to
|
24
|
-
* show and hide error messages specific to the state of an input field, the `ngMessages` and
|
25
|
-
* `ngMessage` directives are designed to handle the complexity, inheritance and priority
|
26
|
-
* sequencing based on the order of how the messages are defined in the template.
|
27
|
-
*
|
28
|
-
* Currently, the ngMessages module only contains the code for the `ngMessages`, `ngMessagesInclude`
|
29
|
-
* `ngMessage` and `ngMessageExp` directives.
|
30
|
-
*
|
31
|
-
* # Usage
|
32
|
-
* The `ngMessages` directive listens on a key/value collection which is set on the ngMessages attribute.
|
33
|
-
* Since the {@link ngModel ngModel} directive exposes an `$error` object, this error object can be
|
34
|
-
* used with `ngMessages` to display control error messages in an easier way than with just regular angular
|
35
|
-
* template directives.
|
36
|
-
*
|
37
|
-
* ```html
|
38
|
-
* <form name="myForm">
|
39
|
-
* <input type="text" ng-model="field" name="myField" required minlength="5" />
|
40
|
-
* <div ng-messages="myForm.myField.$error">
|
41
|
-
* <div ng-message="required">You did not enter a field</div>
|
42
|
-
* <div ng-message="minlength, maxlength">
|
43
|
-
* Your email must be between 5 and 100 characters long
|
44
|
-
* </div>
|
45
|
-
* </div>
|
46
|
-
* </form>
|
47
|
-
* ```
|
48
|
-
*
|
49
|
-
* Now whatever key/value entries are present within the provided object (in this case `$error`) then
|
50
|
-
* the ngMessages directive will render the inner first ngMessage directive (depending if the key values
|
51
|
-
* match the attribute value present on each ngMessage directive). In other words, if your errors
|
52
|
-
* object contains the following data:
|
53
|
-
*
|
54
|
-
* ```javascript
|
55
|
-
* <!-- keep in mind that ngModel automatically sets these error flags -->
|
56
|
-
* myField.$error = { minlength : true, required : false };
|
57
|
-
* ```
|
58
|
-
*
|
59
|
-
* Then the `required` message will be displayed first. When required is false then the `minlength` message
|
60
|
-
* will be displayed right after (since these messages are ordered this way in the template HTML code).
|
61
|
-
* The prioritization of each message is determined by what order they're present in the DOM.
|
62
|
-
* Therefore, instead of having custom JavaScript code determine the priority of what errors are
|
63
|
-
* present before others, the presentation of the errors are handled within the template.
|
64
|
-
*
|
65
|
-
* By default, ngMessages will only display one error at a time. However, if you wish to display all
|
66
|
-
* messages then the `ng-messages-multiple` attribute flag can be used on the element containing the
|
67
|
-
* ngMessages directive to make this happen.
|
68
|
-
*
|
69
|
-
* ```html
|
70
|
-
* <!-- attribute-style usage -->
|
71
|
-
* <div ng-messages="myForm.myField.$error" ng-messages-multiple>...</div>
|
72
|
-
*
|
73
|
-
* <!-- element-style usage -->
|
74
|
-
* <ng-messages for="myForm.myField.$error" multiple>...</ng-messages>
|
75
|
-
* ```
|
76
|
-
*
|
77
|
-
* ## Reusing and Overriding Messages
|
78
|
-
* In addition to prioritization, ngMessages also allows for including messages from a remote or an inline
|
79
|
-
* template. This allows for generic collection of messages to be reused across multiple parts of an
|
80
|
-
* application.
|
81
|
-
*
|
82
|
-
* ```html
|
83
|
-
* <script type="text/ng-template" id="error-messages">
|
84
|
-
* <div ng-message="required">This field is required</div>
|
85
|
-
* <div ng-message="minlength">This field is too short</div>
|
86
|
-
* </script>
|
87
|
-
*
|
88
|
-
* <div ng-messages="myForm.myField.$error">
|
89
|
-
* <div ng-messages-include="error-messages"></div>
|
90
|
-
* </div>
|
91
|
-
* ```
|
92
|
-
*
|
93
|
-
* However, including generic messages may not be useful enough to match all input fields, therefore,
|
94
|
-
* `ngMessages` provides the ability to override messages defined in the remote template by redefining
|
95
|
-
* them within the directive container.
|
96
|
-
*
|
97
|
-
* ```html
|
98
|
-
* <!-- a generic template of error messages known as "my-custom-messages" -->
|
99
|
-
* <script type="text/ng-template" id="my-custom-messages">
|
100
|
-
* <div ng-message="required">This field is required</div>
|
101
|
-
* <div ng-message="minlength">This field is too short</div>
|
102
|
-
* </script>
|
103
|
-
*
|
104
|
-
* <form name="myForm">
|
105
|
-
* <input type="email"
|
106
|
-
* id="email"
|
107
|
-
* name="myEmail"
|
108
|
-
* ng-model="email"
|
109
|
-
* minlength="5"
|
110
|
-
* required />
|
111
|
-
*
|
112
|
-
* <!-- any ng-message elements that appear BEFORE the ng-messages-include will
|
113
|
-
* override the messages present in the ng-messages-include template -->
|
114
|
-
* <div ng-messages="myForm.myEmail.$error">
|
115
|
-
* <!-- this required message has overridden the template message -->
|
116
|
-
* <div ng-message="required">You did not enter your email address</div>
|
117
|
-
*
|
118
|
-
* <!-- this is a brand new message and will appear last in the prioritization -->
|
119
|
-
* <div ng-message="email">Your email address is invalid</div>
|
120
|
-
*
|
121
|
-
* <!-- and here are the generic error messages -->
|
122
|
-
* <div ng-messages-include="error-messages"></div>
|
123
|
-
* </div>
|
124
|
-
* </form>
|
125
|
-
* ```
|
126
|
-
*
|
127
|
-
* In the example HTML code above the message that is set on required will override the corresponding
|
128
|
-
* required message defined within the remote template. Therefore, with particular input fields (such
|
129
|
-
* email addresses, date fields, autocomplete inputs, etc...), specialized error messages can be applied
|
130
|
-
* while more generic messages can be used to handle other, more general input errors.
|
131
|
-
*
|
132
|
-
* ## Dynamic Messaging
|
133
|
-
* ngMessages also supports using expressions to dynamically change key values. Using arrays and
|
134
|
-
* repeaters to list messages is also supported. This means that the code below will be able to
|
135
|
-
* fully adapt itself and display the appropriate message when any of the expression data changes:
|
136
|
-
*
|
137
|
-
* ```html
|
138
|
-
* <form name="myForm">
|
139
|
-
* <input type="email"
|
140
|
-
* name="myEmail"
|
141
|
-
* ng-model="email"
|
142
|
-
* minlength="5"
|
143
|
-
* required />
|
144
|
-
*
|
145
|
-
* <div ng-messages="myForm.myEmail.$error">
|
146
|
-
* <div ng-message="required">You did not enter your email address</div>
|
147
|
-
* <div ng-repeat="errorMessage in errorMessages">
|
148
|
-
* <!-- use ng-message-exp for a message whose key is given by an expression -->
|
149
|
-
* <div ng-message-exp="errorMessage.type">{{ errorMessage.text }}</div>
|
150
|
-
* </div>
|
151
|
-
* </div>
|
152
|
-
* </form>
|
153
|
-
* ```
|
154
|
-
*
|
155
|
-
* The `errorMessage.type` expression can be a string value or it can be an array so
|
156
|
-
* that multiple errors can be associated with a single error message:
|
157
|
-
*
|
158
|
-
* ```html
|
159
|
-
* <input type="email"
|
160
|
-
* ng-model="data.email"
|
161
|
-
* name="myEmail"
|
162
|
-
* ng-minlength="5"
|
163
|
-
* ng-maxlength="100"
|
164
|
-
* required />
|
165
|
-
* <div ng-messages="myForm.myEmail.$error">
|
166
|
-
* <div ng-message-exp="'required'">You did not enter your email address</div>
|
167
|
-
* <div ng-message-exp="['minlength', 'maxlength]">
|
168
|
-
* Your email must be between 5 and 100 characters long
|
169
|
-
* </div>
|
170
|
-
* </div>
|
171
|
-
* ```
|
172
|
-
*
|
173
|
-
* Feel free to use other structural directives such as ng-if and ng-switch to further control
|
174
|
-
* what messages are active and when. Be careful, if you place ng-message on the same element
|
175
|
-
* as these structural directives, Angular may not be able to determine if a message is active
|
176
|
-
* or not. Therefore it is best to place the ng-message on a child element of the structural
|
177
|
-
* directive.
|
178
|
-
*
|
179
|
-
* ```html
|
180
|
-
* <div ng-messages="myForm.myEmail.$error">
|
181
|
-
* <div ng-if="showRequiredError">
|
182
|
-
* <div ng-message="required">Please enter something</div>
|
183
|
-
* </div>
|
184
|
-
* </div>
|
185
|
-
* ```
|
186
|
-
*
|
187
|
-
* ## Animations
|
188
|
-
* If the `ngAnimate` module is active within the application then the `ngMessages`, `ngMessage` and
|
189
|
-
* `ngMessageExp` directives will trigger animations whenever any messages are added and removed from
|
190
|
-
* the DOM by the `ngMessages` directive.
|
191
|
-
*
|
192
|
-
* Whenever the `ngMessages` directive contains one or more visible messages then the `.ng-active` CSS
|
193
|
-
* class will be added to the element. The `.ng-inactive` CSS class will be applied when there are no
|
194
|
-
* messages present. Therefore, CSS transitions and keyframes as well as JavaScript animations can
|
195
|
-
* hook into the animations whenever these classes are added/removed.
|
196
|
-
*
|
197
|
-
* Let's say that our HTML code for our messages container looks like so:
|
198
|
-
*
|
199
|
-
* ```html
|
200
|
-
* <div ng-messages="myMessages" class="my-messages">
|
201
|
-
* <div ng-message="alert" class="some-message">...</div>
|
202
|
-
* <div ng-message="fail" class="some-message">...</div>
|
203
|
-
* </div>
|
204
|
-
* ```
|
205
|
-
*
|
206
|
-
* Then the CSS animation code for the message container looks like so:
|
207
|
-
*
|
208
|
-
* ```css
|
209
|
-
* .my-messages {
|
210
|
-
* transition:1s linear all;
|
211
|
-
* }
|
212
|
-
* .my-messages.ng-active {
|
213
|
-
* // messages are visible
|
214
|
-
* }
|
215
|
-
* .my-messages.ng-inactive {
|
216
|
-
* // messages are hidden
|
217
|
-
* }
|
218
|
-
* ```
|
219
|
-
*
|
220
|
-
* Whenever an inner message is attached (becomes visible) or removed (becomes hidden) then the enter
|
221
|
-
* and leave animation is triggered for each particular element bound to the `ngMessage` directive.
|
222
|
-
*
|
223
|
-
* Therefore, the CSS code for the inner messages looks like so:
|
224
|
-
*
|
225
|
-
* ```css
|
226
|
-
* .some-message {
|
227
|
-
* transition:1s linear all;
|
228
|
-
* }
|
229
|
-
*
|
230
|
-
* .some-message.ng-enter {}
|
231
|
-
* .some-message.ng-enter.ng-enter-active {}
|
232
|
-
*
|
233
|
-
* .some-message.ng-leave {}
|
234
|
-
* .some-message.ng-leave.ng-leave-active {}
|
235
|
-
* ```
|
236
|
-
*
|
237
|
-
* {@link ngAnimate Click here} to learn how to use JavaScript animations or to learn more about ngAnimate.
|
238
|
-
*/
|
239
|
-
angular.module('ngMessages', [])
|
240
|
-
|
241
|
-
/**
|
242
|
-
* @ngdoc directive
|
243
|
-
* @module ngMessages
|
244
|
-
* @name ngMessages
|
245
|
-
* @restrict AE
|
246
|
-
*
|
247
|
-
* @description
|
248
|
-
* `ngMessages` is a directive that is designed to show and hide messages based on the state
|
249
|
-
* of a key/value object that it listens on. The directive itself compliments error message
|
250
|
-
* reporting with the `ngModel` $error object (which stores a key/value state of validation errors).
|
251
|
-
*
|
252
|
-
* `ngMessages` manages the state of internal messages within its container element. The internal
|
253
|
-
* messages use the `ngMessage` directive and will be inserted/removed from the page depending
|
254
|
-
* on if they're present within the key/value object. By default, only one message will be displayed
|
255
|
-
* at a time and this depends on the prioritization of the messages within the template. (This can
|
256
|
-
* be changed by using the `ng-messages-multiple` or `multiple` attribute on the directive container.)
|
257
|
-
*
|
258
|
-
* A remote template can also be used to promote message reusability and messages can also be
|
259
|
-
* overridden.
|
260
|
-
*
|
261
|
-
* {@link module:ngMessages Click here} to learn more about `ngMessages` and `ngMessage`.
|
262
|
-
*
|
263
|
-
* @usage
|
264
|
-
* ```html
|
265
|
-
* <!-- using attribute directives -->
|
266
|
-
* <ANY ng-messages="expression">
|
267
|
-
* <ANY ng-message="stringValue">...</ANY>
|
268
|
-
* <ANY ng-message="stringValue1, stringValue2, ...">...</ANY>
|
269
|
-
* <ANY ng-message-exp="expressionValue">...</ANY>
|
270
|
-
* </ANY>
|
271
|
-
*
|
272
|
-
* <!-- or by using element directives -->
|
273
|
-
* <ng-messages for="expression">
|
274
|
-
* <ng-message when="stringValue">...</ng-message>
|
275
|
-
* <ng-message when="stringValue1, stringValue2, ...">...</ng-message>
|
276
|
-
* <ng-message when-exp="expressionValue">...</ng-message>
|
277
|
-
* </ng-messages>
|
278
|
-
* ```
|
279
|
-
*
|
280
|
-
* @param {string} ngMessages an angular expression evaluating to a key/value object
|
281
|
-
* (this is typically the $error object on an ngModel instance).
|
282
|
-
* @param {string=} ngMessagesMultiple|multiple when set, all messages will be displayed with true
|
283
|
-
*
|
284
|
-
* @example
|
285
|
-
* <example name="ngMessages-directive" module="ngMessagesExample"
|
286
|
-
* deps="angular-messages.js"
|
287
|
-
* animations="true" fixBase="true">
|
288
|
-
* <file name="index.html">
|
289
|
-
* <form name="myForm">
|
290
|
-
* <label>Enter your name:</label>
|
291
|
-
* <input type="text"
|
292
|
-
* name="myName"
|
293
|
-
* ng-model="name"
|
294
|
-
* ng-minlength="5"
|
295
|
-
* ng-maxlength="20"
|
296
|
-
* required />
|
297
|
-
*
|
298
|
-
* <pre>myForm.myName.$error = {{ myForm.myName.$error | json }}</pre>
|
299
|
-
*
|
300
|
-
* <div ng-messages="myForm.myName.$error" style="color:maroon">
|
301
|
-
* <div ng-message="required">You did not enter a field</div>
|
302
|
-
* <div ng-message="minlength">Your field is too short</div>
|
303
|
-
* <div ng-message="maxlength">Your field is too long</div>
|
304
|
-
* </div>
|
305
|
-
* </form>
|
306
|
-
* </file>
|
307
|
-
* <file name="script.js">
|
308
|
-
* angular.module('ngMessagesExample', ['ngMessages']);
|
309
|
-
* </file>
|
310
|
-
* </example>
|
311
|
-
*/
|
312
|
-
.directive('ngMessages', ['$animate', function($animate) {
|
313
|
-
var ACTIVE_CLASS = 'ng-active';
|
314
|
-
var INACTIVE_CLASS = 'ng-inactive';
|
315
|
-
|
316
|
-
return {
|
317
|
-
require: 'ngMessages',
|
318
|
-
restrict: 'AE',
|
319
|
-
controller: ['$element', '$scope', '$attrs', function($element, $scope, $attrs) {
|
320
|
-
var ctrl = this;
|
321
|
-
var latestKey = 0;
|
322
|
-
|
323
|
-
var messages = this.messages = {};
|
324
|
-
var renderLater, cachedCollection;
|
325
|
-
|
326
|
-
this.render = function(collection) {
|
327
|
-
collection = collection || {};
|
328
|
-
|
329
|
-
renderLater = false;
|
330
|
-
cachedCollection = collection;
|
331
|
-
|
332
|
-
// this is true if the attribute is empty or if the attribute value is truthy
|
333
|
-
var multiple = isAttrTruthy($scope, $attrs.ngMessagesMultiple) ||
|
334
|
-
isAttrTruthy($scope, $attrs.multiple);
|
335
|
-
|
336
|
-
var unmatchedMessages = [];
|
337
|
-
var matchedKeys = {};
|
338
|
-
var messageItem = ctrl.head;
|
339
|
-
var messageFound = false;
|
340
|
-
var totalMessages = 0;
|
341
|
-
|
342
|
-
// we use != instead of !== to allow for both undefined and null values
|
343
|
-
while (messageItem != null) {
|
344
|
-
totalMessages++;
|
345
|
-
var messageCtrl = messageItem.message;
|
346
|
-
|
347
|
-
var messageUsed = false;
|
348
|
-
if (!messageFound) {
|
349
|
-
forEach(collection, function(value, key) {
|
350
|
-
if (!messageUsed && truthy(value) && messageCtrl.test(key)) {
|
351
|
-
// this is to prevent the same error name from showing up twice
|
352
|
-
if (matchedKeys[key]) return;
|
353
|
-
matchedKeys[key] = true;
|
354
|
-
|
355
|
-
messageUsed = true;
|
356
|
-
messageCtrl.attach();
|
357
|
-
}
|
358
|
-
});
|
359
|
-
}
|
360
|
-
|
361
|
-
if (messageUsed) {
|
362
|
-
// unless we want to display multiple messages then we should
|
363
|
-
// set a flag here to avoid displaying the next message in the list
|
364
|
-
messageFound = !multiple;
|
365
|
-
} else {
|
366
|
-
unmatchedMessages.push(messageCtrl);
|
367
|
-
}
|
368
|
-
|
369
|
-
messageItem = messageItem.next;
|
370
|
-
}
|
371
|
-
|
372
|
-
forEach(unmatchedMessages, function(messageCtrl) {
|
373
|
-
messageCtrl.detach();
|
374
|
-
});
|
375
|
-
|
376
|
-
unmatchedMessages.length !== totalMessages
|
377
|
-
? $animate.setClass($element, ACTIVE_CLASS, INACTIVE_CLASS)
|
378
|
-
: $animate.setClass($element, INACTIVE_CLASS, ACTIVE_CLASS);
|
379
|
-
};
|
380
|
-
|
381
|
-
$scope.$watchCollection($attrs.ngMessages || $attrs['for'], ctrl.render);
|
382
|
-
|
383
|
-
this.reRender = function() {
|
384
|
-
if (!renderLater) {
|
385
|
-
renderLater = true;
|
386
|
-
$scope.$evalAsync(function() {
|
387
|
-
if (renderLater) {
|
388
|
-
cachedCollection && ctrl.render(cachedCollection);
|
389
|
-
}
|
390
|
-
});
|
391
|
-
}
|
392
|
-
};
|
393
|
-
|
394
|
-
this.register = function(comment, messageCtrl) {
|
395
|
-
var nextKey = latestKey.toString();
|
396
|
-
messages[nextKey] = {
|
397
|
-
message: messageCtrl
|
398
|
-
};
|
399
|
-
insertMessageNode($element[0], comment, nextKey);
|
400
|
-
comment.$$ngMessageNode = nextKey;
|
401
|
-
latestKey++;
|
402
|
-
|
403
|
-
ctrl.reRender();
|
404
|
-
};
|
405
|
-
|
406
|
-
this.deregister = function(comment) {
|
407
|
-
var key = comment.$$ngMessageNode;
|
408
|
-
delete comment.$$ngMessageNode;
|
409
|
-
removeMessageNode($element[0], comment, key);
|
410
|
-
delete messages[key];
|
411
|
-
ctrl.reRender();
|
412
|
-
};
|
413
|
-
|
414
|
-
function findPreviousMessage(parent, comment) {
|
415
|
-
var prevNode = comment;
|
416
|
-
var parentLookup = [];
|
417
|
-
while (prevNode && prevNode !== parent) {
|
418
|
-
var prevKey = prevNode.$$ngMessageNode;
|
419
|
-
if (prevKey && prevKey.length) {
|
420
|
-
return messages[prevKey];
|
421
|
-
}
|
422
|
-
|
423
|
-
// dive deeper into the DOM and examine its children for any ngMessage
|
424
|
-
// comments that may be in an element that appears deeper in the list
|
425
|
-
if (prevNode.childNodes.length && parentLookup.indexOf(prevNode) == -1) {
|
426
|
-
parentLookup.push(prevNode);
|
427
|
-
prevNode = prevNode.childNodes[prevNode.childNodes.length - 1];
|
428
|
-
} else {
|
429
|
-
prevNode = prevNode.previousSibling || prevNode.parentNode;
|
430
|
-
}
|
431
|
-
}
|
432
|
-
}
|
433
|
-
|
434
|
-
function insertMessageNode(parent, comment, key) {
|
435
|
-
var messageNode = messages[key];
|
436
|
-
if (!ctrl.head) {
|
437
|
-
ctrl.head = messageNode;
|
438
|
-
} else {
|
439
|
-
var match = findPreviousMessage(parent, comment);
|
440
|
-
if (match) {
|
441
|
-
messageNode.next = match.next;
|
442
|
-
match.next = messageNode;
|
443
|
-
} else {
|
444
|
-
messageNode.next = ctrl.head;
|
445
|
-
ctrl.head = messageNode;
|
446
|
-
}
|
447
|
-
}
|
448
|
-
}
|
449
|
-
|
450
|
-
function removeMessageNode(parent, comment, key) {
|
451
|
-
var messageNode = messages[key];
|
452
|
-
|
453
|
-
var match = findPreviousMessage(parent, comment);
|
454
|
-
if (match) {
|
455
|
-
match.next = messageNode.next;
|
456
|
-
} else {
|
457
|
-
ctrl.head = messageNode.next;
|
458
|
-
}
|
459
|
-
}
|
460
|
-
}]
|
461
|
-
};
|
462
|
-
|
463
|
-
function isAttrTruthy(scope, attr) {
|
464
|
-
return (isString(attr) && attr.length === 0) || //empty attribute
|
465
|
-
truthy(scope.$eval(attr));
|
466
|
-
}
|
467
|
-
|
468
|
-
function truthy(val) {
|
469
|
-
return isString(val) ? val.length : !!val;
|
470
|
-
}
|
471
|
-
}])
|
472
|
-
|
473
|
-
/**
|
474
|
-
* @ngdoc directive
|
475
|
-
* @name ngMessagesInclude
|
476
|
-
* @restrict AE
|
477
|
-
* @scope
|
478
|
-
*
|
479
|
-
* @description
|
480
|
-
* `ngMessagesInclude` is a directive with the purpose to import existing ngMessage template
|
481
|
-
* code from a remote template and place the downloaded template code into the exact spot
|
482
|
-
* that the ngMessagesInclude directive is placed within the ngMessages container. This allows
|
483
|
-
* for a series of pre-defined messages to be reused and also allows for the developer to
|
484
|
-
* determine what messages are overridden due to the placement of the ngMessagesInclude directive.
|
485
|
-
*
|
486
|
-
* @usage
|
487
|
-
* ```html
|
488
|
-
* <!-- using attribute directives -->
|
489
|
-
* <ANY ng-messages="expression">
|
490
|
-
* <ANY ng-messages-include="remoteTplString">...</ANY>
|
491
|
-
* </ANY>
|
492
|
-
*
|
493
|
-
* <!-- or by using element directives -->
|
494
|
-
* <ng-messages for="expression">
|
495
|
-
* <ng-messages-include src="expressionValue1">...</ng-messages-include>
|
496
|
-
* </ng-messages>
|
497
|
-
* ```
|
498
|
-
*
|
499
|
-
* {@link module:ngMessages Click here} to learn more about `ngMessages` and `ngMessage`.
|
500
|
-
*
|
501
|
-
* @param {string} ngMessagesInclude|src a string value corresponding to the remote template.
|
502
|
-
*/
|
503
|
-
.directive('ngMessagesInclude',
|
504
|
-
['$templateRequest', '$document', '$compile', function($templateRequest, $document, $compile) {
|
505
|
-
|
506
|
-
return {
|
507
|
-
restrict: 'AE',
|
508
|
-
require: '^^ngMessages', // we only require this for validation sake
|
509
|
-
link: function($scope, element, attrs) {
|
510
|
-
var src = attrs.ngMessagesInclude || attrs.src;
|
511
|
-
$templateRequest(src).then(function(html) {
|
512
|
-
$compile(html)($scope, function(contents) {
|
513
|
-
element.after(contents);
|
514
|
-
|
515
|
-
// the anchor is placed for debugging purposes
|
516
|
-
var anchor = jqLite($document[0].createComment(' ngMessagesInclude: ' + src + ' '));
|
517
|
-
element.after(anchor);
|
518
|
-
|
519
|
-
// we don't want to pollute the DOM anymore by keeping an empty directive element
|
520
|
-
element.remove();
|
521
|
-
});
|
522
|
-
});
|
523
|
-
}
|
524
|
-
};
|
525
|
-
}])
|
526
|
-
|
527
|
-
/**
|
528
|
-
* @ngdoc directive
|
529
|
-
* @name ngMessage
|
530
|
-
* @restrict AE
|
531
|
-
* @scope
|
532
|
-
*
|
533
|
-
* @description
|
534
|
-
* `ngMessage` is a directive with the purpose to show and hide a particular message.
|
535
|
-
* For `ngMessage` to operate, a parent `ngMessages` directive on a parent DOM element
|
536
|
-
* must be situated since it determines which messages are visible based on the state
|
537
|
-
* of the provided key/value map that `ngMessages` listens on.
|
538
|
-
*
|
539
|
-
* More information about using `ngMessage` can be found in the
|
540
|
-
* {@link module:ngMessages `ngMessages` module documentation}.
|
541
|
-
*
|
542
|
-
* @usage
|
543
|
-
* ```html
|
544
|
-
* <!-- using attribute directives -->
|
545
|
-
* <ANY ng-messages="expression">
|
546
|
-
* <ANY ng-message="stringValue">...</ANY>
|
547
|
-
* <ANY ng-message="stringValue1, stringValue2, ...">...</ANY>
|
548
|
-
* </ANY>
|
549
|
-
*
|
550
|
-
* <!-- or by using element directives -->
|
551
|
-
* <ng-messages for="expression">
|
552
|
-
* <ng-message when="stringValue">...</ng-message>
|
553
|
-
* <ng-message when="stringValue1, stringValue2, ...">...</ng-message>
|
554
|
-
* </ng-messages>
|
555
|
-
* ```
|
556
|
-
*
|
557
|
-
* @param {expression} ngMessage|when a string value corresponding to the message key.
|
558
|
-
*/
|
559
|
-
.directive('ngMessage', ngMessageDirectiveFactory('AE'))
|
560
|
-
|
561
|
-
|
562
|
-
/**
|
563
|
-
* @ngdoc directive
|
564
|
-
* @name ngMessageExp
|
565
|
-
* @restrict AE
|
566
|
-
* @scope
|
567
|
-
*
|
568
|
-
* @description
|
569
|
-
* `ngMessageExp` is a directive with the purpose to show and hide a particular message.
|
570
|
-
* For `ngMessageExp` to operate, a parent `ngMessages` directive on a parent DOM element
|
571
|
-
* must be situated since it determines which messages are visible based on the state
|
572
|
-
* of the provided key/value map that `ngMessages` listens on.
|
573
|
-
*
|
574
|
-
* @usage
|
575
|
-
* ```html
|
576
|
-
* <!-- using attribute directives -->
|
577
|
-
* <ANY ng-messages="expression">
|
578
|
-
* <ANY ng-message-exp="expressionValue">...</ANY>
|
579
|
-
* </ANY>
|
580
|
-
*
|
581
|
-
* <!-- or by using element directives -->
|
582
|
-
* <ng-messages for="expression">
|
583
|
-
* <ng-message when-exp="expressionValue">...</ng-message>
|
584
|
-
* </ng-messages>
|
585
|
-
* ```
|
586
|
-
*
|
587
|
-
* {@link module:ngMessages Click here} to learn more about `ngMessages` and `ngMessage`.
|
588
|
-
*
|
589
|
-
* @param {expression} ngMessageExp|whenExp an expression value corresponding to the message key.
|
590
|
-
*/
|
591
|
-
.directive('ngMessageExp', ngMessageDirectiveFactory('A'));
|
592
|
-
|
593
|
-
function ngMessageDirectiveFactory(restrict) {
|
594
|
-
return ['$animate', function($animate) {
|
595
|
-
return {
|
596
|
-
restrict: 'AE',
|
597
|
-
transclude: 'element',
|
598
|
-
terminal: true,
|
599
|
-
require: '^^ngMessages',
|
600
|
-
link: function(scope, element, attrs, ngMessagesCtrl, $transclude) {
|
601
|
-
var commentNode = element[0];
|
602
|
-
|
603
|
-
var records;
|
604
|
-
var staticExp = attrs.ngMessage || attrs.when;
|
605
|
-
var dynamicExp = attrs.ngMessageExp || attrs.whenExp;
|
606
|
-
var assignRecords = function(items) {
|
607
|
-
records = items
|
608
|
-
? (isArray(items)
|
609
|
-
? items
|
610
|
-
: items.split(/[\s,]+/))
|
611
|
-
: null;
|
612
|
-
ngMessagesCtrl.reRender();
|
613
|
-
};
|
614
|
-
|
615
|
-
if (dynamicExp) {
|
616
|
-
assignRecords(scope.$eval(dynamicExp));
|
617
|
-
scope.$watchCollection(dynamicExp, assignRecords);
|
618
|
-
} else {
|
619
|
-
assignRecords(staticExp);
|
620
|
-
}
|
621
|
-
|
622
|
-
var currentElement, messageCtrl;
|
623
|
-
ngMessagesCtrl.register(commentNode, messageCtrl = {
|
624
|
-
test: function(name) {
|
625
|
-
return contains(records, name);
|
626
|
-
},
|
627
|
-
attach: function() {
|
628
|
-
if (!currentElement) {
|
629
|
-
$transclude(scope, function(elm) {
|
630
|
-
$animate.enter(elm, null, element);
|
631
|
-
currentElement = elm;
|
632
|
-
|
633
|
-
// in the event that the parent element is destroyed
|
634
|
-
// by any other structural directive then it's time
|
635
|
-
// to deregister the message from the controller
|
636
|
-
currentElement.on('$destroy', function() {
|
637
|
-
if (currentElement) {
|
638
|
-
ngMessagesCtrl.deregister(commentNode);
|
639
|
-
messageCtrl.detach();
|
640
|
-
}
|
641
|
-
});
|
642
|
-
});
|
643
|
-
}
|
644
|
-
},
|
645
|
-
detach: function() {
|
646
|
-
if (currentElement) {
|
647
|
-
var elm = currentElement;
|
648
|
-
currentElement = null;
|
649
|
-
$animate.leave(elm);
|
650
|
-
}
|
651
|
-
}
|
652
|
-
});
|
653
|
-
}
|
654
|
-
};
|
655
|
-
}];
|
656
|
-
|
657
|
-
function contains(collection, key) {
|
658
|
-
if (collection) {
|
659
|
-
return isArray(collection)
|
660
|
-
? collection.indexOf(key) >= 0
|
661
|
-
: collection.hasOwnProperty(key);
|
662
|
-
}
|
663
|
-
}
|
664
|
-
}
|
665
|
-
|
666
|
-
|
667
|
-
})(window, window.angular);
|
@@ -1,11 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
AngularJS v1.4.0-rc.0
|
3
|
-
(c) 2010-2015 Google, Inc. http://angularjs.org
|
4
|
-
License: MIT
|
5
|
-
*/
|
6
|
-
(function(A,h,B){'use strict';function v(h){return["$animate",function(q){return{restrict:"AE",transclude:"element",terminal:!0,require:"^^ngMessages",link:function(m,e,a,g,k){var c=e[0],n,l=a.ngMessage||a.when;a=a.ngMessageExp||a.whenExp;var p=function(d){n=d?w(d)?d:d.split(/[\s,]+/):null;g.reRender()};a?(p(m.$eval(a)),m.$watchCollection(a,p)):p(l);var f,r;g.register(c,r={test:function(d){var b=n;d=b?w(b)?0<=b.indexOf(d):b.hasOwnProperty(d):void 0;return d},attach:function(){f||k(m,function(d){q.enter(d,
|
7
|
-
null,e);f=d;f.on("$destroy",function(){f&&(g.deregister(c),r.detach())})})},detach:function(){if(f){var d=f;f=null;q.leave(d)}}})}}}]}var w=h.isArray,x=h.forEach,y=h.isString,z=h.element;h.module("ngMessages",[]).directive("ngMessages",["$animate",function(h){function q(e,a){return y(a)&&0===a.length||m(e.$eval(a))}function m(e){return y(e)?e.length:!!e}return{require:"ngMessages",restrict:"AE",controller:["$element","$scope","$attrs",function(e,a,g){function k(a,d){for(var b=d,e=[];b&&b!==a;){var c=
|
8
|
-
b.$$ngMessageNode;if(c&&c.length)return l[c];b.childNodes.length&&-1==e.indexOf(b)?(e.push(b),b=b.childNodes[b.childNodes.length-1]):b=b.previousSibling||b.parentNode}}var c=this,n=0,l=this.messages={},p,f;this.render=function(r){r=r||{};p=!1;f=r;for(var d=q(a,g.ngMessagesMultiple)||q(a,g.multiple),b=[],n={},s=c.head,k=!1,l=0;null!=s;){l++;var t=s.message,u=!1;k||x(r,function(b,a){!u&&m(b)&&t.test(a)&&!n[a]&&(u=n[a]=!0,t.attach())});u?k=!d:b.push(t);s=s.next}x(b,function(b){b.detach()});b.length!==
|
9
|
-
l?h.setClass(e,"ng-active","ng-inactive"):h.setClass(e,"ng-inactive","ng-active")};a.$watchCollection(g.ngMessages||g["for"],c.render);this.reRender=function(){p||(p=!0,a.$evalAsync(function(){p&&f&&c.render(f)}))};this.register=function(a,d){var b=n.toString();l[b]={message:d};var g=e[0],f=l[b];c.head?(g=k(g,a))?(f.next=g.next,g.next=f):(f.next=c.head,c.head=f):c.head=f;a.$$ngMessageNode=b;n++;c.reRender()};this.deregister=function(a){var d=a.$$ngMessageNode;delete a.$$ngMessageNode;var b=l[d];(a=
|
10
|
-
k(e[0],a))?a.next=b.next:c.head=b.next;delete l[d];c.reRender()}}]}}]).directive("ngMessagesInclude",["$templateRequest","$document","$compile",function(h,q,m){return{restrict:"AE",require:"^^ngMessages",link:function(e,a,g){var k=g.ngMessagesInclude||g.src;h(k).then(function(c){m(c)(e,function(c){a.after(c);c=z(q[0].createComment(" ngMessagesInclude: "+k+" "));a.after(c);a.remove()})})}}}]).directive("ngMessage",v("AE")).directive("ngMessageExp",v("A"))})(window,window.angular);
|
11
|
-
//# sourceMappingURL=angular-messages.min.js.map
|