From 3a6c782ba1904ef66e75944313b469d8d159a5f4 Mon Sep 17 00:00:00 2001 From: Pierre Date: Thu, 25 May 2017 13:55:49 +0200 Subject: [PATCH] Created a shortcut functions file --- assets/js/common/page.js | 3 +++ assets/js/common/shorcuts.js | 27 +++++++++++++++++++++++++++ assets/js/common/utils.js | 12 ------------ corePage/config/dev.config.php | 3 +++ 4 files changed, 33 insertions(+), 12 deletions(-) diff --git a/assets/js/common/page.js b/assets/js/common/page.js index 21f124ec..50287e0e 100644 --- a/assets/js/common/page.js +++ b/assets/js/common/page.js @@ -93,6 +93,7 @@ ComunicWeb.common.page = { * * @param {String} pageURI The URI to the page * @param {Object} additionnalData Additionnal data to pass to the new page + * @return {Boolean} True for a success */ openPage: function(pageURI, additionnalData){ //Log message @@ -186,6 +187,8 @@ ComunicWeb.common.page = { //Call the method related to the page eval(pageInfos.methodHandler + ("(additionnalData, pageTarget);")); + //Success + return true; }, /** diff --git a/assets/js/common/shorcuts.js b/assets/js/common/shorcuts.js index f64996d8..ec3c30a3 100644 --- a/assets/js/common/shorcuts.js +++ b/assets/js/common/shorcuts.js @@ -3,3 +3,30 @@ * * @author Pierre HUBERT */ + +/** + * Create a quick language access function shorcut + * + * @param {String} stringName The name of the string to show + * @param {Array} stringParams The optionnal parametres to include with the string + * @return {String} The string ready to show + */ +function lang(stringName, stringParams){ + //Check if any params has been specified + if(!stringParams) + var stringParams = []; + + //Call translate function + return ComunicWeb.common.langs.getTranslatedText(stringName, stringParams); +} + +/** + * Function to change currently opened page + * + * @param {String} pageURI The URI to the page + * @param {Object} additionnalData Additionnal data to pass to the new page + * @return {Boolean} True for a success + */ +function openPage(pageURI, additionnalData){ + return ComunicWeb.common.page.openPage(pageURI, additionnalData); +} \ No newline at end of file diff --git a/assets/js/common/utils.js b/assets/js/common/utils.js index 6d0fde93..03aa78ea 100644 --- a/assets/js/common/utils.js +++ b/assets/js/common/utils.js @@ -60,16 +60,4 @@ function emptyElem(container){ */ function checkMail(emailAddress){ return (emailAddress.match(/^[a-zA-Z0-9_.]+@[a-zA-Z0-9-]{1,}[.][a-zA-Z]{2,5}$/) === null ? false : true); -} - -/** - * Create a quick language access function shorcut - */ -function lang(stringName, stringParams){ - //Check if any params has been specified - if(!stringParams) - var stringParams = []; - - //Call translate function - return ComunicWeb.common.langs.getTranslatedText(stringName, stringParams); } \ No newline at end of file diff --git a/corePage/config/dev.config.php b/corePage/config/dev.config.php index 262a07d4..6b80cac8 100644 --- a/corePage/config/dev.config.php +++ b/corePage/config/dev.config.php @@ -74,6 +74,9 @@ $config['JSfiles'] = array( "%PATH_ASSETS%js/pages/login.js", "%PATH_ASSETS%js/pages/logout.js", + //Create shortcuts for common functions + "%PATH_ASSETS%js/common/shorcuts.js", + //Init script "%PATH_ASSETS%js/init.js", );