41 lines
1.2 KiB
JavaScript
41 lines
1.2 KiB
JavaScript
$(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;
|
|
}
|
|
});
|
|
|
|
$("#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();
|
|
});
|
|
});
|