From 4660c26b7a18c83e24f4e37a2c54cfcd33173969 Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Tue, 7 Aug 2012 20:55:18 +0800 Subject: [PATCH] fix for ie8,9 for tinymce --- app/assets/javascripts/ajax_form.js | 40 +++++++++++++++++-- app/controllers/admin/assets_controller.rb | 3 +- app/views/admin/assets/create.html.erb | 22 +--------- .../back_end/bulletins_controller.rb | 6 +-- .../bulletins/_list_bulletin_file.html.erb | 4 +- .../bulletins/create_bulletin_file.html.erb | 1 + 6 files changed, 44 insertions(+), 32 deletions(-) create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/create_bulletin_file.html.erb diff --git a/app/assets/javascripts/ajax_form.js b/app/assets/javascripts/ajax_form.js index df675d4d..35834c96 100644 --- a/app/assets/javascripts/ajax_form.js +++ b/app/assets/javascripts/ajax_form.js @@ -23,10 +23,42 @@ $(document).on('click', '#ajax_form_submit', function(){ // dataType: 'script', dataType: 'html', url:$("#ajaxForm").attr("action"), - success: function(response,status,xhr){ - alert(response); - eval(response); - + success: function(response,status,xhr){ + if(typeof tinyMCEPopup != "undefined"){ + var x = response.split("#"); + var returnurl = x[0], + returntitle = x[1], + returndescription = x[2]; + 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(); + }else{ + //incase if we want to do something for quick edit file upload + // $("#modal-file").modal('hide'); + // var r = ""; + // if(rcom.getInternetExplorerVersion() > -1){ + // r = "" + response + ""; + // r = r.replace(" false + # render :json=>{"url"=>@asset.data.url,"title"=>"xxx","desc"=>"sss"}.to_json + render :layout=>false else flash[:error] = t(:create_fail) @asset_categories = AssetCategory.all diff --git a/app/views/admin/assets/create.html.erb b/app/views/admin/assets/create.html.erb index 44602e50..6d98706f 100644 --- a/app/views/admin/assets/create.html.erb +++ b/app/views/admin/assets/create.html.erb @@ -1,21 +1 @@ - -// 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();})() \ No newline at end of file +<%= @asset.data.url %>#<%= show_all_fields(@asset, 'title') %>#<%= show_all_fields(@asset, 'description') %> \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb index 466ba140..3979ca78 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb @@ -128,11 +128,11 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController @bulletin_file = BulletinFile.new(params[:bulletin_file]) - respond_to do |format| + # respond_to do |format| if @bulletin_file.save - format.js { render 'create_bulletin_file' } + render 'create_bulletin_file',:layout=>false end - end + # end else diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_list_bulletin_file.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_list_bulletin_file.html.erb index 6f946bfd..ce9ce90c 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_list_bulletin_file.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_list_bulletin_file.html.erb @@ -1,10 +1,9 @@ - <%= list_bulletin_file.file.file ? ( link_to list_bulletin_file.title_translations['zh_tw'], list_bulletin_file.file.url, {:target => '_blank', :title => list_bulletin_file.description_translations['zh_tw']} ) : list_bulletin_file.title_translations['zh_tw'] %> <%= list_bulletin_file.file.file ? ( link_to list_bulletin_file.title_translations['en'], list_bulletin_file.file.url, {:target => '_blank', :title => list_bulletin_file.description_translations['en']} ) : list_bulletin_file.title_translations['zh_tw'] %> - + <%= fields_for "bulletin[bulletin_files_attributes][]", list_bulletin_file, :index => list_bulletin_file_counter do |f| %> <%= f.hidden_field :id %> <%= hidden_field_tag :tr, (dom_id list_bulletin_file) %> @@ -14,7 +13,6 @@ - diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/create_bulletin_file.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/create_bulletin_file.html.erb new file mode 100644 index 00000000..db5faa85 --- /dev/null +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/create_bulletin_file.html.erb @@ -0,0 +1 @@ +<%= render :partial => 'list_bulletin_file', :collection => [@bulletin_file] %>