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 $(".main > .loading").fadeOut();
24 * trim text, Remove spaces, wrap
28 function trimText(text
) {
29 return text
.replace(/[ \t\n\r]+/g, " ");
33 var lastNode
= undefined;
34 var mainNodeName
= undefined;
38 if (node
[0] == "admin"){
39 luciLocation
= [node
[1], node
[2]];
44 for(var i
in luciLocation
){
45 nodeUrl
+= luciLocation
[i
];
46 if (i
!= luciLocation
.length
- 1){
53 * get the current node by Burl (primary)
54 * @returns {boolean} success?
56 function getCurrentNodeByUrl() {
58 if (!$('body').hasClass('logged-in')) {
59 luciLocation
= ["Main", "Login"];
63 $(".main > .main-left > .nav > .slide > .menu").each(function () {
65 ulNode
.next().find("a").each(function () {
67 var href
= that
.attr("href");
69 if (href
.indexOf(nodeUrl
) != -1) {
71 ulNode
.next(".slide-menu").stop(true, true);
72 lastNode
= that
.parent();
73 lastNode
.addClass("active");
85 $(".main > .main-left > .nav > .slide > .menu").click(function () {
86 var ul
= $(this).next(".slide-menu");
88 if (!ul
.is(":visible")) {
89 menu
.addClass("active");
90 ul
.addClass("active");
91 ul
.stop(true).slideDown("fast");
93 ul
.stop(true).slideUp("fast", function () {
94 menu
.removeClass("active");
95 ul
.removeClass("active");
101 * hook menu click and add the hash
103 $(".main > .main-left > .nav > .slide > .slide-menu > li > a").click(function () {
104 if (lastNode
!= undefined) lastNode
.removeClass("active");
105 $(this).parent().addClass("active");
106 $(".main > .loading").fadeIn("fast");
113 $(".main > .main-left > .nav > .slide > .slide-menu > li").click(function () {
114 if (lastNode
!= undefined) lastNode
.removeClass("active");
115 $(this).addClass("active");
116 $(".main > .loading").fadeIn("fast");
117 window
.location
= $($(this).find("a")[0]).attr("href");
122 * get current node and open it
124 if (getCurrentNodeByUrl()) {
125 mainNodeName
= "node-" + luciLocation
[0] + "-" + luciLocation
[1];
126 mainNodeName
= mainNodeName
.replace(/[ \t\n\r\/]+/g, "_").toLowerCase();
127 $("body").addClass(mainNodeName
);
129 $(".cbi-button-up").val("");
130 $(".cbi-button-down").val("");
134 * hook other "A Label" and add hash to it.
136 $("#maincontent > .container").find("a").each(function () {
138 var onclick
= that
.attr("onclick");
139 if (onclick
== undefined || onclick
== "") {
140 that
.click(function () {
141 var href
= that
.attr("href");
142 if (href
.indexOf("#") == -1) {
143 $(".main > .loading").fadeIn("fast");
153 var showSide
= false;
154 $(".showSide").click(function () {
156 $(".darkMask").stop(true).fadeOut("fast");
157 $(".main-left").stop(true).animate({
160 $(".main-right").css("overflow-y", "auto");
163 $(".darkMask").stop(true).fadeIn("fast");
164 $(".main-left").stop(true).animate({
167 $(".main-right").css("overflow-y", "hidden");
173 $(".darkMask").click(function () {
176 $(".darkMask").stop(true).fadeOut("fast");
177 $(".main-left").stop(true).animate({
180 $(".main-right").css("overflow-y", "auto");
184 $(window
).resize(function () {
185 if ($(window
).width() > 921) {
186 $(".main-left").css("width", "");
187 $(".darkMask").stop(true);
188 $(".darkMask").css("display", "none");
194 * fix legend position
196 $("legend").each(function () {
198 that
.after("<span class='panel-title'>" + that
.text() + "</span>");
202 $(".main-right").focus();
203 $(".main-right").blur();
204 $("input").attr("size", "0");
206 if (mainNodeName
!= undefined) {
207 console
.log(mainNodeName
);
208 switch (mainNodeName
) {
209 case "node-status-system_log":
210 case "node-status-kernel_log":
211 $("#syslog").focus(function () {
213 $(".main-right").focus();
214 $(".main-right").blur();
217 case "node-status-firewall":
218 var button
= $(".node-status-firewall > .main fieldset li > a");
219 button
.addClass("cbi-button cbi-button-reset a-to-btn");
221 case "node-system-reboot":
222 var button
= $(".node-system-reboot > .main > .main-right p > a");
223 button
.addClass("cbi-button cbi-input-reset a-to-btn");