diff options
-rw-r--r-- | mod/thewire/js/thewire.js | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/mod/thewire/js/thewire.js b/mod/thewire/js/thewire.js new file mode 100644 index 000000000..61f29db81 --- /dev/null +++ b/mod/thewire/js/thewire.js @@ -0,0 +1,28 @@ +elgg.provide('elgg.thewire'); + +elgg.thewire.init = function() { + $("#thewire-textarea").live('keydown', function() { + elgg.thewire.textCounter(this, $("#thewire-characters-remaining span"), 140); + }); + $("#thewire-textarea").live('keyup', function() { + elgg.thewire.textCounter(this, $("#thewire-characters-remaining span"), 140); + }); +} + +elgg.thewire.textCounter = function(textarea, status, limit) { + + var remaining_chars = limit - textarea.value.length; + status.html(remaining_chars); + + if (remaining_chars < 0) { + status.parent().css("color", "#D40D12"); + $("#thewire-submit-button").attr('disabled', 'disabled'); + $("#thewire-submit-button").addClass('elgg-state-disabled'); + } else { + status.parent().css("color", ""); + $("#thewire-submit-button").removeAttr('disabled', 'disabled'); + $("#thewire-submit-button").removeClass('elgg-state-disabled'); + } +} + +elgg.register_hook_handler('init', 'system', elgg.thewire.init);
\ No newline at end of file |