Skip to content
Extraits de code Groupes Projets
Valider c2061d4f rédigé par Benaka Moorthi's avatar Benaka Moorthi
Parcourir les fichiers

Refs #4077, #4041, resize treemap on widget resize and fix regression in...

Refs #4077, #4041, resize treemap on widget resize and fix regression in jqplot refactoring (export as image didn't work).
parent ed569f20
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -24,9 +24,8 @@
var $element = this.$element = $(element);
$element.data('uiControlObject', this);
// convert values in params that are arrays to comma separated string lists
var params = JSON.parse($element.attr('data-params') || '{}');
for (var key in params) {
for (var key in params) { // convert values in params that are arrays to comma separated string lists
if (params[key] instanceof Array) {
params[key] = params[key].join(',');
}
......@@ -46,7 +45,7 @@
* to the DOM.
*
* TODO: instead of having other pieces of the UI manually calling cleanupUnusedControls,
* MutationObservers should be called
* MutationObservers should be used
*/
UIControl.cleanupUnusedControls = function () {
var controls = UIControl._controls;
......@@ -88,6 +87,20 @@
delete this.$element;
this._baseDestroyCalled = true;
},
/**
* Handle the widget resize event, if we're currently in a widget.
*
* TODO: should use proper resize detection (see
* http://www.backalleycoder.com/2013/03/18/cross-browser-event-based-element-resize-detection/ )
* with timeouts (since resizing widgets can be expensive)
*/
onWidgetResize: function (handler) {
var $widget = this.$element.closest('.widgetContent');
$widget.on('widget:maximise', handler)
.on('widget:minimise', handler)
.on('widget:resize', handler);
}
};
......
......@@ -148,7 +148,7 @@
// export as image
target.on('piwikExportAsImage', function () {
self.exportAsImage(target, lang);
self.exportAsImage(target, self._lang);
});
// manage resources
......@@ -161,6 +161,10 @@
}
}
});
this.$element.closest('.widgetContent').on('widget:resize', function () {
self._resizeGraph();
});
},
_resizeGraph: function () {
......
......@@ -311,9 +311,9 @@
saveLayout();
}
// reload all widgets containing a graph to make them display correct
$('.widget:has(".piwik-graph")').each(function (id, elem) {
reloadWidget($(elem).attr('id'));
// trigger resize event on all widgets
$('.widgetContent').each(function () {
$(this).trigger('widget:resize');
});
}
......
......@@ -111,6 +111,11 @@
self._leaveNode();
return false;
});
this.onWidgetResize(function () {
var $treemap = self.$element.find('.infoviz-treemap');
self.treemap.canvas.resize($treemap.width(), $treemap.height());
});
},
/**
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter