From 3d9293cbbe521a942eeacb7655071e3b16b01e84 Mon Sep 17 00:00:00 2001 From: sgiehl <stefan@piwik.org> Date: Sun, 7 Jul 2013 14:00:21 +0200 Subject: [PATCH] fixed some jsdoc; removed some deprecated js functions that were already unused --- plugins/CoreHome/javascripts/broadcast.js | 10 +-- plugins/CoreHome/javascripts/popover.js | 30 ++++++--- .../Dashboard/javascripts/dashboardObject.js | 2 +- plugins/Dashboard/javascripts/widgetMenu.js | 31 --------- plugins/Zeitgeist/javascripts/ajaxHelper.js | 6 +- plugins/Zeitgeist/javascripts/piwikHelper.js | 66 +------------------ 6 files changed, 33 insertions(+), 112 deletions(-) diff --git a/plugins/CoreHome/javascripts/broadcast.js b/plugins/CoreHome/javascripts/broadcast.js index 868623b8c5..c0689c408c 100644 --- a/plugins/CoreHome/javascripts/broadcast.js +++ b/plugins/CoreHome/javascripts/broadcast.js @@ -167,7 +167,7 @@ var broadcast = { * NOTE: this method will only make ajax call and replacing main content. * * @param {string} ajaxUrl querystring with parameters to be updated - * @param {boolean} disableHistory the hash change won't be available in the browser history + * @param {boolean} [disableHistory] the hash change won't be available in the browser history * @return {void} */ propagateAjax: function (ajaxUrl, disableHistory) { @@ -224,7 +224,7 @@ var broadcast = { * NOTE: This method will refresh the page with new values. * * @param {string} str url with parameters to be updated - * @param {boolean} showAjaxLoading whether to show the ajax loading gif or not. + * @param {boolean} [showAjaxLoading] whether to show the ajax loading gif or not. * @return {void} */ propagateNewPage: function (str, showAjaxLoading) { @@ -422,7 +422,7 @@ var broadcast = { * Return hash string if hash exists on address bar. * else return false; * - * @return {string|false} + * @return {string|boolean} current hash or false if it is empty */ isHashExists: function () { var hashStr = broadcast.getHashFromUrl(); @@ -438,7 +438,7 @@ var broadcast = { * Get Hash from given url or from current location. * return empty string if no hash present. * - * @param {string} url + * @param {string} [url] url to get hash from (defaults to current location) * @return {string} the hash part of the given url */ getHashFromUrl: function (url) { @@ -513,7 +513,7 @@ var broadcast = { * Empty String if param is not found. * * @param {string} param parameter to search for - * @param {string} url url to check + * @param {string} [url] url to check, defaults to current location * @return {string} value of the given param within the given url */ getValueFromUrl: function (param, url) { diff --git a/plugins/CoreHome/javascripts/popover.js b/plugins/CoreHome/javascripts/popover.js index 91f9c09ec1..4287782142 100644 --- a/plugins/CoreHome/javascripts/popover.js +++ b/plugins/CoreHome/javascripts/popover.js @@ -66,9 +66,9 @@ var Piwik_Popover = (function () { /** * Open the popover with a loading message * - * @param popoverName string name of the popover - * @param popoverSubject string subject of the popover (e.g. url, optional) - * @param height int height of the popover in px (optional) + * @param {string} popoverName name of the popover + * @param {string} [popoverSubject] subject of the popover (e.g. url, optional) + * @param {int} [height] height of the popover in px (optional) */ showLoading: function (popoverName, popoverSubject, height) { var loading = $(document.createElement('div')).addClass('Piwik_Popover_Loading'); @@ -113,7 +113,11 @@ var Piwik_Popover = (function () { return container; }, - /** Add a help button to the current popover */ + /** + * Add a help button to the current popover + * + * @param {string} helpUrl + */ addHelpButton: function (helpUrl) { if (!isOpen) { return; @@ -144,7 +148,13 @@ var Piwik_Popover = (function () { centerPopover(); }, - /** Show an error message. All params are HTML! */ + /** + * Show an error message. All params are HTML! + * + * @param {string} title + * @param {string} [message] + * @param {string} [backLabel] + */ showError: function (title, message, backLabel) { var error = $(document.createElement('div')).addClass('Piwik_Popover_Error'); @@ -172,7 +182,11 @@ var Piwik_Popover = (function () { this.setContent(error); }, - /** Add a callback for the next time the popover is closed or the content changes */ + /** + * Add a callback for the next time the popover is closed or the content changes + * + * @param {function} callback + */ onClose: function (callback) { closeCallback = callback; }, @@ -186,8 +200,8 @@ var Piwik_Popover = (function () { /** * Create a Popover and load the specified URL in it - * @param url - * @param loadingName + * @param {string} url + * @param {string} loadingName */ createPopupAndLoadUrl: function (url, loadingName) { // open the popover diff --git a/plugins/Dashboard/javascripts/dashboardObject.js b/plugins/Dashboard/javascripts/dashboardObject.js index b8f3dbb19d..67614dd231 100644 --- a/plugins/Dashboard/javascripts/dashboardObject.js +++ b/plugins/Dashboard/javascripts/dashboardObject.js @@ -475,7 +475,7 @@ /** * Save the current layout in database if it has changed - * @param {string} action + * @param {string} [action] action to perform (defaults to saveLayout) */ function saveLayout(action) { diff --git a/plugins/Dashboard/javascripts/widgetMenu.js b/plugins/Dashboard/javascripts/widgetMenu.js index 3be0597947..d4af3c0b29 100644 --- a/plugins/Dashboard/javascripts/widgetMenu.js +++ b/plugins/Dashboard/javascripts/widgetMenu.js @@ -64,37 +64,6 @@ widgetsHelper.getWidgetNameFromUniqueId = function (uniqueId) { return widget["name"]; }; -/** - * Returns an parameter object to be used for an jquery ajax request to fetch the widget html - * - * @param {string} widgetUniqueId unique id of the widget - * @param {object} widgetParameters parameters to be used for loading the widget - * @param {function} onWidgetLoadedCallback callback to be executed after widget is loaded - * @return {object} - * @deprecated since 1.9.3 - will be removed in next major release. use widgetsHelper.loadWidgetAjax - */ -widgetsHelper.getLoadWidgetAjaxRequest = function (widgetUniqueId, widgetParameters, onWidgetLoadedCallback) { - var token_auth = broadcast.getValueFromUrl('token_auth'); - if (token_auth.length && token_auth != 'anonymous') { - widgetParameters['token_auth'] = token_auth; - } - var disableLink = broadcast.getValueFromUrl('disableLink'); - if (disableLink.length) { - widgetParameters['disableLink'] = disableLink; - } - - return { - widgetUniqueId: widgetUniqueId, - type: 'GET', - url: 'index.php', - dataType: 'html', - async: true, - error: piwikHelper.ajaxHandleError, - success: onWidgetLoadedCallback, - data: piwikHelper.getQueryStringFromParameters(widgetParameters) + "&widget=1&idSite=" + piwik.idSite + "&period=" + piwik.period + "&date=" + broadcast.getValueFromUrl('date') + "&token_auth=" + piwik.token_auth - }; -}; - /** * Sends and ajax request to query for the widgets html * diff --git a/plugins/Zeitgeist/javascripts/ajaxHelper.js b/plugins/Zeitgeist/javascripts/ajaxHelper.js index 7f6349429a..02711b6945 100644 --- a/plugins/Zeitgeist/javascripts/ajaxHelper.js +++ b/plugins/Zeitgeist/javascripts/ajaxHelper.js @@ -167,7 +167,7 @@ function ajaxHelper() { * Set callback to redirect on success handler * &update=1(+x) will be appended to the current url * - * @param {object} params to modify in redirect url + * @param {object} [params] to modify in redirect url * @return {void} */ this.redirectOnSuccess = function (params) { @@ -235,7 +235,7 @@ function ajaxHelper() { /** * Set the div element to show while request is loading * - * @param {String} element selector for the loading element + * @param {String} [element] selector for the loading element */ this.setLoadingElement = function (element) { if (!element) { @@ -258,7 +258,7 @@ function ajaxHelper() { /** * Send the request - * @param {Boolean} sync indicates if the request should be synchronous (defaults to false) + * @param {Boolean} [sync] indicates if the request should be synchronous (defaults to false) * @return {void} */ this.send = function (sync) { diff --git a/plugins/Zeitgeist/javascripts/piwikHelper.js b/plugins/Zeitgeist/javascripts/piwikHelper.js index dc4f68bc9f..26eed9d8f3 100644 --- a/plugins/Zeitgeist/javascripts/piwikHelper.js +++ b/plugins/Zeitgeist/javascripts/piwikHelper.js @@ -229,7 +229,7 @@ var piwikHelper = { /** * Shows the loading message with the given Id - * @param {string} loadingDivID id of the domNode (defaults to ajaxLoading) + * @param {string} [loadingDivID] id of the domNode (defaults to ajaxLoading) * @return {void} */ showAjaxLoading: function(loadingDivID) @@ -240,7 +240,7 @@ var piwikHelper = { /** * Hides the loading message with the given id - * @param {string} loadingDivID id of the domNode (defaults to ajaxLoading) + * @param {string} [loadingDivID] id of the domNode (defaults to ajaxLoading) * @return {void} */ hideAjaxLoading: function(loadingDivID) @@ -249,28 +249,6 @@ var piwikHelper = { $('#'+loadingDivID).hide(); }, - /** - * Returns default configuration for ajax requests - * @param {string} loadingDivID id of domNode used for loading message - * @param {string} errorDivID id of domNode used for error messages - * @param {object} params params used for handling response - * @return {object} - * @deprecated sine 1.9.3 - will be removed in 2.0 - * @see use ajaxHelper for ajax requests - */ - getStandardAjaxConf: function(loadingDivID, errorDivID, params) - { - piwikHelper.showAjaxLoading(loadingDivID); - piwikHelper.hideAjaxError(errorDivID); - var ajaxRequest = {}; - ajaxRequest.type = 'GET'; - ajaxRequest.url = 'index.php'; - ajaxRequest.dataType = 'json'; - ajaxRequest.error = piwikHelper.ajaxHandleError; - ajaxRequest.success = function(response) { piwikHelper.ajaxHandleResponse(response, loadingDivID, errorDivID, params); }; - return ajaxRequest; - }, - /** * Reloads the page after the given period * @param {int} timeoutPeriod @@ -314,46 +292,6 @@ var piwikHelper = { }, 2000); }, - /** - * Method to handle ajax response - * @param {object} response - * @param {string} loadingDivID - * @param {string} errorDivID - * @param {object} params - * @return {void} - * @deprecated since 1.9.3 - will be removed in 2.0 - * @see use ajaxHelper for ajax requests - */ - ajaxHandleResponse: function(response, loadingDivID, errorDivID, params) - { - if(response.result == "error") - { - piwikHelper.hideAjaxLoading(loadingDivID); - piwikHelper.showAjaxError(response.message, errorDivID); - } - else - { - // add updated=1 to the URL so that a "Your changes have been saved" message is displayed - var urlToRedirect = piwikHelper.getCurrentQueryStringWithParametersModified(params); - var updatedUrl = new RegExp('&updated=([0-9]+)'); - var updatedCounter = updatedUrl.exec(urlToRedirect); - if(!updatedCounter) - { - urlToRedirect += '&updated=1'; - } - else - { - updatedCounter = 1 + parseInt(updatedCounter[1]); - urlToRedirect = urlToRedirect.replace(new RegExp('(&updated=[0-9]+)'), '&updated=' + updatedCounter); - } - var currentHashStr = window.location.hash; - if(currentHashStr.length > 0) { - urlToRedirect += currentHashStr; - } - piwikHelper.redirectToUrl(urlToRedirect); - } - }, - /** * Scrolls the window to the jquery element 'elem' * if the top of the element is not currently visible on screen -- GitLab