// This is a manifest file that'll be compiled into including all the files listed below. // Add new JavaScript/Coffee code in separate files in this directory and they'll automatically // be included in the compiled file accessible from http://example.com/assets/application.js // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the // the compiled file. // //= require jquery //= require jquery_ujs //= require rails.validations //= require rostra/jquery.jeditable //= require rostra/tiny_mce/jquery.tinymce $(document).ready(function() { var show_message_when_logged_out_user_attempts_to_vote = function() { $('a.vote').click(function() { var link = $(this); if (link.attr('href') == '#') { link.parent().next().fadeIn(); return false; } }); }(); var answer_comment_form = function() { $('a.leave_comment').click(function() { $(this).closest('.answer').find('form.comment').fadeIn(); return false; }); }(); var closeable_flash_messages = function() { $('.flash a.closeable').click(function() { var flash = $(this).parent(); flash.animate({'opacity': 0}, 250, function() { flash.slideUp(250, function() { flash.css('opacity', 1) }); }) return false; }); }(); $('textarea.wysiwyg').tinymce({ script_url:'/assets/rostra/tiny_mce/tiny_mce.js', theme: 'advanced', theme_advanced_buttons1 : "bold,italic,underline,|,link,|,bullist,numlist,", theme_advanced_buttons2 : "", theme_advanced_buttons3 : "", theme_advanced_toolbar_location : "top", theme_advanced_toolbar_align : "left", plugins: 'paste', paste_remove_styles: true, paste_remove_spans: true, setup: function (ed) { ed.onInit.add(function(ed){ ed.pasteAsPlainText = true; }); } }); var inline_comment_editing = function() { $('.edit_comment').click(function() { $(this).closest('.comment').find('.editable').trigger('edit'); return false; }); $('.editable').each(function() { var comment = $(this); var ajax_url = comment.closest('.comment').find('.edit_comment').attr('href'); comment.editable(ajax_url, { type: 'textarea', cancel: 'Cancel', submit: 'Update', method: 'PUT', event: 'edit', onblur: 'ignore', }); }); }(); });