diff options
author | sgiehl <stefan@piwik.org> | 2015-12-25 21:47:55 +0300 |
---|---|---|
committer | sgiehl <stefan@piwik.org> | 2015-12-25 21:47:55 +0300 |
commit | b22dee447834c12f1095ba8ecf356970b2312dbf (patch) | |
tree | 46a966716922f3d44734929486c43a26d37230f7 /plugins/CoreHome/javascripts/corehome.js | |
parent | 72fa5107adcdbe1f4b8850f89c95dd3d5f5e6f4a (diff) | |
parent | 611316e743d17d819b511d008da0e80e6425b686 (diff) |
Merge branch 'master' into 3.0
Conflicts:
core/Version.php
plugins/CoreConsole/Commands/ManagePlugin.php
plugins/CoreHome/angularjs/siteselector/siteselector.directive.js
plugins/CoreHome/javascripts/corehome.js
plugins/Ecommerce/Menu.php
plugins/Events/Events.php
plugins/Goals/Goals.php
plugins/Live/templates/index.twig
plugins/UserCountryMap/UserCountryMap.php
plugins/UsersManager/stylesheets/usersManager.less
plugins/VisitsSummary/Controller.php
plugins/VisitsSummary/Reports/Get.php
tests/UI/expected-ui-screenshots
Diffstat (limited to 'plugins/CoreHome/javascripts/corehome.js')
-rwxr-xr-x | plugins/CoreHome/javascripts/corehome.js | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/plugins/CoreHome/javascripts/corehome.js b/plugins/CoreHome/javascripts/corehome.js index 7b14515538..4526c9ec71 100755 --- a/plugins/CoreHome/javascripts/corehome.js +++ b/plugins/CoreHome/javascripts/corehome.js @@ -126,6 +126,65 @@ handleSectionToggle(this, 'inline', !$(this).is(':checked')); }); + // + // reports by dimension list behavior + // + + // when a report dimension is clicked, load the appropriate report + var currentWidgetLoading = null; + $('body').on('click', '.reportDimension', function (e) { + var view = $(this).closest('.reportsByDimensionView'), + report = $('.dimensionReport', view), + loading = $('.loadingPiwik', view); + + // make this dimension the active one + $('.activeDimension', view).removeClass('activeDimension'); + $(this).addClass('activeDimension'); + + // hide the visible report & show the loading elem + report.hide(); + loading.show(); + + // load the report using the data-url attribute (which holds the URL to the report) + var widgetParams = broadcast.getValuesFromUrl($(this).attr('data-url')); + for (var key in widgetParams) { + widgetParams[key] = decodeURIComponent(widgetParams[key]); + } + + var widgetUniqueId = widgetParams.module + widgetParams.action; + currentWidgetLoading = widgetUniqueId; + + var ajaxRequest = new ajaxHelper(); + ajaxRequest.addParams(widgetParams, 'get'); + ajaxRequest.setCallback(function (response) { + // if the widget that was loaded was not for the latest clicked link, do nothing w/ the response + if (widgetUniqueId != currentWidgetLoading) { + return; + } + + loading.hide(); + report.css('display', 'inline-block').html($(response)); + + // scroll to report + piwikHelper.lazyScrollTo(report, 400); + }); + ajaxRequest.setErrorCallback(function (deferred, status) { + if (status == 'abort' || !deferred || deferred.status < 400 || deferred.status >= 600) { + return; + } + + loading.hide(); + + var errorMessage = _pk_translate('General_ErrorRequest', ['', '']); + if ($('#loadingError').html()) { + errorMessage = $('#loadingError').html(); + } + + report.css('display', 'inline-block').html('<div class="dimensionLoadingError">' + errorMessage + '</div>'); + }); + ajaxRequest.setFormat('html'); + ajaxRequest.send(false); + }); }); }(jQuery)); |