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
22 $(".main > .loading").fadeOut();
25 * trim text, Remove spaces, wrap
29 function trimText(text) {
30 return text.replace(/[ \t\n\r]+/g, " ");
33 var lastNode = undefined;
34 var mainNodeName = undefined;
39 if (node[0] == "admin"){
40 luciLocation = [node[1], node[2]];
45 for(var i in luciLocation){
46 nodeUrl += luciLocation[i];
47 if (i != luciLocation.length - 1){
54 * get the current node by Burl (primary)
55 * @returns {boolean} success?
57 function getCurrentNodeByUrl() {
59 if (!$('body').hasClass('logged-in')) {
60 luciLocation = ["Main", "Login"];
64 $(".main > .main-left > .nav > .slide > .menu").each(function () {
66 ulNode.next().find("a").each(function () {
68 var href = that.attr("href");
70 if (href.indexOf(nodeUrl) != -1) {
72 ulNode.next(".slide-menu").stop(true, true);
73 lastNode = that.parent();
74 lastNode.addClass("active");
86 $(".main > .main-left > .nav > .slide > .menu").click(function () {
87 var ul = $(this).next(".slide-menu");
89 if (!ul.is(":visible")) {
90 menu.addClass("active");
91 ul.addClass("active");
92 ul.stop(true).slideDown("fast");
94 ul.stop(true).slideUp("fast", function () {
95 menu.removeClass("active");
96 ul.removeClass("active");
103 * hook menu click and add the hash
105 $(".main > .main-left > .nav > .slide > .slide-menu > li > a").click(function () {
106 if (lastNode != undefined) lastNode.removeClass("active");
107 $(this).parent().addClass("active");
108 $(".main > .loading").fadeIn("fast");
115 $(".main > .main-left > .nav > .slide > .slide-menu > li").click(function () {
116 if (lastNode != undefined) lastNode.removeClass("active");
117 $(this).addClass("active");
118 $(".main > .loading").fadeIn("fast");
119 window.location = $($(this).find("a")[0]).attr("href");
124 * get current node and open it
126 if (getCurrentNodeByUrl()) {
127 mainNodeName = "node-" + luciLocation[0] + "-" + luciLocation[1];
128 mainNodeName = mainNodeName.replace(/[ \t\n\r\/]+/g, "_").toLowerCase();
129 $("body").addClass(mainNodeName);
135 var showSide = false;
136 $(".showSide").click(function () {
138 $(".darkMask").stop(true).fadeOut("fast");
139 $(".main-left").stop(true).animate({
142 $(".main-right").css("overflow-y", "visible");
145 $(".darkMask").stop(true).fadeIn("fast");
146 $(".main-left").stop(true).animate({
149 $(".main-right").css("overflow-y", "hidden");
154 $(".darkMask").click(function () {
157 $(".darkMask").stop(true).fadeOut("fast");
158 $(".main-left").stop(true).animate({
161 $(".main-right").css("overflow-y", "visible");
165 $(window).resize(function () {
166 if ($(window).width() > 921) {
167 $(".main-left").css("width", "");
168 $(".darkMask").stop(true);
169 $(".darkMask").css("display", "none");
175 * fix legend position
177 $("legend").each(function () {
179 that.after("<span class='panel-title'>" + that.text() + "</span>");
182 $(".cbi-section-table-titles, .cbi-section-table-descr, .cbi-section-descr").each(function () {
184 if (that.text().trim() == ""){
185 that.css("display", "none");
189 $(".main-right").focus();
190 $(".main-right").blur();
191 $("input").attr("size", "0");
192 $(".cbi-button-up").val("__");
193 $(".cbi-button-down").val("__");
194 $(".slide > a").removeAttr("href");
196 if (mainNodeName != undefined) {
197 console.log(mainNodeName);
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");