Replace retired Freebase Topic Blocks with Freebase Suggest flyout -

part of
#696
This commit is contained in:
Tom Morris 2013-07-26 10:55:42 -04:00
parent 559e0124ca
commit c8f0e88bd4

View File

@ -156,10 +156,11 @@ DataTableCellUI.prototype._render = function() {
} }
var preview = null; var preview = null;
if ((service) && (service.preview)) { if ((service) && (service.preview)
&& service.preview.url.indexOf("http://www.freebase.com/widget/topic") < 0) {
preview = service.preview; preview = service.preview;
} else if (ReconciliationManager.isFreebaseIdOrMid(r.identifierSpace)) { } else if (ReconciliationManager.isFreebaseIdOrMid(r.identifierSpace)) {
preview = DataTableCellUI.topicBlockPreview; preview = DataTableCellUI.internalPreview;
} }
if (preview) { if (preview) {
a.click(function(evt) { a.click(function(evt) {
@ -436,30 +437,37 @@ DataTableCellUI.prototype._postProcessSeveralCells = function(command, params, b
); );
}; };
// FIXME: Topic Blocks are gone DataTableCellUI.internalPreview = {
DataTableCellUI.topicBlockPreview = { srchurl: 'https://www.googleapis.com/freebase/v1/search?filter=(all mid:${id})&output=(notable:/client/summary description type)&key='+CustomSuggest.FREEBASE_API_KEY+"&callback=?",
url: 'http://www.freebase.com/widget/topic{{id}}?mode=content&blocks=[{"block":"full_info"},{"block":"article_props"}]', imgurl : 'https://www.googleapis.com/freebase/v1/image${id}?maxwidth=75&errorid=/freebase/no_image_png&key='+CustomSuggest.FREEBASE_API_KEY,
width: 430, width: 430,
height: 300 height: 300
}; };
// TODO: Inject code to format using Suggest here?
DataTableCellUI.prototype._previewCandidateTopic = function(candidate, elmt, preview) { DataTableCellUI.prototype._previewCandidateTopic = function(candidate, elmt, preview) {
var self = this; var self = this;
var id = candidate.id; var id = candidate.id;
var url = preview.url.replace("{{id}}", id);
var fakeMenu = MenuSystem.createMenu(); var fakeMenu = MenuSystem.createMenu();
fakeMenu fakeMenu
.width(414) .width(414)
.addClass('data-table-topic-popup') .addClass('data-table-topic-popup')
.html(DOM.loadHTML("core", "scripts/views/data-table/cell-recon-preview-popup-header.html")); .html(DOM.loadHTML("core", "scripts/views/data-table/cell-recon-preview-popup-header.html"));
var iframe = $('<iframe></iframe>') if (preview && preview.url) { // Service has a preview URL associated with it
.width(preview.width) var url = preview.srch.replace("{{id}}", id);
.height(preview.height) var iframe = $('<iframe></iframe>')
.attr("src", url) .width(preview.width)
.appendTo(fakeMenu); .height(preview.height)
.attr("src", url)
.appendTo(fakeMenu);
} else { // Otherwise use our internal preview
var url = DataTableCellUI.internalPreview.srchurl.replace("\${id}",id);
$.ajax(url,{dataType:"jsonp"}).done(function(searchResponse) {
var data = searchResponse.result[0];
var html = $.suggest.suggest.create_flyout(data, preview.imgurl);
fakeMenu.append(html);
});
}
MenuSystem.showMenu(fakeMenu, function(){}); MenuSystem.showMenu(fakeMenu, function(){});
MenuSystem.positionMenuLeftRight(fakeMenu, $(elmt)); MenuSystem.positionMenuLeftRight(fakeMenu, $(elmt));