Temporary fix: map guid to id before showing topicblock popups for recon candidates.

Added match and match similar buttons on topicblock popups.
Made topicblock popups show only 2 blocks.

git-svn-id: http://google-refine.googlecode.com/svn/trunk@566 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
David Huynh 2010-04-28 23:51:38 +00:00
parent 66b324f9cc
commit f9698d77ae
4 changed files with 114 additions and 24 deletions

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,28 @@
var Freebase = {};
Freebase.mqlread = function(query, options, onDone) {
var params = {};
var queryEnv = {
"query": query
};
if (options) {
for (var n in options) {
var v = options[n];
if (typeof v != "string") {
v = JSON.stringify(v);
}
queryEnv[n] = v;
}
}
params.query = JSON.stringify(queryEnv);
$.getJSON(
"http://api.freebase.com/api/service/mqlread?" + $.param(params) + "&callback=?",
null,
onDone,
"jsonp"
);
};

View File

@ -90,13 +90,15 @@ DataTableCellUI.prototype._render = function() {
.addClass("data-table-recon-topic") .addClass("data-table-recon-topic")
.attr("href", "http://www.freebase.com/view" + candidate.id) .attr("href", "http://www.freebase.com/view" + candidate.id)
.attr("target", "_blank") .attr("target", "_blank")
.click(function(evt) {
self._previewCandidateTopic(candidate.id, this);
evt.preventDefault();
return false;
})
.text(candidate.name) .text(candidate.name)
.appendTo(li); .appendTo(li)
.click(function(evt) {
if (!evt.metaKey && !evt.ctrlKey) {
self._previewCandidateTopic(candidate, this);
evt.preventDefault();
return false;
}
});
var score; var score;
if (candidate.score < 1) { if (candidate.score < 1) {
@ -305,26 +307,77 @@ DataTableCellUI.prototype._postProcessSeveralCells = function(command, params, c
); );
}; };
DataTableCellUI.prototype._previewCandidateTopic = function(id, elmt) { DataTableCellUI.topicBlockParams = {
var url = "http://www.freebase.com/widget/topic" + id + '?mode=content&blocks=[{"block"%3A"image"}%2C{"block"%3A"full_info"}%2C{"block"%3A"article_props"}]'; "mode" : "content",
"blocks" : JSON.stringify([
{
"block" : "full_info",
},
{
"block" : "article_props"
}
])
};
DataTableCellUI.topicBlockDimensions = {
width: 430,
height: 300
};
DataTableCellUI.prototype._previewCandidateTopic = function(candidate, elmt) {
var self = this;
var id = candidate.id;
var fakeMenu = MenuSystem.createMenu(); var render = function(id2) {
fakeMenu var url = "http://www.freebase.com/widget/topic" + id2 + '?' + $.param(DataTableCellUI.topicBlockParams);
.width(700)
.height(300)
.css("background", "none")
.css("border", "none");
var iframe = $('<iframe></iframe>') var fakeMenu = MenuSystem.createMenu();
.attr("width", "100%") fakeMenu
.attr("height", "100%") .width(DataTableCellUI.topicBlockDimensions.width)
.css("background", "none") .css("background", "none")
.css("border", "none") .css("border", "none")
.attr("src", url) .html(
.appendTo(fakeMenu); '<div class="data-table-topic-popup-header">' +
'<button title="Match topic to this cell" bind="matchButton">Match</button> ' +
'<button title="Match topic to all visible cells with same content" bind="matchSimilarButton">Match Similar</button>' +
'</div>'
);
MenuSystem.showMenu(fakeMenu, function(){}); var iframe = $('<iframe></iframe>')
MenuSystem.positionMenuLeftRight(fakeMenu, $(elmt)); .addClass("data-table-topic-popup-iframe")
.width(DataTableCellUI.topicBlockDimensions.width)
.height(DataTableCellUI.topicBlockDimensions.height)
.attr("src", url)
.appendTo(fakeMenu);
MenuSystem.showMenu(fakeMenu, function(){});
MenuSystem.positionMenuLeftRight(fakeMenu, $(elmt));
var elmts = DOM.bind(fakeMenu);
elmts.matchButton.click(function() {
self._doMatchTopicToOneCell(candidate);
MenuSystem.dismissAll();
});
elmts.matchSimilarButton.click(function() {
self._doMatchTopicToSimilarCells(candidate);
MenuSystem.dismissAll();
});
};
if (id.indexOf("/guid/") !== 0) {
render(id);
} else {
Freebase.mqlread(
{
"guid" : "#" + id.substring(6),
"id" : null
},
null,
function(o) {
render(o.result.id);
}
);
}
}; };
DataTableCellUI.prototype._startEdit = function(elmt) { DataTableCellUI.prototype._startEdit = function(elmt) {

View File

@ -239,4 +239,13 @@ textarea.data-table-cell-editor-editor {
span.data-table-cell-editor-key { span.data-table-cell-editor-key {
color: #aaa; color: #aaa;
}
.data-table-topic-popup-header {
padding: 5px;
background: #DBE8EB;
}
iframe.data-table-topic-popup-iframe {
background: #DBE8EB;
border: none;
} }