diff --git a/src/main/webapp/project.html b/src/main/webapp/project.html
index 7027b5214..e94ee0503 100644
--- a/src/main/webapp/project.html
+++ b/src/main/webapp/project.html
@@ -1 +1 @@
-
Freebase Gridworks
starting up ...
\ No newline at end of file
+
Freebase Gridworks
starting up ...
\ No newline at end of file
diff --git a/src/main/webapp/scripts/util/freebase.js b/src/main/webapp/scripts/util/freebase.js
new file mode 100644
index 000000000..1a9b6500b
--- /dev/null
+++ b/src/main/webapp/scripts/util/freebase.js
@@ -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"
+ );
+};
\ No newline at end of file
diff --git a/src/main/webapp/scripts/views/data-table-cell-ui.js b/src/main/webapp/scripts/views/data-table-cell-ui.js
index 2cdc06b0d..412567987 100644
--- a/src/main/webapp/scripts/views/data-table-cell-ui.js
+++ b/src/main/webapp/scripts/views/data-table-cell-ui.js
@@ -90,13 +90,15 @@ DataTableCellUI.prototype._render = function() {
.addClass("data-table-recon-topic")
.attr("href", "http://www.freebase.com/view" + candidate.id)
.attr("target", "_blank")
- .click(function(evt) {
- self._previewCandidateTopic(candidate.id, this);
- evt.preventDefault();
- return false;
- })
.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;
if (candidate.score < 1) {
@@ -305,26 +307,77 @@ DataTableCellUI.prototype._postProcessSeveralCells = function(command, params, c
);
};
-DataTableCellUI.prototype._previewCandidateTopic = function(id, elmt) {
- 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"}]';
+DataTableCellUI.topicBlockParams = {
+ "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();
- fakeMenu
- .width(700)
- .height(300)
- .css("background", "none")
- .css("border", "none");
+ var render = function(id2) {
+ var url = "http://www.freebase.com/widget/topic" + id2 + '?' + $.param(DataTableCellUI.topicBlockParams);
- var iframe = $('')
- .attr("width", "100%")
- .attr("height", "100%")
- .css("background", "none")
- .css("border", "none")
- .attr("src", url)
- .appendTo(fakeMenu);
+ var fakeMenu = MenuSystem.createMenu();
+ fakeMenu
+ .width(DataTableCellUI.topicBlockDimensions.width)
+ .css("background", "none")
+ .css("border", "none")
+ .html(
+ ''
+ );
- MenuSystem.showMenu(fakeMenu, function(){});
- MenuSystem.positionMenuLeftRight(fakeMenu, $(elmt));
+ var iframe = $('')
+ .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) {
diff --git a/src/main/webapp/styles/views/data-table-view.css b/src/main/webapp/styles/views/data-table-view.css
index 30c3fc7ab..8578e9727 100644
--- a/src/main/webapp/styles/views/data-table-view.css
+++ b/src/main/webapp/styles/views/data-table-view.css
@@ -239,4 +239,13 @@ textarea.data-table-cell-editor-editor {
span.data-table-cell-editor-key {
color: #aaa;
+}
+
+.data-table-topic-popup-header {
+ padding: 5px;
+ background: #DBE8EB;
+}
+iframe.data-table-topic-popup-iframe {
+ background: #DBE8EB;
+ border: none;
}
\ No newline at end of file