1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-03-09 15:40:03 +00:00

fix ezengreen

This commit is contained in:
suyuan168 2022-05-24 22:10:16 +08:00
parent f6819bdfa9
commit 02df59a6f7
27 changed files with 259 additions and 385 deletions

View file

@ -0,0 +1,118 @@
'use strict';
'require baseclass';
'require ui';
return baseclass.extend({
__init__: function() {
ui.menu.load().then(L.bind(this.render, this));
},
render: function(tree) {
var node = tree,
url = '';
this.renderModeMenu(tree);
if (L.env.dispatchpath.length >= 3) {
for (var i = 0; i < 3 && node; i++) {
node = node.children[L.env.dispatchpath[i]];
url = url + (url ? '/' : '') + L.env.dispatchpath[i];
}
if (node)
this.renderTabMenu(node, url);
}
document.addEventListener('poll-start', this.handleBodyMargin);
document.addEventListener('poll-stop', this.handleBodyMargin);
document.addEventListener('uci-new-changes', this.handleBodyMargin);
document.addEventListener('uci-clear-changes', this.handleBodyMargin);
window.addEventListener('resize', this.handleBodyMargin);
this.handleBodyMargin();
},
renderTabMenu: function(tree, url, level) {
var container = document.querySelector('#tabmenu'),
ul = E('ul', { 'class': 'tabs' }),
children = ui.menu.getChildren(tree),
activeNode = null;
for (var i = 0; i < children.length; i++) {
var isActive = (L.env.dispatchpath[3 + (level || 0)] == children[i].name),
activeClass = isActive ? ' active' : '',
className = 'tabmenu-item-%s %s'.format(children[i].name, activeClass);
ul.appendChild(E('li', { 'class': className }, [
E('a', { 'href': L.url(url, children[i].name) }, [ _(children[i].title) ] )]));
if (isActive)
activeNode = children[i];
}
if (ul.children.length == 0)
return E([]);
container.appendChild(ul);
container.style.display = '';
if (activeNode)
this.renderTabMenu(activeNode, url + '/' + activeNode.name, (level || 0) + 1);
return ul;
},
renderMainMenu: function(tree, url, level) {
var ul = level ? E('ul', { 'class': 'dropdown-menu' }) : document.querySelector('#topmenu'),
children = ui.menu.getChildren(tree);
if (children.length == 0 || level > 1)
return E([]);
for (var i = 0; i < children.length; i++) {
var submenu = this.renderMainMenu(children[i], url + '/' + children[i].name, (level || 0) + 1),
subclass = (!level && submenu.firstElementChild) ? 'dropdown' : null,
linkclass = (!level && submenu.firstElementChild) ? 'menu' : null,
linkurl = submenu.firstElementChild ? '#' : L.url(url, children[i].name);
var li = E('li', { 'class': subclass }, [
E('a', { 'class': linkclass, 'href': linkurl }, [ _(children[i].title) ]),
submenu
]);
ul.appendChild(li);
}
ul.style.display = '';
return ul;
},
renderModeMenu: function(tree) {
var ul = document.querySelector('#modemenu'),
children = ui.menu.getChildren(tree);
for (var i = 0; i < children.length; i++) {
var isActive = (L.env.requestpath.length ? children[i].name == L.env.requestpath[0] : i == 0);
ul.appendChild(E('li', { 'class': isActive ? 'active' : null }, [
E('a', { 'href': L.url(children[i].name) }, [ _(children[i].title) ]),
' ',
E('span', { 'class': 'divider' }, [ '|' ])
]));
if (isActive)
this.renderMainMenu(children[i], children[i].name);
}
if (ul.children.length > 1)
ul.style.display = '';
},
handleBodyMargin: function(ev) {
var body = document.querySelector('body'),
head = document.querySelector('header');
body.style.marginTop = head.offsetHeight + 'px';
}
});

File diff suppressed because it is too large Load diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 553 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 836 B

View file

@ -0,0 +1,61 @@
#content-desktop {display: block;}
#content-mobile {display: none;}
@media screen and (max-width: 600px) {
#content-desktop {display: none;}
#content-mobile {display: block;}
}
header h3 a, header .brand {
float: left;
display: block;
padding: 12px 6px 12px 6px;
margin: 0 0 0 10px;
font-size: 22px;
font-weight: 240;
}
header div > ul, .nav {
display: block;
float: left;
margin: 7px 8px 0 8px;
position: relative;
left: 0;
}
header div > ul a, .nav a {
display: block;
float: left;
padding: 12px 6px 12px 6px;
line-height: 14px;
letter-spacing: 0.2px;
}
.menu-dropdown, .dropdown-menu {
top: 38px;
min-width: 180px;
max-width: 260px;
}
@media screen and (max-device-width: 660px) {
#maincontent.container {
width: 98%;
margin: 30px 0 0 6px;
}
}
@media screen and (max-device-width: 360px) {
#maincontent.container {
width: 96%;
margin: 30px 0 0 6px;
}
}
@media screen and (max-device-width: 200px) {
#maincontent.container {
width: 94%;
margin: 40px 0 0 2px;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB