]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - include/javascript/yui3/build/autocomplete/autocomplete-sources-min.js
Release 6.5.0
[Github/sugarcrm.git] / include / javascript / yui3 / build / autocomplete / autocomplete-sources-min.js
1 /*
2 Copyright (c) 2010, Yahoo! Inc. All rights reserved.
3 Code licensed under the BSD License:
4 http://developer.yahoo.com/yui/license.html
5 version: 3.3.0
6 build: 3167
7 */
8 YUI.add("autocomplete-sources",function(g){var e=g.Lang,a="_sourceSuccess",c="maxResults",d="requestTemplate",b="resultListLocator";function f(){}f.prototype={_YQL_SOURCE_REGEX:/^(?:select|set|use)\s+/i,_createIOSource:function(l){var i={},j={},k=this,n,h,m;j.sendRequest=function(p){var o=function(s){var t=s.request,q,u,r;if(i[t]){k[a](i[t],s);}else{q=k.get(c);u=k.get(d);r=l;if(u){r+=u(t);}r=e.sub(r,{maxResults:q>0?q:1000,query:encodeURIComponent(t)});if(n&&n.isInProgress()){n.abort();}n=g.io(r,{on:{success:function(y,v){var x;try{x=g.JSON.parse(v.responseText);}catch(w){g.error("JSON parse error",w);}if(x){i[t]=x;k[a](x,s);}}}});}};h=p;if(!m){m=true;g.use("io-base","json-parse",function(){j.sendRequest=o;o(h);});}};return j;},_createJSONPSource:function(l){var i={},j={},k=this,h,m;j.sendRequest=function(o){var n=function(p){var q=p.request;if(i[q]){k[a](i[q],p);}else{l._config.on.success=function(r){i[q]=r;k[a](r,p);};l.send(q);}};h=o;if(!m){m=true;g.use("jsonp",function(){if(!(l instanceof g.JSONPRequest)){l=new g.JSONPRequest(l,{format:g.bind(k._jsonpFormatter,k)});}j.sendRequest=n;n(h);});}};return j;},_createStringSource:function(h){if(this._YQL_SOURCE_REGEX.test(h)){return this._createYQLSource(h);}else{if(h.indexOf("{callback}")!==-1){return this._createJSONPSource(h);}else{return this._createIOSource(h);}}},_createYQLSource:function(k){var i={},l={},j=this,h,m;if(!this.get(b)){this.set(b,this._defaultYQLLocator);}l.sendRequest=function(p){var o,n=function(u){var v=u.request,w,s,q,t,r;if(i[v]){j[a](i[v],u);}else{w=function(x){i[v]=x;j[a](x,u);};s=j.get("yqlEnv");q=j.get(c);t={proto:j.get("yqlProtocol")};r=e.sub(k,{maxResults:q>0?q:1000,query:v});if(o){o._callback=w;o._opts=t;o._params.q=r;if(s){o._params.env=s;}}else{o=new g.YQLRequest(r,{on:{success:w},allowCache:false},s?{env:s}:null,t);}o.send();}};h=p;if(!m){m=true;g.use("yql",function(){l.sendRequest=n;n(h);});}};return l;},_defaultYQLLocator:function(i){var j=i&&i.query&&i.query.results,h;if(j&&e.isObject(j)){h=g.Object.values(j)||[];j=h.length===1?h[0]:h;if(!e.isArray(j)){j=[j];}}else{j=[];}return j;},_jsonpFormatter:function(i,j,k){var h=this.get(c),l=this.get(d);if(l){i+=l(k);}return e.sub(i,{callback:j,maxResults:h>0?h:1000,query:encodeURIComponent(k)});}};f.ATTRS={yqlEnv:{value:null},yqlProtocol:{value:"http"}};g.Base.mix(g.AutoCompleteBase,[f]);},"3.3.0",{optional:["io-base","json-parse","jsonp","yql"],requires:["autocomplete-base"]});