From b6e123e47603f345de81cdbad2a28823522b8c2c Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 16 Jul 2015 10:49:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=B3=E4=B8=8A=E8=A7=92=E5=AF=BC=E8=88=AA?= =?UTF-8?q?=E6=A0=8F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/layouts/_base_header.html.erb | 5 +---- public/javascripts/header.js | 20 +++++++++++++------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/app/views/layouts/_base_header.html.erb b/app/views/layouts/_base_header.html.erb index b800a1722..16fa44c73 100644 --- a/app/views/layouts/_base_header.html.erb +++ b/app/views/layouts/_base_header.html.erb @@ -101,10 +101,7 @@ addSlipMenu(); addProjectSlipMenu (); addCourseSlipMenu(); - }); - - jQuery(document).ready(function($) { - $('.sub_menu').find("a").attr('target', '_blank'); + $('.sub_menu').find("a").attr('target', '_blank'); $('.project_sub_menu').find("a").attr('target', '_blank'); $('.course_sub_menu').find("a").attr('target', '_blank'); }); diff --git a/public/javascripts/header.js b/public/javascripts/header.js index e27f758d3..06748d726 100644 --- a/public/javascripts/header.js +++ b/public/javascripts/header.js @@ -1,11 +1,15 @@ function addSlipMenu () { - var loggedas = $('#current_user_li:first'); + var loggedas = $('#current_user_li a:first'); var sub_menu = $('#user_sub_menu'); - loggedas.mouseenter(function(event) { + loggedas.mouseenter(function() { sub_menu.show(); + $('#my_projects_ul').hide(); + $('#my_courses_ul').hide(); }); - sub_menu.mouseleave(function(event) { + sub_menu.mouseleave(function() { sub_menu.hide(); + $('#my_projects_ul').hide(); + $('#my_courses_ul').hide(); }); } @@ -13,24 +17,26 @@ function addProjectSlipMenu () { var loggedas = $('#my_projects_li'); var project_sub_menu = $('#my_projects_ul'); var course_sub_menu = $('#my_courses_ul'); - loggedas.mouseenter(function(event) { + loggedas.mouseenter(function() { course_sub_menu.hide(); project_sub_menu.show(); }); - loggedas.mouseleave(function(event) { + loggedas.mouseleave(function() { project_sub_menu.hide(); + course_sub_menu.hide(); }); } function addCourseSlipMenu () { var loggedas = $('#my_courses_li'); var project_sub_menu = $('#my_projects_ul'); var course_sub_menu = $('#my_courses_ul'); - loggedas.mouseenter(function(event) { + loggedas.mouseenter(function() { project_sub_menu.hide(); course_sub_menu.show(); }); - loggedas.mouseleave(function(event) { + loggedas.mouseleave(function() { course_sub_menu.hide(); + project_sub_menu.hide(); }); }