1
0
mirror of https://github.com/wbbaddons/Tims-Chat.git synced 2024-12-22 21:40:08 +00:00

Add function to show an inputError

This commit is contained in:
Tim Düsterhus 2013-07-09 21:42:01 +02:00
parent 9530dad294
commit 9c27cd5429

View File

@ -33,7 +33,9 @@ exposed by a function if necessary.
newMessageCount = 0 newMessageCount = 0
scrollUpNotifications = off scrollUpNotifications = off
chatSession = Date.now() chatSession = Date.now()
errorVisible = false errorVisible = false
inputErrorHidingTimer = null
lastMessage = null lastMessage = null
@ -141,16 +143,13 @@ and afterwards sent to the server by an AJAX request.
enableSmilies: $('#timsChatSmilies').data 'status' enableSmilies: $('#timsChatSmilies').data 'status'
showLoadingOverlay: false showLoadingOverlay: false
success: -> success: ->
$('#timsChatInputContainer').removeClass('formError').find('.innerError').hide() hideInputError()
getMessages() getMessages()
failure: (data) -> failure: (data) ->
return true unless (data?.returnValues?.errorType?) or (data?.message?) return true unless (data?.returnValues?.errorType?) or (data?.message?)
$('#timsChatInputContainer').addClass('formError').find('.innerError').show().html (data?.returnValues?.errorType) ? data.message showInputError (data?.returnValues?.errorType) ? data.message
setTimeout ->
$('#timsChatInputContainer').removeClass('formError').find('.innerError').hide()
, 5e3
false false
@ -347,6 +346,24 @@ Finished! Enable the input now and join the chat.
true true
Shows an error message below the input.
showInputError = (message) ->
$('#timsChatInputContainer').addClass('formError').find('.innerError').show().html message
clearTimeout inputErrorHidingTimer if inputErrorHidingTimer?
inputErrorHidingTimer = setTimeout ->
hideInputError()
, 5e3
Hides the error message below the input.
hideInputError = ->
clearTimeout inputErrorHidingTimer if inputErrorHidingTimer?
inputErrorHidingTimer = null
$('#timsChatInputContainer').removeClass('formError').find('.innerError').hide()
Free the fish. Free the fish.
freeTheFish = -> freeTheFish = ->