Modifications of the JS in Design
This commit is contained in:
parent
77b8fcdd1d
commit
07ccacb7d7
|
@ -11,7 +11,7 @@ function r_editor(tgetUrl,tpostUrl,tfilename,toption){
|
|||
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>";
|
||||
code = "<span id='file_editor' 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(){
|
||||
|
@ -28,12 +28,7 @@ function r_editor(tgetUrl,tpostUrl,tfilename,toption){
|
|||
});
|
||||
};
|
||||
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");
|
||||
|
||||
$.post(editor.postUrl,{filename:editor.filename,context:html.children("textarea").val(),authenticity_token:$('meta[name=csrf-token]').attr('content')},null,"script");
|
||||
};
|
||||
editor.destroy = function(){
|
||||
html.remove();
|
||||
|
|
|
@ -44,7 +44,7 @@ class Admin::DesignsController < ApplicationController
|
|||
def edit_file
|
||||
@design = Design.find(params[:id])
|
||||
filename = params[:filename]
|
||||
files = @design.stylesheets + @design.javascripts + @design.images
|
||||
files = @design.themes + @design.javascripts + @design.images
|
||||
file_to_removed = files.find{ |obj|
|
||||
obj.file_filename == filename
|
||||
}
|
||||
|
@ -56,11 +56,12 @@ class Admin::DesignsController < ApplicationController
|
|||
replace_target = eval("@design.#{type.downcase.pluralize}")
|
||||
new_file = replace_target.build(:file => temp_file,:to_save=>true)
|
||||
file_to_removed.destroy
|
||||
@design.save
|
||||
new_file.save
|
||||
temp_file.close
|
||||
}
|
||||
render :json => new_file.file.url
|
||||
|
||||
respond_to do |format|
|
||||
format.js {}
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
|
|
|
@ -13,6 +13,7 @@ class Design
|
|||
has_many :pages
|
||||
|
||||
embeds_one :layout
|
||||
embeds_many :stylesheets
|
||||
embeds_many :themes
|
||||
embeds_many :javascripts
|
||||
embeds_many :images
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
$('#file_editor').remove();
|
Loading…
Reference in New Issue