fabActions.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*!
  2. * Angular Material Design
  3. * https://github.com/angular/material
  4. * @license MIT
  5. * v0.11.4
  6. */
  7. goog.provide('ng.material.components.fabActions');
  8. goog.require('ng.material.core');
  9. (function() {
  10. 'use strict';
  11. /**
  12. * @ngdoc module
  13. * @name material.components.fabActions
  14. */
  15. angular
  16. .module('material.components.fabActions', ['material.core'])
  17. .directive('mdFabActions', MdFabActionsDirective);
  18. /**
  19. * @ngdoc directive
  20. * @name mdFabActions
  21. * @module material.components.fabActions
  22. *
  23. * @restrict E
  24. *
  25. * @description
  26. * The `<md-fab-actions>` directive is used inside of a `<md-fab-speed-dial>` or
  27. * `<md-fab-toolbar>` directive to mark an element (or elements) as the actions and setup the
  28. * proper event listeners.
  29. *
  30. * @usage
  31. * See the `<md-fab-speed-dial>` or `<md-fab-toolbar>` directives for example usage.
  32. */
  33. function MdFabActionsDirective() {
  34. return {
  35. restrict: 'E',
  36. require: ['^?mdFabSpeedDial', '^?mdFabToolbar'],
  37. compile: function(element, attributes) {
  38. var children = element.children();
  39. var hasNgRepeat = false;
  40. angular.forEach(['', 'data-', 'x-'], function(prefix) {
  41. hasNgRepeat = hasNgRepeat || (children.attr(prefix + 'ng-repeat') ? true : false);
  42. });
  43. // Support both ng-repeat and static content
  44. if (hasNgRepeat) {
  45. children.addClass('md-fab-action-item');
  46. } else {
  47. // Wrap every child in a new div and add a class that we can scale/fling independently
  48. children.wrap('<div class="md-fab-action-item">');
  49. }
  50. }
  51. }
  52. }
  53. })();
  54. ng.material.components.fabActions = angular.module("material.components.fabActions");