Skip to content

Commit

Permalink
Refs #22337; Changed the following:
Browse files Browse the repository at this point in the history
- Removed top and bottom padding of share box which brought box sizing
  differences for embed charts
- Loaded the share box logic only after the googlechart draw logic is
  completed both in embed chart and embed dashboard
- No longer load the sharing options within inline charts
- Share links now open in target blank in order to avoid browser
  blocking when attempting to click the links especially on Chrome
  • Loading branch information
ichim-david committed Jan 7, 2015
1 parent c6adade commit 3771a99
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 43 deletions.
2 changes: 2 additions & 0 deletions docs/HISTORY.txt
Expand Up @@ -3,6 +3,8 @@ Changelog

12.2-dev - (unreleased)
-----------------------
* Bugfix: fix share and embed actions after fixes done for 22290
[ichimdav refs 22337]

12.1 - (2015-01-06)
-------------------
Expand Down
2 changes: 1 addition & 1 deletion eea/googlecharts/views/css/embed.css
Expand Up @@ -72,7 +72,7 @@ a:visited, a:hover {
}

.googlechart-share {
padding: 0.3em 0.5em 0.5em 0.5em;
padding: 0 0.5em;
display: block;
float:right;
}
Expand Down
70 changes: 36 additions & 34 deletions eea/googlecharts/views/js/embed_common.js
Expand Up @@ -26,41 +26,43 @@ function putImageDivInPosition(div_id, position, vhash){
}

