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
|
$(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"), 10);
if(publisherMaxChars > serviceMaxChars) {
publisherMaxChars = serviceMaxChars;
}
});
if (selectedServices.length > 0) {
var counter = $("<span class='counter'></span>");
$("#status_message_text").after(counter);
$("#status_message_text").charCount({
allowed: publisherMaxChars,
warning: publisherMaxChars / 10,
counter: counter
});
}
if(hiddenField.length > 0) { hiddenField.remove(); }
else {
$("#new_status_message").append(
$("<input></input>", {
name: "services[]",
type: "hidden",
value: provider
})
);
}
});
$("#submit_new_message").bind("tap click", function(evt){
evt.preventDefault();
$("#new_status_message").submit();
});
new Diaspora.MarkdownEditor("#status_message_text");
});
|