Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

images get inserted without having to close the facebox and open it a…

…gain
  • Loading branch information...
commit 822b99fdb7f8a5e17bf0f22e6b6f72749596c351 1 parent 02189c4
@jeffkreeftmeijer jeffkreeftmeijer authored
View
12 app/controllers/wysihat_files_controller.rb
@@ -3,19 +3,19 @@ def index
@wysihat_file, @wysihat_files = WysihatFile.new, WysihatFile.all
render :layout => false
end
-
+
def create
- @wysihat_file = WysihatFile.new(params[:wysihat_file])
-
+ @wysihat_file = WysihatFile.new(:file => params[:wysihat_file][:file])
+
responds_to_parent do
render :update do |page|
if(@wysihat_file.save)
- page.insert_html :bottom, :wysihat_files, :partial => 'wysihat_file', :object => @wysihat_file
+ page.insert_html :bottom, :wysihat_files, :partial => 'wysihat_file', :object => @wysihat_file
end
- end
+ end
end
end
-
+
def destroy
@wysihat_file = WysihatFile.find(params[:id])
respond_to do |wants|
View
9 app/helpers/wysihat_files_helper.rb
@@ -1,13 +1,18 @@
module WysihatFilesHelper
- def include_link(file)
+ def include_link(file)
function = file.file_content_type.starts_with?('image') ?
".insertImage(this.href);" :
".insertHTML('<a href=\"' + this.href + '\">#{file.file_file_name}</a>');"
link_to_function(
file.file_file_name,
- "$$('iframe##{params[:editor]}')[0]#{function}facebox.close();",
+ "$$('iframe##{editor_id}')[0]#{function}facebox.close();",
:href => file.file.url
)
end
+
+ def editor_id
+ return params[:wysihat_file][:editor] if params[:wysihat_file] && params[:wysihat_file][:editor]
+ params[:editor]
+ end
end
View
6 app/views/wysihat_files/_form.html.erb
@@ -1,5 +1,7 @@
<% form_for @wysihat_file, :html => { :multipart => true, :target => 'file_upload' } do |f| %>
-
+
+ <%= f.hidden_field(:editor, :value => params[:editor]) %>
+
<p>
<%= f.label :file %><br/>
<%= f.file_field :file %>
@@ -7,7 +9,7 @@
<p>
<%= f.submit %>
</p>
-
+
<% end %>
<iframe id='file_upload' name="file_upload" style="width:1px;height:1px;border:0px" src="about:blank"></iframe>
Please sign in to comment.
Something went wrong with that request. Please try again.