Made r_editor into class style add functions
This commit is contained in:
parent
dabd6dd5b5
commit
9eb80d7424
|
@ -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 = "<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(){
|
||||
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($("<span style='border:solid; width:400px;height:300px; float:right;'></span>").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(){
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 %>
|
||||
<li class="<%= li_class %>" <%= "path='#{t.file.url}'" if (item_snapshot || item_editable) %> >
|
||||
<li class="<%= li_class %>" <%= "path='#{t.file.url}' fileid='#{t._id}'" if (item_snapshot || item_editable) %> >
|
||||
<%= t.file_filename %>
|
||||
<% if item_destroy %>
|
||||
<%=fields_for "design["+fieldname_p+"][]",t,:index=>nil do |f| %>
|
||||
|
|
|
@ -23,8 +23,6 @@
|
|||
<%= File.basename (Design.all.last.layout.url) %>
|
||||
<% end %>
|
||||
</p>
|
||||
|
||||
|
||||
<p>
|
||||
<%= render :partial => 'design_file' ,:locals => { :fieldname=>"stylesheet",:object=>@design ,:f=>f,:rtype=>'stylesheets',:item_destroy=>true,:item_editable=>true } %>
|
||||
</p>
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
<li><%= link_to t('homepage'), root_path %></li>
|
||||
<li><%= link_to t('admin.item'), admin_items_path %></li>
|
||||
<li><%= link_to t('admin.layout'), admin_layouts_path %></li>
|
||||
<li><%= link_to t('admin.design'), admin_designs_path %></li>
|
||||
<li><%= link_to t('admin.asset'), admin_assets_path %></li>
|
||||
<li><%= link_to t('admin.user_info'), admin_user_info_models_path %></li>
|
||||
<li><%= link_to t('admin.user_role'), admin_user_role_models_path %></li>
|
||||
|
|
|
@ -46,6 +46,7 @@ PrototypeR4::Application.routes.draw do
|
|||
resources :layouts
|
||||
resources :designs do
|
||||
member do
|
||||
post 'edit_file' => 'designs#edit_file'
|
||||
get 'delete'
|
||||
end
|
||||
end
|
||||
|
|
Reference in New Issue