1 | /*!
|
---|
2 | * AngularJS Material Design
|
---|
3 | * https://github.com/angular/material
|
---|
4 | * @license MIT
|
---|
5 | * v1.2.3
|
---|
6 | */
|
---|
7 | (function( window, angular, undefined ){
|
---|
8 | "use strict";
|
---|
9 |
|
---|
10 | /**
|
---|
11 | * @ngdoc module
|
---|
12 | * @name material.components.showHide
|
---|
13 | */
|
---|
14 |
|
---|
15 | // Add additional handlers to ng-show and ng-hide that notify directives
|
---|
16 | // contained within that they should recompute their size.
|
---|
17 | // These run in addition to AngularJS's built-in ng-hide and ng-show directives.
|
---|
18 | angular.module('material.components.showHide', [
|
---|
19 | 'material.core'
|
---|
20 | ])
|
---|
21 | .directive('ngShow', createDirective('ngShow', true))
|
---|
22 | .directive('ngHide', createDirective('ngHide', false));
|
---|
23 |
|
---|
24 |
|
---|
25 | function createDirective(name, targetValue) {
|
---|
26 | return ['$mdUtil', '$window', function($mdUtil, $window) {
|
---|
27 | return {
|
---|
28 | restrict: 'A',
|
---|
29 | multiElement: true,
|
---|
30 | link: function($scope, $element, $attr) {
|
---|
31 | var unregister = $scope.$on('$md-resize-enable', function() {
|
---|
32 | unregister();
|
---|
33 |
|
---|
34 | var node = $element[0];
|
---|
35 | var cachedTransitionStyles = node.nodeType === $window.Node.ELEMENT_NODE ?
|
---|
36 | $window.getComputedStyle(node) : {};
|
---|
37 |
|
---|
38 | $scope.$watch($attr[name], function(value) {
|
---|
39 | if (!!value === targetValue) {
|
---|
40 | $mdUtil.nextTick(function() {
|
---|
41 | $scope.$broadcast('$md-resize');
|
---|
42 | });
|
---|
43 |
|
---|
44 | var opts = {
|
---|
45 | cachedTransitionStyles: cachedTransitionStyles
|
---|
46 | };
|
---|
47 |
|
---|
48 | $mdUtil.dom.animator.waitTransitionEnd($element, opts).then(function() {
|
---|
49 | $scope.$broadcast('$md-resize');
|
---|
50 | });
|
---|
51 | }
|
---|
52 | });
|
---|
53 | });
|
---|
54 | }
|
---|
55 | };
|
---|
56 | }];
|
---|
57 | }
|
---|
58 |
|
---|
59 | })(window, window.angular); |
---|