123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223 |
- //自定义js
- var smallNavWidth= 70;
- var expandNavWidth = 220;
- var navDiffer = 150;
- //公共配置
- layer.config({
- extend: ['skin/moon/style.css']
- });
- function changeLeftNavImg(){
- var img = $("#l-nav-img").attr("src");
- var index = img.lastIndexOf("/");
- if(index == -1)
- return;
- var flag = img.substr(index + 1);
- if( $(document.body).hasClass("mini-navbar") == true) {
- $("#l-nav-img").parent().removeClass("l-nav-div-offsetl");
- $("#l-nav-img").parent().addClass("l-nav-div-offsets");
- $("#l-nav-img").attr("src", img.substr(0, index + 1) + "l-nav-close.png");
- }
- else
- {
- $("#l-nav-img").parent().addClass("l-nav-div-offsetl");
- $("#l-nav-img").parent().removeClass("l-nav-div-offsets");
- $("#l-nav-img").attr("src",img.substr(0,index + 1) + "l-nav-open.png");
- }
- }
- var lastLevelNavActive = null;
- function getLastLevelNavActive()
- {
- return lastLevelNavActive;
- }
- function setLastLevelNavActive(elem){
- lastLevelNavActive = elem;
- }
- $(document).ready(function () {
- // MetsiMenu
- $('#side-menu').metisMenu();
- // 打开右侧边栏
- $('.right-sidebar-toggle').click(function () {
- $('#right-sidebar').toggleClass('sidebar-open');
- });
- // 右侧边栏使用slimscroll
- $('.sidebar-container').slimScroll({
- height: '100%',
- railOpacity: 0.4,
- wheelStep: 10
- });
- // 打开聊天窗口
- $('.open-small-chat').click(function () {
- $(this).children().toggleClass('fa-comments').toggleClass('fa-remove');
- $('.small-chat-box').toggleClass('active');
- });
- // 聊天窗口使用slimscroll
- $('.small-chat-box .content').slimScroll({
- height: '234px',
- railOpacity: 0.4
- });
- // Small todo handler
- $('.check-link').click(function () {
- var button = $(this).find('i');
- var label = $(this).next('span');
- button.toggleClass('fa-check-square').toggleClass('fa-square-o');
- label.toggleClass('todo-completed');
- return false;
- });
- //固定菜单栏
- $(function () {
- $('.sidebar-collapse').slimScroll({
- height: '100%',
- railOpacity: 0.9,
- alwaysVisible: false
- });
- });
-
- // 菜单切换
- $('.navbar-minimalize').click(function () {
- $("body").toggleClass("mini-navbar");
- changeLeftNavImg();
- SmoothlyMenu();
- });
- // 侧边栏高度
- function fix_height() {
- var heightWithoutNavbar = $("body > #wrapper").height() - 61;
- $(".sidebard-panel").css("min-height", heightWithoutNavbar + "px");
- }
- fix_height();
- $(window).bind("load resize click scroll", function () {
- if (!$("body").hasClass('body-small')) {
- fix_height();
- }
- });
- //侧边栏滚动
- $(window).scroll(function () {
- if ($(window).scrollTop() > 0 && !$('body').hasClass('fixed-nav')) {
- $('#right-sidebar').addClass('sidebar-top');
- } else {
- $('#right-sidebar').removeClass('sidebar-top');
- }
- });
- $('.full-height-scroll').slimScroll({
- height: '100%'
- });
- $('#side-menu>li').click(function () {
- if ($('body').hasClass('mini-navbar')) {
- NavToggle();
- }
- });
- $('#side-menu>li li a').click(function(){
- var href = $(this).attr("href");
- if( href != undefined && href != "" )///末端菜单,取消上一激活状态,加载激活状态
- {
- if(lastLevelNavActive != null)
- {
- $(lastLevelNavActive).parent().removeClass("last-nav-activel");
- }
- $(this).parent().addClass("last-nav-activel");
- lastLevelNavActive = this;
- }
- if ($(window).width() < 769) {
- NavToggle();
- }
- });
-
- $('.nav-close').click(NavToggle);
- });
- $(window).bind("load resize", function () {
- if ($(this).width() < 769) {
- $('body').addClass('mini-navbar');
- $('.navbar-static-side').fadeIn();
- changeLeftNavImg();
- }
- });
- function NavToggle(){
- $('.navbar-minimalize').trigger('click');
- }
- function SmoothlyMenu() {
- if (!$('body').hasClass('mini-navbar')) {
- $('#side-menu').hide();
- setTimeout(
- function () {
- $('#side-menu').fadeIn(500);
- }, 100);
- } else if ($('body').hasClass('fixed-sidebar')) {
- $('#side-menu').hide();
- setTimeout(
- function () {
- $('#side-menu').fadeIn(500);
- }, 300);
- } else {
- $('#side-menu').removeAttr('style');
- }
- }
- //主题设置
- $(function () {
-
-
- var webroot=document.location.href;
- webroot=webroot.substring(webroot.indexOf('//')+2,webroot.length);
- webroot=webroot.substring(webroot.indexOf('/')+1,webroot.length);
- webroot=webroot.substring(0,webroot.indexOf('/'));
- rootpath="/"+webroot;
-
- //设置皮肤
- // $.get(rootpath+"/static/common/skin-config.jsp", function (data) {
- // $('body').append(data);
- // });
-
- if (localStorageSupport) {
- var collapse = localStorage.getItem("collapse_menu");
- var fixednavbar = localStorage.getItem("fixednavbar");
- var boxedlayout = localStorage.getItem("boxedlayout");
- var body = $('body');
- if (collapse == 'on') {
- if (!body.hasClass('body-small')) {
- body.addClass('mini-navbar');
- }
- }
- if (fixednavbar == 'on') {
- $(".navbar-static-top").removeClass('navbar-static-top').addClass('navbar-fixed-top');
- body.addClass('fixed-nav');
- }
- if (boxedlayout == 'on') {
- body.addClass('boxed-layout');
- }
- }
- });
- //判断浏览器是否支持html5本地存储
- function localStorageSupport() {
- return (('localStorage' in window) && window['localStorage'] !== null)
- }
|