From 18e18a4add1d83f64e03a422ba779a836bbf5232 Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Mon, 13 Aug 2012 15:10:53 +0800 Subject: [PATCH 1/7] Fix for banner on ie --- .../javascripts/lib/jquery.preload-min.js | 9 ++++++ app/helpers/application_helper.rb | 1 + lib/parsers/parser_common.rb | 28 +++++++++++-------- 3 files changed, 27 insertions(+), 11 deletions(-) create mode 100755 app/assets/javascripts/lib/jquery.preload-min.js diff --git a/app/assets/javascripts/lib/jquery.preload-min.js b/app/assets/javascripts/lib/jquery.preload-min.js new file mode 100755 index 00000000..cf3a0f1f --- /dev/null +++ b/app/assets/javascripts/lib/jquery.preload-min.js @@ -0,0 +1,9 @@ +/** + * jQuery.Preload - Multifunctional preloader + * Copyright (c) 2008 Ariel Flesler - aflesler(at)gmail(dot)com + * Dual licensed under MIT and GPL. + * Date: 3/25/2009 + * @author Ariel Flesler + * @version 1.0.8 + */ +;(function($){var h=$.preload=function(c,d){if(c.split)c=$(c);d=$.extend({},h.defaults,d);var f=$.map(c,function(a){if(!a)return;if(a.split)return d.base+a+d.ext;var b=a.src||a.href;if(typeof d.placeholder=='string'&&a.src)a.src=d.placeholder;if(b&&d.find)b=b.replace(d.find,d.replace);return b||null}),data={loaded:0,failed:0,next:0,done:0,total:f.length};if(!data.total)return finish();var g=$(Array(d.threshold+1).join('')).load(handler).error(handler).bind('abort',handler).each(fetch);function handler(e){data.element=this;data.found=e.type=='load';data.image=this.src;data.index=this.index;var a=data.original=c[this.index];data[data.found?'loaded':'failed']++;data.done++;if(d.enforceCache)h.cache.push($('').attr('src',data.image)[0]);if(d.placeholder&&a.src)a.src=data.found?data.image:d.notFound||a.src;if(d.onComplete)d.onComplete(data);if(data.done\n" javascripts << "\n" end + javascripts << "\n" javascripts << "\n" javascripts << "\n" # javascripts << "\n" diff --git a/lib/parsers/parser_common.rb b/lib/parsers/parser_common.rb index 8bfedfe8..56dcd480 100644 --- a/lib/parsers/parser_common.rb +++ b/lib/parsers/parser_common.rb @@ -44,17 +44,23 @@ module ParserCommon ad_banner = AdBanner.find(banner["id"]) rescue nil if ad_banner res << "" res << "" res << "
" @@ -74,7 +80,7 @@ module ParserCommon res << "link_open='#{ad_image.link_open}' " # res << "link_url='#{(ad_image.direct_to_after_click?? ad_image.out_link : ad_banner.context) || ' '}' " res << "link_url='#{(ad_image.out_link)}' " - res << "style='cursor:pointer'" if !ad_image.out_link.blank? + res << "style='cursor:pointer; visibility='hidden'" if !ad_image.out_link.blank? res << "/>" end res << "
" From 895918dfff4cfb87e40e53ba702d002270b627f0 Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Mon, 13 Aug 2012 18:31:50 +0800 Subject: [PATCH 2/7] form validation --- app/assets/javascripts/ajax_form.js | 59 ++++++++++++++++++++++------- 1 file changed, 45 insertions(+), 14 deletions(-) diff --git a/app/assets/javascripts/ajax_form.js b/app/assets/javascripts/ajax_form.js index 35834c96..f627ac85 100644 --- a/app/assets/javascripts/ajax_form.js +++ b/app/assets/javascripts/ajax_form.js @@ -23,17 +23,29 @@ $(document).on('click', '#ajax_form_submit', function(){ // dataType: 'script', dataType: 'html', url:$("#ajaxForm").attr("action"), + beforeSubmit: function(){ + var sub = true; + $("span.error").remove(); + $("#ajaxForm input").each(function(){ + if($(this).val() == ""){ + $("Cannot be empty.").insertAfter($(this)); + sub = false; + } + }) + if(!sub) + return false; + }, success: function(response,status,xhr){ if(typeof tinyMCEPopup != "undefined"){ - var x = response.split("#"); + 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") { + 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(); @@ -41,22 +53,41 @@ $(document).on('click', '#ajax_form_submit', function(){ // ... and preview if necessary if (win.ImageDialog.showPreviewImage) win.ImageDialog.showPreviewImage(returnurl); - } - tinyMCEPopup.close(); + } + tinyMCEPopup.close(); }else{ //incase if we want to do something for quick edit file upload - // $("#modal-file").modal('hide'); + // 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")); - // alert(r.html()) + // 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); // } - // $('#bulletin_files tbody').append(r); + // console.log(modalvalues[1]); + // $("#"+modalvalues[1]).modal('hide'); + //$('#bulletin_files tbody').append(r); //$(response).fadeIn(); } }, From 134f49359dcf36b0e313e80a4fc487ccdebdc167 Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Mon, 13 Aug 2012 18:45:02 +0800 Subject: [PATCH 3/7] form validation again --- app/assets/javascripts/ajax_form.js | 7 +++++-- app/assets/stylesheets/message.css | 4 ++++ app/views/admin/assets/file_upload.html.erb | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/ajax_form.js b/app/assets/javascripts/ajax_form.js index f627ac85..065e09fd 100644 --- a/app/assets/javascripts/ajax_form.js +++ b/app/assets/javascripts/ajax_form.js @@ -26,14 +26,17 @@ $(document).on('click', '#ajax_form_submit', function(){ beforeSubmit: function(){ var sub = true; $("span.error").remove(); + $("#dyn_error").empty(); $("#ajaxForm input").each(function(){ if($(this).val() == ""){ - $("Cannot be empty.").insertAfter($(this)); + $(" *").insertAfter($(this)); sub = false; } }) - if(!sub) + if(!sub){ + $("#dyn_error").text("Cannot be empty."); return false; + } }, success: function(response,status,xhr){ if(typeof tinyMCEPopup != "undefined"){ diff --git a/app/assets/stylesheets/message.css b/app/assets/stylesheets/message.css index 7206bd72..ffa954f1 100644 --- a/app/assets/stylesheets/message.css +++ b/app/assets/stylesheets/message.css @@ -11,3 +11,7 @@ .warning{ color:orange; } +label#dyn_error { + + margin-left: 50%; +} \ No newline at end of file diff --git a/app/views/admin/assets/file_upload.html.erb b/app/views/admin/assets/file_upload.html.erb index 06141117..c954624b 100644 --- a/app/views/admin/assets/file_upload.html.erb +++ b/app/views/admin/assets/file_upload.html.erb @@ -9,6 +9,7 @@ +