1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
<?php
/**
* Wire add form body
*
* @uses $vars['post']
*/
$post = elgg_extract('post', $vars);
$text = elgg_echo('post');
if ($post) {
$text = elgg_echo('thewire:reply');
}
if ($post) {
echo elgg_view('input/hidden', array(
'internalname' => 'parent_guid',
'value' => $post->guid,
));
}
?>
<textarea id="thewire-textarea" name="body" class="mtm"></textarea>
<div id="thewire-characters-remaining">
<span>140</span> <?php echo elgg_echo('thewire:charleft'); ?>
</div>
<?php
echo elgg_view('input/submit', array(
'value' => $text,
'internalid' => 'thewire-submit-button',
));
?>
<script type="text/javascript">
$(document).ready(function() {
$("#thewire-textarea").bind('keydown', function() {
textCounter(this, $("#thewire-characters-remaining span"), 140);
});
$("#thewire-textarea").bind('keyup', function() {
textCounter(this, $("#thewire-characters-remaining span"), 140);
});
});
function textCounter(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").css('background', '#999999');
$("#thewire-submit-button").css('border-color', '#999999');
$("#thewire-submit-button").css('cursor', 'default');
} else {
status.parent().css("color", "");
$("#thewire-submit-button").removeAttr('disabled', 'disabled');
$("#thewire-submit-button").css('background', '#4690d6');
$("#thewire-submit-button").css('border-color', '#4690d6');
$("#thewire-submit-button").css('cursor', 'pointer');
}
}
</script>
|