-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.js
executable file
·222 lines (198 loc) · 5.57 KB
/
main.js
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
//initialize code here
layui.config({debug: false}).use(['form', 'element'], function() {
var form = layui.form,
$ = layui.$,
element = layui.element;
//initailize the tab component
var tab = {
activeWindowId: 0,
tabAdd: function(title, url, id) {
//create a new tab window
element.tabAdd('xbs_tab', {
title: title,
content: '<iframe tab-id="' + id + '" id="iframe_' + id + '" frameborder="0" src="' + url + '" scrolling="yes" class="x-iframe"></iframe>',
id: id
});
this.activeWindowId = id;
},
tabDelete: function(othis) {
// remove the specified window
element.tabDelete('xbs_tab', '44');
othis.addClass('layui-btn-disabled');
},
tabChange: function(id) {
// do tab change
element.tabChange('xbs_tab', id);
}
};
/* bind button event for closing the tab window */
$('.layui-tab-close').click(function(event) {
$('.layui-tab-title li').eq(0).find('i').remove();
});
//listening for tab change event
element.on('tab(xbs_tab)', function() {
tab.activeWindowId = this.getAttribute('lay-id');
});
/* bind event for checked all the checkbox in data list table */
form.on('checkbox(select-all)', function(data) {
var checked = data.elem.checked;
if (checked) {
$('input[name="id"]').prop("checked", true);
//re-render checkbox element
form.render('checkbox');
} else {
$('input[name="id"]').prop("checked", false);
form.render('checkbox');
}
});
/* bind event to reload the iframe window */
$('#frame-reload').on("click", function() {
document.getElementById("iframe_" + tab.activeWindowId).contentWindow.location.reload(true);
});
$('.container .left_open i').click(function(event) {
if ($('.left-nav').css('left') == '0px') {
$('.left-nav').animate({
left: '-221px'
}, 100);
$('.page-content').animate({
left: '0px'
}, 100);
$('.page-content-bg').hide();
} else {
$('.left-nav').animate({
left: '0px'
}, 100);
$('.page-content').animate({
left: '221px'
}, 100);
if ($(window).width() < 768) {
$('.page-content-bg').show();
}
}
});
$('.page-content-bg').click(function(event) {
$('.left-nav').animate({
left: '-221px'
}, 100);
$('.page-content').animate({
left: '0px'
}, 100);
$(this).hide();
});
$("tbody.x-cate tr[fid!='0']").hide();
// 栏目多级显示效果
$('.x-show').click(function() {
if ($(this).attr('status') == 'true') {
$(this).html('');
$(this).attr('status', 'false');
cateId = $(this).parents('tr').attr('cate-id');
$("tbody tr[fid=" + cateId + "]").show();
} else {
cateIds = [];
$(this).html('');
$(this).attr('status', 'true');
cateId = $(this).parents('tr').attr('cate-id');
getCateId(cateId);
for (var i in cateIds) {
$("tbody tr[cate-id=" + cateIds[i] + "]").hide().find('.x-show').html('').attr('status', 'true');
}
}
})
//左侧菜单效果
// $('#content').bind("click",function(event){
$('.left-nav #nav li').click(function(event) {
if ($(this).children('.sub-menu').length) {
if ($(this).hasClass('open')) {
$(this).removeClass('open');
$(this).find('.nav_right').html('');
$(this).children('.sub-menu').stop().slideUp();
$(this).siblings().children('.sub-menu').slideUp();
} else {
$(this).addClass('open');
$(this).children('a').find('.nav_right').html('');
$(this).children('.sub-menu').stop().slideDown();
$(this).siblings().children('.sub-menu').stop().slideUp();
$(this).siblings().find('.nav_right').html('');
$(this).siblings().removeClass('open');
}
} else {
var url = $(this).children('a').attr('_href');
var title = $(this).find('cite').html();
var index = $('.left-nav #nav li').index($(this));
for (var i = 0; i < $('.x-iframe').length; i++) {
if ($('.x-iframe').eq(i).attr('tab-id') == index + 1) {
tab.tabChange(index + 1);
event.stopPropagation();
return;
}
};
tab.tabAdd(title, url, index + 1);
tab.tabChange(index + 1);
}
event.stopPropagation();
})
});
/*弹出层*/
/*
参数解释:
title 标题
url 请求的url
id 需要操作的数据id
w 弹出层宽度(缺省调默认值)
h 弹出层高度(缺省调默认值)
*/
function x_admin_open(title, url, w, h) {
if (title == null || title == '') {
title = false;
};
if (url == null || url == '') {
url = "404.html";
};
if (w == null || w == '') {
w = ($(window).width() * 0.9);
};
if (h == null || h == '') {
h = ($(window).height() - 50);
};
var layer = parent.layer === undefined ? layui.layer : top.layer;
layer.open({
type: 2,
area: [w + 'px', h + 'px'],
fix: true, //不固定
//maxmin: true,
shadeClose: false,
shade: 0.4,
title: title,
content: url
});
}
// 打开一最大化的窗口
function x_open_full(title, url) {
var index = layer.open({
type: 2,
area: ['100%','100%'],
title: title,
content: url,
maxmin: false,
success : function(layero, index){
setTimeout(function(){
layui.layer.tips('点击此处返回列表', '.layui-layer-setwin .layui-layer-close', {
tips: 3
});
},500)
}
});
}
/*关闭弹出框口*/
function x_admin_close(callback) {
var index = parent.layer.getFrameIndex(window.name);
parent.layer.close(index);
switch (callback) {
case "reload": //刷新页面
parent.location.reload();
break;
case "render": //重新渲染列表组件
parent.render();
break;
}
}