Skip to content

Commit

Permalink
Merge pull request #197 from liudonghua/trunk
Browse files Browse the repository at this point in the history
Trunk
  • Loading branch information
jerrykuku authored Mar 18, 2021
2 parents e8c3cb7 + a3fc3f0 commit d0a4c41
Show file tree
Hide file tree
Showing 6 changed files with 174 additions and 116 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ include $(TOPDIR)/rules.mk

LUCI_TITLE:=Argon Theme
LUCI_DEPENDS:=
PKG_VERSION:=2.2.6
PKG_RELEASE:=20210215
PKG_VERSION:=2.2.7
PKG_RELEASE:=20210318

include $(TOPDIR)/feeds/luci/luci.mk

# call BuildPackage - OpenWrt buildroot signature
# call BuildPackage - OpenWrt buildroot signature
3 changes: 3 additions & 0 deletions htdocs/luci-static/argon/css/cascade.css
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,9 @@ div[style="width:100%;height:300px;border:1px solid #000;background:#fff"] {
background-color: var(--primary);
transition: all 0.2s;
}
.main .main-left .nav li.slide ul.active {
display: block;
}
.main .main-left .nav li.slide .slide-menu .active:hover {
background: none;
}
Expand Down
15 changes: 7 additions & 8 deletions htdocs/luci-static/argon/less/cascade.less
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// out: ../css/cascade.css, compress: false , sourceMap: false
// out: ../css/cascade.css, compress: true , sourceMap: false
/**
* Argon is a clean HTML5 theme for LuCI. It is based on luci-theme-material and Argon Template
*
Expand All @@ -8,7 +8,7 @@
* Have a bug? Please create an issue here on GitHub!
* https://github.com/jerrykuku/luci-theme-argon/issues
*
* luci-theme-material:
* luci-theme-material:
* Copyright 2015 Lutty Yang <[email protected]>
* https://github.com/LuttyYang/luci-theme-material/
*
Expand Down Expand Up @@ -780,12 +780,11 @@ header {
right: 1.25rem;
float: right;

span[data-indicator] {
display: inline-block;
span[data-indicator="poll-status"] {
display: block;
font-size: 0.8rem;
font-weight: bold;
padding: 0.3rem 0.8rem;
margin: 0 0.5rem;
white-space: nowrap;
text-decoration: none;
text-transform: uppercase;
Expand Down Expand Up @@ -2417,8 +2416,8 @@ body:not(.Interfaces) .cbi-rowstyle-2:first-child {
width: 0;
height: 100%;
transition: width .25s ease-in;
background: #5e72e4;
background: var(--primary);
background: #5bc0de;
background: var(--bar-bg);
}

.cbi-progressbar::after {
Expand Down Expand Up @@ -3814,7 +3813,7 @@ pre.command-output {
display: inline-block;
}



.main>.main-left>.nav>.slide>.slide-menu>li>a {
font-size: 0.8rem;
Expand Down
156 changes: 156 additions & 0 deletions htdocs/luci-static/resources/menu.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
'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(node);

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.querySelector('a.showSide')
.addEventListener('click', ui.createHandlerFn(this, 'handleSidebarToggle'));
},

handleMenuExpand: function (ev) {
var a = ev.target, slide = a.parentNode, slide_menu = a.nextElementSibling;

document.querySelectorAll('.main .main-left .nav > li >ul.active').forEach(function (ul) {
if (ul !== slide) {
ul.classList.remove('active');
}

});

if (!slide_menu)
return;

slide_menu.classList.add('active');
a.blur();
ev.preventDefault();
ev.stopPropagation();
},

renderMainMenu: function (tree, url, level) {
var l = (level || 0) + 1,
ul = E('ul', { 'class': level ? 'slide-menu' : 'nav' }),
children = ui.menu.getChildren(tree);

if (children.length == 0 || l > 2)
return E([]);

for (var i = 0; i < children.length; i++) {
var isActive = ((L.env.dispatchpath[l] == children[i].name) && (L.env.dispatchpath[l - 1] == tree.name)),
submenu = this.renderMainMenu(children[i], url + '/' + children[i].name, l),
hasChildren = submenu.children.length,
activeClass = hasChildren ? 'slide' : null;
if (isActive) {
ul.classList.add('active');
activeClass += " active";
}

ul.appendChild(E('li', { 'class': activeClass }, [
E('a', {
'href': L.url(url, children[i].name),
'click': (l == 1) ? ui.createHandlerFn(this, 'handleMenuExpand') : null,
'class': hasChildren ? 'menu' : null,
'data-title': hasChildren ? children[i].title.replace(" ", "_") : children[i].title.replace(" ", "_"),
}, [_(children[i].title)]),
submenu
]));
}

if (l == 1) {
document.querySelector('#mainmenu').appendChild(ul);
document.querySelector('#mainmenu').style.display = '';

}
return ul;
},

renderModeMenu: function (tree) {
var menu = 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);

if (i > 0)
menu.appendChild(E([], ['\u00a0|\u00a0']));

menu.appendChild(E('li', {}, [
E('a', {
'href': L.url(children[i].name),
'class': isActive ? 'active' : null
}, [_(children[i].title)])
]));

if (isActive)
this.renderMainMenu(children[i], children[i].name);
}

if (menu.children.length > 1)
menu.style.display = '';
},

renderTabMenu: function (tree, url, level) {
var container = document.querySelector('#tabmenu'),
l = (level || 0) + 1,
ul = E('ul', { 'class': 'tabs' }),
children = ui.menu.getChildren(tree),
activeNode = null;

if (children.length == 0)
return E([]);

for (var i = 0; i < children.length; i++) {
var isActive = (L.env.dispatchpath[l + 2] == 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];
}

container.appendChild(ul);
container.style.display = '';

if (activeNode)
container.appendChild(this.renderTabMenu(activeNode, url + '/' + activeNode.name, l));

return ul;
},

handleSidebarToggle: function (ev) {
var btn = ev.currentTarget,
bar = document.querySelector('#mainmenu');

if (btn.classList.contains('active')) {
btn.classList.remove('active');
bar.classList.remove('active');
}
else {
btn.classList.add('active');
bar.classList.add('active');
}
}
});
10 changes: 5 additions & 5 deletions luasrc/view/themes/argon/footer.htm
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
Have a bug? Please create an issue here on GitHub!
https://github.com/jerrykuku/luci-theme-argon/issues

luci-theme-material:
luci-theme-material:
Copyright 2015 Lutty Yang <lutty@wcan.in>

Agron Theme
https://demos.creative-tim.com/argon-dashboard/index.html
https://demos.creative-tim.com/argon-dashboard/index.html

Licensed to the public under the Apache License 2.0
Licensed to the public under the Apache License 2.0
-%>

<% local ver = require "luci.version" %>
Expand Down Expand Up @@ -41,6 +41,6 @@
}
})
</script>
<script src="<%=media%>/js/script.js"></script>
<script type="text/javascript">L.require('menu')</script>
</body>
</html>
100 changes: 0 additions & 100 deletions luasrc/view/themes/argon/header.htm
Original file line number Diff line number Diff line change
Expand Up @@ -119,106 +119,6 @@
<script src="<%=resource%>/cbi.js?v=2.2.4"></script>
<script src="<%=resource%>/luci.js?v=2.2.4"></script>
<script src="<%=media%>/js/jquery.min.js?v=2.2.4"></script>
<script type="text/javascript">//<![CDATA[
function EF() { return L.dom.create.apply(L.dom, arguments) }
(function() {
function get_children(node) {
var children = [];
for (var k in node.children) {
if (!node.children.hasOwnProperty(k))
continue;
if (!node.children[k].satisfied)
continue;
if (!node.children[k].hasOwnProperty('title'))
continue;
children.push(Object.assign(node.children[k], { name: k }));
}
return children.sort(function(a, b) {
return ((a.order || 1000) - (b.order || 1000));
});
}
function render_mainmenu(tree, url, level) {
var l = (level || 0) + 1,
ul = EF('ul', { 'class': level ? 'slide-menu' : 'nav' }),
children = get_children(tree);
if (children.length == 0 || l > 2)
return EF([]);
for (var i = 0; i < children.length; i++) {
var submenu = render_mainmenu(children[i], url + '/' + children[i].name, l),
hasChildren = submenu.children.length;
ul.appendChild(EF('li', { 'class': hasChildren ? 'slide' : null }, [
EF('a', {
'href': hasChildren ? '#' : L.url(url, children[i].name),
'class': hasChildren ? 'menu' : null,
'data-title': hasChildren ? children[i].title.replace(" ", "_") : children[i].title.replace(" ", "_"),
}, [ _(children[i].title) ]),
submenu
]));
}
if (l == 1) {
var container = document.querySelector('#mainmenu');
container.appendChild(ul);
container.style.display = '';
}
return ul;
}
function render_modemenu(tree) {
var ul = document.querySelector('#modemenu'),
children = get_children(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(EF('li', {}, [
EF('a', {
'href': L.url(children[i].name),
'class': isActive ? 'active' : null
}, [ _(children[i].title) ])
]));
if (isActive)
render_mainmenu(children[i], children[i].name);
}
if (ul.children.length > 1)
ul.style.display = '';
}
function render_tabmenu(tree, url, level) {
var container = document.querySelector('#tabmenu'),
l = (level || 0) + 1,
ul = EF('ul', { 'class': 'tabs' }),
children = get_children(tree),
activeNode = null;
if (children.length == 0)
return EF([]);
for (var i = 0; i < children.length; i++) {
var isActive = (L.env.dispatchpath[l + 2] == children[i].name),
activeClass = isActive ? ' active' : '',
className = 'tabmenu-item-%s %s'.format(children[i].name, activeClass);
ul.appendChild(EF('li', { 'class': className }, [
EF('a', { 'href': L.url(url, children[i].name) }, [ _(children[i].title) ] )
]));
if (isActive)
activeNode = children[i];
}
container.appendChild(ul);
container.style.display = '';
if (activeNode)
container.appendChild(render_tabmenu(activeNode, url + '/' + activeNode.name, l));
return ul;
}
document.addEventListener('luci-loaded', function(ev) {
var tree = <%= luci.http.write_json(luci.dispatcher.menu_json() or {}) %>,
node = tree,
url = '';
render_modemenu(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)
render_tabmenu(node, url);
}
});
})();
//]]></script>
</head>

<body
Expand Down

0 comments on commit d0a4c41

Please sign in to comment.