mirror of
				https://github.com/Ysurac/openmptcprouter-feeds.git
				synced 2025-03-09 15:40:03 +00:00 
			
		
		
		
	Update OpenMPTCProuter theme
This commit is contained in:
		
							parent
							
								
									6ad526f972
								
							
						
					
					
						commit
						c5c8bd41e3
					
				
					 5 changed files with 121 additions and 132 deletions
				
			
		| 
						 | 
				
			
			@ -1792,6 +1792,7 @@ button.btn::-moz-focus-inner, input[type=submit].btn::-moz-focus-inner {
 | 
			
		|||
	background-color: #bfbfbf;
 | 
			
		||||
	border-radius: 3px;
 | 
			
		||||
	text-shadow: none;
 | 
			
		||||
	margin-left: .4em;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
a.label:link,
 | 
			
		||||
| 
						 | 
				
			
			@ -1822,10 +1823,6 @@ a.label:hover {
 | 
			
		|||
/* LuCI specific items */
 | 
			
		||||
.hidden { display: none }
 | 
			
		||||
 | 
			
		||||
#xhr_poll_status {
 | 
			
		||||
	  cursor: pointer;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
form.inline { display: inline; margin-bottom: 0; }
 | 
			
		||||
 | 
			
		||||
/*header .pull-right { padding-top: 8px; }*/
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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';
 | 
			
		||||
	}
 | 
			
		||||
});
 | 
			
		||||
| 
						 | 
				
			
			@ -12,6 +12,7 @@
 | 
			
		|||
    <ul class="breadcrumb pull-right" id="modemenu" style="display:none"></ul>
 | 
			
		||||
   </footer>
 | 
			
		||||
  </div>
 | 
			
		||||
  <script type="text/javascript">L.require('menu-openmptcprouter')</script>
 | 
			
		||||
 </body>
 | 
			
		||||
</html>
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -40,9 +40,6 @@
 | 
			
		|||
		<% end -%>
 | 
			
		||||
		<script src="<%=url('admin/translations', luci.i18n.context.lang)%><%# ?v=PKG_VERSION %>"></script>
 | 
			
		||||
		<script src="<%=resource%>/cbi.js"></script>
 | 
			
		||||
		<script src="<%=resource%>/xhr.js"></script>
 | 
			
		||||
 | 
			
		||||
		<% include("themes/openmptcprouter/json-menu") %>
 | 
			
		||||
	</head>
 | 
			
		||||
 | 
			
		||||
	<body class="lang_<%=luci.i18n.context.lang%> <% if node then %><%= striptags( node.title ) %><%- end %>" data-page="<%= table.concat(disp.context.requestpath, "-") %>">
 | 
			
		||||
| 
						 | 
				
			
			@ -51,12 +48,7 @@
 | 
			
		|||
				<div class="container">
 | 
			
		||||
					<a class="brand" href="#" alt="OpenMPTCProuter"><img src="<%=resource%>/openmptcprouter/images/omr-logo.png" height="30" width="30" alt="OMR" /> OpenMPTCProuter</a>
 | 
			
		||||
					<ul class="nav" id="topmenu" style="display:none"></ul>
 | 
			
		||||
					<div class="pull-right">
 | 
			
		||||
						<span id="xhr_poll_status" style="display:none" onclick="XHR.running() ? XHR.halt() : XHR.run()">
 | 
			
		||||
							<span class="label success" id="xhr_poll_status_on"><%:Auto Refresh%> <%:on%></span>
 | 
			
		||||
							<span class="label" id="xhr_poll_status_off" style="display:none"><%:Auto Refresh%> <%:off%></span>
 | 
			
		||||
						</span>
 | 
			
		||||
					</div>
 | 
			
		||||
					<div id="indicators" class="pull-right"></div>
 | 
			
		||||
				</div>
 | 
			
		||||
			</div>
 | 
			
		||||
		</header>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,119 +0,0 @@
 | 
			
		|||
<script type="text/javascript">
 | 
			
		||||
	(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_tabmenu(tree, url, level) {
 | 
			
		||||
			var container = document.querySelector('#tabmenu'),
 | 
			
		||||
			    ul = E('ul', { 'class': 'tabs' }),
 | 
			
		||||
			    children = get_children(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)
 | 
			
		||||
				render_tabmenu(activeNode, url + '/' + activeNode.name, (level || 0) + 1);
 | 
			
		||||
 | 
			
		||||
			return ul;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		function render_mainmenu(tree, url, level) {
 | 
			
		||||
			var ul = level ? E('ul', { 'class': 'dropdown-menu' }) : document.querySelector('#topmenu'),
 | 
			
		||||
			    children = get_children(tree);
 | 
			
		||||
 | 
			
		||||
			if (children.length == 0 || level > 1)
 | 
			
		||||
				return E([]);
 | 
			
		||||
 | 
			
		||||
			for (var i = 0; i < children.length; i++) {
 | 
			
		||||
				var submenu = render_mainmenu(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;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		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(E('li', { 'class': isActive ? 'active' : null }, [
 | 
			
		||||
					E('a', { 'href': L.url(children[i].name) }, [ _(children[i].title) ]),
 | 
			
		||||
					' ',
 | 
			
		||||
					E('span', { 'class': 'divider' }, [ '|' ])
 | 
			
		||||
				]));
 | 
			
		||||
 | 
			
		||||
				if (isActive)
 | 
			
		||||
					render_mainmenu(children[i], children[i].name);
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if (ul.children.length > 1)
 | 
			
		||||
				ul.style.display = '';
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		document.addEventListener('luci-loaded', function(ev) {
 | 
			
		||||
			var tree = <%= luci.http.write_json(luci.dispatcher.context.authsession and 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>
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue