2016-08-22 12:59:56 +02:00

7 lines
12 KiB
JavaScript

/*!
* Angular Material Design
* https://github.com/angular/material
* @license MIT
* v0.10.0
*/
!function(e,t,n){"use strict";function o(e,n,o,i,l,a,r,m,c,s){function p(){o.initOptionalProperties(e,s,{searchText:null,selectedItem:null}),a(n),$(),l(function(){C(),f(),g()})}function h(){function e(){var e=X.ul.getBoundingClientRect(),n={};e.right>o.right-d&&(n.left=t.right-e.width+"px"),X.$.ul.css(n)}if(!X)return l(h,0,!1);var t=X.wrap.getBoundingClientRect(),n=X.snap.getBoundingClientRect(),o=X.root.getBoundingClientRect(),i=n.bottom-o.top,a=o.bottom-n.top,r=t.left-o.left,m=t.width,c={left:r+"px",minWidth:m+"px",maxWidth:Math.max(t.right-o.left,o.right-t.left)-d+"px"};i>a&&o.height-t.bottom-d<u?(c.top="auto",c.bottom=a+"px",c.maxHeight=Math.min(u,t.top-o.top-d)+"px"):(c.top=i+"px",c.bottom="auto",c.maxHeight=Math.min(u,o.bottom-t.bottom-d)+"px"),X.$.ul.css(c),l(e,0,!1)}function g(){X.$.root.length&&(a(X.$.ul),X.$.ul.detach(),X.$.root.append(X.$.ul),m.pin&&m.pin(X.$.ul,c))}function f(){e.autofocus&&X.input.focus()}function $(){var n=parseInt(e.delay,10)||0;s.$observe("disabled",function(e){G.isDisabled=e}),s.$observe("required",function(e){G.isRequired=null!==e}),e.$watch("searchText",n?o.debounce(M,n):M),L(y),e.$watch("selectedItem",I),t.element(r).on("resize",h),e.$on("$destroy",x)}function x(){t.element(r).off("resize",h),X.$.ul.remove()}function C(){X={main:n[0],ul:n.find("ul")[0],input:n.find("input")[0],wrap:n.find("md-autocomplete-wrap")[0],root:document.body},X.li=X.ul.getElementsByTagName("li"),X.snap=v(),X.$=A(X)}function v(){for(var e=n;e.length;e=e.parent())if(t.isDefined(e.attr("md-autocomplete-snap")))return e[0];return X.wrap}function A(e){var n={};for(var o in e)n[o]=t.element(e[o]);return n}function b(e,t){!e&&t&&h(),e?o.enableScrolling():X&&l(function(){o.disableScrollAround(X.ul)},0,!1)}function T(){te=!0}function w(){te=!1,oe||(G.hidden=!0)}function E(){X.input.focus()}function y(t,n){t&&(e.searchText=S(t)),e.itemChange&&t!==n&&e.itemChange(U(t))}function I(e,t){for(var n=0;n<ne.length;++n)ne[n](e,t)}function L(e){-1==ne.indexOf(e)&&ne.push(e)}function D(e){var t=ne.indexOf(e);-1!=t&&ne.splice(t,1)}function M(t,n){G.index=H(),t!==n&&t!==S(e.selectedItem)&&(e.selectedItem=null,e.textChange&&t!==n&&e.textChange(U(e.selectedItem)),W()?F():(G.loading=!1,G.matches=[],G.hidden=_(),Y()))}function O(){oe=!1,te||(G.hidden=!0)}function R(){oe=!0,t.isString(e.searchText)||(e.searchText=""),e.minLength>0||(G.hidden=_(),G.hidden||F())}function k(e){switch(e.keyCode){case i.KEY_CODE.DOWN_ARROW:if(G.loading)return;e.preventDefault(),G.index=Math.min(G.index+1,G.matches.length-1),V(),Y();break;case i.KEY_CODE.UP_ARROW:if(G.loading)return;e.preventDefault(),G.index=G.index<0?G.matches.length-1:Math.max(0,G.index-1),V(),Y();break;case i.KEY_CODE.TAB:case i.KEY_CODE.ENTER:if(G.hidden||G.loading||G.index<0||G.matches.length<1)return;e.preventDefault(),B(G.index);break;case i.KEY_CODE.ESCAPE:G.matches=[],G.hidden=!0,G.index=H()}}function N(){return t.isNumber(e.minLength)?e.minLength:1}function S(t){return t&&e.itemText?e.itemText(U(t)):t}function U(e){if(e){var t={};return G.itemName&&(t[G.itemName]=e),t}}function H(){return e.autoselect?0:-1}function _(){return W()?void 0:!0}function q(){return S(G.matches[G.index])}function W(){return t.isDefined(e.searchText)&&e.searchText.length>=N()}function j(e,t,n){Object.defineProperty(G,e,{get:function(){return n},set:function(e){var o=n;n=e,t(e,o)}})}function B(t){e.selectedItem=G.matches[t],G.hidden=!0,G.index=0,G.matches=[],l(function(){X.$.input.controller("ngModel").$setViewValue(S(e.selectedItem)||e.searchText),G.hidden=!0})}function P(){e.searchText="",B(-1);var t=document.createEvent("CustomEvent");t.initCustomEvent("input",!0,!0,{value:e.searchText}),X.input.dispatchEvent(t),X.input.focus()}function K(n){function o(t){ee[l]=t,n===e.searchText&&(G.loading=!1,Z=null,G.matches=t,G.hidden=_(),Y(),h())}var i=e.$parent.$eval(Q),l=n.toLowerCase();t.isArray(i)?o(i):i&&(G.loading=!0,i.success&&i.success(o),i.then&&i.then(o),i.error&&i.error(function(){G.loading=!1}))}function Y(){G.messages=[z(),q()]}function z(){if(ie===G.matches.length)return"";switch(ie=G.matches.length,G.matches.length){case 0:return"There are no matches available.";case 1:return"There is 1 match available.";default:return"There are "+G.matches.length+" matches available."}}function V(){if(X.li[G.index]){var e=X.li[G.index],t=e.offsetTop,n=t+e.offsetHeight,o=X.ul.clientHeight;t<X.ul.scrollTop?X.ul.scrollTop=t:n>X.ul.scrollTop+o&&(X.ul.scrollTop=n-o)}}function F(){var t=e.searchText,n=t.toLowerCase();Z&&Z.cancel&&(Z.cancel(),Z=null),!e.noCache&&ee[n]?(G.matches=ee[n],Y()):K(t),oe&&(G.hidden=_())}var G=this,J=e.itemsExpr.split(/ in /i),Q=J[1],X=null,Z=null,ee={},te=!1,ne=[],oe=!1,ie=0;return j("hidden",b,!0),G.scope=e,G.parent=e.$parent,G.itemName=J[0],G.matches=[],G.loading=!1,G.hidden=!0,G.index=null,G.messages=[],G.id=o.nextUid(),G.isDisabled=null,G.isRequired=null,G.keydown=k,G.blur=O,G.focus=R,G.clear=P,G.select=B,G.listEnter=T,G.listLeave=w,G.mouseUp=E,G.getCurrentDisplayValue=q,G.registerSelectedItemWatcher=L,G.unregisterSelectedItemWatcher=D,p()}function i(e,t){return{controller:"MdAutocompleteCtrl",controllerAs:"$mdAutocompleteCtrl",scope:{inputName:"@mdInputName",inputMinlength:"@mdInputMinlength",inputMaxlength:"@mdInputMaxlength",searchText:"=?mdSearchText",selectedItem:"=?mdSelectedItem",itemsExpr:"@mdItems",itemText:"&mdItemText",placeholder:"@placeholder",noCache:"=?mdNoCache",itemChange:"&?mdSelectedItemChange",textChange:"&?mdSearchTextChange",minLength:"=?mdMinLength",delay:"=?mdDelay",autofocus:"=?mdAutofocus",floatingLabel:"@?mdFloatingLabel",autoselect:"=?mdAutoselect",menuClass:"@?mdMenuClass"},template:function(e,t){function n(){var t=e.find("md-item-template").remove(),n=t.length?t.html():e.html();return t.length||e.empty(),n}function o(){var t=e.find("md-not-found").remove(),n=t.length?t.html():"";return n?'<li ng-if="!$mdAutocompleteCtrl.matches.length && !$mdAutocompleteCtrl.loading && !$mdAutocompleteCtrl.hidden" ng-hide="$mdAutocompleteCtrl.hidden" md-autocomplete-parent-scope>'+n+"</li>":""}function i(){return t.mdFloatingLabel?' <md-input-container flex ng-if="floatingLabel"> <label>{{floatingLabel}}</label> <input type="search" id="fl-input-{{$mdAutocompleteCtrl.id}}" name="{{inputName}}" autocomplete="off" ng-required="isRequired" ng-minlength="inputMinlength" ng-maxlength="inputMaxlength" ng-disabled="$mdAutocompleteCtrl.isDisabled" ng-model="$mdAutocompleteCtrl.scope.searchText" ng-keydown="$mdAutocompleteCtrl.keydown($event)" ng-blur="$mdAutocompleteCtrl.blur()" ng-focus="$mdAutocompleteCtrl.focus()" aria-owns="ul-{{$mdAutocompleteCtrl.id}}" aria-label="{{floatingLabel}}" aria-autocomplete="list" aria-haspopup="true" aria-activedescendant="" aria-expanded="{{!$mdAutocompleteCtrl.hidden}}"/> <div md-autocomplete-parent-scope md-autocomplete-replace>'+r+"</div> </md-input-container>":' <input flex type="search" id="input-{{$mdAutocompleteCtrl.id}}" name="{{inputName}}" ng-if="!floatingLabel" autocomplete="off" ng-required="isRequired" ng-disabled="$mdAutocompleteCtrl.isDisabled" ng-model="$mdAutocompleteCtrl.scope.searchText" ng-keydown="$mdAutocompleteCtrl.keydown($event)" ng-blur="$mdAutocompleteCtrl.blur()" ng-focus="$mdAutocompleteCtrl.focus()" placeholder="{{placeholder}}" aria-owns="ul-{{$mdAutocompleteCtrl.id}}" aria-label="{{placeholder}}" aria-autocomplete="list" aria-haspopup="true" aria-activedescendant="" aria-expanded="{{!$mdAutocompleteCtrl.hidden}}"/> <button type="button" tabindex="-1" ng-if="$mdAutocompleteCtrl.scope.searchText && !$mdAutocompleteCtrl.isDisabled" ng-click="$mdAutocompleteCtrl.clear()"> <md-icon md-svg-icon="md-close"></md-icon> <span class="md-visually-hidden">Clear</span> </button> '}var l=o(),a=n(),r=e.html();return' <md-autocomplete-wrap layout="row" ng-class="{ \'md-whiteframe-z1\': !floatingLabel }" role="listbox"> '+i()+' <md-progress-linear ng-if="$mdAutocompleteCtrl.loading" md-mode="indeterminate"></md-progress-linear> <ul role="presentation" class="md-autocomplete-suggestions md-whiteframe-z1 {{menuClass || \'\'}}" id="ul-{{$mdAutocompleteCtrl.id}}" ng-hide="$mdAutocompleteCtrl.hidden" ng-mouseenter="$mdAutocompleteCtrl.listEnter()" ng-mouseleave="$mdAutocompleteCtrl.listLeave()" ng-mouseup="$mdAutocompleteCtrl.mouseUp()"> <li ng-repeat="(index, item) in $mdAutocompleteCtrl.matches" ng-class="{ selected: index === $mdAutocompleteCtrl.index }" ng-click="$mdAutocompleteCtrl.select(index)" md-autocomplete-list-item="$mdAutocompleteCtrl.itemName"> '+a+" </li> "+l+' </ul> </md-autocomplete-wrap> <aria-status class="md-visually-hidden" role="status" aria-live="assertive"> <p ng-repeat="message in $mdAutocompleteCtrl.messages" ng-if="message">{{message}}</p> </aria-status>'}}}function l(e,n,o){function i(i){var l=o(n.html())(e),r=t.element("<div>").text(l).html(),m=n.attr("md-highlight-flags")||"",c=e.$watch(i,function(e){var t=a(e,m),o=r.replace(t,'<span class="highlight">$&</span>');n.html(o)});n.on("$destroy",function(){c()})}function l(e){return e?e.replace(/[\\\^\$\*\+\?\.\(\)\|\{\}\[\]]/g,"\\$&"):e}function a(e,t){var n="";return t.indexOf("^")>=1&&(n+="^"),n+=e,t.indexOf("$")>=1&&(n+="$"),new RegExp(l(n),t.replace(/[\$\^]/g,""))}return this.init=i,i()}function a(){return{terminal:!0,scope:!1,controller:"MdHighlightCtrl",link:function(e,t,n,o){o.init(n.mdHighlightText)}}}function r(e,t){function n(n,o,i){var l=n.$parent.$mdAutocompleteCtrl,a=l.parent.$new(!1,l.parent),r=l.scope.$eval(i.mdAutocompleteListItem);a[r]=n.item,e(o.contents())(a),o.attr({role:"option",id:"item_"+t.nextUid()})}return{terminal:!0,link:n,scope:!1}}function m(e,t){function n(t,n,o){var i=t.$parent.$mdAutocompleteCtrl;e(n.contents())(i.parent),o.hasOwnProperty("mdAutocompleteReplace")&&(n.after(n.contents()),n.remove())}return{restrict:"A",terminal:!0,link:n,scope:!1}}t.module("material.components.autocomplete",["material.core","material.components.icon"]),t.module("material.components.autocomplete").controller("MdAutocompleteCtrl",o);var c=41,u=5.5*c,d=8;o.$inject=["$scope","$element","$mdUtil","$mdConstant","$timeout","$mdTheming","$window","$animate","$rootElement","$attrs"],t.module("material.components.autocomplete").directive("mdAutocomplete",i),i.$inject=["$mdTheming","$mdUtil"],t.module("material.components.autocomplete").controller("MdHighlightCtrl",l),l.$inject=["$scope","$element","$interpolate"],t.module("material.components.autocomplete").directive("mdHighlightText",a),t.module("material.components.autocomplete").directive("mdAutocompleteListItem",r),r.$inject=["$compile","$mdUtil"],t.module("material.components.autocomplete").directive("mdAutocompleteParentScope",m),m.$inject=["$compile","$mdUtil"]}(window,window.angular);