From 9a067e896d81ccd338a57bd24eeb951ad06f854b Mon Sep 17 00:00:00 2001 From: lutty Date: Tue, 2 May 2017 12:17:24 +0800 Subject: [PATCH] fix some bug and sync some code from luci-theme-bootstrap Signed-off-by: lutty --- .../luasrc/view/themes/material/header.htm | 215 +++++++++++---------- 1 file changed, 115 insertions(+), 100 deletions(-) mode change 100755 => 100644 themes/luci-theme-material/luasrc/view/themes/material/header.htm diff --git a/themes/luci-theme-material/luasrc/view/themes/material/header.htm b/themes/luci-theme-material/luasrc/view/themes/material/header.htm old mode 100755 new mode 100644 index 8419ade76..d84fd278a --- a/themes/luci-theme-material/luasrc/view/themes/material/header.htm +++ b/themes/luci-theme-material/luasrc/view/themes/material/header.htm @@ -2,14 +2,14 @@ Material is a clean HTML5 theme for LuCI. It is based on luci-theme-bootstrap and MUI luci-theme-material - Copyright 2015 Lutty Yang + Copyright 2015-2017 Lutty Yang Have a bug? Please create an issue here on GitHub! https://github.com/LuttyYang/luci-theme-material/issues luci-theme-bootstrap: Copyright 2008 Steven Barth - Copyright 2008 Jo-Philipp Wich + Copyright 2008-2016 Jo-Philipp Wich Copyright 2012 David Menting MUI: @@ -19,7 +19,6 @@ -%> <% - local ver = require "luci.version" local sys = require "luci.sys" local util = require "luci.util" local http = require "luci.http" @@ -51,30 +50,27 @@ end end - -- send as HTML5 + -- send as HTML5 http.prepare_content("text/html") local function nodeurl(prefix, name, query) - local url = controller .. prefix .. name .. "/" + local u = url(prefix, name) if query then - url = url .. http.build_querystring(query) + u = u .. http.build_querystring(query) end - return pcdata(url) + return pcdata(u) end - local function subtree(prefix, node, level) + local function render_tabmenu(prefix, node, level) if not level then level = 1 end local childs = disp.node_childs(node) if #childs > 0 then - - if level > 2 then -%> -
    - <% - end + if level > 2 then + write('
      ') + end local selected_node local selected_name @@ -86,21 +82,100 @@ selected_node = nnode selected_name = v end - if level > 2 then - %> -
    • - <%=striptags(translate(nnode.title))%> -
    • - <% end + + if level > 2 then + write('
    • %s
    • ' %{ + v, (nnode._menu_selected or (node.leaf and v == leaf)) and 'active' or '', + nodeurl(prefix, v, nnode.query), + striptags(translate(nnode.title)) + }) + end end - if level > 2 then - %> -
    -<% end + if level > 2 then + write('
') + end if selected_node then - subtree(prefix .. selected_name .. "/", selected_node, level + 1) + render_tabmenu(prefix .. "/" .. selected_name, selected_node, level + 1) + end + end + end + + local function render_submenu(prefix, node) + local childs = disp.node_childs(node) + if #childs > 0 then + write('
    ') + + for i, r in ipairs(childs) do + local nnode = node.nodes[r] + local title = pcdata(striptags(translate(nnode.title))) + + write('
  • %s
  • ' %{ + title, + nodeurl(prefix, r, nnode.query), + title + }) + end + + write('
') + end + end + + local function render_topmenu() + local childs = disp.node_childs(cattree) + if #childs > 0 then + write('') + end + end + + local function render_changes() + -- calculate the number of unsaved changes + if tree.nodes[category] and tree.nodes[category].ucidata then + local ucichanges = 0 + + for i, j in pairs(require("luci.model.uci").cursor():changes()) do + for k, l in pairs(j) do + for m, n in pairs(l) do + ucichanges = ucichanges + 1; + end + end + end + + if ucichanges > 0 then + write('%s: %d' %{ + url(category, 'uci/changes'), + http.urlencode(http.formvalue('redir') or REQUEST_URI), + translate('Unsaved Changes'), + ucichanges + }) end end end @@ -134,96 +209,30 @@ <% end -%> <% if css then %> - + <% end -%> - -
<%=boardinfo.hostname or "?"%>
- <% - -- calculate the number of unsaved changes - if tree.nodes[category] and tree.nodes[category].ucidata then - local ucichanges = 0 - for i, j in pairs(require("luci.model.uci").cursor():changes()) do - for k, l in pairs(j) do - for m, n in pairs(l) do - ucichanges = ucichanges + 1; - end - end - end - %> - <% if ucichanges > 0 then %> - "><%:Unsaved Changes%>: <%=ucichanges%> - <% end %> + <% render_changes() %> - <% end %>
- -
+
Loading...
- + <% render_topmenu() %>
-
+
<%- end -%> - <% if category then subtree("/" .. category .. "/", cattree) end %> - + <% if category then render_tabmenu(category, cattree) end %> + + -- 2.11.0