/*! * typeahead.js 0.10.5 * https://github.com/twitter/typeahead.js * Copyright 2013-2014 Twitter, Inc. and other contributors; Licensed MIT */ /** * @license * Copyright 2010 Google Inc. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ function MarkerClusterer(map,opt_markers,opt_options){this.extend(MarkerClusterer,google.maps.OverlayView),this.map_=map,this.markers_=[],this.clusters_=[],this.sizes=[53,56,66,78,90],this.styles_=[],this.ready_=!1;var options=opt_options||{};this.gridSize_=options.gridSize||60,this.minClusterSize_=options.minimumClusterSize||2,this.maxZoom_=options.maxZoom||null,this.styles_=options.styles||[],this.imagePath_=options.imagePath||this.MARKER_CLUSTER_IMAGE_PATH_,this.imageExtension_=options.imageExtension||this.MARKER_CLUSTER_IMAGE_EXTENSION_,this.zoomOnClick_=!0,null!=options.zoomOnClick&&(this.zoomOnClick_=options.zoomOnClick),this.averageCenter_=!1,null!=options.averageCenter&&(this.averageCenter_=options.averageCenter),this.setupStyles_(),this.setMap(map),this.prevZoom_=this.map_.getZoom();var that=this;google.maps.event.addListener(this.map_,"zoom_changed",(function(){var zoom=that.map_.getZoom();that.prevZoom_!=zoom&&(that.prevZoom_=zoom,that.resetViewport())})),google.maps.event.addListener(this.map_,"idle",(function(){that.redraw()})),opt_markers&&opt_markers.length&&this.addMarkers(opt_markers,!1)}function Cluster(markerClusterer){this.markerClusterer_=markerClusterer,this.map_=markerClusterer.getMap(),this.gridSize_=markerClusterer.getGridSize(),this.minClusterSize_=markerClusterer.getMinClusterSize(),this.averageCenter_=markerClusterer.isAverageCenter(),this.center_=null,this.markers_=[],this.bounds_=null,this.clusterIcon_=new ClusterIcon(this,markerClusterer.getStyles(),markerClusterer.getGridSize())}function ClusterIcon(cluster,styles,opt_padding){cluster.getMarkerClusterer().extend(ClusterIcon,google.maps.OverlayView),this.styles_=styles,this.padding_=opt_padding||0,this.cluster_=cluster,this.center_=null,this.map_=cluster.getMap(),this.div_=null,this.sums_=null,this.visible_=!1,this.setMap(this.map_)}!function($){var _=function(){"use strict";return{isMsie:function(){return!!/(msie|trident)/i.test(navigator.userAgent)&&navigator.userAgent.match(/(msie |rv:)(\d+(.\d+)?)/i)[2]},isBlankString:function(str){return!str||/^\s*$/.test(str)},escapeRegExChars:function(str){return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},isString:function(obj){return"string"==typeof obj},isNumber:function(obj){return"number"==typeof obj},isArray:$.isArray,isFunction:$.isFunction,isObject:$.isPlainObject,isUndefined:function(obj){return void 0===obj},toStr:function(s){return _.isUndefined(s)||null===s?"":s+""},bind:$.proxy,each:function(collection,cb){$.each(collection,(function(index,value){return cb(value,index)}))},map:$.map,filter:$.grep,every:function(obj,test){var result=!0;return obj?($.each(obj,(function(key,val){if(!(result=test.call(null,val,key,obj)))return!1})),!!result):result},some:function(obj,test){var result=!1;return obj?($.each(obj,(function(key,val){if(result=test.call(null,val,key,obj))return!1})),!!result):result},mixin:$.extend,getUniqueId:(counter=0,function(){return counter++}),templatify:function(obj){return $.isFunction(obj)?obj:function(){return String(obj)}},defer:function(fn){setTimeout(fn,0)},debounce:function(func,wait,immediate){var timeout,result;return function(){var later,callNow,context=this,args=arguments;return later=function(){timeout=null,immediate||(result=func.apply(context,args))},callNow=immediate&&!timeout,clearTimeout(timeout),timeout=setTimeout(later,wait),callNow&&(result=func.apply(context,args)),result}},throttle:function(func,wait){var context,args,timeout,result,previous,later;return previous=0,later=function(){previous=new Date,timeout=null,result=func.apply(context,args)},function(){var now=new Date,remaining=wait-(now-previous);return context=this,args=arguments,remaining<=0?(clearTimeout(timeout),timeout=null,previous=now,result=func.apply(context,args)):timeout||(timeout=setTimeout(later,remaining)),result}},noop:function(){}};var counter}(),tokenizers=function(){"use strict";return{nonword:nonword,whitespace:whitespace,obj:{nonword:getObjTokenizer(nonword),whitespace:getObjTokenizer(whitespace)}};function whitespace(str){return(str=_.toStr(str))?str.split(/\s+/):[]}function nonword(str){return(str=_.toStr(str))?str.split(/\W+/):[]}function getObjTokenizer(tokenizer){return function(){var args=[].slice.call(arguments,0);return function(o){var tokens=[];return _.each(args,(function(k){tokens=tokens.concat(tokenizer(_.toStr(o[k])))})),tokens}}}}(),LruCache=function(){"use strict";function LruCache(maxSize){this.maxSize=_.isNumber(maxSize)?maxSize:100,this.reset(),this.maxSize<=0&&(this.set=this.get=$.noop)}function List(){this.head=this.tail=null}function Node(key,val){this.key=key,this.val=val,this.prev=this.next=null}return _.mixin(LruCache.prototype,{set:function(key,val){var node,tailItem=this.list.tail;this.size>=this.maxSize&&(this.list.remove(tailItem),delete this.hash[tailItem.key]),(node=this.hash[key])?(node.val=val,this.list.moveToFront(node)):(node=new Node(key,val),this.list.add(node),this.hash[key]=node,this.size++)},get:function(key){var node=this.hash[key];if(node)return this.list.moveToFront(node),node.val},reset:function(){this.size=0,this.hash={},this.list=new List}}),_.mixin(List.prototype,{add:function(node){this.head&&(node.next=this.head,this.head.prev=node),this.head=node,this.tail=this.tail||node},remove:function(node){node.prev?node.prev.next=node.next:this.head=node.next,node.next?node.next.prev=node.prev:this.tail=node.prev},moveToFront:function(node){this.remove(node),this.add(node)}}),LruCache}(),PersistentStorage=function(){"use strict";var ls,methods;try{(ls=window.localStorage).setItem("~~~","!"),ls.removeItem("~~~")}catch(err){ls=null}function PersistentStorage(namespace){this.prefix=["__",namespace,"__"].join(""),this.ttlKey="__ttl__",this.keyMatcher=new RegExp("^"+_.escapeRegExChars(this.prefix))}return methods=ls&&window.JSON?{_prefix:function(key){return this.prefix+key},_ttlKey:function(key){return this._prefix(key)+this.ttlKey},get:function(key){return this.isExpired(key)&&this.remove(key),decode(ls.getItem(this._prefix(key)))},set:function(key,val,ttl){return _.isNumber(ttl)?ls.setItem(this._ttlKey(key),encode(now()+ttl)):ls.removeItem(this._ttlKey(key)),ls.setItem(this._prefix(key),encode(val))},remove:function(key){return ls.removeItem(this._ttlKey(key)),ls.removeItem(this._prefix(key)),this},clear:function(){var i,key,keys=[],len=ls.length;for(i=0;ittl)}}:{get:_.noop,set:_.noop,remove:_.noop,clear:_.noop,isExpired:_.noop},_.mixin(PersistentStorage.prototype,methods),PersistentStorage;function now(){return(new Date).getTime()}function encode(val){return JSON.stringify(_.isUndefined(val)?null:val)}function decode(val){return JSON.parse(val)}}(),Transport=function(){"use strict";var pendingRequestsCount=0,pendingRequests={},maxPendingRequests=6,sharedCache=new LruCache(10);function Transport(o){var fn;o=o||{},this.cancelled=!1,this.lastUrl=null,this._send=o.transport?(fn=o.transport,function(url,o){var deferred=$.Deferred();return fn(url,o,onSuccess,onError),deferred;function onSuccess(resp){_.defer((function(){deferred.resolve(resp)}))}function onError(err){_.defer((function(){deferred.reject(err)}))}}):$.ajax,this._get=o.rateLimiter?o.rateLimiter(this._get):this._get,this._cache=!1===o.cache?new LruCache(0):sharedCache}return Transport.setMaxPendingRequests=function(num){maxPendingRequests=num},Transport.resetCache=function(){sharedCache.reset()},_.mixin(Transport.prototype,{_get:function(url,o,cb){var jqXhr,that=this;function done(resp){cb&&cb(null,resp),that._cache.set(url,resp)}function fail(){cb&&cb(!0)}function always(){pendingRequestsCount--,delete pendingRequests[url],that.onDeckRequestArgs&&(that._get.apply(that,that.onDeckRequestArgs),that.onDeckRequestArgs=null)}this.cancelled||url!==this.lastUrl||((jqXhr=pendingRequests[url])?jqXhr.done(done).fail(fail):pendingRequestsCountarrayB[bi]||(intersection.push(arrayA[ai]),ai++),bi++);return intersection;function compare(a,b){return a-b}}(matches,ids):ids})),matches?_.map(function(array){for(var seen={},uniques=[],i=0,len=array.length;i0||!this.transport)&&cb&&cb(matches)},clear:function(){this.index.reset()},clearPrefetchCache:function(){this.storage&&this.storage.clear()},clearRemoteCache:function(){this.transport&&Transport.resetCache()},ttAdapter:function(){return _.bind(this.get,this)}}),Bloodhound;function ignoreDuplicates(){return!1}}(this);var html={wrapper:'',dropdown:'',dataset:'
',suggestions:'',suggestion:'
'},css=function(){"use strict";var css={wrapper:{position:"relative",display:"inline-block"},hint:{position:"absolute",top:"0",left:"0",borderColor:"transparent",boxShadow:"none",opacity:"1"},input:{position:"relative",verticalAlign:"top",backgroundColor:"transparent"},inputWithNoHint:{position:"relative",verticalAlign:"top"},dropdown:{position:"absolute",top:"100%",left:"0",zIndex:"100",display:"none"},suggestions:{display:"block"},suggestion:{whiteSpace:"nowrap",cursor:"pointer"},suggestionChild:{whiteSpace:"normal"},ltr:{left:"0",right:"auto"},rtl:{left:"auto",right:" 0"}};return _.isMsie()&&_.mixin(css.input,{backgroundImage:"url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)"}),_.isMsie()&&_.isMsie()<=7&&_.mixin(css.input,{marginTop:"-1px"}),css}(),EventBus=function(){"use strict";function EventBus(o){o&&o.el||$.error("EventBus initialized without el"),this.$el=$(o.el)}return _.mixin(EventBus.prototype,{trigger:function(type){var args=[].slice.call(arguments,1);this.$el.trigger("typeahead:"+type,args)}}),EventBus}(),EventEmitter=function(){"use strict";var splitter=/\s+/,nextTick=function(){var nextTickFn;nextTickFn=window.setImmediate?function(fn){setImmediate((function(){fn()}))}:function(fn){setTimeout((function(){fn()}),0)};return nextTickFn}();return{onSync:function(types,cb,context){return on.call(this,"sync",types,cb,context)},onAsync:function(types,cb,context){return on.call(this,"async",types,cb,context)},off:function(types){var type;if(!this._callbacks)return this;types=types.split(splitter);for(;type=types.shift();)delete this._callbacks[type];return this},trigger:function(types){var type,callbacks,args,syncFlush,asyncFlush;if(!this._callbacks)return this;types=types.split(splitter),args=[].slice.call(arguments,1);for(;(type=types.shift())&&(callbacks=this._callbacks[type]);)syncFlush=getFlush(callbacks.sync,this,[type].concat(args)),asyncFlush=getFlush(callbacks.async,this,[type].concat(args)),syncFlush()&&nextTick(asyncFlush);return this}};function on(method,types,cb,context){var type;if(!cb)return this;for(types=types.split(splitter),cb=context?function(fn,context){return fn.bind?fn.bind(context):function(){fn.apply(context,[].slice.call(arguments,0))}}(cb,context):cb,this._callbacks=this._callbacks||{};type=types.shift();)this._callbacks[type]=this._callbacks[type]||{sync:[],async:[]},this._callbacks[type][method].push(cb);return this}function getFlush(callbacks,context,args){return function(){for(var cancelled,i=0,len=callbacks.length;!cancelled&&i