2 * Rosy is a theme for LuCI. It is based on luci-theme-bootstrap
5 * Copyright 2018 Rosy Song <rosysong@rosinson.com>
6 * Copyright 2018 Yan Lan Shen <yanlan.shen@rosinson.com>
8 * Have a bug? Please create an issue here on GitHub!
9 * https://github.com/rosywrt/luci-theme-rosy/issues
11 * luci-theme-bootstrap:
12 * Copyright 2008 Steven Barth <steven@midlink.org>
13 * Copyright 2008 Jo-Philipp Wich <jow@openwrt.org>
14 * Copyright 2012 David Menting <david@nut-bolt.nl>
16 * Licensed to the public under the Apache License 2.0
20 $(".main > .loading").fadeOut();
23 * trim text, Remove spaces, wrap
27 function trimText(text
) {
28 return text
.replace(/[ \t\n\r]+/g, " ");
32 var lastNode
= undefined;
33 var mainNodeName
= undefined;
37 if (node
[0] == "admin"){
38 luciLocation
= [node
[1], node
[2]];
43 for(var i
in luciLocation
){
44 nodeUrl
+= luciLocation
[i
];
45 if (i
!= luciLocation
.length
- 1){
52 * get the current node by Burl (primary)
53 * @returns {boolean} success?
55 function getCurrentNodeByUrl() {
57 if (!$('body').hasClass('logged-in')) {
58 luciLocation
= ["Main", "Login"];
62 $(".main > .main-left .nav > .slide > .menu").each(function () {
64 ulNode
.next().find("a").each(function () {
66 var href
= that
.attr("href");
68 if (href
.indexOf(nodeUrl
) != -1) {
70 ulNode
.next(".slide-menu").stop(true, true);
71 lastNode
= that
.parent();
72 lastNode
.addClass("active");
84 $(".main > .main-left .nav > .slide > .menu").click(function () {
85 var ul
= $(this).next(".slide-menu");
87 if (!ul
.is(":visible")) {
88 menu
.addClass("active");
89 ul
.addClass("active");
90 ul
.stop(true).slideDown("fast");
92 ul
.stop(true).slideUp("fast", function () {
93 menu
.removeClass("active");
94 ul
.removeClass("active");
102 * hook menu click and add the hash
104 $(".main > .main-left .nav > .slide > .slide-menu > li > a").click(function () {
105 if (lastNode
!= undefined) lastNode
.removeClass("active");
106 $(this).parent().addClass("active");
107 $(".main > .loading").fadeIn("fast");
114 $(".main > .main-left .nav > .slide > .slide-menu > li").click(function () {
115 if (lastNode
!= undefined) lastNode
.removeClass("active");
116 $(this).addClass("active");
117 $(".main > .loading").fadeIn("fast");
118 window
.location
= $($(this).find("a")[0]).attr("href");
123 * get current node and open it
125 if (getCurrentNodeByUrl()) {
126 mainNodeName
= "node-" + luciLocation
[0] + "-" + luciLocation
[1];
127 mainNodeName
= mainNodeName
.replace(/[ \t\n\r\/]+/g, "_").toLowerCase();
128 $("body").addClass(mainNodeName
);
130 $(".cbi-button-up").val("");
131 $(".cbi-button-down").val("");
135 * hook other "A Label" and add hash to it.
137 $("#maincontent > .container").find("a").each(function () {
139 var onclick
= that
.attr("onclick");
140 if (onclick
== undefined || onclick
== "") {
141 that
.click(function () {
142 var href
= that
.attr("href");
143 if (href
.indexOf("#") == -1) {
144 $(".main > .loading").fadeIn("fast");
154 var showSide
= false;
155 $(".showSide").click(function () {
157 $(".main-left").stop(true).animate({
160 $(".main-right").css("overflow-y", "auto");
163 $(".main-left").stop(true).animate({
166 $(".main-right").css("overflow-y", "hidden");
172 $(".logged-in .main-left").click(function () {
176 $(this).stop(true).fadeOut("fast");
177 $(".main-left").stop(true).animate({
180 $(".main-right").css("overflow-y", "auto");
184 $(".logged-in .main-left > *").click(function () {
185 event
.stopPropagation();
186 if ((navigator
.userAgent
.indexOf('MSIE') >= 0)&& (navigator
.userAgent
.indexOf('Opera') < 0)){
187 event
.cancelBubble
= true;
189 event
.stopPropagation();
193 $(window
).resize(function () {
194 if ($(window
).width() > 921) {
195 $(".main-left").css("width", "");
196 $(".darkMask").stop(true);
197 $(".darkMask").css("display", "none");
200 if( $(window
).width() > 992 ){
201 $('.logged-in .main-right').width( $(window
).width() - $('.logged-in .main-left').width() - 50 );
206 * fix legend position
208 $("legend").each(function () {
210 that
.after("<span class='panel-title'>" + that
.text() + "</span>");
213 $(".cbi-section-table-titles, .cbi-section-table-descr, .cbi-section-descr").each(function () {
215 if (that
.text().trim() == ""){
216 that
.css("display", "none");
221 $(".main-right").focus();
222 $(".main-right").blur();
223 $("input").attr("size", "0");
225 if (mainNodeName
!= undefined) {
226 console
.log(mainNodeName
);
227 switch (mainNodeName
) {
228 case "node-status-system_log":
229 case "node-status-kernel_log":
230 $("#syslog").focus(function () {
232 $(".main-right").focus();
233 $(".main-right").blur();
236 case "node-status-firewall":
237 var button
= $(".node-status-firewall > .main fieldset li > a");
238 button
.addClass("cbi-button cbi-button-reset a-to-btn");
240 case "node-system-reboot":
241 var button
= $(".node-system-reboot > .main > .main-right p > a");
242 button
.addClass("cbi-button cbi-input-reset a-to-btn");
247 $('<div class="iconpwd"></div>').appendTo($('.node-main-login form .cbi-value input[type="password"]').parent()[0]);
249 $('<div class="iconuser"></div>').appendTo($('.node-main-login form .cbi-value input[type="text"]').parent()[0]);
251 $('<div class="iconeye"></div>').appendTo($('.node-main-login form .cbi-value input[type="password"]').parent()[0]);
254 $('.cbi-value-field .iconeye').click(function(){
256 $('.node-main-login form .cbi-value-last input[type="password"]').prop('type', 'text');
257 $('.node-main-login form .cbi-value-field .iconeye').removeClass('opeye').addClass('cleye');
260 $('.node-main-login form .cbi-value-last input[type="text"]').prop('type', 'password');
261 $('.node-main-login form .cbi-value-field .iconeye').removeClass('cleye').addClass('opeye');
267 if( $(window
).width() > 992 ){
268 $('.logged-in .main-right').width( $(window
).width() - $('.logged-in .main-left').width() - 50 );