Skip to content

Commit 355bf6a

Browse files
committed
feat(angular): Upgrade to Angular 1.4
1 parent 7e4fb15 commit 355bf6a

23 files changed

+18154
-11634
lines changed

Diff for: config/lib/js/angular/angular-animate.js

+3,455-1,871
Large diffs are not rendered by default.

Diff for: config/lib/js/angular/angular-animate.min.js

+48-29
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: config/lib/js/angular/angular-animate.min.js.map

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: config/lib/js/angular/angular-aria.js

+124-78
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
2-
* @license AngularJS v1.3.13
3-
* (c) 2010-2014 Google, Inc. http://angularjs.org
2+
* @license AngularJS v1.4.3
3+
* (c) 2010-2015 Google, Inc. http://angularjs.org
44
* License: MIT
55
*/
66
(function(window, angular, undefined) {'use strict';
@@ -19,21 +19,21 @@
1919
*
2020
* ## Usage
2121
*
22-
* For ngAria to do its magic, simply include the module as a dependency. The directives supported
23-
* by ngAria are:
22+
* For ngAria to do its magic, simply include the module `ngAria` as a dependency. The following
23+
* directives are supported:
2424
* `ngModel`, `ngDisabled`, `ngShow`, `ngHide`, `ngClick`, `ngDblClick`, and `ngMessages`.
2525
*
2626
* Below is a more detailed breakdown of the attributes handled by ngAria:
2727
*
2828
* | Directive | Supported Attributes |
2929
* |---------------------------------------------|----------------------------------------------------------------------------------------|
30-
* | {@link ng.directive:ngModel ngModel} | aria-checked, aria-valuemin, aria-valuemax, aria-valuenow, aria-invalid, aria-required |
3130
* | {@link ng.directive:ngDisabled ngDisabled} | aria-disabled |
3231
* | {@link ng.directive:ngShow ngShow} | aria-hidden |
3332
* | {@link ng.directive:ngHide ngHide} | aria-hidden |
34-
* | {@link ng.directive:ngClick ngClick} | tabindex, keypress event |
3533
* | {@link ng.directive:ngDblclick ngDblclick} | tabindex |
3634
* | {@link module:ngMessages ngMessages} | aria-live |
35+
* | {@link ng.directive:ngModel ngModel} | aria-checked, aria-valuemin, aria-valuemax, aria-valuenow, aria-invalid, aria-required, input roles |
36+
* | {@link ng.directive:ngClick ngClick} | tabindex, keypress event, button role |
3737
*
3838
* Find out more information about each directive by reading the
3939
* {@link guide/accessibility ngAria Developer Guide}.
@@ -88,7 +88,8 @@ function $AriaProvider() {
8888
ariaMultiline: true,
8989
ariaValue: true,
9090
tabindex: true,
91-
bindKeypress: true
91+
bindKeypress: true,
92+
bindRoleForClick: true
9293
};
9394

9495
/**
@@ -107,6 +108,8 @@ function $AriaProvider() {
107108
* - **tabindex** – `{boolean}` – Enables/disables tabindex tags
108109
* - **bindKeypress** – `{boolean}` – Enables/disables keypress event binding on `<div>` and
109110
* `<li>` elements with ng-click
111+
* - **bindRoleForClick** – `{boolean}` – Adds role=button to non-interactive elements like `div`
112+
* using ng-click, making them more accessible to users of assistive technologies
110113
*
111114
* @description
112115
* Enables/disables various ARIA attributes
@@ -120,9 +123,8 @@ function $AriaProvider() {
120123
var ariaCamelName = attr.$normalize(ariaAttr);
121124
if (config[ariaCamelName] && !attr[ariaCamelName]) {
122125
scope.$watch(attr[attrName], function(boolVal) {
123-
if (negate) {
124-
boolVal = !boolVal;
125-
}
126+
// ensure boolean value
127+
boolVal = negate ? !boolVal : !!boolVal;
126128
elem.attr(ariaAttr, boolVal);
127129
});
128130
}
@@ -134,6 +136,7 @@ function $AriaProvider() {
134136
* @name $aria
135137
*
136138
* @description
139+
* @priority 200
137140
*
138141
* The $aria service contains helper methods for applying common
139142
* [ARIA](http://www.w3.org/TR/wai-aria/) attributes to HTML directives.
@@ -197,6 +200,10 @@ ngAriaModule.directive('ngShow', ['$aria', function($aria) {
197200
return $aria.config(normalizedAttr) && !elem.attr(attr);
198201
}
199202

203+
function shouldAttachRole(role, elem) {
204+
return !elem.attr('role') && (elem.attr('type') === role) && (elem[0].nodeName !== 'INPUT');
205+
}
206+
200207
function getShape(attr, elem) {
201208
var type = attr.type,
202209
role = attr.role;
@@ -210,82 +217,112 @@ ngAriaModule.directive('ngShow', ['$aria', function($aria) {
210217
return {
211218
restrict: 'A',
212219
require: '?ngModel',
213-
link: function(scope, elem, attr, ngModel) {
220+
priority: 200, //Make sure watches are fired after any other directives that affect the ngModel value
221+
compile: function(elem, attr) {
214222
var shape = getShape(attr, elem);
215-
var needsTabIndex = shouldAttachAttr('tabindex', 'tabindex', elem);
216-
217-
function ngAriaWatchModelValue() {
218-
return ngModel.$modelValue;
219-
}
220-
221-
function getRadioReaction() {
222-
if (needsTabIndex) {
223-
needsTabIndex = false;
224-
return function ngAriaRadioReaction(newVal) {
225-
var boolVal = newVal === attr.value;
226-
elem.attr('aria-checked', boolVal);
227-
elem.attr('tabindex', 0 - !boolVal);
228-
};
229-
} else {
230-
return function ngAriaRadioReaction(newVal) {
231-
elem.attr('aria-checked', newVal === attr.value);
232-
};
233-
}
234-
}
235223

236-
function ngAriaCheckboxReaction(newVal) {
237-
elem.attr('aria-checked', !!newVal);
238-
}
224+
return {
225+
pre: function(scope, elem, attr, ngModel) {
226+
if (shape === 'checkbox' && attr.type !== 'checkbox') {
227+
//Use the input[checkbox] $isEmpty implementation for elements with checkbox roles
228+
ngModel.$isEmpty = function(value) {
229+
return value === false;
230+
};
231+
}
232+
},
233+
post: function(scope, elem, attr, ngModel) {
234+
var needsTabIndex = shouldAttachAttr('tabindex', 'tabindex', elem);
239235

240-
switch (shape) {
241-
case 'radio':
242-
case 'checkbox':
243-
if (shouldAttachAttr('aria-checked', 'ariaChecked', elem)) {
244-
scope.$watch(ngAriaWatchModelValue, shape === 'radio' ?
245-
getRadioReaction() : ngAriaCheckboxReaction);
236+
function ngAriaWatchModelValue() {
237+
return ngModel.$modelValue;
246238
}
247-
break;
248-
case 'range':
249-
if ($aria.config('ariaValue')) {
250-
if (attr.min && !elem.attr('aria-valuemin')) {
251-
elem.attr('aria-valuemin', attr.min);
252-
}
253-
if (attr.max && !elem.attr('aria-valuemax')) {
254-
elem.attr('aria-valuemax', attr.max);
255-
}
256-
if (!elem.attr('aria-valuenow')) {
257-
scope.$watch(ngAriaWatchModelValue, function ngAriaValueNowReaction(newVal) {
258-
elem.attr('aria-valuenow', newVal);
259-
});
239+
240+
function getRadioReaction() {
241+
if (needsTabIndex) {
242+
needsTabIndex = false;
243+
return function ngAriaRadioReaction(newVal) {
244+
var boolVal = (attr.value == ngModel.$viewValue);
245+
elem.attr('aria-checked', boolVal);
246+
elem.attr('tabindex', 0 - !boolVal);
247+
};
248+
} else {
249+
return function ngAriaRadioReaction(newVal) {
250+
elem.attr('aria-checked', (attr.value == ngModel.$viewValue));
251+
};
260252
}
261253
}
262-
break;
263-
case 'multiline':
264-
if (shouldAttachAttr('aria-multiline', 'ariaMultiline', elem)) {
265-
elem.attr('aria-multiline', true);
254+
255+
function ngAriaCheckboxReaction() {
256+
elem.attr('aria-checked', !ngModel.$isEmpty(ngModel.$viewValue));
266257
}
267-
break;
268-
}
269258

270-
if (needsTabIndex) {
271-
elem.attr('tabindex', 0);
272-
}
259+
switch (shape) {
260+
case 'radio':
261+
case 'checkbox':
262+
if (shouldAttachRole(shape, elem)) {
263+
elem.attr('role', shape);
264+
}
265+
if (shouldAttachAttr('aria-checked', 'ariaChecked', elem)) {
266+
scope.$watch(ngAriaWatchModelValue, shape === 'radio' ?
267+
getRadioReaction() : ngAriaCheckboxReaction);
268+
}
269+
break;
270+
case 'range':
271+
if (shouldAttachRole(shape, elem)) {
272+
elem.attr('role', 'slider');
273+
}
274+
if ($aria.config('ariaValue')) {
275+
var needsAriaValuemin = !elem.attr('aria-valuemin') &&
276+
(attr.hasOwnProperty('min') || attr.hasOwnProperty('ngMin'));
277+
var needsAriaValuemax = !elem.attr('aria-valuemax') &&
278+
(attr.hasOwnProperty('max') || attr.hasOwnProperty('ngMax'));
279+
var needsAriaValuenow = !elem.attr('aria-valuenow');
273280

274-
if (ngModel.$validators.required && shouldAttachAttr('aria-required', 'ariaRequired', elem)) {
275-
scope.$watch(function ngAriaRequiredWatch() {
276-
return ngModel.$error.required;
277-
}, function ngAriaRequiredReaction(newVal) {
278-
elem.attr('aria-required', !!newVal);
279-
});
280-
}
281+
if (needsAriaValuemin) {
282+
attr.$observe('min', function ngAriaValueMinReaction(newVal) {
283+
elem.attr('aria-valuemin', newVal);
284+
});
285+
}
286+
if (needsAriaValuemax) {
287+
attr.$observe('max', function ngAriaValueMinReaction(newVal) {
288+
elem.attr('aria-valuemax', newVal);
289+
});
290+
}
291+
if (needsAriaValuenow) {
292+
scope.$watch(ngAriaWatchModelValue, function ngAriaValueNowReaction(newVal) {
293+
elem.attr('aria-valuenow', newVal);
294+
});
295+
}
296+
}
297+
break;
298+
case 'multiline':
299+
if (shouldAttachAttr('aria-multiline', 'ariaMultiline', elem)) {
300+
elem.attr('aria-multiline', true);
301+
}
302+
break;
303+
}
281304

282-
if (shouldAttachAttr('aria-invalid', 'ariaInvalid', elem)) {
283-
scope.$watch(function ngAriaInvalidWatch() {
284-
return ngModel.$invalid;
285-
}, function ngAriaInvalidReaction(newVal) {
286-
elem.attr('aria-invalid', !!newVal);
287-
});
288-
}
305+
if (needsTabIndex) {
306+
elem.attr('tabindex', 0);
307+
}
308+
309+
if (ngModel.$validators.required && shouldAttachAttr('aria-required', 'ariaRequired', elem)) {
310+
scope.$watch(function ngAriaRequiredWatch() {
311+
return ngModel.$error.required;
312+
}, function ngAriaRequiredReaction(newVal) {
313+
elem.attr('aria-required', !!newVal);
314+
});
315+
}
316+
317+
if (shouldAttachAttr('aria-invalid', 'ariaInvalid', elem)) {
318+
scope.$watch(function ngAriaInvalidWatch() {
319+
return ngModel.$invalid;
320+
}, function ngAriaInvalidReaction(newVal) {
321+
elem.attr('aria-invalid', !!newVal);
322+
});
323+
}
324+
}
325+
};
289326
}
290327
};
291328
}])
@@ -310,19 +347,28 @@ ngAriaModule.directive('ngShow', ['$aria', function($aria) {
310347
var fn = $parse(attr.ngClick, /* interceptorFn */ null, /* expensiveChecks */ true);
311348
return function(scope, elem, attr) {
312349

350+
var nodeBlackList = ['BUTTON', 'A', 'INPUT', 'TEXTAREA'];
351+
313352
function isNodeOneOf(elem, nodeTypeArray) {
314353
if (nodeTypeArray.indexOf(elem[0].nodeName) !== -1) {
315354
return true;
316355
}
317356
}
318357

358+
if ($aria.config('bindRoleForClick')
359+
&& !elem.attr('role')
360+
&& !isNodeOneOf(elem, nodeBlackList)) {
361+
elem.attr('role', 'button');
362+
}
363+
319364
if ($aria.config('tabindex') && !elem.attr('tabindex')) {
320365
elem.attr('tabindex', 0);
321366
}
322367

323-
if ($aria.config('bindKeypress') && !attr.ngKeypress && isNodeOneOf(elem, ['DIV', 'LI'])) {
368+
if ($aria.config('bindKeypress') && !attr.ngKeypress && !isNodeOneOf(elem, nodeBlackList)) {
324369
elem.on('keypress', function(event) {
325-
if (event.keyCode === 32 || event.keyCode === 13) {
370+
var keyCode = event.which || event.keyCode;
371+
if (keyCode === 32 || keyCode === 13) {
326372
scope.$apply(callback);
327373
}
328374

Diff for: config/lib/js/angular/angular-aria.min.js

+9-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)