2011-07-28 10:08:16 +00:00
|
|
|
function r_editor(tgetUrl,tpostUrl,tfilename,toption){
|
2011-07-27 09:23:01 +00:00
|
|
|
if(!toption){ toption =new Array();}
|
|
|
|
if(!toption['width']){toption['width']=400;}
|
|
|
|
if(!toption['height']){toption['height']=300;}
|
|
|
|
var editor = this;
|
2011-07-28 10:08:16 +00:00
|
|
|
editor.filename = tfilename;
|
2011-07-27 09:23:01 +00:00
|
|
|
editor.getUrl = tgetUrl;
|
|
|
|
editor.postUrl = tpostUrl;
|
2011-07-28 10:54:31 +00:00
|
|
|
editor.nodeToBeChanged=""
|
2011-07-27 09:23:01 +00:00
|
|
|
editor.width = toption['width'];
|
|
|
|
editor.height = toption['height'];
|
|
|
|
var html='';
|
|
|
|
editor.init = function(){
|
|
|
|
code = "<span style='border:solid; width:"+editor.width+"px;height:"+editor.height+"px; float:right;' ><textarea style='height:87%;width:97%;resize:none;border:none;' ></textarea><input type='button' class='send' value='Send' ><input type='button' class='discard' value='Discard' ></span>";
|
|
|
|
html = $(code);
|
|
|
|
html.children("textarea").load(editor.getUrl);
|
|
|
|
html.children("input.discard").click(function(){
|
2011-07-29 09:49:10 +00:00
|
|
|
editor.destroy();
|
2011-07-27 09:23:01 +00:00
|
|
|
});
|
|
|
|
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(){
|
2011-07-28 10:54:31 +00:00
|
|
|
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");
|
|
|
|
|
2011-07-27 09:23:01 +00:00
|
|
|
};
|
|
|
|
editor.destroy = function(){
|
|
|
|
html.remove();
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2011-07-26 10:22:17 +00:00
|
|
|
$(".r_edit").live("click",function(){
|
2011-07-28 10:08:16 +00:00
|
|
|
new_editor = new r_editor($(this).attr("path"),"edit_file",$(this).attr("filename"));
|
2011-07-27 09:23:01 +00:00
|
|
|
$(this).after(new_editor.init());
|
2011-07-26 10:22:17 +00:00
|
|
|
});
|
|
|
|
|
2011-07-27 09:23:01 +00:00
|
|
|
|
2011-07-22 08:28:41 +00:00
|
|
|
$(".r_snapshot").live({
|
|
|
|
mouseenter:
|
2011-07-19 10:31:53 +00:00
|
|
|
function(){
|
|
|
|
$(this).append($("<span></span>").html('<p class="z-preview"><img src="'+$(this).attr("path")+'"width="220" height="19" /></p>'));
|
2011-07-22 08:28:41 +00:00
|
|
|
},
|
|
|
|
mouseleave:
|
2011-07-19 10:31:53 +00:00
|
|
|
function(){
|
|
|
|
$(this).find("span:last").remove();
|
|
|
|
}
|
2011-07-22 08:28:41 +00:00
|
|
|
}
|
|
|
|
);
|
2011-07-19 10:31:53 +00:00
|
|
|
|
2011-07-21 03:22:31 +00:00
|
|
|
$('input.multi_files').live("change", function(){
|
2011-09-08 10:12:04 +00:00
|
|
|
$(this).parent().prev("ul").append("<li>" + $(this).val() + "</li>");
|
|
|
|
new_node = $(this).parent().clone();
|
|
|
|
$(this).parent().css("display","none");
|
2011-07-26 10:22:17 +00:00
|
|
|
new_node.children('input.multi_files').val("");
|
|
|
|
$(this).parent().before(new_node);
|
2011-07-19 10:31:53 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
$('a.remove_mark').live("click",function(){
|
2011-07-20 09:05:28 +00:00
|
|
|
$(this).prev("input").val("true");
|
2011-07-19 10:31:53 +00:00
|
|
|
$(this).parent().css("text-decoration","line-through")
|
2011-09-08 10:12:04 +00:00
|
|
|
$(this).parent().removeClass("r_snapshot");
|
|
|
|
$(this).next().remove();
|
2011-07-19 10:31:53 +00:00
|
|
|
$(this).remove();
|
|
|
|
return false;
|
|
|
|
});
|