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