//= require jquery.livequery //= require chosen.jquery // //initial state $(function() { $('#wrapper_activities_header form').hide(); $('#new_<%= SocialStream.activity_forms.first %>').show(); $('#select_<%= SocialStream.activity_forms.first %>').addClass('selected'); $('#security').chosen(); $("#input_activities").Watermark("<%= I18n.t('activity.input') %>","#666"); $("#event_name").Watermark("<%= I18n.t('event.input') %>","#666"); }); $(document).ready(function() { activate_anti_rebounds(); }); activate_anti_rebounds = function(){ $('#wrapper_activities_header form').submit(function() { $(this).find('input[type=text]').each(function() { $(this).blur().attr('readonly', true); }); $("#masterSubmitButton").val("<%= I18n.t('activity.sending') %>...").attr("disabled", true); // Add _relation_ids[] parameter from authorization selector $('.liveAdded').remove(); var currentForm = $(this); $('#security option:selected').each(function() { currentForm.append( $('') .addClass('liveAdded') .attr('type', 'hidden') .attr('name', currentForm .attr('id').split('_')[1]+'[_relation_ids][]') .val($(this).attr('value'))); }); return true; }); $('.new_comment').submit(function() { $(this).find('input[type=text]').each(function() { $(this).blur().attr('readonly', true); }); $(this).find(".submitActivity").each(function() { $(this).val("<%= I18n.t('activity.sending') %>...").attr("disabled", true); }); return true; }); } unblock_all_forms = function() { //Sharing buttons $(".submitActivity").val("<%= I18n.t('share') %>").removeAttr("disabled"); //Header activities form $("#masterSubmitButton").val("<%= I18n.t('share') %>").removeAttr("disabled"); $('#wrapper_activities_header form').find('input[type=text]').each(function() { $(this).removeAttr("readonly").val("").blur(); }); //New comments $('.input_new_comments').each(function() { $(this).removeAttr("readonly").val(""); }); } $('#masterSubmitButton').live('click',function(){ $('#wrapper_activities_header form:visible').submit(); }); //clicks form selector $('.activity_form_selector').live('click',function(){ $('.activity_form_selector').removeClass('selected'); $(this).addClass('selected'); $('#wrapper_activities_header form').hide(); $('#new_'+this.id.split("_")[1]).show(); }); //javascript for main activities input $(function() { $("#input_activities").click(function(){ $("#masterSubmitButton").show(); }); }); //javascript for comments $(function() { //show only the text fields for new comment if there are any comment to the post $(".activity_new_comment").each(function(){ if ($.trim($(this).siblings(".activity_comments").text()) != ""){ $(this).show(); } }); $(".activities_comment_btn").hide(); //if there are 4 or more commments we only show the last 2 and a link to show the rest $(".activity_comments").each(function(){ var comments = $(this).children(".subactivity"); //check if there are more than 3 comments if (comments.size() > 3){ $(this).prepend("