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.0 KiB

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