-
Notifications
You must be signed in to change notification settings - Fork 2.9k
/
publisher.js
43 lines (35 loc) · 1.24 KB
/
publisher.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
36
37
38
39
40
41
42
43
$(document).ready(function(){
// no publisher available
if($("#new_status_message").length === 0) { return; }
$(".service_icon").bind("tap click", function() {
var service = $(this).toggleClass("dim"),
selectedServices = $("#new_status_message .service_icon:not(.dim)"),
provider = service.attr("id"),
hiddenField = $("#new_status_message input[name='services[]'][value='" + provider + "']"),
publisherMaxChars = 40000,
serviceMaxChars;
$("#new_status_message .counter").remove();
$.each(selectedServices, function() {
serviceMaxChars = parseInt($(this).attr("maxchar"));
if(publisherMaxChars > serviceMaxChars) {
publisherMaxChars = serviceMaxChars;
}
});
$("#status_message_text").charCount({allowed: publisherMaxChars, warning: publisherMaxChars/10 });
if(hiddenField.length > 0) { hiddenField.remove(); }
else {
$("#new_status_message").append(
$("<input/>", {
name: "services[]",
type: "hidden",
value: provider
})
);
}
});
$("#submit_new_message").bind("tap click", function(evt){
evt.preventDefault();
$("#new_status_message").submit();
});
autosize($("#status_message_text"));
});