Changes for jquery 1.7 (.live -> .on), create module_layout

This commit is contained in:
Christophe Vilayphiou 2012-02-20 03:24:05 +08:00
parent 3ff2e7867e
commit a3f152b200
6 changed files with 105 additions and 3 deletions

View File

@ -9,7 +9,7 @@ function resize() {
} }
} }
$(document).ready(function(){ $(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'); $(this).hasClass('open') ? $(this).removeClass('open') : $(this).addClass('open');
$('.bar-login .dropdown-menu').toggle(); $('.bar-login .dropdown-menu').toggle();
return false; return false;
@ -20,7 +20,7 @@ $(document).ready(function(){
$('.bar-login .dropdown-menu').hide(); $('.bar-login .dropdown-menu').hide();
}); });
$('.dropdown-menu').live('click', function(e) { $(document).on('click', '.dropdown-menu', function(e) {
e.stopPropagation(); e.stopPropagation();
$('.bar-login .dropdown-menu').show(); $('.bar-login .dropdown-menu').show();
}); });

View File

@ -1,7 +1,7 @@
class ObitFrontendComponentController< ApplicationController class ObitFrontendComponentController< ApplicationController
before_filter :setup_vars before_filter :setup_vars
before_filter {|c| c.front_end_available(@app_title)} before_filter {|c| c.front_end_available(@app_title)}
layout 'production' layout 'module_widget'
def setup_vars def setup_vars
@app_title = request.fullpath.split('/')[2] @app_title = request.fullpath.split('/')[2]

View File

@ -0,0 +1,14 @@
<!DOCTYPE HTML>
<html>
<head>
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<%= stylesheet_link_tag "widget" %>
<%= javascript_include_tag "widget" %>
<%= csrf_meta_tag %>
</head>
<body>
<%= yield %>
</body>
</html>

View File

@ -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");
});
});

View File

@ -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