From 002417221f727d93b20eebc40bb85509d1584880 Mon Sep 17 00:00:00 2001 From: ewinslow Date: Mon, 14 Mar 2011 23:55:06 +0000 Subject: Refs #3016: Why didn't you make it in last commit? git-svn-id: http://code.elgg.org/elgg/trunk@8712 36083f99-b078-4883-b0ff-0f9b5a30f544 --- mod/thewire/js/thewire.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 mod/thewire/js/thewire.js (limited to 'mod') 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 -- cgit v1.2.3