wide/static/js/menu.js

55 lines
2.0 KiB
JavaScript
Raw Normal View History

2014-11-12 18:13:14 +03:00
/*
* Copyright (c) 2014, B3log
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
2014-09-10 14:08:35 +04:00
var menu = {
2014-10-13 13:01:44 +04:00
init: function () {
2014-09-10 14:08:35 +04:00
this.subMenu();
2014-09-13 09:05:50 +04:00
// 点击子菜单后消失
2014-10-13 13:01:44 +04:00
$(".frame li").click(function () {
2014-09-13 09:05:50 +04:00
$(this).closest(".frame").hide();
$(".menu > ul > li > a, .menu > ul> li > span").removeClass("selected");
2014-09-13 09:05:50 +04:00
});
2014-09-10 14:08:35 +04:00
},
2014-10-13 13:01:44 +04:00
disabled: function (list) {
for (var i = 0, max = list.length; i < max; i++) {
$(".menu li." + list[i]).addClass("disabled");
}
},
undisabled: function (list) {
for (var i = 0, max = list.length; i < max; i++) {
$(".menu li." + list[i]).removeClass("disabled");
}
},
2014-09-13 09:05:50 +04:00
// 焦点不在菜单上时需点击展开子菜单,否则为鼠标移动展开
2014-10-13 13:01:44 +04:00
subMenu: function () {
$(".menu > ul > li > a, .menu > ul> li > span").click(function () {
2014-09-10 14:08:35 +04:00
var $it = $(this);
$it.next().show();
$(".menu > ul > li > a, .menu > ul> li > span").removeClass("selected");
$(this).addClass("selected");
2014-09-10 14:08:35 +04:00
$(".menu > ul > li > a, .menu > ul> li > span").unbind();
2014-10-13 13:01:44 +04:00
$(".menu > ul > li > a, .menu > ul> li > span").mouseover(function () {
2014-09-10 14:08:35 +04:00
$(".frame").hide();
$(this).next().show();
$(".menu > ul > li > a, .menu > ul> li > span").removeClass("selected");
$(this).addClass("selected");
2014-09-10 14:08:35 +04:00
});
});
}
};