From 4661b0210ddb5e90739eee69bc2a5262b060747c Mon Sep 17 00:00:00 2001 From: Junxian Wu Date: Sat, 11 Jun 2016 07:48:30 -0700 Subject: [PATCH] Popover to generate iframe html tag when standalone button is clicked (#575) * fixed * basic implementation of the iframe embed popover * remove unecessary comments * remove public embed iframe * remove debug print line and public access * remove uncessary extra line and use better text explain * maintain the style of airbnb/master * fixed style * re-run the test locally. Made sure it passed --- caravel/assets/javascripts/explore.js | 54 +++++++++++++++++++ caravel/assets/javascripts/modules/caravel.js | 3 -- caravel/templates/caravel/explore.html | 2 +- 3 files changed, 55 insertions(+), 4 deletions(-) diff --git a/caravel/assets/javascripts/explore.js b/caravel/assets/javascripts/explore.js index fe64c85e59fd9..73546364139b4 100644 --- a/caravel/assets/javascripts/explore.js +++ b/caravel/assets/javascripts/explore.js @@ -194,6 +194,60 @@ function initExploreView() { }); }); + $('#standalone').click(function () { + var src_link = window.location.origin + slice.data.standalone_endpoint; + var dataToCopy = ''; + var close = ''; + var copy = ''; + var spaces = '   '; + var widthInput = ''; + var heightInput = ''; + var popover = ""; + popover = popover + spaces + copy + spaces + close + spaces + widthInput + spaces + heightInput; + + var $standalone = $(this); + $standalone.popover({ + content: popover, + title: 'embed html', + placement: 'left', + html: true, + trigger: 'manual' + }) + .popover('show'); + $('#copy_embed').tooltip().click(function () { + var success = copyURLToClipboard(dataToCopy); + if (success) { + $(this).attr("data-original-title", "Copied!").tooltip('fixTitle').tooltip('show'); + window.setTimeout(destroyPopover, 1200); + } + }); + + $('#close_standalone').click(destroyPopover); + + function destroyPopover() { + $standalone.popover('destroy'); + } + + var $standalone_width = $('#standalone_width'); + var $standalone_height = $('#standalone_height'); + var $standalone_text = $('#standalone_text'); + + $standalone_height.change(function () { + generateEmbedHTML(); + }); + $standalone_width.change(function () { + generateEmbedHTML(); + }); + generateEmbedHTML(); + function generateEmbedHTML() { + var width = $standalone_width.val(); + var height = $standalone_height.val(); + dataToCopy = ''; + $standalone_text.val(dataToCopy); + } + }); + $("#viz_type").change(function () { $("#query").submit(); }); diff --git a/caravel/assets/javascripts/modules/caravel.js b/caravel/assets/javascripts/modules/caravel.js index c3794b7af4e3c..440240af87f68 100644 --- a/caravel/assets/javascripts/modules/caravel.js +++ b/caravel/assets/javascripts/modules/caravel.js @@ -276,9 +276,6 @@ var px = (function () { $('#json').click(function () { window.location = data.json_endpoint; }); - $('#standalone').click(function () { - window.location = data.standalone_endpoint; - }); $('#csv').click(function () { window.location = data.csv_endpoint; }); diff --git a/caravel/templates/caravel/explore.html b/caravel/templates/caravel/explore.html index 1510f8d80c222..925d85620af1f 100644 --- a/caravel/templates/caravel/explore.html +++ b/caravel/templates/caravel/explore.html @@ -62,7 +62,7 @@   - +