forked from cleaver/drupal-twitter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
twitter.js
35 lines (32 loc) · 1.06 KB
/
twitter.js
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
/**
* Attach handlers to count the number of words in a given textfield, in its
* description.
*/
$(document).ready(function() {
$("#twitter-textfield").keyup(function() {
var charsLeft = (140 - $(this).val().length);
var descDiv = $(this).parent().parent().parent().children(".description");
$(descDiv).html("<strong>" + charsLeft + "</strong> characters remaining");
if (charsLeft < 0) {
$(descDiv).addClass("negative");
$("#twitter-post-button").attr('disabled', 'true');
} else {
$(descDiv).removeClass("negative");
$("#twitter-post-button").removeAttr('disabled');
}
});
if (!$("#twitter-toggle").attr("checked")) {
$("#twitter-textfield-wrapper").hide();
$("#twitter-account-wrapper").hide();
}
$("#twitter-toggle").bind("click", function() {
if ($("#twitter-toggle").attr("checked")) {
$("#twitter-textfield-wrapper").show();
$("#twitter-account-wrapper").show();
}
else {
$("#twitter-textfield-wrapper").hide();
$("#twitter-account-wrapper").hide();
}
});
});