diff options
Diffstat (limited to 'plugins/Dashboard/templates/dashboardWidget.js')
-rwxr-xr-x | plugins/Dashboard/templates/dashboardWidget.js | 82 |
1 files changed, 41 insertions, 41 deletions
diff --git a/plugins/Dashboard/templates/dashboardWidget.js b/plugins/Dashboard/templates/dashboardWidget.js index 7ac8a8f6eb..617f03d4c6 100755 --- a/plugins/Dashboard/templates/dashboardWidget.js +++ b/plugins/Dashboard/templates/dashboardWidget.js @@ -4,7 +4,7 @@ * @link http://piwik.org * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later */ -(function( $ ){ +(function ($) { $.widget('piwik.dashboardWidget', { @@ -12,17 +12,17 @@ * Boolean indicating wether the widget is currently maximised * @type {Boolean} */ - isMaximised: false, + isMaximised: false, /** * Unique Id of the widget * @type {String} */ - uniqueId: null, + uniqueId: null, /** * Object holding the widget parameters * @type {Object} */ - widgetParameters: {}, + widgetParameters: {}, /** * Options available for initialization @@ -37,23 +37,23 @@ /** * creates a widget object */ - _create: function() { + _create: function () { - if(!this.options.uniqueId) { + if (!this.options.uniqueId) { piwikHelper.error('widgets can\'t be created without an uniqueId'); return; } else { this.uniqueId = this.options.uniqueId; } - if(this.options.widgetParameters) { + if (this.options.widgetParameters) { this.widgetParameters = this.options.widgetParameters; } this._createDashboardWidget(this.uniqueId); var self = this; - this.element.on('setParameters.dashboardWidget', function(e, params) { self.setParameters(params); }); + this.element.on('setParameters.dashboardWidget', function (e, params) { self.setParameters(params); }); this.reload(true, true); }, @@ -62,9 +62,9 @@ * Cleanup some events and dialog * Called automatically upon removing the widgets domNode */ - destroy: function() { - if(this.isMaximised) { - $('[widgetId='+this.uniqueId+']').dialog('destroy'); + destroy: function () { + if (this.isMaximised) { + $('[widgetId=' + this.uniqueId + ']').dialog('destroy'); } $('*', this.element).off('.dashboardWidget'); // unbind all events $('.widgetContent', this.element).trigger('widget:destroy'); @@ -75,7 +75,7 @@ * Returns the data currently set for the widget * @return {object} */ - getWidgetObject: function() { + getWidgetObject: function () { return { uniqueId: this.uniqueId, parameters: this.widgetParameters, @@ -86,13 +86,13 @@ /** * Show the current widget in an ui.dialog */ - maximise: function() { + maximise: function () { this.isMaximised = true; $('.button#close, .button#maximise', this.element).hide(); - 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); + 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); var width = Math.floor($('body').width() * 0.7); @@ -104,12 +104,12 @@ position: ['center', 'center'], resizable: true, autoOpen: true, - close: function(event, ui) { + close: function (event, ui) { self.isMaximised = false; $('.button#minimise, .button#refresh', $(this)).hide(); $('body').off('.dashboardWidget'); $(this).dialog("destroy"); - $('#'+self.uniqueId+'-placeholder').replaceWith(this); + $('#' + self.uniqueId + '-placeholder').replaceWith(this); $(this).removeAttr('style'); self.options.onChange(); $(this).find('div.piwik-graph').trigger('resizeGraph'); @@ -119,8 +119,8 @@ this.element.find('div.piwik-graph').trigger('resizeGraph'); var currentWidget = this.element; - $('body').on('click.dashboardWidget', function(ev) { - if(ev.target.className == "ui-widget-overlay") { + $('body').on('click.dashboardWidget', function (ev) { + if (ev.target.className == "ui-widget-overlay") { $(currentWidget).dialog("close"); } }); @@ -131,15 +131,15 @@ /** * Reloads the widgets content with the currently set parameters */ - reload: function(hideLoading, notJQueryUI) { + reload: function (hideLoading, notJQueryUI) { if (!notJQueryUI) { piwikHelper.log('widget.reload() was called by jquery.ui, ignoring', arguments.callee.caller); return; } var self = this, currentWidget = this.element; - function onWidgetLoadedReplaceElementWithContent(loadedContent) - { + + function onWidgetLoadedReplaceElementWithContent(loadedContent) { $('.widgetContent', currentWidget).html(loadedContent); $('.widgetContent', currentWidget).removeClass('loading'); $('.widgetContent', currentWidget).trigger('widget:create', [self]); @@ -147,7 +147,7 @@ // Reading segment from hash tag (standard case) or from the URL (when embedding dashboard) var segment = broadcast.getValueFromHash('segment') || broadcast.getValueFromUrl('segment'); - if(segment.length) { + if (segment.length) { this.widgetParameters.segment = segment; } @@ -165,7 +165,7 @@ * * @param {object} parameters */ - setParameters: function(parameters) { + setParameters: function (parameters) { if (!this.isMaximised && (parameters.viewDataTable == 'tableAllColumns' || parameters.viewDataTable == 'tableGoals')) { this.maximise(); @@ -185,7 +185,7 @@ * * @param {String} uniqueId */ - _createDashboardWidget: function(uniqueId) { + _createDashboardWidget: function (uniqueId) { var widgetName = widgetsHelper.getWidgetNameFromUniqueId(uniqueId); if (!widgetName) { @@ -195,42 +195,42 @@ var emptyWidgetContent = widgetsHelper.getEmptyWidgetHtml(uniqueId, widgetName); this.element.html(emptyWidgetContent); - var widgetElement = $('#'+ uniqueId, this.element); + var widgetElement = $('#' + uniqueId, this.element); var self = this; widgetElement - .on( 'mouseenter.dashboardWidget', function() { - if(!self.isMaximised) { + .on('mouseenter.dashboardWidget', function () { + if (!self.isMaximised) { $(this).addClass('widgetHover'); $('.widgetTop', this).addClass('widgetTopHover'); $('.button#close, .button#maximise', this).show(); - if(!$('.widgetContent', this).hasClass('hidden')) { + if (!$('.widgetContent', this).hasClass('hidden')) { $('.button#minimise, .button#refresh', this).show(); } } }) - .on( 'mouseleave.dashboardWidget', function() { - if(!self.isMaximised) { + .on('mouseleave.dashboardWidget', function () { + if (!self.isMaximised) { $(this).removeClass('widgetHover'); $('.widgetTop', this).removeClass('widgetTopHover'); $('.button#close, .button#maximise, .button#minimise, .button#refresh', this).hide(); } }); - if(this.options.isHidden) { + if (this.options.isHidden) { $('.widgetContent', widgetElement).toggleClass('hidden'); } $('.button#close', widgetElement) - .on( 'click.dashboardWidget', function(ev){ - piwikHelper.modalConfirm('#confirm',{yes: function(){ + .on('click.dashboardWidget', function (ev) { + piwikHelper.modalConfirm('#confirm', {yes: function () { self.element.remove(); self.options.onChange(); }}); }); $('.button#maximise', widgetElement) - .on( 'click.dashboardWidget', function(ev){ - if($('.widgetContent', $(this).parents('.widget')).hasClass('hidden')) { + .on('click.dashboardWidget', function (ev) { + if ($('.widgetContent', $(this).parents('.widget')).hasClass('hidden')) { self.isMaximised = false; self.options.isHidden = false; $('.widgetContent', $(this).parents('.widget')).removeClass('hidden'); @@ -244,8 +244,8 @@ }); $('.button#minimise', widgetElement) - .on( 'click.dashboardWidget', function(ev){ - if(!self.isMaximised) { + .on('click.dashboardWidget', function (ev) { + if (!self.isMaximised) { $('.widgetContent', $(this).parents('.widget')).addClass('hidden'); $('.button#minimise, .button#refresh', $(this).parents('.widget')).hide(); self.options.isHidden = true; @@ -256,7 +256,7 @@ }); $('.button#refresh', widgetElement) - .on('click.dashboardWidget', function(ev){ + .on('click.dashboardWidget', function (ev) { self.reload(false, true); }); @@ -265,4 +265,4 @@ }); -})( jQuery ); +})(jQuery); |