From ac0930fa352de64d43ba2ddaad7b5976cbd113f4 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Fri, 31 May 2013 02:52:35 +0400 Subject: [PATCH] more refactoring and some fixes... Signed-off-by: Alex A. Naanou --- ui/base.js | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/ui/base.js b/ui/base.js index de7207ef..e59ae3b1 100755 --- a/ui/base.js +++ b/ui/base.js @@ -321,11 +321,15 @@ function updateInfo(elem, data, target){ return elem .appendTo(target) } + + function showInfo(elem, data, target){ elem = elem == null ? $('.overlay-info') : elem elem = data == null ? elem : updateInfo(elem, data, traget) return elem.fadeIn() } + + function hideInfo(elem){ elem = elem == null ? $('.overlay-info') : elem return elem.fadeOut() @@ -355,23 +359,23 @@ function updateStatus(message){ return elem } - if(arguments.length > 1){ - message = Array.apply(Array, arguments).join(' ') - } - if(typeof(message) == typeof('s') && /^error.*/i.test(message)){ console.error.apply(console, arguments) } else { console.log.apply(console, arguments) } + if(arguments.length > 1){ + message = Array.apply(Array, arguments).join(' ') + } + return updateInfo(elem, message) } // Same as updateInfo(...) but will aslo show and animate-close the message function showStatus(message){ - return updateStatus(message) + return updateStatus.apply(null, arguments) .stop() .show() .delay(500) @@ -384,12 +388,24 @@ function showStatus(message){ // // NOTE: this will show the message but will not hide it. function showErrorStatus(message){ - return updateStatus('Error:' + message) + message = Array.apply(Array, arguments) + message.splice(0, 0, 'Error:') + return updateStatus.apply(null, message) .stop() .show() } +// shorthand methods... +function hideStatus(){ + // yes, this indeed looks funny ;) + return showStatus() +} +function getStatus(){ + return updateStatus() +} + + /********************************************************************** * Constructors