Modified:
trunk/src/core.js
trunk/src/suggest.js
Log:
added code for handling timeouts
Modified: trunk/src/core.js
==============================================================================
--- trunk/src/core.js (original)
+++ trunk/src/core.js Wed Dec 10 17:11:32 2008
@@ -482,7 +482,11 @@
// 3. { result: [...] }
// 4. { query: { result: [...] } }
var result = [];
- if ("list" in o && "listItems" in o.list)
+ if (o.code == "/api/status/timeout"){
+ this.handle({id:"TIMEOUT", input:input, result:result});
+ return;
+ }
+ else if ("list" in o && "listItems" in o.list)
result = o.list.listItems;
else if ("result" in o)
result = o.result;
@@ -659,21 +663,25 @@
/**
* show loading message
*/
-p.loading_show = function(input) {
+p.loading_show = function(input, content) {
+
+ content = typeof(content) == "string" ? content : "loading...";
this.list_hide();
- if (!$("#fbs_loading").length) {
+ if (!$("#fbs_loading").length || (this._last_loading_content !=
content) ){
+ $("#fbs_loading").remove();
$(document.body)
.append(
'<div style="display:none;position:absolute"
id="fbs_loading" class="fbs-topshadow">' +
'<div class="fbs-bottomshadow">'+
'<ul class="fbs-ul">' +
'<li class="fbs-li">'+
- '<div
class="fbs-li-name">loading...</div>' +
+ '<div class="fbs-li-name">'+ content
+ '</div>' +
'</li>' +
'</ul>' +
'</div>' +
'</div>');
}
+ this._last_loading_content = content;
this.position($("#fbs_loading"), input);
};
@@ -904,6 +912,14 @@
switch (data.id) {
case "TEXTCHANGE":
this.sm.transition("start", null, null, data);
+ break;
+ case "TIMEOUT":
+ if (options["timeout_content"]){
+ this.c.loading_hide(data.input);
+ this.c.loading_show(data.input,options["timeout_content"]);
+ } else {
+ this.sm.transition("start");
+ }
break;
case "LIST_RESULT":
this.sm.transition("selecting", null, data);
Modified: trunk/src/suggest.js
==============================================================================
--- trunk/src/suggest.js (original)
+++ trunk/src/suggest.js Wed Dec 10 17:11:32 2008
@@ -23,6 +23,10 @@
* service_url: This the base url to all the api services like
autocomplete,
* blurbs and thumbnails. Default
is "http://www.freebase.com".
*
+ * freebase_url: This is the base url to the freebase site. If set, the
control will
+ * create absolute urls with freebase_url as the base;
otherwise relative urls
+ * are used.
+ *
* ac_path: The path to the autcomplete service. Default
is "/api/service/search".
*
* ac_param: A dicionary of query parameters to the autocomplete
service.
@@ -150,7 +154,8 @@
thumbnail_param: {maxwidth: 70, maxheight: 70},
filter: null,
transform: null,
- initialize: false
+ initialize: false,
+ timeout_content:null
};
};
// inheritance: prototype/constructor chaining