more refactoring and some fixes...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2013-05-31 02:52:35 +04:00
parent 5737fbdd3d
commit ac0930fa35

View File

@ -321,11 +321,15 @@ function updateInfo(elem, data, target){
return elem return elem
.appendTo(target) .appendTo(target)
} }
function showInfo(elem, data, target){ function showInfo(elem, data, target){
elem = elem == null ? $('.overlay-info') : elem elem = elem == null ? $('.overlay-info') : elem
elem = data == null ? elem : updateInfo(elem, data, traget) elem = data == null ? elem : updateInfo(elem, data, traget)
return elem.fadeIn() return elem.fadeIn()
} }
function hideInfo(elem){ function hideInfo(elem){
elem = elem == null ? $('.overlay-info') : elem elem = elem == null ? $('.overlay-info') : elem
return elem.fadeOut() return elem.fadeOut()
@ -355,23 +359,23 @@ function updateStatus(message){
return elem return elem
} }
if(arguments.length > 1){
message = Array.apply(Array, arguments).join(' ')
}
if(typeof(message) == typeof('s') && /^error.*/i.test(message)){ if(typeof(message) == typeof('s') && /^error.*/i.test(message)){
console.error.apply(console, arguments) console.error.apply(console, arguments)
} else { } else {
console.log.apply(console, arguments) console.log.apply(console, arguments)
} }
if(arguments.length > 1){
message = Array.apply(Array, arguments).join(' ')
}
return updateInfo(elem, message) return updateInfo(elem, message)
} }
// Same as updateInfo(...) but will aslo show and animate-close the message // Same as updateInfo(...) but will aslo show and animate-close the message
function showStatus(message){ function showStatus(message){
return updateStatus(message) return updateStatus.apply(null, arguments)
.stop() .stop()
.show() .show()
.delay(500) .delay(500)
@ -384,12 +388,24 @@ function showStatus(message){
// //
// NOTE: this will show the message but will not hide it. // NOTE: this will show the message but will not hide it.
function showErrorStatus(message){ function showErrorStatus(message){
return updateStatus('Error:' + message) message = Array.apply(Array, arguments)
message.splice(0, 0, 'Error:')
return updateStatus.apply(null, message)
.stop() .stop()
.show() .show()
} }
// shorthand methods...
function hideStatus(){
// yes, this indeed looks funny ;)
return showStatus()
}
function getStatus(){
return updateStatus()
}
/********************************************************************** /**********************************************************************
* Constructors * Constructors