From b6c06c6d4f58213410953e1f1ed0a8116727e1d7 Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Wed, 19 Sep 2012 17:59:17 +0800 Subject: [PATCH] tiny mce fix --- app/assets/javascripts/ajax_form.js.erb | 182 +++++++++--------- app/views/admin/assets/create.html.erb | 26 ++- .../assets/{create.js.erb => create1.js.erb} | 0 app/views/admin/assets/file_upload.html.erb | 3 +- config/mongoid.yml | 2 +- 5 files changed, 124 insertions(+), 89 deletions(-) rename app/views/admin/assets/{create.js.erb => create1.js.erb} (100%) diff --git a/app/assets/javascripts/ajax_form.js.erb b/app/assets/javascripts/ajax_form.js.erb index 917c352d..d56024b3 100644 --- a/app/assets/javascripts/ajax_form.js.erb +++ b/app/assets/javascripts/ajax_form.js.erb @@ -1,5 +1,5 @@ <%#= encoding: utf-8 %> -$(document).on('click', '#ajax_form_submit', function(){ +// $(document).on('click', '#ajax_form_submit', function(){ // $('#ajaxForm').ajaxSubmit({ // beforeSubmit: function(a,f,o) { // o.dataType = 'script'; @@ -20,92 +20,102 @@ $(document).on('click', '#ajax_form_submit', function(){ // }); - var o = { - // dataType: 'script', - dataType: 'html', - url:$("#ajaxForm").attr("action"), - beforeSubmit: function(){ - var sub = true; - $("span.error").remove(); - $("#dyn_error").empty(); - $("#ajaxForm input").each(function(){ - if($(this).val() == ""){ - $(" *").insertAfter($(this)); - sub = false; - } - }) - if(!sub){ - $("#dyn_error").text("Cannot be empty."); - $("#dyn_error").text("<%= I18n.t('cant_empty_star') %>"); - return false; - } - }, - 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(); +// var o = { +// // dataType: 'script', +// dataType: 'html', +// url:$("#ajaxForm").attr("action"), +// beforeSubmit: function(){ +// var sub = true; +// $("span.error").remove(); +// $("#dyn_error").empty(); +// $("#ajaxForm input").each(function(){ +// if($(this).val() == ""){ +// $(" *").insertAfter($(this)); +// sub = false; +// } +// }) +// if(!sub){ +// $("#dyn_error").text("Cannot be empty."); +// $("#dyn_error").text("<%= I18n.t('cant_empty_star') %>"); +// return false; +// } +// }, +// 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 - // var modalvalues = ""; - // var r = ""; - // if(rcom.getInternetExplorerVersion() > -1){ - // r = "" + response + ""; - // r = r.replace("**",""); - // r = r.replace("**",""); - // r = $(r); - // modalvalues = r.find("span").attr("data-content").split("#"); - // r.attr("id",r.find("span").attr("for")); - // var table=document.getElementById(modalvalues[0]); - // //var tbody = table.getElementsByTagName("tbody"); - // var row = table.insertRow(table.rows.length-1); - // var c1 = row.insertCell(0), - // c2 = row.insertCell(1), - // c3 = row.insertCell(2); - // c1.innerHTML = r.find("td").eq(0).html(); - // c2.innerHTML = r.find("td").eq(1).html(); - // c3.innerHTML = r.find("td").eq(2).html(); - // var trow = $("#bulletin_files tfoot").find("tr").eq(0); - // $("#bulletin_files tbody").append(trow); - // }else{ +// // ... 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 +// // var modalvalues = ""; +// // var r = ""; +// // if(rcom.getInternetExplorerVersion() > -1){ +// // r = "" + response + ""; +// // r = r.replace("**",""); +// // r = r.replace("**",""); +// // r = $(r); +// // modalvalues = r.find("span").attr("data-content").split("#"); +// // r.attr("id",r.find("span").attr("for")); +// // var table=document.getElementById(modalvalues[0]); +// // //var tbody = table.getElementsByTagName("tbody"); +// // var row = table.insertRow(table.rows.length-1); +// // var c1 = row.insertCell(0), +// // c2 = row.insertCell(1), +// // c3 = row.insertCell(2); +// // c1.innerHTML = r.find("td").eq(0).html(); +// // c2.innerHTML = r.find("td").eq(1).html(); +// // c3.innerHTML = r.find("td").eq(2).html(); +// // var trow = $("#bulletin_files tfoot").find("tr").eq(0); +// // $("#bulletin_files tbody").append(trow); +// // }else{ - // response = response.replace("**",""); - // response = response.replace("**",""); - // r = $(response); - // modalvalues = r.find("span").attr("data-content").split("#"); - // $('#' + modalvalues[0]+ ' tbody').append(r); - // } - // console.log(modalvalues[1]); - // $("#"+modalvalues[1]).modal('hide'); - //$('#bulletin_files tbody').append(r); - //$(response).fadeIn(); - } - }, - error:function(){ - alert("error"); - } - } +// // response = response.replace("**",""); +// // response = response.replace("**",""); +// // r = $(response); +// // modalvalues = r.find("span").attr("data-content").split("#"); +// // $('#' + modalvalues[0]+ ' tbody').append(r); +// // } +// // console.log(modalvalues[1]); +// // $("#"+modalvalues[1]).modal('hide'); +// //$('#bulletin_files tbody').append(r); +// //$(response).fadeIn(); +// } +// }, +// 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); +// 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); -}); \ No newline at end of file +// }); + +$('#ajaxForm').ajaxForm({ + beforeSubmit: function(a,f,o) { + o.dataType = 'script'; + + }, + success: function(data) { + + } + }); \ No newline at end of file diff --git a/app/views/admin/assets/create.html.erb b/app/views/admin/assets/create.html.erb index 6d98706f..81b112dc 100644 --- a/app/views/admin/assets/create.html.erb +++ b/app/views/admin/assets/create.html.erb @@ -1 +1,25 @@ -<%= @asset.data.url %>#<%= show_all_fields(@asset, 'title') %>#<%= show_all_fields(@asset, 'description') %> \ No newline at end of file +<% if !request.xhr? %> + +<% end %> \ No newline at end of file diff --git a/app/views/admin/assets/create.js.erb b/app/views/admin/assets/create1.js.erb similarity index 100% rename from app/views/admin/assets/create.js.erb rename to app/views/admin/assets/create1.js.erb diff --git a/app/views/admin/assets/file_upload.html.erb b/app/views/admin/assets/file_upload.html.erb index 5e19a1ad..9552f039 100644 --- a/app/views/admin/assets/file_upload.html.erb +++ b/app/views/admin/assets/file_upload.html.erb @@ -54,7 +54,8 @@
diff --git a/config/mongoid.yml b/config/mongoid.yml index 219e1372..0d68cb7a 100644 --- a/config/mongoid.yml +++ b/config/mongoid.yml @@ -8,7 +8,7 @@ defaults: &defaults development: <<: *defaults - database: i18n_var + database: prototype_r4_ldap0229 test: <<: *defaults