Skip to content
Extraits de code Groupes Projets
Valider 1ed3cd1e rédigé par diosmosis's avatar diosmosis
Parcourir les fichiers

Fix widget list positioning bug in widgetMenu.js, added several hooks to...

Fix widget list positioning bug in widgetMenu.js, added several hooks to dashboardWidget.js for custom handling of widget buttons.
parent f95bb763
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -435,7 +435,8 @@ ...@@ -435,7 +435,8 @@
"JsTrackingTag": "JavaScript Tracking Code", "JsTrackingTag": "JavaScript Tracking Code",
"ViewDocumentationFor": "View documentation for %1$s", "ViewDocumentationFor": "View documentation for %1$s",
"WellDone": "Well done!", "WellDone": "Well done!",
"All": "All" "All": "All",
"Segment": "Segment"
}, },
"Actions": { "Actions": {
"PluginDescription": "Reports about the page views, the outlinks and downloads. Outlinks and Downloads tracking is automatic! You can also track your internal website's Search Engine.", "PluginDescription": "Reports about the page views, the outlinks and downloads. Outlinks and Downloads tracking is automatic! You can also track your internal website's Search Engine.",
......
...@@ -33,7 +33,10 @@ ...@@ -33,7 +33,10 @@
onChange: null, onChange: null,
widgetParameters: {}, widgetParameters: {},
title: null, title: null,
onRemove: null onRemove: null,
onRefresh: null,
onMaximise: null,
onMinimise: null
}, },
/** /**
...@@ -92,40 +95,13 @@ ...@@ -92,40 +95,13 @@
maximise: function () { maximise: function () {
this.isMaximised = true; this.isMaximised = true;
this.element.before('<div id="' + this.uniqueId + '-placeholder" class="widgetPlaceholder widget"> </div>'); if (this.options.onMaximise) {
$('#' + this.uniqueId + '-placeholder').height(this.element.height()); this.options.onMaximise(this.element);
$('#' + this.uniqueId + '-placeholder').width(this.element.width() - 16); } else {
this._maximiseImpl();
var width = Math.floor($('body').width() * 0.7); }
var self = this;
this.element.dialog({
title: '',
modal: true,
width: width,
position: ['center', 'center'],
resizable: true,
autoOpen: true,
close: function (event, ui) {
self.isMaximised = false;
$('body').off('.dashboardWidget');
$(this).dialog("destroy");
$('#' + self.uniqueId + '-placeholder').replaceWith(this);
$(this).removeAttr('style');
self.options.onChange();
$(this).find('div.piwik-graph').trigger('resizeGraph');
$('.widgetContent', self.element).trigger('widget:minimise');
}
});
this.element.find('div.piwik-graph').trigger('resizeGraph');
var currentWidget = this.element; $('.widgetContent', this.element).trigger('widget:maximise');
$('body').on('click.dashboardWidget', function (ev) {
if (/ui-widget-overlay/.test(ev.target.className)) {
$(currentWidget).dialog("close");
}
});
$('.widgetContent', currentWidget).trigger('widget:maximise');
return this; return this;
}, },
...@@ -168,7 +144,6 @@ ...@@ -168,7 +144,6 @@
* @param {object} parameters * @param {object} parameters
*/ */
setParameters: function (parameters) { setParameters: function (parameters) {
if (!this.isMaximised && (parameters.viewDataTable == 'tableAllColumns' || parameters.viewDataTable == 'tableGoals')) { if (!this.isMaximised && (parameters.viewDataTable == 'tableAllColumns' || parameters.viewDataTable == 'tableGoals')) {
this.maximise(); this.maximise();
} }
...@@ -241,37 +216,113 @@ ...@@ -241,37 +216,113 @@
$('.button#maximise', widgetElement) $('.button#maximise', widgetElement)
.on('click.dashboardWidget', function (ev) { .on('click.dashboardWidget', function (ev) {
if ($('.widgetContent', $(this).parents('.widget')).hasClass('hidden')) { if (self.options.onMaximise) {
self.isMaximised = false; self.options.onMaximise(self.element);
self.options.isHidden = false;
$(this).closest('.widget').removeClass('hiddenContent').find('.widgetContent').removeClass('hidden');
$(this).closest('.widget').find('div.piwik-graph').trigger('resizeGraph');
self.options.onChange();
$('.widgetContent', widgetElement).trigger('widget:minimise');
} else { } else {
self.maximise(); if ($('.widgetContent', $(this).parents('.widget')).hasClass('hidden')) {
self.showContent();
} else {
self.maximise();
}
} }
}); });
$('.button#minimise', widgetElement) $('.button#minimise', widgetElement)
.on('click.dashboardWidget', function (ev) { .on('click.dashboardWidget', function (ev) {
if (!self.isMaximised) { if (self.options.onMinimise) {
$('.widgetContent', $(this).closest('.widget').addClass('hiddenContent')).addClass('hidden'); self.options.onMinimise(self.element);
self.options.isHidden = true;
self.options.onChange();
} else { } else {
self.element.dialog("close"); if (!self.isMaximised) {
self.hideContent();
} else {
self.element.dialog("close");
}
} }
}); });
$('.button#refresh', widgetElement) $('.button#refresh', widgetElement)
.on('click.dashboardWidget', function (ev) { .on('click.dashboardWidget', function (ev) {
self.reload(false, true); if (self.options.onRefresh) {
self.options.onRefresh(self.element);
} else {
self.reload(false, true);
}
}); });
},
widgetElement.show(); /**
} * Hide the widget content. Triggers the onChange event.
*/
hideContent: function () {
$('.widgetContent', this.element.find('.widget').addClass('hiddenContent')).addClass('hidden');
this.options.isHidden = true;
this.options.onChange();
},
/**
* Show the widget content. Triggers the onChange event.
*/
showContent: function () {
this.isMaximised = false;
this.options.isHidden = false;
this.element.find('.widget').removeClass('hiddenContent').find('.widgetContent').removeClass('hidden');
this.element.find('.widget').find('div.piwik-graph').trigger('resizeGraph');
this.options.onChange();
$('.widgetContent', this.element).trigger('widget:minimise');
},
/**
* Default maximise behavior. Will create a dialog that is 70% of the document's width,
* displaying the widget alone.
*/
_maximiseImpl: function () {
this.detachWidget();
var width = Math.floor($('body').width() * 0.7);
var self = this;
this.element.dialog({
title: '',
modal: true,
width: width,
position: ['center', 'center'],
resizable: true,
autoOpen: true,
close: function (event, ui) {
self.isMaximised = false;
$('body').off('.dashboardWidget');
$(this).dialog("destroy");
$('#' + self.uniqueId + '-placeholder').replaceWith(this);
$(this).removeAttr('style');
self.options.onChange();
$(this).find('div.piwik-graph').trigger('resizeGraph');
$('.widgetContent', self.element).trigger('widget:minimise');
}
});
this.element.find('div.piwik-graph').trigger('resizeGraph');
var currentWidget = this.element;
$('body').on('click.dashboardWidget', function (ev) {
if (/ui-widget-overlay/.test(ev.target.className)) {
$(currentWidget).dialog("close");
}
});
},
/**
* Detaches the widget from the DOM and replaces it with a placeholder element.
* The placeholder element will have the save dimensions as the widget and will have
* the widgetPlaceholder CSS class.
*
* @return {jQuery} the detached widget
*/
detachWidget: function () {
this.element.before('<div id="' + this.uniqueId + '-placeholder" class="widgetPlaceholder widget"> </div>');
$('#' + this.uniqueId + '-placeholder').height(this.element.height());
$('#' + this.uniqueId + '-placeholder').width(this.element.width() - 16);
return this.element.detach();
}
}); });
})(jQuery); })(jQuery);
\ No newline at end of file
...@@ -224,7 +224,7 @@ widgetsHelper.loadWidgetAjax = function (widgetUniqueId, widgetParameters, onWid ...@@ -224,7 +224,7 @@ widgetsHelper.loadWidgetAjax = function (widgetUniqueId, widgetParameters, onWid
if ($('.' + settings.categorylistClass + ' .' + settings.choosenClass, widgetPreview).length) { if ($('.' + settings.categorylistClass + ' .' + settings.choosenClass, widgetPreview).length) {
var position = $('.' + settings.categorylistClass + ' .' + settings.choosenClass, widgetPreview).position().top - var position = $('.' + settings.categorylistClass + ' .' + settings.choosenClass, widgetPreview).position().top -
$('.' + settings.categorylistClass).position().top; $('.' + settings.categorylistClass, widgetPreview).position().top;
$('.' + settings.widgetlistClass, widgetPreview).css('top', position); $('.' + settings.widgetlistClass, widgetPreview).css('top', position);
$('.' + settings.widgetlistClass, widgetPreview).css('marginBottom', position); $('.' + settings.widgetlistClass, widgetPreview).css('marginBottom', position);
......
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