Fix uploader, ie9 ok, not ie8
This commit is contained in:
parent
73b2cd1035
commit
8ea7bf75cd
|
@ -1,7 +1,43 @@
|
||||||
$(document).on('click', '#ajax_form_submit', function(){
|
$(document).on('click', '#ajax_form_submit', function(){
|
||||||
$('#ajaxForm').ajaxSubmit({
|
// $('#ajaxForm').ajaxSubmit({
|
||||||
beforeSubmit: function(a,f,o) {
|
// beforeSubmit: function(a,f,o) {
|
||||||
o.dataType = 'script';
|
// o.dataType = 'script';
|
||||||
}
|
// if (o.dataType == 'script') {
|
||||||
});
|
// o.url = o.url.split('?'); // split on GET params
|
||||||
|
// if (o.url[0].substr(-3) != '.js') o.url[0] += '.js'; // force rails to respond to respond to the request with :format = js
|
||||||
|
// o.url = o.url.join('?'); // join on GET params
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
// success: function(response,status,xhr){
|
||||||
|
// alert(response);
|
||||||
|
// alert(status);
|
||||||
|
// alert(xhr);
|
||||||
|
// },
|
||||||
|
// error:function(){
|
||||||
|
// alert("error");
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
|
||||||
|
|
||||||
|
var o = {
|
||||||
|
// dataType: 'script',
|
||||||
|
dataType: 'html',
|
||||||
|
url:$("#ajaxForm").attr("action"),
|
||||||
|
success: function(response,status,xhr){
|
||||||
|
alert(response);
|
||||||
|
eval(response);
|
||||||
|
|
||||||
|
},
|
||||||
|
error:function(){
|
||||||
|
alert("error");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (o.dataType == 'script') {
|
||||||
|
o.url = o.url.split('?'); // split on GET params
|
||||||
|
if (o.url[0].substr(-3) != '.js') o.url[0] += '.js'; // force rails to respond to respond to the request with :format = js
|
||||||
|
o.url = o.url.join('?'); // join on GET params
|
||||||
|
}
|
||||||
|
$('#ajaxForm').ajaxSubmit(o);
|
||||||
|
|
||||||
});
|
});
|
|
@ -47,7 +47,7 @@ function myFileBrowser(field_name, url, type, win) {
|
||||||
var cmsURL = window.location.toString();
|
var cmsURL = window.location.toString();
|
||||||
cmsURL = cmsURL.split("/");
|
cmsURL = cmsURL.split("/");
|
||||||
cmsURL = "<%= Rails.application.routes.url_helpers.file_upload_admin_assets_path %>";
|
cmsURL = "<%= Rails.application.routes.url_helpers.file_upload_admin_assets_path %>";
|
||||||
console.log(cmsURL);
|
// console.log(cmsURL);
|
||||||
// script URL - use an absolute path!
|
// script URL - use an absolute path!
|
||||||
if (cmsURL.indexOf("?") < 0) {
|
if (cmsURL.indexOf("?") < 0) {
|
||||||
//add the type as the only query parameter
|
//add the type as the only query parameter
|
||||||
|
|
|
@ -32,15 +32,16 @@ class Admin::AssetsController < OrbitBackendController
|
||||||
@asset = Asset.new(params[:asset])
|
@asset = Asset.new(params[:asset])
|
||||||
@asset.filename = @asset.title rescue nil
|
@asset.filename = @asset.title rescue nil
|
||||||
if @asset.filename && @asset.save
|
if @asset.filename && @asset.save
|
||||||
respond_to do |format|
|
# respond_to do |format|
|
||||||
format.js {
|
# format.js {
|
||||||
if params[:uploader]
|
# if params[:uploader]
|
||||||
render 'create'
|
# render 'create'
|
||||||
else
|
# else
|
||||||
render 'js/remove_pop_up_and_reload_content', :locals => {:function => 'replaceWith', :id => "asset_#{@asset.id}", :value => @asset, :values => nil, :partial => 'admin/assets/asset', :locals => nil}
|
# render 'js/remove_pop_up_and_reload_content', :locals => {:function => 'replaceWith', :id => "asset_#{@asset.id}", :value => @asset, :values => nil, :partial => 'admin/assets/asset', :locals => nil}
|
||||||
end
|
# end
|
||||||
}
|
# }
|
||||||
end
|
# end
|
||||||
|
render :layout => false
|
||||||
else
|
else
|
||||||
flash[:error] = t(:create_fail)
|
flash[:error] = t(:create_fail)
|
||||||
@asset_categories = AssetCategory.all
|
@asset_categories = AssetCategory.all
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
|
||||||
|
// Uncomment and change this document.domain value if you are loading the script cross subdomains
|
||||||
|
// document.domain = 'moxiecode.com';
|
||||||
|
(function(){
|
||||||
|
var returnurl = "<%= @asset.data.url %>";
|
||||||
|
var returntitle = "<%= show_all_fields(@asset, 'title') %>";
|
||||||
|
var returndescription = "<%= show_all_fields(@asset, 'description') %>";
|
||||||
|
var win = tinyMCEPopup.getWindowArg("window");
|
||||||
|
win.document.getElementById(tinyMCEPopup.getWindowArg("input")).value = returnurl;
|
||||||
|
win.document.getElementById(tinyMCEPopup.getWindowArg("alt")).value = returndescription;
|
||||||
|
win.document.getElementById(tinyMCEPopup.getWindowArg("title")).value = returntitle;
|
||||||
|
if (typeof(win.ImageDialog) != "undefined") {
|
||||||
|
// we are, so update image dimensions...
|
||||||
|
if (win.ImageDialog.getImageData)
|
||||||
|
win.ImageDialog.getImageData();
|
||||||
|
|
||||||
|
// ... and preview if necessary
|
||||||
|
if (win.ImageDialog.showPreviewImage)
|
||||||
|
win.ImageDialog.showPreviewImage(returnurl);
|
||||||
|
}
|
||||||
|
tinyMCEPopup.close();})()
|
File diff suppressed because one or more lines are too long
|
@ -1,8 +1,10 @@
|
||||||
<%= javascript_include_tag "new_admin" %>
|
<%= javascript_include_tag "new_admin" %>
|
||||||
<%= stylesheet_link_tag "new_admin" %>
|
<%= stylesheet_link_tag "new_admin" %>
|
||||||
|
<%= javascript_include_tag "tinymce/tiny_mce_popup" %>
|
||||||
|
|
||||||
|
|
||||||
<%= flash_messages %>
|
<%= flash_messages %>
|
||||||
|
<body onload="tinyMCEPopup.executeOnLoad('init();')">
|
||||||
<%= form_for :asset, :url => admin_assets_path(:uploader => true), :html => {:id => 'ajaxForm', :multipart => true } do |f| %>
|
<%= form_for :asset, :url => admin_assets_path(:uploader => true), :html => {:id => 'ajaxForm', :multipart => true } do |f| %>
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<h3><%= t 'admin.file_upload' %></h3>
|
<h3><%= t 'admin.file_upload' %></h3>
|
||||||
|
@ -55,4 +57,5 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
</body>
|
Loading…
Reference in New Issue