2 * Material is a clean HTML5 theme for LuCI. It is based on luci-theme-bootstrap and MUI
5 * Copyright 2015 Lutty Yang <lutty@wcan.in>
7 * Have a bug? Please create an issue here on GitHub!
8 * https://github.com/LuttyYang/luci-theme-material/issues
10 * luci-theme-bootstrap:
11 * Copyright 2008 Steven Barth <steven@midlink.org>
12 * Copyright 2008 Jo-Philipp Wich <jow@openwrt.org>
13 * Copyright 2012 David Menting <david@nut-bolt.nl>
16 * https://github.com/muicss/mui
18 * Licensed to the public under the Apache License 2.0
21 document
.addEventListener('luci-loaded', function(ev
) {
23 $(".main > .loading").fadeOut();
26 * trim text, Remove spaces, wrap
30 function trimText(text
) {
31 return text
.replace(/[ \t\n\r]+/g, " ");
34 var lastNode
= undefined;
35 var mainNodeName
= undefined;
40 if (node
[0] == "admin"){
41 luciLocation
= [node
[1], node
[2]];
46 for(var i
in luciLocation
){
47 nodeUrl
+= luciLocation
[i
];
48 if (i
!= luciLocation
.length
- 1){
55 * get the current node by Burl (primary)
56 * @returns {boolean} success?
58 function getCurrentNodeByUrl() {
60 if (!$('body').hasClass('logged-in')) {
61 luciLocation
= ["Main", "Login"];
65 $(".main > .main-left > .nav > .slide > .menu").each(function () {
67 ulNode
.next().find("a").each(function () {
69 var href
= that
.attr("href");
71 if (href
.endsWith(nodeUrl
) || href
.indexOf('/' + nodeUrl
+ '/') != -1) {
73 ulNode
.next(".slide-menu").stop(true, true);
74 lastNode
= that
.parent();
75 lastNode
.addClass("active");
87 $(".main > .main-left > .nav > .slide > .menu").click(function () {
88 var ul
= $(this).next(".slide-menu");
90 if (!ul
.is(":visible")) {
91 menu
.addClass("active");
92 ul
.addClass("active");
93 ul
.stop(true).slideDown("fast");
95 ul
.stop(true).slideUp("fast", function () {
96 menu
.removeClass("active");
97 ul
.removeClass("active");
104 * hook menu click and add the hash
106 $(".main > .main-left > .nav > .slide > .slide-menu > li > a").click(function () {
107 if (lastNode
!= undefined) lastNode
.removeClass("active");
108 $(this).parent().addClass("active");
109 $(".main > .loading").fadeIn("fast");
116 $(".main > .main-left > .nav > .slide > .slide-menu > li").click(function () {
117 if (lastNode
!= undefined) lastNode
.removeClass("active");
118 $(this).addClass("active");
119 $(".main > .loading").fadeIn("fast");
120 window
.location
= $($(this).find("a")[0]).attr("href");
125 * get current node and open it
127 if (getCurrentNodeByUrl()) {
128 mainNodeName
= "node-" + luciLocation
[0] + "-" + luciLocation
[1];
129 mainNodeName
= mainNodeName
.replace(/[ \t\n\r\/]+/g, "_").toLowerCase();
130 $("body").addClass(mainNodeName
);
136 var showSide
= false;
137 $(".showSide").click(function () {
139 $(".darkMask").stop(true).fadeOut("fast");
140 $(".main-left").stop(true).animate({
143 $(".main-right").css("overflow-y", "visible");
146 $(".darkMask").stop(true).fadeIn("fast");
147 $(".main-left").stop(true).animate({
150 $(".main-right").css("overflow-y", "hidden");
155 $(".darkMask").click(function () {
158 $(".darkMask").stop(true).fadeOut("fast");
159 $(".main-left").stop(true).animate({
162 $(".main-right").css("overflow-y", "visible");
166 $(window
).resize(function () {
167 if ($(window
).width() > 921) {
168 $(".main-left").css("width", "");
169 $(".darkMask").stop(true);
170 $(".darkMask").css("display", "none");
176 * fix legend position
178 $("legend").each(function () {
180 that
.after("<span class='panel-title'>" + that
.text() + "</span>");
183 $(".cbi-section-table-titles, .cbi-section-table-descr, .cbi-section-descr").each(function () {
185 if (that
.text().trim() == ""){
186 that
.css("display", "none");
190 $(".main-right").focus();
191 $(".main-right").blur();
192 $("input").attr("size", "0");
193 $(".cbi-button-up").val("__");
194 $(".cbi-button-down").val("__");
195 $(".slide > a").removeAttr("href");
197 if (mainNodeName
!= undefined) {
198 switch (mainNodeName
) {
199 case "node-status-system_log":
200 case "node-status-kernel_log":
201 $("#syslog").focus(function () {
203 $(".main-right").focus();
204 $(".main-right").blur();
207 case "node-status-firewall":
208 var button
= $(".node-status-firewall > .main fieldset li > a");
209 button
.addClass("cbi-button cbi-button-reset a-to-btn");
211 case "node-system-reboot":
212 var button
= $(".node-system-reboot > .main > .main-right p > a");
213 button
.addClass("cbi-button cbi-input-reset a-to-btn");