7 lines
19 KiB
JavaScript
Executable File
7 lines
19 KiB
JavaScript
Executable File
/*!
|
|
* AngularJS Material Design
|
|
* https://github.com/angular/material
|
|
* @license MIT
|
|
* v1.1.18-master-97a1616
|
|
*/
|
|
!function(P,L,_){"use strict";e.$inject=["$mdSelect","$mdUtil","$mdConstant","$mdTheming","$mdAria","$parse","$sce","$injector"],t.$inject=["$parse","$mdUtil","$mdConstant","$mdTheming"],n.$inject=["$mdButtonInkRipple","$mdUtil","$mdTheming"],r.$inject=["$$interimElementProvider"];var H=8,h=0,c=L.element('<div class="md-container"><div class="md-icon"></div></div>');function e(O,E,T,D,R,V,B,e){var t=T.KEY_CODE;t.SPACE,t.ENTER,t.UP_ARROW,t.DOWN_ARROW;return{restrict:"E",require:["^?mdInputContainer","mdSelect","ngModel","?^form"],compile:function(e,t){var n=L.element("<md-select-value><span></span></md-select-value>");n.append('<span class="md-select-icon" aria-hidden="true"></span>'),n.addClass("md-select-value"),n[0].hasAttribute("id")||n.attr("id","select_value_label_"+E.nextUid());var r=e.find("md-content");r.length||e.append(L.element("<md-content>").append(e.contents()));r.attr("role","presentation"),t.mdOnOpen&&(e.find("md-content").prepend(L.element('<div> <md-progress-circular md-mode="indeterminate" ng-if="$$loadingAsyncDone === false" md-diameter="25px"></md-progress-circular></div>')),e.find("md-option").attr("ng-show","$$loadingAsyncDone"));if(t.name){var i=L.element('<select class="md-visually-hidden"></select>');i.attr({name:t.name,"aria-hidden":"true",tabindex:"-1"});var o=e.find("md-option");L.forEach(o,function(e){var t=L.element("<option>"+e.innerHTML+"</option>");e.hasAttribute("ng-value")?t.attr("ng-value",e.getAttribute("ng-value")):e.hasAttribute("value")&&t.attr("value",e.getAttribute("value")),i.append(t)}),i.append('<option ng-value="'+t.ngModel+'" selected></option>'),e.parent().append(i)}var A=E.parseAttributeBoolean(t.multiple),l=A?"multiple":"",a='<div class="md-select-menu-container" aria-hidden="true" role="presentation"><md-select-menu role="presentation" {0}>{1}</md-select-menu></div>';a=E.supplant(a,[l,e.html()]),e.empty().append(n),e.append(a),t.tabindex||t.$set("tabindex",0);return function(r,n,i,e){var t,o,l,a,d,s=!0,c=e[0],u=e[1],p=e[2],f=e[3],m=n.find("md-select-value"),h=L.isDefined(i.readonly),g=E.parseAttributeBoolean(i.mdNoAsterisk);if(g&&n.addClass("md-no-asterisk"),c){var v=c.isErrorGetter||function(){return p.$invalid&&(p.$touched||f&&f.$submitted)};if(c.input&&n.find("md-select-header").find("input")[0]!==c.input[0])throw new Error("<md-input-container> can only have *one* child <input>, <textarea> or <select> element!");c.input=n,c.label||R.expect(n,"aria-label",n.attr("placeholder")),r.$watch(v,c.setInvalid)}!function(){if(l=L.element(n[0].querySelector(".md-select-menu-container")),a=r,i.mdContainerClass){var e=l[0].getAttribute("class")+" "+i.mdContainerClass;l[0].setAttribute("class",e)}(d=l.find("md-select-menu").controller("mdSelectMenu")).init(p,i.ngModel),n.on("$destroy",function(){l.remove()})}(),D(n);var b,$=p.$render;function y(){l&&(d=d||l.find("md-select-menu").controller("mdSelectMenu"),u.setLabelText(d.selectedLabels()))}function w(){if(o){var e=d.selectedLabels({mode:"aria"});n.attr("aria-label",e.length?o+": "+e:o)}}p.$render=function(){$(),y(),w(),k()},i.$observe("placeholder",p.$render),c&&c.label&&i.$observe("required",function(e){c.label.toggleClass("md-required",e&&!g)}),u.setLabelText=function(e){u.setIsPlaceholder(!e);var t=!1;if(i.mdSelectedText&&i.mdSelectedHtml)throw Error("md-select cannot have both `md-selected-text` and `md-selected-html`");if(i.mdSelectedText||i.mdSelectedHtml)e=V(i.mdSelectedText||i.mdSelectedHtml)(r),t=!0;else if(!e){e=i.placeholder||(c&&c.label?c.label.text():"")||"",t=!0}var n=m.children().eq(0);i.mdSelectedHtml?n.html(B.getTrustedHtml(e)):t?n.text(e):n.html(e)},u.setIsPlaceholder=function(e){e?(m.addClass("md-select-placeholder"),c&&c.label&&c.label.addClass("md-placeholder")):(m.removeClass("md-select-placeholder"),c&&c.label&&c.label.removeClass("md-placeholder"))},h||(n.on("focus",function(e){c&&c.setFocused(!0)}),n.on("blur",function(e){s&&(s=!1,a._mdSelectIsOpen&&e.stopImmediatePropagation()),a._mdSelectIsOpen||(c&&c.setFocused(!1),k())})),u.triggerClose=function(){V(i.mdOnClose)(r)},r.$$postDigest(function(){!function(){var e=n.attr("aria-label")||n.attr("placeholder");!e&&c&&c.label&&(e=c.label.text());o=e,R.expect(n,"aria-label",e)}(),y(),w()}),r.$watch(function(){return d.selectedLabels()},y),i.$observe("ngMultiple",function(e){b&&b();var t=V(e);b=r.$watch(function(){return t(r)},function(e,t){e===_&&t===_||(e?n.attr("multiple","multiple"):n.removeAttr("multiple"),n.attr("aria-multiselectable",e?"true":"false"),l&&(d.setMultiple(e),$=p.$render,p.$render=function(){$(),y(),w(),k()},p.$render()))})}),i.$observe("disabled",function(e){L.isString(e)&&(e=!0),t!==_&&t===e||((t=e)?n.attr({"aria-disabled":"true"}).removeAttr("tabindex").off("click",x).off("keydown",S):n.attr({tabindex:i.tabindex,"aria-disabled":"false"}).on("click",x).on("keydown",S))}),i.hasOwnProperty("disabled")||i.hasOwnProperty("ngDisabled")||(n.attr({"aria-disabled":"false"}),n.on("click",x),n.on("keydown",S));var C={role:"listbox","aria-expanded":"false","aria-multiselectable":A&&!i.ngMultiple?"true":"false"};n[0].hasAttribute("id")||(C.id="select_"+E.nextUid());var M="select_container_"+E.nextUid();function k(){E.nextTick(function(){c&&c.setHasValue(0<d.selectedLabels().length||(n[0].validity||{}).badInput)})}function S(e){if(T.isNavigationKey(e))e.preventDefault(),x();else if(I(e,T)){e.preventDefault();var t=d.optNodeForKeyboardSearch(e);if(!t||t.hasAttribute("disabled"))return;var n=L.element(t).controller("mdOption");d.isMultiple||d.deselect(Object.keys(d.selected)[0]),d.select(n.hashKey,n.value),d.refreshViewValue()}}function x(){a._mdSelectIsOpen=!0,n.attr("aria-expanded","true"),O.show({scope:a,preserveScope:!0,skipCompile:!0,element:l,target:n[0],selectCtrl:u,preserveElement:!0,hasBackdrop:!0,loadingAsync:!!i.mdOnOpen&&(r.$eval(i.mdOnOpen)||!0)}).finally(function(){a._mdSelectIsOpen=!1,n.focus(),n.attr("aria-expanded","false"),p.$setTouched()})}l.attr("id",M),n.find("md-select-menu").length||(C["aria-owns"]=M),n.attr(C),r.$on("$destroy",function(){O.destroy().finally(function(){c&&(c.setFocused(!1),c.setHasValue(!1),c.input=null),p.$setTouched()})})}},controller:function(){}}}function t(f,m,e,i){return{restrict:"E",require:["mdSelectMenu"],scope:!(t.$inject=["$scope","$attrs","$element"]),controller:t,link:{pre:function(o,e,t,n){var l=n[0];function r(e){var t=m.getClosest(e.target,"md-option"),n=t&&L.element(t).data("$mdOptionController");if(t&&n){if(t.hasAttribute("disabled"))return e.stopImmediatePropagation(),!1;var r=l.hashGetter(n.value),i=L.isDefined(l.selected[r]);o.$apply(function(){l.isMultiple?i?l.deselect(r):l.select(r,n.value):i||(l.deselect(Object.keys(l.selected)[0]),l.select(r,n.value)),l.refreshViewValue()})}}e.addClass("_md"),i(e),e.on("click",r),e.on("keypress",function(e){13!=e.keyCode&&32!=e.keyCode||r(e)})}}};function t(o,e,i){var l,a=this;a.isMultiple=L.isDefined(e.multiple),a.selected={},a.options={},o.$watchCollection(function(){return a.options},function(){a.ngModel.$render()}),a.setMultiple=function(e){var t=a.ngModel;if(l=l||t.$isEmpty,a.isMultiple=e,a.isMultiple){var n=!1,r=function(e){n?u():m.nextTick(function(){u(),n=!0})};t.$validators["md-multiple"]=i,t.$render=r,o.$watchCollection(a.modelBinding,function(e){i(e)&&r()}),t.$isEmpty=function(e){return!e||0===e.length}}else delete t.$validators["md-multiple"],t.$render=p;function i(e,t){return L.isArray(e||t||[])}};var r,d,s,c="";function u(){var n=a.ngModel.$modelValue||a.ngModel.$viewValue||[];if(L.isArray(n)){var e=Object.keys(a.selected),t=n.map(a.hashGetter);e.filter(function(e){return-1===t.indexOf(e)}).forEach(a.deselect),t.forEach(function(e,t){a.select(e,n[t])})}}function p(){var e=a.ngModel.$viewValue||a.ngModel.$modelValue;Object.keys(a.selected).forEach(a.deselect),a.select(a.hashGetter(e),e)}a.optNodeForKeyboardSearch=function(e){r&&clearTimeout(r),r=setTimeout(function(){c="",d=s=r=_},300),c+=e.key;var t=new RegExp("^"+c,"i");d||(d=i.find("md-option"),s=new Array(d.length),L.forEach(d,function(e,t){s[t]=e.textContent.trim()}));for(var n=0;n<s.length;++n)if(t.test(s[n]))return d[n]},a.init=function(e,t){a.ngModel=e,a.modelBinding=t,a.ngModel.$isEmpty=function(e){return!a.options[a.hashGetter(e)]};var n=m.getModelOption(e,"trackBy");if(n){var r={},i=f(n);a.hashGetter=function(e,t){return r.$value=e,i(t||o,r)}}else a.hashGetter=function(e){return L.isObject(e)?"object_"+(e.$$mdSelectId||(e.$$mdSelectId=++h)):e};a.setMultiple(a.isMultiple)},a.selectedLabels=function(e){var t,n=(e=e||{}).mode||"html",r=m.nodesToArray(i[0].querySelectorAll("md-option[selected]"));return r.length?("html"==n?t=function(e){if(e.hasAttribute("md-option-empty"))return"";var t=e.innerHTML,n=e.querySelector(".md-ripple-container");n&&(t=t.replace(n.outerHTML,""));var r=e.querySelector(".md-container");return r&&(t=t.replace(r.outerHTML,"")),t}:"aria"==n&&(t=function(e){return e.hasAttribute("aria-label")?e.getAttribute("aria-label"):e.textContent}),m.uniq(r.map(t)).join(", ")):""},a.select=function(e,t){var n=a.options[e];n&&n.setSelected(!0),a.selected[e]=t},a.deselect=function(e){var t=a.options[e];t&&t.setSelected(!1),delete a.selected[e]},a.addOption=function(e,t){if(L.isDefined(a.options[e]))throw new Error('Duplicate md-option values are not allowed in a select. Duplicate value "'+t.value+'" found.');a.options[e]=t,L.isDefined(a.selected[e])&&(a.select(e,t.value),L.isDefined(a.ngModel.$$rawModelValue)&&a.hashGetter(a.ngModel.$$rawModelValue)===e&&a.ngModel.$validate(),a.refreshViewValue())},a.removeOption=function(e){delete a.options[e]},a.refreshViewValue=function(){var e,t=[];for(var n in a.selected)(e=a.options[n])?t.push(e.value):t.push(a.selected[n]);var r=m.getModelOption(a.ngModel,"trackBy"),i=a.isMultiple?t:t[0],o=a.ngModel.$modelValue;(r?L.equals(o,i):o+""===i)||(a.ngModel.$setViewValue(i),a.ngModel.$render())}}}function n(r,i,s){return e.$inject=["$element"],{restrict:"E",require:["mdOption","^^mdSelectMenu"],controller:e,compile:function(e,t){e.append(L.element('<div class="md-text">').append(e.contents())),e.attr("tabindex",t.tabindex||"0"),function(e){var t=e.value,n=e.ngValue;return t||n}(t)||e.attr("md-option-empty","");return n}};function n(o,t,e,n){var l=n[0],a=n[1];function d(e,t,n){if(a.hashGetter){var r=a.hashGetter(t,o),i=a.hashGetter(e,o);l.hashKey=i,l.value=e,a.removeOption(r,l),a.addOption(i,l)}else n||o.$$postDigest(function(){d(e,t,!0)})}s(t),a.isMultiple&&(t.addClass("md-checkbox-enabled"),t.prepend(c.clone())),L.isDefined(e.ngValue)?o.$watch(e.ngValue,d):L.isDefined(e.value)?d(e.value):o.$watch(function(){return t.text().trim()},d),e.$observe("disabled",function(e){e?t.attr("tabindex","-1"):t.attr("tabindex","0")}),o.$$postDigest(function(){e.$observe("selected",function(e){L.isDefined(e)&&("string"==typeof e&&(e=!0),e?(a.isMultiple||a.deselect(Object.keys(a.selected)[0]),a.select(l.hashKey,l.value)):a.deselect(l.hashKey),a.refreshViewValue())})}),r.attach(o,t),function(){var e={role:"option","aria-selected":"false"};t[0].hasAttribute("id")||(e.id="select_option_"+i.nextUid());t.attr(e)}(),o.$on("$destroy",function(){a.removeOption(l.hashKey,l)})}function e(t){this.selected=!1,this.setSelected=function(e){e&&!this.selected?t.attr({selected:"selected","aria-selected":"true"}):!e&&this.selected&&(t.removeAttr("selected"),t.attr("aria-selected","false")),this.selected=e}}}function r(e){return t.$inject=["$mdSelect","$mdConstant","$mdUtil","$window","$q","$$rAF","$animateCss","$animate","$document"],e("$mdSelect").setDefaults({methods:["target"],options:t});function t(d,s,R,V,o,c,u,p,B){var f=R.dom.animator,m=s.KEY_CODE;return{parent:"body",themable:!0,onShow:function(n,l,a){return function(){a.loadingAsync&&!a.isRemoved&&(n.$$loadingAsyncDone=!1,o.when(a.loadingAsync).then(function(){n.$$loadingAsyncDone=!0,delete a.loadingAsync}).then(function(){c(r)}))}(),function(e,t){var n=l.find("md-select-menu");if(!t.target)throw new Error(R.supplant("$mdSelect.show() expected a target element in options.target but got '{0}'!",[t.target]));L.extend(t,{isRemoved:!1,target:L.element(t.target),parent:L.element(t.parent),selectEl:n,contentEl:l.find("md-content"),optionNodes:n[0].getElementsByTagName("md-option")})}(0,a),a.hideBackdrop=function(e,t,n){n.disableParentScroll&&!R.getClosest(n.target,"MD-DIALOG")?n.restoreScroll=R.disableScrollAround(n.element,n.parent):n.disableParentScroll=!1;n.hasBackdrop&&(n.backdrop=R.createBackdrop(e,"md-select-backdrop md-click-catcher"),p.enter(n.backdrop,B[0].body,null,{duration:0}));return function(){n.backdrop&&n.backdrop.remove(),n.disableParentScroll&&n.restoreScroll(),delete n.restoreScroll}}(n,0,a),function(e,n,t){t.parent!==n.parent()&&n.parent().attr("aria-owns",n.attr("id"));return n.parent().find("md-select-value").attr("aria-hidden","true"),t.parent.append(n),o(function(e,t){try{u(n,{removeClass:"md-leave",duration:0}).start().then(r).then(e)}catch(e){t(e)}})}(0,l,a).then(function(e){return l.attr("aria-hidden","false"),a.alreadyOpen=!0,a.cleanupInteraction=function(){if(a.isRemoved)return;var r=a.selectEl,t=r.controller("mdSelectMenu")||{};return l.addClass("md-clickable"),a.backdrop&&a.backdrop.on("click",e),r.on("keydown",n),r.on("click",o),function(){a.backdrop&&a.backdrop.off("click",e),r.off("keydown",n),r.off("click",o),l.removeClass("md-clickable"),a.isRemoved=!0};function e(e){e.preventDefault(),e.stopPropagation(),a.restoreFocus=!1,R.nextTick(d.hide,!0)}function n(e){switch(e.preventDefault(),e.stopPropagation(),e.keyCode){case m.UP_ARROW:return void i("prev");case m.DOWN_ARROW:return void i("next");case m.SPACE:case m.ENTER:var t=R.getClosest(e.target,"md-option");t&&(r.triggerHandler({type:"click",target:t}),e.preventDefault()),o(e);break;case m.TAB:case m.ESCAPE:e.stopPropagation(),e.preventDefault(),a.restoreFocus=!0,R.nextTick(d.hide,!0);break;default:if(I(e,s)){var n=r.controller("mdSelectMenu").optNodeForKeyboardSearch(e);a.focusedNode=n||a.focusedNode,n&&n.focus()}}}function i(e){for(var t,n=R.nodesToArray(a.optionNodes),r=n.indexOf(a.focusedNode);-1===r?r=0:"next"===e&&r<n.length-1?r++:"prev"===e&&0<r&&r--,(t=n[r]).hasAttribute("disabled")&&(t=_),!t&&r<n.length-1&&0<r;);t&&t.focus(),a.focusedNode=t}function o(n){if(!(n&&"click"==n.type&&n.currentTarget!=r[0]||function(){var e=!1;if(n&&0<n.currentTarget.children.length){var t=n.currentTarget.children[0];if(t.scrollHeight>t.clientHeight&&0<t.children.length)n.pageX-n.currentTarget.getBoundingClientRect().left>t.querySelector("md-option").offsetWidth&&(e=!0)}return e}())){var e=R.getClosest(n.target,"md-option");e&&e.hasAttribute&&!e.hasAttribute("disabled")&&(n.preventDefault(),n.stopPropagation(),t.isMultiple||(a.restoreFocus=!0,R.nextTick(function(){d.hide(t.ngModel.$viewValue)},!0)))}}}(),a.cleanupResizing=function(){var e=function(r,i,o){return function(){if(!o.isRemoved){var e=h(r,i,o),t=e.container,n=e.dropDown;t.element.css(f.toCss(t.styles)),n.element.css(f.toCss(n.styles))}}}(n,l,a),t=L.element(V);return t.on("resize",e),t.on("orientationchange",e),function(){t.off("resize",e),t.off("orientationchange",e)}}(),i(a.focusedNode),e},a.hideBackdrop);function r(){return o(function(e){if(a.isRemoved)return o.reject(!1);var t=h(n,l,a);t.container.element.css(f.toCss(t.container.styles)),t.dropDown.element.css(f.toCss(t.dropDown.styles)),c(function(){l.addClass("md-active"),t.dropDown.element.css(f.toCss({transform:""})),i(a.focusedNode),e()})})}function i(e){e&&!e.hasAttribute("disabled")&&e.focus()}},onRemove:function(e,t,n){var r=null,i=e.$on("$destroy",function(){r.end()});return(n=n||{}).cleanupInteraction(),n.cleanupResizing(),n.hideBackdrop(),!0===n.$destroy?o():function(){return(r=u(t,{addClass:"md-leave"})).start()}().then(o);function o(){i(),t.removeClass("md-active").attr("aria-hidden","true").css({display:"none",top:"",right:"",bottom:"",left:"","font-size":"","min-width":""}),t.parent().find("md-select-value").removeAttr("aria-hidden"),function(e){var t=e.selectCtrl;if(t){var n=e.selectEl.controller("mdSelectMenu");t.setLabelText(n?n.selectedLabels():""),t.triggerClose()}}(n),!n.$destroy&&n.restoreFocus&&n.target.focus()}},hasBackdrop:!0,disableParentScroll:!0};function h(e,t,n){var r,i=t[0],o=n.target[0].children[0],l=B[0].body,a=n.selectEl[0],d=n.contentEl[0],s=l.getBoundingClientRect(),c=o.getBoundingClientRect(),u={left:s.left+H,top:H,bottom:s.height-H,right:s.width-H-(R.floatingScrollbars()?16:0)},p=c.top-u.top,f=(c.left,c.left,c.width,u.bottom-(c.top+c.height)),m=s.width-2*H,h=a.querySelector("md-option[selected]"),g=a.getElementsByTagName("md-option"),v=a.getElementsByTagName("md-optgroup"),b=function(e,t){var n=!1;try{var r=e[0].style.display;e[0].style.display="block",n=t.scrollHeight>t.offsetHeight,e[0].style.display=r}finally{}return n}(t,d);r=function(e){return e&&L.isFunction(e.then)}(n.loadingAsync)?d.firstElementChild||d:h||(v.length?v[0]:g.length?g[0]:d.firstElementChild||d),d.offsetWidth>m?d.style["max-width"]=m+"px":d.style.maxWidth=null,b&&a.classList.add("md-overflow");var $=r;"MD-OPTGROUP"===($.tagName||"").toUpperCase()&&(r=$=g[0]||d.firstElementChild||d),n.focusedNode=$,i.style.display="block";var y,w,C,M,k,S=a.getBoundingClientRect(),x=function(e){return e?{left:e.offsetLeft,top:e.offsetTop,width:e.offsetWidth,height:e.offsetHeight}:{left:0,top:0,width:0,height:0}}(r);if(r){var A=V.getComputedStyle(r);x.paddingLeft=parseInt(A.paddingLeft,10)||0,x.paddingRight=parseInt(A.paddingRight,10)||0}if(b){var O=d.offsetHeight/2;d.scrollTop=x.top+x.height/2-O,p<O?d.scrollTop=Math.min(x.top,d.scrollTop+O-p):f<O&&(d.scrollTop=Math.max(x.top+x.height-S.height,d.scrollTop-O+f))}y=c.left+x.left-x.paddingLeft+2,w=Math.floor(c.top+c.height/2-x.height/2-x.top+d.scrollTop)+2,C=x.left+c.width/2+"px "+(x.top+x.height/2-d.scrollTop)+"px 0px",M=Math.min(c.width+x.paddingLeft+x.paddingRight,m),k=P.getComputedStyle(o)["font-size"];var E=i.getBoundingClientRect(),T=Math.round(100*Math.min(c.width/S.width,1))/100,D=Math.round(100*Math.min(c.height/S.height,1))/100;return{container:{element:L.element(i),styles:{left:Math.floor(N(u.left,y,u.right-E.width)),top:Math.floor(N(u.top,w,u.bottom-E.height)),"min-width":M,"font-size":k}},dropDown:{element:L.element(a),styles:{transformOrigin:C,transform:n.alreadyOpen?"":R.supplant("scale({0},{1})",[T,D])}}}}}function N(e,t,n){return Math.max(e,Math.min(t,n))}}function I(e,t){var n=String.fromCharCode(e.keyCode),r=e.keyCode<=31;return n&&n.length&&!r&&!t.isMetaKey(e)&&!t.isFnLockKey(e)&&!t.hasModifierKey(e)}L.module("material.components.select",["material.core","material.components.backdrop"]).directive("mdSelect",e).directive("mdSelectMenu",t).directive("mdOption",n).directive("mdOptgroup",function(){return{restrict:"E",compile:function(t,n){t.parent().find("md-select-header").length||function(){var e=t.find("label");e.length||(e=L.element("<label>"),t.prepend(e));e.addClass("md-container-ignore"),e.attr("aria-hidden","true"),n.label&&e.text(n.label)}()}}}).directive("mdSelectHeader",function(){return{restrict:"E"}}).provider("$mdSelect",r)}(window,window.angular); |