You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

6 lines
3.4 KiB

7 years ago
  1. /*!
  2. * Angular Material Design
  3. * https://github.com/angular/material
  4. * @license MIT
  5. * v1.1.2-master-a9ba340
  6. */
  7. !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(){var e=a.getViewValue()==d.value;e!==m&&("md-radio-group"!==o[0].parentNode.nodeName.toLowerCase()&&o.parent().toggleClass(r,e),e&&a.setActiveDescendant(o.attr("id")),m=e,o.attr("aria-checked",e).toggleClass(r,e))}function l(n,i){n.attr({id:d.id||"radio_"+t.nextUid(),role:"radio","aria-checked":"false"}),e.expectWithText(n,"aria-label")}var m;n(o),l(o,i),d.ngValue?t.nextTick(s,!1):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);