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
18 KiB

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