2010-03-03 00:48:21 +01:00
|
|
|
(function() {
|
2010-10-18 19:44:42 +02:00
|
|
|
/*
|
|
|
|
* Make suggest widgets clean up when removed.
|
|
|
|
*/
|
|
|
|
var oldInit = $.suggest.suggest.prototype._init;
|
|
|
|
$.suggest.suggest.prototype._init = function() {
|
|
|
|
oldInit.call(this);
|
|
|
|
|
|
|
|
var self = this;
|
|
|
|
this.input.bind("remove", function() {
|
|
|
|
self._destroy();
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2010-03-05 20:28:35 +01:00
|
|
|
/*
|
|
|
|
* Property suggest
|
|
|
|
*/
|
2010-03-03 00:48:21 +01:00
|
|
|
$.suggest(
|
|
|
|
"suggestP",
|
|
|
|
$.extend(
|
|
|
|
true,
|
|
|
|
{},
|
|
|
|
$.suggest.suggest.prototype,
|
|
|
|
{
|
|
|
|
create_item: function(data, response_data) {
|
|
|
|
var css = this.options.css;
|
2010-06-29 00:42:53 +02:00
|
|
|
|
2010-03-03 00:48:21 +01:00
|
|
|
var li = $("<li>").addClass(css.item);
|
2010-06-29 00:42:53 +02:00
|
|
|
|
2010-03-03 00:48:21 +01:00
|
|
|
var name = $("<div>")
|
|
|
|
.addClass(css.item_name)
|
|
|
|
.append(
|
2010-06-29 00:42:53 +02:00
|
|
|
$("<label>").append(
|
|
|
|
$.suggest.strongify(
|
|
|
|
data.name || data.guid, response_data.prefix
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
2010-03-11 22:19:51 +01:00
|
|
|
|
2010-03-03 00:48:21 +01:00
|
|
|
data.name = name.text(); // this converts html escaped strings like "&" back to "&"
|
|
|
|
li.append(name);
|
2010-06-29 00:42:53 +02:00
|
|
|
|
2010-03-03 00:48:21 +01:00
|
|
|
name.prepend($("<div>").addClass(css.item_type).text(data.id));
|
|
|
|
|
|
|
|
return li;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2010-06-29 00:42:53 +02:00
|
|
|
var originalSuggestP = $.suggest.suggestP;
|
|
|
|
$.suggest.suggestP = function(input, options) {
|
|
|
|
originalSuggestP.call(this, input, options);
|
|
|
|
|
|
|
|
if ("ac_param" in options) {
|
|
|
|
var ac_param = options.ac_param;
|
|
|
|
if ("schema" in ac_param) {
|
|
|
|
this.options.ac_param.schema = ac_param.schema;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
$.suggest.suggestP.prototype = originalSuggestP.prototype;
|
|
|
|
|
2010-03-03 00:48:21 +01:00
|
|
|
$.extend(
|
|
|
|
$.suggest.suggestP,
|
|
|
|
{
|
|
|
|
defaults: $.extend(
|
|
|
|
true,
|
|
|
|
{},
|
|
|
|
$.suggest.suggest.defaults, {
|
2010-09-23 00:55:28 +02:00
|
|
|
service_url: Refine.refineHelperService,
|
2010-06-29 00:42:53 +02:00
|
|
|
service_path: "/suggest_property",
|
|
|
|
flyout_service_url: "http://www.freebase.com",
|
2010-03-05 20:28:35 +01:00
|
|
|
css: { pane: "fbs-pane fbs-pane-property" }
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Type suggest
|
|
|
|
*/
|
|
|
|
$.suggest(
|
|
|
|
"suggestT",
|
|
|
|
$.extend(
|
|
|
|
true,
|
|
|
|
{},
|
|
|
|
$.suggest.suggest.prototype,
|
|
|
|
{
|
|
|
|
create_item: function(data, response_data) {
|
|
|
|
var css = this.options.css;
|
|
|
|
|
|
|
|
var li = $("<li>").addClass(css.item);
|
|
|
|
|
|
|
|
var name = $("<div>")
|
|
|
|
.addClass(css.item_name)
|
|
|
|
.append(
|
|
|
|
$("<label>")
|
|
|
|
.append($.suggest.strongify(data.name || data.guid, response_data.prefix)));
|
|
|
|
|
|
|
|
data.name = name.text(); // this converts html escaped strings like "&" back to "&"
|
|
|
|
li.append(name);
|
|
|
|
|
|
|
|
name.prepend($("<div>").addClass(css.item_type).text(data.id));
|
|
|
|
|
|
|
|
return li;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
$.extend(
|
|
|
|
$.suggest.suggestT,
|
|
|
|
{
|
|
|
|
defaults: $.extend(
|
|
|
|
true,
|
|
|
|
{},
|
|
|
|
$.suggest.suggest.defaults, {
|
|
|
|
css: { pane: "fbs-pane fbs-pane-type" }
|
2010-03-03 00:48:21 +01:00
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
|
|
|
);
|
|
|
|
})();
|