index.js
3.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/**
* index
* 默认依赖
*/
'use strict';
var $ = require('jquery');
var isMenuShow = false;
var localStorage = window.localStorage;
/**
* 左侧导航
*/
$('#sidebar .nav .has-sub>a').click(function() {
var child = $(this).parent().find('.sub-menu');
$('#sidebar .nav .has-sub>a').each(function() {
$(this).find('.sub-menu').slideUp('fast');
$(this).removeClass('active');
});
if (!child.is(':visible')) {
child.slideDown('fast');
if (!child.parent().hasClass('active'))
child.parent().addClass('active');
} else {
child.slideUp('fast');
child.parent().removeClass('active');
}
isMenuShow = true;
return false;
});
$("#sidebar .nav .sub-menu a").each(function() {
var attr = $(this).attr('href');
if (!isMenuShow && attr == window.location.pathname + window.location.search) {
$(this).parents(".sub-menu").show();
$(this).parent("li").addClass("active");
$(this).parents(".has-sub ").addClass("active");
localStorage.setItem("router", attr);
localStorage.getItem("router");
isMenuShow = true;
}
});
/**
* 左侧最小化
*/
$(".sidebar-minify-btn").click(function(){
$("#page-container").toggleClass("page-sidebar-minified");
});
$(".dropdown").hover(function () {
$(".dropdown-menu").show();
}, function () {
$(".dropdown-menu").hide();
});
/**
* 切换店铺
*/
$('.shops_id').click(function (){
var shop_id = $(this).attr('data-shopid');
$.getJSON('/index/ajaxshop?shops_id='+shop_id, function (data){
if(data.code == 200){
window.location.href="/";
}else{
alert(data.message);
}
})
});
// LocalStorage.setItem("router",);
$('.panel-heading').hover(function() {
$(this).find('.panel-btns').fadeIn('fast');
}, function() {
$(this).find('.panel-btns').fadeOut('fast');
});
$('.panel .panel-close').click(function() {
$(this).closest('.panel').fadeOut(200);
return false;
});
// Minimize Panel
$('.panel .panel-minimize').click(function() {
var t = $(this);
var p = t.closest('.panel');
if (!$(this).hasClass('maximize')) {
p.find('.panel-body, .panel-footer').slideUp(200);
t.addClass('maximize');
t.find('i').removeClass('fa-minus').addClass('fa-plus');
} else {
p.find('.panel-body, .panel-footer').slideDown(200);
t.removeClass('maximize');
t.find('i').removeClass('fa-plus').addClass('fa-minus');
}
return false;
});
var timer = null;
$('.dropdown-toggle').on('mouseenter', function() {
$('.dropdown-menu').hide();
$(this).siblings('.dropdown-menu').show();
}).on('mouseleave', function() {
var that = this;
clearTimeout(timer);
timer = setTimeout(function() {
$(that).siblings('.dropdown-menu').hide();
}, 1000);
});
$('.dropdown-menu').on('mouseenter', function() {
clearTimeout(timer);
$(this).show();
}).on('mouseleave', function() {
$(this).hide();
});
$(document).on("click",".delay-btn",function(){
var $this=$(this);
$this.prop("disabled",true);
setTimeout(function(){
$this.prop("disabled",false)
},2000);
});
$(document).on("keyup change","input[type='number']",function(){
$(this).val($(this).val().replace(/[^0-9]/g, ''));
});