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
2.2 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 MdSwitch(e,t,n,a,r,i,o){function d(e,d){var c=l.compile(e,d).post;return e.addClass("md-dragging"),function(e,d,l,s){function m(t){h&&h(e)||(t.stopPropagation(),d.addClass("md-dragging"),w={width:f.prop("offsetWidth")})}function g(e){if(w){e.stopPropagation(),e.srcEvent&&e.srcEvent.preventDefault();var t=e.pointer.distanceX/w.width,a=v.$viewValue?1+t:t;a=Math.max(0,Math.min(1,a)),f.css(n.CSS.TRANSFORM,"translate3d("+100*a+"%,0,0)"),w.translate=a}}function u(t){if(w){t.stopPropagation(),d.removeClass("md-dragging"),f.css(n.CSS.TRANSFORM,"");var a=v.$viewValue?w.translate<.5:w.translate>.5;a&&p(!v.$viewValue),w=null,e.skipToggle=!0,o(function(){e.skipToggle=!1},1)}}function p(t){e.$apply(function(){v.$setViewValue(t),v.$render()})}var v=(s[0],s[1]||t.fakeNgModel()),h=(s[2],null);null!=l.disabled?h=function(){return!0}:l.ngDisabled&&(h=a(l.ngDisabled));var f=angular.element(d[0].querySelector(".md-thumb-container")),$=angular.element(d[0].querySelector(".md-container")),b=angular.element(d[0].querySelector(".md-label"));r(function(){d.removeClass("md-dragging")}),c(e,d,l,s),h&&e.$watch(h,function(e){d.attr("tabindex",e?-1:0)}),l.$observe("mdInvert",function(e){var n=t.parseAttributeBoolean(e);n?d.prepend(b):d.prepend($),d.toggleClass("md-inverted",n)}),i.register($,"drag"),$.on("$md.dragstart",m).on("$md.drag",g).on("$md.dragend",u);var w}}var l=e[0];return{restrict:"E",priority:n.BEFORE_NG_ARIA,transclude:!0,template:'<div class="md-container"><div class="md-bar"></div><div class="md-thumb-container"><div class="md-thumb" md-ink-ripple md-ink-ripple-checkbox></div></div></div><div ng-transclude class="md-label"></div>',require:["^?mdInputContainer","?ngModel","?^form"],compile:d}}goog.provide("ngmaterial.components.switch"),goog.require("ngmaterial.components.checkbox"),goog.require("ngmaterial.core"),MdSwitch.$inject=["mdCheckboxDirective","$mdUtil","$mdConstant","$parse","$$rAF","$mdGesture","$timeout"],angular.module("material.components.switch",["material.core","material.components.checkbox"]).directive("mdSwitch",MdSwitch),ngmaterial.components["switch"]=angular.module("material.components.switch");