/*! * Angular Material Design * https://github.com/angular/material * @license MIT * v1.1.0-master-2b98560 */ !function(e,t,n){"use strict";function o(e,o,i,l,r,a,c,d,p,h,f){function g(){i.initOptionalProperties(e,p,{searchText:"",selectedItem:null}),r(o),b(),i.nextTick(function(){w(),v(),e.autofocus&&o.on("focus",C)})}function $(){e.requireMatch&&Me&&Me.$setValidity("md-require-match",!!e.selectedItem)}function x(){function t(){var e=0,t=o.find("md-input-container");if(t.length){var n=t.find("input");e=t.prop("offsetHeight"),e-=n.prop("offsetTop"),e-=n.prop("offsetHeight"),e+=t.prop("offsetTop")}return e}function n(){var e=Ae.scrollContainer.getBoundingClientRect(),t={};e.right>c.right-s&&(t.left=r.right-e.width+"px"),Ae.$.scrollContainer.css(t)}if(!Ae)return i.nextTick(x,!1,e);var l,r=Ae.wrap.getBoundingClientRect(),a=Ae.snap.getBoundingClientRect(),c=Ae.root.getBoundingClientRect(),d=a.bottom-c.top,h=c.bottom-a.top,f=r.left-c.left,g=r.width,$=t();p.mdFloatingLabel&&(f+=m,g-=2*m),l={left:f+"px",minWidth:g+"px",maxWidth:Math.max(r.right-c.left,c.right-r.left)-s+"px"},d>h&&c.height-r.bottom-s=W()}function oe(e,t,n){Object.defineProperty(ve,e,{get:function(){return n},set:function(e){var o=n;n=e,t(e,o)}})}function ie(t){i.nextTick(function(){_(ve.matches[t]).then(function(e){var t=Ae.$.input.controller("ngModel");t.$setViewValue(e),t.$render()})["finally"](function(){e.selectedItem=ve.matches[t],U(!1)})},!1)}function le(){re(),ae()}function re(){ve.index=0,ve.matches=[]}function ae(){U(!0),e.searchText="";var t=document.createEvent("CustomEvent");t.initCustomEvent("change",!0,!0,{value:""}),Ae.input.dispatchEvent(t),Ae.input.blur(),e.searchText="",Ae.input.focus()}function ce(n){function o(t){t&&(t=h.when(t),Re++,U(!0),i.nextTick(function(){t.then(l)["finally"](function(){0===--Re&&U(!1)})},!0,e))}function l(t){we[a]=t,(n||"")===(e.searchText||"")&&ge(t)}var r=e.$parent.$eval(be),a=n.toLowerCase(),c=t.isArray(r),u=!!r.then;c?l(r):u&&o(r)}function ue(){te().then(function(e){ve.messages=[se(),e]})}function se(){if(Ie===ve.matches.length)return"";switch(Ie=ve.matches.length,ve.matches.length){case 0:return"There are no matches available.";case 1:return"There is 1 match available.";default:return"There are "+ve.matches.length+" matches available."}}function me(){if(Ae.li[0]){var e=Ae.li[0].offsetHeight,t=e*ve.index,n=t+e,o=Ae.scroller.clientHeight,i=Ae.scroller.scrollTop;ti+o&&pe(n-o)}}function de(){return 0!==Re}function pe(e){Ae.$.scrollContainer.controller("mdVirtualRepeatContainer").scrollTo(e)}function he(){var e=(ve.scope.searchText||"").length;return ve.hasNotFound&&!X()&&(!ve.loading||de())&&e>=W()&&(Ee||Te)&&!Z()}function fe(){var t=e.searchText||"",n=t.toLowerCase();!e.noCache&&we[n]?ge(we[n]):ce(t),ve.hidden=K()}function ge(t){ve.matches=t,ve.hidden=K(),ve.loading&&U(!1),e.selectOnMatch&&$e(),ue(),x()}function $e(){var t=e.searchText,n=ve.matches,o=n[0];1===n.length&&_(o).then(function(n){var o=t==n;e.matchInsensitive&&!o&&(o=t.toLowerCase()==n.toLowerCase()),o&&ie(0)})}function xe(t,n){p[t]&&e.$parent.$eval(p[t],n||{})}var ve=this,Ce=e.itemsExpr.split(/ in /i),be=Ce[1],Ae=null,we={},Te=!1,ye=[],Ee=!1,Ie=0,Re=0,ke=null,Me=null;return oe("hidden",E,!0),ve.scope=e,ve.parent=e.$parent,ve.itemName=Ce[0],ve.matches=[],ve.loading=!1,ve.hidden=!0,ve.index=null,ve.messages=[],ve.id=i.nextUid(),ve.isDisabled=null,ve.isRequired=null,ve.isReadonly=null,ve.hasNotFound=!1,ve.keydown=V,ve.blur=H,ve.focus=B,ve.clear=le,ve.select=ie,ve.listEnter=R,ve.listLeave=k,ve.mouseUp=M,ve.getCurrentDisplayValue=te,ve.registerSelectedItemWatcher=S,ve.unregisterSelectedItemWatcher=F,ve.notFoundVisible=he,ve.loadingIsVisible=ee,ve.positionDropdown=x,g()}function i(e){return{controller:"MdAutocompleteCtrl",controllerAs:"$mdAutocompleteCtrl",scope:{inputName:"@mdInputName",inputMinlength:"@mdInputMinlength",inputMaxlength:"@mdInputMaxlength",searchText:"=?mdSearchText",selectedItem:"=?mdSelectedItem",itemsExpr:"@mdItems",itemText:"&mdItemText",placeholder:"@placeholder",noCache:"=?mdNoCache",requireMatch:"=?mdRequireMatch",selectOnMatch:"=?mdSelectOnMatch",matchInsensitive:"=?mdMatchCaseInsensitive",itemChange:"&?mdSelectedItemChange",textChange:"&?mdSearchTextChange",minLength:"=?mdMinLength",delay:"=?mdDelay",autofocus:"=?mdAutofocus",floatingLabel:"@?mdFloatingLabel",autoselect:"=?mdAutoselect",menuClass:"@?mdMenuClass",inputId:"@?mdInputId",escapeOptions:"@?mdEscapeOptions"},link:function(e,t,n,o){o.hasNotFound=!!t.attr("md-has-not-found")},template:function(t,n){function o(){var e=t.find("md-item-template").detach(),n=e.length?e.html():t.html();return e.length||t.empty(),""+n+""}function i(){var e=t.find("md-not-found").detach(),n=e.length?e.html():"";return n?'
  • '+n+"
  • ":""}function l(){return n.mdFloatingLabel?'
    '+c+"
    ":' '}var r=i(),a=o(),c=t.html(),u=n.tabindex;return r&&t.attr("md-has-not-found",!0),t.attr("tabindex","-1")," "+l()+'
    • '+a+"
    • "+r+'

    {{message}}

    '}}}function l(e,t){function n(e,n,o){return function(e,n,i){function l(n,o){c[o]=e[n],e.$watch(n,function(e){t.nextTick(function(){c[o]=e})})}function r(){var t=!1,n=!1;e.$watch(function(){n||t||(t=!0,e.$$postDigest(function(){n||c.$digest(),t=n=!1}))}),c.$watch(function(){n=!0})}var a=e.$mdAutocompleteCtrl,c=a.parent.$new(),u=a.itemName;l("$index","$index"),l("item",u),r(),o(c,function(e){n.after(e)})}}return{restrict:"AE",compile:n,terminal:!0,transclude:"element"}}function r(e,t,n){this.$scope=e,this.$element=t,this.$attrs=n,this.regex=null}function a(e,t){return{terminal:!0,controller:"MdHighlightCtrl",compile:function(n,o){var i=t(o.mdHighlightText),l=e(n.html());return function(e,t,n,o){o.init(i,l)}}}}t.module("material.components.autocomplete",["material.core","material.components.icon","material.components.virtualRepeat"]),o.$inject=["$scope","$element","$mdUtil","$mdConstant","$mdTheming","$window","$animate","$rootElement","$attrs","$q","$log"],t.module("material.components.autocomplete").controller("MdAutocompleteCtrl",o);var c=41,u=5.5*c,s=8,m=2;i.$inject=["$$mdSvgRegistry"],t.module("material.components.autocomplete").directive("mdAutocomplete",i),l.$inject=["$compile","$mdUtil"],t.module("material.components.autocomplete").directive("mdAutocompleteParentScope",l),r.$inject=["$scope","$element","$attrs"],t.module("material.components.autocomplete").controller("MdHighlightCtrl",r),r.prototype.init=function(e,t){this.flags=this.$attrs.mdHighlightFlags||"",this.unregisterFn=this.$scope.$watch(function(n){return{term:e(n),contentText:t(n)}}.bind(this),this.onRender.bind(this),!0),this.$element.on("$destroy",this.unregisterFn)},r.prototype.onRender=function(e,t){var n=e.contentText;null!==this.regex&&e.term===t.term||(this.regex=this.createRegex(e.term,this.flags)),e.term?this.applyRegex(n):this.$element.text(n)},r.prototype.applyRegex=function(e){var n=this.resolveTokens(e);this.$element.empty(),n.forEach(function(e){if(e.isMatch){var n=t.element('').text(e.text);this.$element.append(n)}else this.$element.append(document.createTextNode(e))}.bind(this))},r.prototype.resolveTokens=function(e){function t(t,o){var i=e.slice(t,o);i&&n.push(i)}var n=[],o=0;return e.replace(this.regex,function(e,i){t(o,i),n.push({text:e,isMatch:!0}),o=i+e.length}),t(o),n},r.prototype.createRegex=function(e,t){var n="",o="",i=this.sanitizeRegex(e);return t.indexOf("^")>=0&&(n="^"),t.indexOf("$")>=0&&(o="$"),new RegExp(n+i+o,t.replace(/[$\^]/g,""))},r.prototype.sanitizeRegex=function(e){return e&&e.toString().replace(/[\\\^\$\*\+\?\.\(\)\|\{}\[\]]/g,"\\$&")},a.$inject=["$interpolate","$parse"],t.module("material.components.autocomplete").directive("mdHighlightText",a)}(window,window.angular);