function r_editor(tgetUrl,tpostUrl,tfilename,toption){ if(!toption){ toption =new Array();} if(!toption['width']){toption['width']=400;} if(!toption['height']){toption['height']=300;} var editor = this; editor.filename = tfilename; editor.getUrl = tgetUrl; editor.postUrl = tpostUrl; editor.nodeToBeChanged="" editor.width = toption['width']; editor.height = toption['height']; var html=''; editor.init = function(){ code = ""; html = $(code); html.children("textarea").load(editor.getUrl); html.children("input.discard").click(function(){ editor.reload(); }); html.children("input.send").click(function(){ editor.send(); }); return html; }; editor.reload = function(){ $.get(editor.getUrl,function(data){ html.children("textarea").text(data); }); }; editor.send = function(){ callback_for_send = function(data){ editor.postUrl = data; alert($(this).attr("path")); }; $.post(editor.postUrl,{filename:editor.filename,context:html.children("textarea").val(),authenticity_token:$('meta[name=csrf-token]').attr('content')},callback_for_send,"json"); }; editor.destroy = function(){ html.remove(); }; } $(".r_edit").live("click",function(){ new_editor = new r_editor($(this).attr("path"),"edit_file",$(this).attr("filename")); $(this).after(new_editor.init()); }); $(".r_snapshot").live({ mouseenter: function(){ $(this).append($("").html('