From a3f152b20098f2319ad88bf4c3a3f36f4d48160d Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Mon, 20 Feb 2012 03:24:05 +0800 Subject: [PATCH] Changes for jquery 1.7 (.live -> .on), create module_layout --- app/assets/javascripts/orbit-1.0.js | 4 +- .../obit_frontend_component_controller.rb | 2 +- app/views/layouts/module_widget.html.erb | 14 ++++ .../assets/javascripts/announcement/.gitkeep | 0 .../assets/javascripts/announcement_link.js | 79 +++++++++++++++++++ .../app/assets/javascripts/module_widget.js | 9 +++ 6 files changed, 105 insertions(+), 3 deletions(-) create mode 100644 app/views/layouts/module_widget.html.erb delete mode 100644 vendor/built_in_modules/announcement/app/assets/javascripts/announcement/.gitkeep create mode 100644 vendor/built_in_modules/announcement/app/assets/javascripts/announcement_link.js create mode 100644 vendor/built_in_modules/announcement/app/assets/javascripts/module_widget.js diff --git a/app/assets/javascripts/orbit-1.0.js b/app/assets/javascripts/orbit-1.0.js index e7077dcc..56c7ae1c 100644 --- a/app/assets/javascripts/orbit-1.0.js +++ b/app/assets/javascripts/orbit-1.0.js @@ -9,7 +9,7 @@ function resize() { } } $(document).ready(function(){ - $('.orbit-bar-member').live('click', function(){ + $(document).on('click', '.orbit-bar-member', function(){ $(this).hasClass('open') ? $(this).removeClass('open') : $(this).addClass('open'); $('.bar-login .dropdown-menu').toggle(); return false; @@ -20,7 +20,7 @@ $(document).ready(function(){ $('.bar-login .dropdown-menu').hide(); }); - $('.dropdown-menu').live('click', function(e) { + $(document).on('click', '.dropdown-menu', function(e) { e.stopPropagation(); $('.bar-login .dropdown-menu').show(); }); diff --git a/app/controllers/obit_frontend_component_controller.rb b/app/controllers/obit_frontend_component_controller.rb index 06bb06a5..d0be3a25 100644 --- a/app/controllers/obit_frontend_component_controller.rb +++ b/app/controllers/obit_frontend_component_controller.rb @@ -1,7 +1,7 @@ class ObitFrontendComponentController< ApplicationController before_filter :setup_vars before_filter {|c| c.front_end_available(@app_title)} - layout 'production' + layout 'module_widget' def setup_vars @app_title = request.fullpath.split('/')[2] diff --git a/app/views/layouts/module_widget.html.erb b/app/views/layouts/module_widget.html.erb new file mode 100644 index 00000000..e010355e --- /dev/null +++ b/app/views/layouts/module_widget.html.erb @@ -0,0 +1,14 @@ + + + + + <%= stylesheet_link_tag "widget" %> + <%= javascript_include_tag "widget" %> + <%= csrf_meta_tag %> + + + <%= yield %> + + diff --git a/vendor/built_in_modules/announcement/app/assets/javascripts/announcement/.gitkeep b/vendor/built_in_modules/announcement/app/assets/javascripts/announcement/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/vendor/built_in_modules/announcement/app/assets/javascripts/announcement_link.js b/vendor/built_in_modules/announcement/app/assets/javascripts/announcement_link.js new file mode 100644 index 00000000..9e2bf762 --- /dev/null +++ b/vendor/built_in_modules/announcement/app/assets/javascripts/announcement_link.js @@ -0,0 +1,79 @@ +$(document).ready(function(){ + $(".tag1").addClass("active"); + + $(document).on("click", ".tag1", function () { + for (i=1; i<=4; i++){ + $("#news_"+i).css("display","none"); + $("#links_"+i).css("display","none"); + $(".tag"+i).removeClass("active"); + } + $("#news_1").fadeIn(); + $("#links_1").fadeIn(); + $(this).addClass("active"); + return false; + }); + $(document).on("click", ".tag2", function () { + for (i=1; i<=4; i++){ + $("#news_"+i).css("display","none"); + $("#links_"+i).css("display","none"); + $(".tag"+i).removeClass("active"); + } + $("#news_2").fadeIn(); + $("#links_2").fadeIn(); + $(this).addClass("active"); + return false; + }); + $(document).on("click", ".tag3", function () { + for (i=1; i<=4; i++){ + $("#news_"+i).css("display","none"); + $("#links_"+i).css("display","none"); + $(".tag"+i).removeClass("active"); + } + $("#news_3").fadeIn(); + $("#links_3").fadeIn(); + $(this).addClass("active"); + return false; + }); + $(document).on("click", ".tag4", function () { + for (i=1; i<=4; i++){ + $("#news_"+i).css("display","none"); + $("#links_"+i).css("display","none"); + $(".tag"+i).removeClass("active"); + } + $("#news_4").fadeIn(); + $("#links_4").fadeIn(); + $(this).addClass("active"); + return false; + }); + + var topic1="0px"; + var topic2="-948px"; + var topic3="-1896px"; + var topic_page=1; + $(document).on("click", ".topic_prev", function() { + if (topic_page !=1){ + topic_page-=1; + }else{ + } + if (topic_page == 1) + $("#topic_list").stop().animate({"left": topic1}, "slow"); + if (topic_page == 2) + $("#topic_list").stop().animate({"left": topic2}, "slow"); + if (topic_page == 3) + $("#topic_list").stop().animate({"left": topic3}, "slow"); + + }); + $(document).on("click", ".topic_next", function() { + if (topic_page >=1 && topic_page <=2){ + topic_page+=1; + }else{ + } + if (topic_page == 1) + $("#topic_list").stop().animate({"left": topic1}, "slow"); + if (topic_page == 2) + $("#topic_list").stop().animate({"left": topic2}, "slow"); + if (topic_page == 3) + $("#topic_list").stop().animate({"left": topic3}, "slow"); + + }); +}); diff --git a/vendor/built_in_modules/announcement/app/assets/javascripts/module_widget.js b/vendor/built_in_modules/announcement/app/assets/javascripts/module_widget.js new file mode 100644 index 00000000..9c429aac --- /dev/null +++ b/vendor/built_in_modules/announcement/app/assets/javascripts/module_widget.js @@ -0,0 +1,9 @@ +// This is a manifest file that'll be compiled into including all the files listed below. +// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically +// be included in the compiled file accessible from http://example.com/assets/application.js +// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the +// the compiled file. +// +//= require jquery +//= require jquery_ujs +//= require announcement_link \ No newline at end of file