diff options
author | Thomas Steur <tsteur@users.noreply.github.com> | 2016-09-29 04:52:01 +0300 |
---|---|---|
committer | Matthieu Aubry <mattab@users.noreply.github.com> | 2016-09-29 04:52:01 +0300 |
commit | 4354f12ab879dc025c8a529e064b53e8bcd60a1d (patch) | |
tree | b0c4121eda233d3bfeeae29a482dc8f5a3d6304b /plugins | |
parent | 5b507041236eba51396d62bb9d4e155294e17768 (diff) |
When opening the visitor profile, do not apply the segment (#10533)
* When opening the visitor profile, do not apply the segment
* added ui test for profile but does work for me
* next try to make ui test work
* add expected screenshot
* added missing doc
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/CoreHome/javascripts/popover.js | 10 | ||||
-rw-r--r-- | plugins/Live/javascripts/visitorProfile.js | 5 | ||||
-rw-r--r-- | plugins/Morpheus/javascripts/ajaxHelper.js | 42 |
3 files changed, 51 insertions, 6 deletions
diff --git a/plugins/CoreHome/javascripts/popover.js b/plugins/CoreHome/javascripts/popover.js index bdde52e0d8..e1a303931e 100644 --- a/plugins/CoreHome/javascripts/popover.js +++ b/plugins/CoreHome/javascripts/popover.js @@ -227,8 +227,9 @@ var Piwik_Popover = (function () { * @param {string} url * @param {string} loadingName * @param {string} [dialogClass] css class to add to dialog + * @param {object} [ajaxRequest] optional instance of ajaxHelper */ - createPopupAndLoadUrl: function (url, loadingName, dialogClass) { + createPopupAndLoadUrl: function (url, loadingName, dialogClass, ajaxRequest) { // make sure the minimum top position of the popover is 15px var ensureMinimumTop = function () { var popoverContainer = $('#Piwik_Popover').parent(); @@ -254,11 +255,14 @@ var Piwik_Popover = (function () { setPopoverTitleIfOneFoundInContainer(); ensureMinimumTop(); }; - var ajaxRequest = new ajaxHelper(); + + if ('undefined' === typeof ajaxRequest) { + ajaxRequest = new ajaxHelper(); + } ajaxRequest.addParams(piwikHelper.getArrayFromQueryString(url), 'get'); ajaxRequest.setCallback(callback); ajaxRequest.setFormat('html'); ajaxRequest.send(false); } }; -})();
\ No newline at end of file +})(); diff --git a/plugins/Live/javascripts/visitorProfile.js b/plugins/Live/javascripts/visitorProfile.js index c5bea438af..38cf21765d 100644 --- a/plugins/Live/javascripts/visitorProfile.js +++ b/plugins/Live/javascripts/visitorProfile.js @@ -51,7 +51,10 @@ url += '&showMap=0'; } - Piwik_Popover.createPopupAndLoadUrl(url, _pk_translate('Live_VisitorProfile'), 'visitor-profile-popup'); + var ajaxRequest = new ajaxHelper(); + ajaxRequest.removeDefaultParameter('segment'); + + Piwik_Popover.createPopupAndLoadUrl(url, _pk_translate('Live_VisitorProfile'), 'visitor-profile-popup', ajaxRequest); }; $.extend(VisitorProfileControl.prototype, UIControl.prototype, { diff --git a/plugins/Morpheus/javascripts/ajaxHelper.js b/plugins/Morpheus/javascripts/ajaxHelper.js index 8050539192..71001c722e 100644 --- a/plugins/Morpheus/javascripts/ajaxHelper.js +++ b/plugins/Morpheus/javascripts/ajaxHelper.js @@ -149,6 +149,8 @@ function ajaxHelper() { */ this.requestHandle = null; + this.defaultParams = ['idSite', 'period', 'date', 'segment']; + /** * Adds params to the request. * If params are given more then once, the latest given value is used for the request @@ -312,6 +314,42 @@ function ajaxHelper() { }; /** + * Detect whether are allowed to use the given default parameter or not + * @param string parameter + * @returns {boolean} + * @private + */ + this._useGETDefaultParameter = function (parameter) { + if (parameter && this.defaultParams) { + var i; + for (i = 0; i < this.defaultParams.length; i++) { + if (this.defaultParams[i] === parameter) { + return true; + } + } + } + + return false; + } + + /** + * Removes a default parameter that is usually send automatically along the request. + * + * @param {String} parameter A name such as "period", "date", "segment". + */ + this.removeDefaultParameter = function (parameter) { + if (parameter && this.defaultParams) { + + var i; + for (i = 0; i < this.defaultParams.length; i++) { + if (this.defaultParams[i] === parameter) { + this.defaultParams.splice(i, 1); + } + } + } + } + + /** * Send the request * @param {Boolean} [sync] indicates if the request should be synchronous (defaults to false) * @return {void} @@ -482,13 +520,13 @@ function ajaxHelper() { } for (var key in defaultParams) { - if (!params[key] && !this.postParams[key] && defaultParams[key]) { + if (this._useGETDefaultParameter(key) && !params[key] && !this.postParams[key] && defaultParams[key]) { params[key] = defaultParams[key]; } } // handle default date & period if not already set - if (!params.date && !this.postParams.date) { + if (this._useGETDefaultParameter('date') && !params.date && !this.postParams.date) { params.date = piwik.currentDateString || broadcast.getValueFromUrl('date'); if (params.period == 'range' && piwik.currentDateString) { params.date = piwik.startDateString + ',' + params.date; |