').appendTo(menu);
function createSuggestion(suggestion) {
var menuItem = MenuSystem.createMenuItem().appendTo(menu);
menuItem.html(suggestion.id).click(function() {
commitProperty(suggestion);
});
}
for (var i = 0; i < suggestions.length; i++) {
createSuggestion(suggestions[i]);
}
} else {
var divSearch = $('
').addClass("schema-alignment-link-menu-type-search").html('
Search for a property
').appendTo(menu);
}
var input = $('
').appendTo($('
').appendTo(divSearch));
MenuSystem.showMenu(menu, function(){});
MenuSystem.positionMenuAboveBelow(menu, $(elmt));
var suggestOptions = {
type : '/type/property'
};
if (this._link.target != null && "type" in this._link.target && this._link.target.type != null) {
/*
suggestOptions.mql_filter = [{
"/type/property/expected_type" : {
id: this._link.target.type.id
}
}];
*/
} else {
var sourceTypeID = this._parentUINode.getExpectedType();
if (sourceTypeID != null) {
suggestOptions.schema = sourceTypeID;
}
}
input.suggestP(suggestOptions).bind("fb-select", function(e, data) { commitProperty(data); });
input[0].focus();
};
SchemaAlignmentDialog.UILink.prototype.getJSON = function() {
if ("property" in this._link && this._link.property != null &&
"target" in this._link && this._link.target != null) {
var targetJSON = this._targetUI.getJSON();
if (targetJSON != null) {
return {
property: cloneDeep(this._link.property),
target: targetJSON
};
}
}
return null;
};
SchemaAlignmentDialog.UILink.prototype._configureTarget = function() {
var self = this;
var dismissBusy = DialogSystem.showBusy();
$.getJSON(
"http://api.freebase.com/api/service/mqlread?query=" + JSON.stringify({
query: {
"id" : this._link.property.id,
"type" : "/type/property",
"expected_type" : {
"id" : null,
"name" : null,
"/freebase/type_hints/mediator" : null
}
}
}) + "&callback=?",
null,
function(o) {
dismissBusy();
if ("result" in o) {
var expected_type = o.result.expected_type;
self._link.target.type = {
id: expected_type.id,
name: expected_type.name
};
if (expected_type["/freebase/type_hints/mediator"] === true) {
self._link.target.nodeType = "anonymous";
} else if (expected_type.id == "/type/key") {
self._link.target.nodeType = "cell-as-key";
} else if (expected_type.id.match(/^\/type\//)) {
self._link.target.nodeType = "cell-as-value";
} else if (!("topic" in self._link.target)) {
self._link.target.nodeType = "cell-as-topic";
self._link.target.createForNoReconMatch = true;
}
self._targetUI.render();
}
self._renderMain();
self._dialog.preview();
},
"jsonp"
);
};