/*! * Angular Material Design * https://github.com/angular/material * @license MIT * v0.9.8 */ goog.provide('ng.material.components.button'); goog.require('ng.material.core'); /** * @ngdoc module * @name material.components.button * @description * * Button */ angular .module('material.components.button', [ 'material.core' ]) .directive('mdButton', MdButtonDirective); /** * @ngdoc directive * @name mdButton * @module material.components.button * * @restrict E * * @description * `` is a button directive with optional ink ripples (default enabled). * * If you supply a `href` or `ng-href` attribute, it will become an `` element. Otherwise, it will * become a `'; } function postLink(scope, element, attr) { var node = element[0]; $mdTheming(element); $mdButtonInkRipple.attach(scope, element); var elementHasText = node.textContent.trim(); if (!elementHasText) { $mdAria.expect(element, 'aria-label'); } // For anchor elements, we have to set tabindex manually when the // element is disabled if (isAnchor(attr) && angular.isDefined(attr.ngDisabled) ) { scope.$watch(attr.ngDisabled, function(isDisabled) { element.attr('tabindex', isDisabled ? -1 : 0); }); } // disabling click event when disabled is true element.on('click', function(e){ if (attr.disabled === true) { e.preventDefault(); e.stopImmediatePropagation(); } }); // restrict focus styles to the keyboard scope.mouseActive = false; element.on('mousedown', function() { scope.mouseActive = true; $timeout(function(){ scope.mouseActive = false; }, 100); }) .on('focus', function() { if(scope.mouseActive === false) { element.addClass('md-focused'); } }) .on('blur', function() { element.removeClass('md-focused'); }); } } MdButtonDirective.$inject = ["$mdButtonInkRipple", "$mdTheming", "$mdAria", "$timeout"]; ng.material.components.button = angular.module("material.components.button");