You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

121 lines
4.2 KiB

<%--
Created by IntelliJ IDEA.
User: 10295
Date: 2018/4/15
Time: 23:25
To change this template use File | Settings | File Templates.
--%>
<!DOCTYPE html>
<html lang="en">
<%@ page pageEncoding="utf-8"%>
<head>
<script id="a_tmpl" type="text/x-jquery-tmpl">
<a href="#" class="list-group-item list-group-item-action list-group-item-success" id="menu{{= id}}" data-id="{{= id}}" data-name="{{= name}}" data-href="{{= href}}"></a>
</script>
<script id="span_tmpl" type="text/x-jquery-tmpl">
{{if length>0}}
{{= name}}<span class="badge badge-primary badge-pill">{{= length}}</span><i class="fas fa-angle-right"></i>
{{else}}
<span class="d-inline-block col-6 text-right">{{= name}}</span><span class="d-inline-block col-6 text-right"><i class="fas fa-adjust"></i></span>
{{/if}}
</script>
<script id="button_tmpl" type="text/x-jquery-tmpl">
<button type="button" id="btn_{{= id}}" class="btn btn-secondary btn-lg" data-id="{{= id}}">
{{= name}}
<i class="fas fa-times" style="display: none"></i>
</button>
</script>
<script>
function showMenu() {
var child = $("." + $(this).attr("id"));
i = $(this).find('i');
classPrefix = 'fas fa-angle-';
if (i.attr('class') == classPrefix + 'right') {
i.attr('class', classPrefix + 'down');
child.fadeIn()
} else {
i.attr('class', classPrefix + 'right');
hideMenu(child)
}
}
function hideMenu(child) {
if (child.length > 1) {
child.find('i').attr('class', classPrefix + 'right');
}
child.each(function () {
$(this).fadeOut();
hideMenu($("." + $(this).attr('id')));
})
}
function addMenu(menus) {
for (var menu in menus) {
id = menus[menu].id;
menuId=$("#a_tmpl").tmpl({'id':id,'name':menus[menu].menuName,'href':menus[menu].href}).appendTo('.list-group');
if (menus[menu].menuLevel > 0) {
menuId.addClass('offset-' + menus[menu].menuLevel).addClass('menu' + menus[menu].parentId);
menuId.hide();
}
$("#span_tmpl").tmpl({'name':menus[menu].menuName,'length':menus[menu].childMenu.length}).appendTo(menuId);
if (menus[menu].childMenu.length > 0) {
menuId.click(showMenu);
addMenu(menus[menu].childMenu,menus[menu].href);
} else {
menuId.click(function () {
btnId = '#btn_' + $(this).data('id');
if ($(btnId).length == 0) {
$("#tabs").append('<button type="button" id="' + btnId.substr(1) + '" class="btn btn-secondary btn-lg" data-id="' + $(this).data('id') + '">' + $(this).text() + '\n' +
' <i class="fas fa-times" style="display: none"></i>\n' +
' </button>')
}
$(btnId).click();
iframe = '#iframe_' + $(this).data('id');
if ($(iframe).length == 0) {
$(top.document).find('#nav-tabContent').append('<div id="' + iframe.substr(1) + '" class="tab-pane fade embed-responsive embed-responsive-16by9" >\n' +
' <iframe class="embed-responsive-item" src="' + $(this).data('href') + '"></iframe>\n' +
' </div>');
}
$(iframe).addClass('active show');
$(iframe).siblings().removeClass('active show');
});
}
}
}
$(function () {
addMenu(${menus}['data']);
$("#datatmlp").tmpl()
});
</script>
</head>
<div class="show" id="navbarNavDropdown">
<div class="col-2">
<div class="list-group">
</div>
</div>
</div>
</html>