|
|
/*! * Angular Material Design * https://github.com/angular/material
* @license MIT * v1.1.0-master-2b98560 */ !function(e,t,n){"use strict";function i(e,n,i,r){function o(o,d,a,s){function u(){d.hasClass("md-focused")||d.addClass("md-focused")}function c(i){var r=i.which||i.keyCode;if(r==n.KEY_CODE.ENTER||i.currentTarget==i.target)switch(r){case n.KEY_CODE.LEFT_ARROW:case n.KEY_CODE.UP_ARROW:i.preventDefault(),l.selectPrevious(),u();break;case n.KEY_CODE.RIGHT_ARROW:case n.KEY_CODE.DOWN_ARROW:i.preventDefault(),l.selectNext(),u();break;case n.KEY_CODE.ENTER:var o=t.element(e.getClosest(d[0],"form"));o.length>0&&o.triggerHandler("submit")}}d.addClass("_md"),i(d);var l=s[0],m=s[1]||e.fakeNgModel();l.init(m),o.mouseActive=!1,d.attr({role:"radiogroup",tabIndex:d.attr("tabindex")||"0"}).on("keydown",c).on("mousedown",function(e){o.mouseActive=!0,r(function(){o.mouseActive=!1},100)}).on("focus",function(){o.mouseActive===!1&&l.$element.addClass("md-focused")}).on("blur",function(){l.$element.removeClass("md-focused")})}function d(e){this._radioButtonRenderFns=[],this.$element=e}function a(){return{init:function(e){this._ngModelCtrl=e,this._ngModelCtrl.$render=t.bind(this,this.render)},add:function(e){this._radioButtonRenderFns.push(e)},remove:function(e){var t=this._radioButtonRenderFns.indexOf(e);t!==-1&&this._radioButtonRenderFns.splice(t,1)},render:function(){this._radioButtonRenderFns.forEach(function(e){e()})},setViewValue:function(e,t){this._ngModelCtrl.$setViewValue(e,t),this.render()},getViewValue:function(){return this._ngModelCtrl.$viewValue},selectNext:function(){return s(this.$element,1)},selectPrevious:function(){return s(this.$element,-1)},setActiveDescendant:function(e){this.$element.attr("aria-activedescendant",e)},isDisabled:function(){return this.$element[0].hasAttribute("disabled")}}}function s(n,i){var r=e.iterator(n[0].querySelectorAll("md-radio-button"),!0);if(r.count()){var o=function(e){return!t.element(e).attr("disabled")},d=n[0].querySelector("md-radio-button.md-checked"),a=r[i<0?"previous":"next"](d,o)||r.first();t.element(a).triggerHandler("click")}}return d.prototype=a(),{restrict:"E",controller:["$element",d],require:["mdRadioGroup","?ngModel"],link:{pre:o}}}function r(e,t,n){function i(i,o,d,a){function s(){if(!a)throw"RadioButton: No RadioGroupController could be found.";a.add(c),d.$observe("value",c),o.on("click",u).on("$destroy",function(){a.remove(c)})}function u(e){o[0].hasAttribute("disabled")||a.isDisabled()||i.$apply(function(){a.setViewValue(d.value,e&&e.type)})}function c(){function e(e){"MD-RADIO-GROUP"!=o.parent()[0].nodeName&&o.parent()[e?"addClass":"removeClass"](r)}var t=a.getViewValue()==d.value;t!==m&&(m=t,o.attr("aria-checked",t),t?(e(!0),o.addClass(r),a.setActiveDescendant(o.attr("id"))):(e(!1),o.removeClass(r)))}function l(n,i){function r(){return d.id||"radio_"+t.nextUid()}i.ariaId=r(),n.attr({id:i.ariaId,role:"radio","aria-checked":"false"}),e.expectWithText(n,"aria-label")}var m;n(o),l(o,i),s()}var r="md-checked";return{restrict:"E",require:"^mdRadioGroup",transclude:!0,template:'<div class="md-container" md-ink-ripple md-ink-ripple-checkbox><div class="md-off"></div><div class="md-on"></div></div><div ng-transclude class="md-label"></div>',link:i}}i.$inject=["$mdUtil","$mdConstant","$mdTheming","$timeout"],r.$inject=["$mdAria","$mdUtil","$mdTheming"],t.module("material.components.radioButton",["material.core"]).directive("mdRadioGroup",i).directive("mdRadioButton",r)}(window,window.angular);
|