From 2ea319387926ba213fa6641bc77e195818f04e4f Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Mon, 13 Aug 2012 11:03:11 +0800 Subject: [PATCH] Fix for banner link --- app/models/ad_image.rb | 4 ++-- lib/parsers/parser_common.rb | 3 ++- public/static/kernel.js | 13 ++++++++----- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/app/models/ad_image.rb b/app/models/ad_image.rb index 6508e2df..c01bc6b4 100644 --- a/app/models/ad_image.rb +++ b/app/models/ad_image.rb @@ -27,7 +27,7 @@ class AdImage attr_reader :parse_post_date,:parse_unpost_date before_validation :add_http - validates :out_link, :presence => true, :format => /^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?$/ix + validates :out_link, :format => /^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?$/ix, :allow_blank => true def parse_post_date=(att) self.post_date = (Date.parse att.gsub(/\s+/, "") rescue nil) @@ -59,7 +59,7 @@ class AdImage protected def add_http - unless self.out_link[/^http:\/\//] || self.out_link[/^https:\/\//] + unless self.out_link[/^http:\/\//] || self.out_link[/^https:\/\//] || self.out_link.blank? self.out_link = 'http://' + self.out_link end end diff --git a/lib/parsers/parser_common.rb b/lib/parsers/parser_common.rb index 56fe0c92..8bfedfe8 100644 --- a/lib/parsers/parser_common.rb +++ b/lib/parsers/parser_common.rb @@ -73,7 +73,8 @@ module ParserCommon res << "time_to_next='#{ad_banner.transition_msec}' " 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 || ad_banner.context || ' ')}' " + res << "link_url='#{(ad_image.out_link)}' " + res << "style='cursor:pointer'" if !ad_image.out_link.blank? res << "/>" end res << "" diff --git a/public/static/kernel.js b/public/static/kernel.js index 0034929d..38cffeef 100644 --- a/public/static/kernel.js +++ b/public/static/kernel.js @@ -26,14 +26,17 @@ function getTimeout() { $(document).ready(function() { $('.slideshow').children('img').click(function() { - if($(this).attr('link_open')=='new_window') + if($(this).attr('link_url')!='') { - window.open($(this).attr('link_url')); + if($(this).attr('link_open')=='new_window') + { + window.open($(this).attr('link_url')); } - else - { - document.location.href=$(this).attr('link_url') + else + { + document.location.href=$(this).attr('link_url') } + } }) }); // Ad Banner FX code [end]