bef272760a9e5606aa396a88ed587eadc05173ab
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 $(".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;
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-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 if ($('.nav').length
> 0 && $(window
).width() > 992) {
86 var oScroll
= new MyScrollBar({
89 bgColor
: 'transprent',
90 barColor
: '#839dd67a',
91 enterColor
: '#839dd6cc',
95 $(".main-left .nav > .slide > .menu").click(function () {
96 var ul
= $(this).next(".slide-menu");
98 if (!ul
.is(":visible")) {
99 menu
.addClass("active");
100 ul
.addClass("active");
101 ul
.stop(true).slideDown("fast");
103 ul
.stop(true).slideUp("fast", function () {
104 menu
.removeClass("active");
105 ul
.removeClass("active");
108 if ($('.nav').length
> 0 && $(window
).width() > 992) {
109 oScroll
.setSize(200);
111 setInterval(function () {
112 if ($('.nav').height() < $('.navbar-container').height()) {
113 $('.nav').css('transform', 'translate(0px, 0px)');
120 * hook menu click and add the hash
122 $(".main-left .nav > .slide > .slide-menu > li > a").click(function () {
123 if (lastNode
!= undefined) lastNode
.removeClass("active");
124 $(this).parent().addClass("active");
125 $(".loading").fadeIn("fast");
132 $(".main-left .nav > .slide > .slide-menu > li").click(function () {
133 if (lastNode
!= undefined) lastNode
.removeClass("active");
134 $(this).addClass("active");
135 $(".loading").fadeIn("fast");
136 win
.location
= $($(this).find("a")[0]).attr("href");
141 * get current node and open it
143 if (getCurrentNodeByUrl()) {
144 mainNodeName
= "node-" + luciLocation
[0] + "-" + luciLocation
[1];
145 mainNodeName
= mainNodeName
.replace(/[ \t\n\r\/]+/g, "_").toLowerCase();
146 $("body").addClass(mainNodeName
);
148 $(".cbi-button-up").val("");
149 $(".cbi-button-down").val("");
153 * hook other "A Label" and add hash to it.
155 $("#maincontent > .container").find("a").each(function () {
157 var onclick
= that
.attr("onclick");
158 if (onclick
== undefined || onclick
== "") {
159 that
.click(function () {
160 var href
= that
.attr("href");
161 if (href
.indexOf("#") == -1) {
162 $(".loading").fadeIn("fast");
172 var showSide
= false;
173 $(".showSide").click(function () {
175 $(".darkMask").stop(true).fadeOut("fast");
176 $(".main-left").stop(true).fadeOut("fast");
177 $(".main-right").css("overflow-y", "visible");
180 $(".darkMask").stop(true).fadeIn("fast");
181 $(".main-left").stop(true).animate({
183 }, "fast").fadeIn("fast");
184 $(".main-right").css("overflow-y", "hidden");
188 if($(win
).width() <= 992){
189 $(".main-left").click(function(e
) {
191 $(".main-left").stop(true).fadeOut("fast");
197 $(".darkMask").click(function () {
200 $(".darkMask").stop(true).fadeOut("fast");
201 $(".main-left").stop(true).animate({
204 $(".main-right").css("overflow-y", "visible");
208 $('.login .main-right').css('min-height', $(win
).height());
209 $(win
).resize(function () {
210 if ($(win
).width() > 921) {
211 $(".main-left").css("width", "");
212 $(".darkMask").stop(true);
213 $(".darkMask").css("display", "none");
217 $('.login .main-right').css('min-height', $(win
).height());
221 * fix legend position
223 $("legend").each(function () {
225 that
.after("<span class='panel-title'>" + that
.text() + "</span>");
228 $(".cbi-section-table-titles, .cbi-section-table-descr, .cbi-section-descr").each(function () {
230 if (that
.text().trim() == "") {
231 that
.css("display", "none");
236 $(".main-right").focus();
237 $(".main-right").blur();
238 $("input").attr("size", "0");
240 if (mainNodeName
!= undefined) {
241 console
.log(mainNodeName
);
242 switch (mainNodeName
) {
243 case "node-status-system_log":
244 case "node-status-kernel_log":
245 $("#syslog").focus(function () {
247 $(".main-right").focus();
248 $(".main-right").blur();
251 case "node-status-firewall":
252 var button
= $(".node-status-firewall > .main fieldset li > a");
253 button
.addClass("cbi-button cbi-button-reset a-to-btn");
255 case "node-system-reboot":
256 var button
= $(".node-system-reboot > .main > .main-right p > a");
257 button
.addClass("cbi-button cbi-input-reset a-to-btn");
262 $('.lang_enInterfaces .ifacebox-head').each(function () {
263 $(this).next().css('border-color', $(this).css('background-color'));
266 $('<div>').appendTo('.login > .main .cbi-value-last .cbi-value-field');
267 $('.login > .main .cbi-value-last .cbi-value-field > div').click(function(){
268 var thisParent
= $(this).parent();
269 if( thisParent
.attr('class').indexOf('op-eye') == (-1) ){
270 thisParent
.addClass('op-eye');
271 $(this).prev().attr('type', 'text');
273 thisParent
.removeClass('op-eye');
274 $(this).prev().attr('type', 'password');
279 $('#cbi-network-switch_vlan .table').wrap('<div id="vlan_table"></div>');