diff --git a/app/assets/javascripts/design_temp.js b/app/assets/javascripts/design_temp.js index 7f9570cc..2f67aff8 100644 --- a/app/assets/javascripts/design_temp.js +++ b/app/assets/javascripts/design_temp.js @@ -1,7 +1,46 @@ +function r_editor(tgetUrl,tpostUrl,tfileid,toption){ + if(!toption){ toption =new Array();} + if(!toption['width']){toption['width']=400;} + if(!toption['height']){toption['height']=300;} + var editor = this; + editor.fileid = tfileid; + editor.getUrl = tgetUrl; + editor.postUrl = tpostUrl; + 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){ + alert("reload!"); + html.children("textarea").text(data); + }); + }; + editor.send = function(){ + $.post(editor.postUrl,{fileid:editor.fileid,context:html.text()}); + }; + editor.destroy = function(){ + html.remove(); + }; +} + $(".r_edit").live("click",function(){ - $(this).after($("").load($(this).attr("path"))); + new_editor = new r_editor($(this).attr("path"),"edit_file",$(this).attr("fileid")); + $(this).after(new_editor.init()); }); + $(".r_snapshot").live({ mouseenter: function(){ diff --git a/app/controllers/admin/designs_controller.rb b/app/controllers/admin/designs_controller.rb index 9891ff2a..5bf47a20 100644 --- a/app/controllers/admin/designs_controller.rb +++ b/app/controllers/admin/designs_controller.rb @@ -23,9 +23,9 @@ class Admin::DesignsController < ApplicationController end end - def file_edit + def edit_file @design = Design.find(params[:id]) - debugger +# debugger end def edit diff --git a/app/views/admin/designs/_design_file.html.erb b/app/views/admin/designs/_design_file.html.erb index 498fc4f0..75a3e538 100644 --- a/app/views/admin/designs/_design_file.html.erb +++ b/app/views/admin/designs/_design_file.html.erb @@ -10,7 +10,7 @@ <% li_class += 'r_destroy ' if item_destroy %> <% li_class += 'r_snapshot ' if item_snapshot %> <% li_class += 'r_edit ' if item_editable %> -
<%= render :partial => 'design_file' ,:locals => { :fieldname=>"stylesheet",:object=>@design ,:f=>f,:rtype=>'stylesheets',:item_destroy=>true,:item_editable=>true } %>
diff --git a/app/views/layouts/admin.html.erb b/app/views/layouts/admin.html.erb index b533f82b..3e448cf0 100644 --- a/app/views/layouts/admin.html.erb +++ b/app/views/layouts/admin.html.erb @@ -34,6 +34,7 @@