jQuery(function($){
$('.googlecharts-embed-dialog').dialog({ autoOpen: false, width: '80%'});
var share_dialog = $('#share-dialog');
var embed_url = document.location.href;
var doc = $(document);
var doc_height = doc.height();
var doc_width = doc.width();
var iframeCode = '<iframe width=\'' + doc_width + '\' height=\'' + doc_height + '\' src=\'' + embed_url + '\'></iframe>';
share_dialog.find('.share-dialog-text').text(iframeCode);
$('.open-dialog').click(function(ev) {
$($(this).attr('data-dialog')).dialog('open');
ev.preventDefault();
});
if (!window.EEAGoogleCharts) {
return;
}
var embed_obj = window.EEAGoogleCharts.embed;
var hash = embed_obj.hash;
var baseurl_uri = window.encodeURIComponent(embed_obj['baseurl_' + hash] + '/#tab-' + embed_obj['chart_id_' + hash]);
var chart_share = $('.googlechart-share');
chart_share.parent().appendTo("#googlechart_bottom_images_" + hash);
$(".googlechart_left_image").find('img').appendTo("#share-dialog");
$(".googlechart-datasources-info").appendTo('.googlechart-notes');
doc.hover(function() {
chart_share.fadeIn();
}, function() {
chart_share.fadeOut();
});
doc.bind('googlecharts.embed.ready', function() {
$('.googlecharts-embed-dialog').dialog({ autoOpen: false, width: '80%'});
var share_dialog = $('#share-dialog');
var embed_url = this.location.href;
var doc_height = doc.height();
var doc_width = doc.width();
var iframeCode = '<iframe width=\'' + doc_width + '\' height=\'' + doc_height + '\' src=\'' + embed_url + '\'></iframe>';
share_dialog.find('.share-dialog-text').text(iframeCode);
$('.open-dialog').click(function(ev) {
$($(this).attr('data-dialog')).dialog('open');
ev.preventDefault();
});
if (!window.EEAGoogleCharts) {
return;
}
var embed_obj = window.EEAGoogleCharts.embed;
var hash = embed_obj.hash;
var baseurl_uri = window.encodeURIComponent(embed_obj['baseurl_' + hash] + '/#tab-' + embed_obj['chart_id_' + hash]);
var chart_share = $('.googlechart-share');
chart_share.parent().appendTo("#googlechart_bottom_images_" + hash);
$(".googlechart_left_image").find('img').appendTo("#share-dialog");
$(".googlechart-datasources-info").appendTo('.googlechart-notes');
doc.hover(function() {
chart_share.fadeIn();
}, function() {
chart_share.fadeOut();
});

var enlarge_button = $('.googlechart-enlarge');
enlarge_button.attr('href', embed_url);
// show the enlarge button only if we are inside of the iframe
if(window === window.top) {
enlarge_button.hide();
}
$('.share-button').each(function(){
this.href = this.href + baseurl_uri;
var enlarge_button = $('.googlechart-enlarge');
enlarge_button.attr('href', embed_url);
// show the enlarge button only if we are inside of the iframe
if(window === window.top) {
enlarge_button.hide();
}
$('.share-button').each(function(){
this.href = this.href + baseurl_uri;
});
});
});
13 changes: 6 additions & 7 deletions eea/googlecharts/views/zpt/embed-chart.pt
Expand Up @@ -248,6 +248,7 @@
}else if(jQuery('#googlechart_dashboard_$vhash').is(':visible')){
if (isInline_$vhash !== 'True'){
drawChart(settings_$vhash, other_options_$vhash);
jQuery(document).trigger('googlecharts.embed.ready');
}
else{
jQuery('#googlechart_dashboard_$vhash')
Expand All @@ -257,8 +258,6 @@
.data('other_options', other_options_$vhash);
}
}
});
function hashchanged(){
if (jQuery('#googlechart_dashboard_$vhash').is(':visible')){
Expand All @@ -272,7 +271,7 @@
<div tal:attributes="id string:googlechart_dashboard_$vhash" class="embedded-dashboard googlechart_dashboard isChart">
</div>
<!--? Share box -->
<div class="googlechart-share-box" metal:define-macro="share">
<div class="googlechart-share-box" metal:define-macro="share" tal:condition="python:not inline">
<div class="googlechart-share" style="display:none;">
<div class="pull-right">
<!--? Save -->
Expand All @@ -299,7 +298,7 @@

<!--? Explore Data -->
<div class="pull-left">
<a tal:condition="python:not inline" class="go-to-original-link"
<a class="go-to-original-link"
tal:attributes="href url"
i18n:translate="" target="_top"><span class="sprite sprite-explore"></span>Explore</a>
</div>
Expand All @@ -313,9 +312,9 @@
<textarea class="share-dialog-text" cols="69" rows="5"> </textarea>
<p><strong>Share:</strong></p>
<div class="googlechart googlechart-social">
<a href="https://twitter.com/intent/tweet?url=" class="share-button share-button-twitter">Twitter</a>
<a href="https://www.facebook.com/sharer/sharer.php?u=" class="share-button share-button-facebook">Facebook</a>
<a href="https://plus.google.com/share?url=" class="share-button share-button-gplus">Google Plus</a>
<a href="https://twitter.com/intent/tweet?url=" class="share-button share-button-twitter" target="_blank">Twitter</a>
<a href="https://www.facebook.com/sharer/sharer.php?u=" class="share-button share-button-facebook" target="_blank">Facebook</a>
<a href="https://plus.google.com/share?url=" class="share-button share-button-gplus" target="_blank">Google Plus</a>

</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions eea/googlecharts/views/zpt/embed-dashboard.pt
Expand Up @@ -109,6 +109,7 @@
};
if (isPrint || isInline_$vhash !== 'True'){
drawDashboardEmbed(settings_$vhash);
jQuery(document).trigger('googlecharts.embed.ready');
}
else{
jQuery('#googlechart_dashboard_$vhash')
Expand Down
2 changes: 1 addition & 1 deletion eea/googlecharts/views/zpt/inline-includes.pt
Expand Up @@ -37,7 +37,7 @@ jQuery(window).scrollStopped(function(){
jQuery.each(jQuery('.embedded-dashboard:visible'), function(idx, elem){
if (isScrolledIntoView(elem)){
if (jQuery(elem).hasClass('not_visible')){
jQuery(elem).removeClass('not_visible')
jQuery(elem).removeClass('not_visible');
if (jQuery(elem).hasClass('isChart')){
drawChart(jQuery(elem).data('settings'), jQuery(elem).data('other_options'));
}
Expand Down

0 comments on commit 3771a99

Please sign in to comment.