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.
 
 
 

7 lines
3.7 KiB

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