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 if ($('.nav').length
> 0 && $(window
).width() > 992) {
85 var oScroll
= new MyScrollBar({
88 bgColor
: 'transprent',
89 barColor
: '#839dd67a',
90 enterColor
: '#839dd6cc',
95 $(".main > .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)');
121 * hook menu click and add the hash
123 $(".main > .main-left .nav > .slide > .slide-menu > li > a").click(function () {
124 if (lastNode
!= undefined) lastNode
.removeClass("active");
125 $(this).parent().addClass("active");
126 $(".main > .loading").fadeIn("fast");
133 $(".main > .main-left .nav > .slide > .slide-menu > li").click(function () {
134 if (lastNode
!= undefined) lastNode
.removeClass("active");
135 $(this).addClass("active");
136 $(".main > .loading").fadeIn("fast");
137 window
.location
= $($(this).find("a")[0]).attr("href");
142 * get current node and open it
144 if (getCurrentNodeByUrl()) {
145 mainNodeName
= "node-" + luciLocation
[0] + "-" + luciLocation
[1];
146 mainNodeName
= mainNodeName
.replace(/[ \t\n\r\/]+/g, "_").toLowerCase();
147 $("body").addClass(mainNodeName
);
149 $(".cbi-button-up").val("");
150 $(".cbi-button-down").val("");
154 * hook other "A Label" and add hash to it.
156 $("#maincontent > .container").find("a").each(function () {
158 var onclick
= that
.attr("onclick");
159 if (onclick
== undefined || onclick
== "") {
160 that
.click(function () {
161 var href
= that
.attr("href");
162 if (href
.indexOf("#") == -1) {
163 $(".main > .loading").fadeIn("fast");
173 var showSide
= false;
174 $(".showSide").click(function () {
176 $(".main-left").stop(true).animate({
179 $(".main-right").css("overflow-y", "auto");
182 $(".main-left").stop(true).animate({
185 $(".main-right").css("overflow-y", "hidden");
191 $(".logged-in .main-left").click(function () {
195 $(this).stop(true).fadeOut("fast");
196 $(".main-left").stop(true).animate({
199 $(".main-right").css("overflow-y", "auto");
203 $(".logged-in .main-left > *").click(function () {
204 event
.stopPropagation();
205 if ((navigator
.userAgent
.indexOf('MSIE') >= 0)&& (navigator
.userAgent
.indexOf('Opera') < 0)){
206 event
.cancelBubble
= true;
208 event
.stopPropagation();
212 $(window
).resize(function () {
213 if ($(window
).width() > 921) {
214 $(".main-left").css("width", "");
215 $(".darkMask").stop(true);
216 $(".darkMask").css("display", "none");
219 if( $(window
).width() > 992 ){
220 $('.logged-in .main-right').width( $(window
).width() - $('.logged-in .main-left').width() - 50 );
225 * fix legend position
227 $("legend").each(function () {
229 that
.after("<span class='panel-title'>" + that
.text() + "</span>");
232 $(".cbi-section-table-titles, .cbi-section-table-descr, .cbi-section-descr").each(function () {
234 if (that
.text().trim() == ""){
235 that
.css("display", "none");
240 $(".main-right").focus();
241 $(".main-right").blur();
242 $("input").attr("size", "0");
244 if (mainNodeName
!= undefined) {
245 console
.log(mainNodeName
);
246 switch (mainNodeName
) {
247 case "node-status-system_log":
248 case "node-status-kernel_log":
249 $("#syslog").focus(function () {
251 $(".main-right").focus();
252 $(".main-right").blur();
255 case "node-status-firewall":
256 var button
= $(".node-status-firewall > .main fieldset li > a");
257 button
.addClass("cbi-button cbi-button-reset a-to-btn");
259 case "node-system-reboot":
260 var button
= $(".node-system-reboot > .main > .main-right p > a");
261 button
.addClass("cbi-button cbi-input-reset a-to-btn");
266 $('<div class="iconpwd"></div>').appendTo($('.node-main-login form .cbi-value input[type="password"]').parent()[0]);
268 $('<div class="iconuser"></div>').appendTo($('.node-main-login form .cbi-value input[type="text"]').parent()[0]);
270 $('<div class="iconeye"></div>').appendTo($('.node-main-login form .cbi-value input[type="password"]').parent()[0]);
273 $('.cbi-value-field .iconeye').click(function(){
275 $('.node-main-login form .cbi-value-last input[type="password"]').prop('type', 'text');
276 $('.node-main-login form .cbi-value-field .iconeye').removeClass('opeye').addClass('cleye');
279 $('.node-main-login form .cbi-value-last input[type="text"]').prop('type', 'password');
280 $('.node-main-login form .cbi-value-field .iconeye').removeClass('cleye').addClass('opeye');
286 $('body.logged-in').css('min-height', $(window
).height());
289 if( $(window
).width() > 992 ){
290 $('.logged-in .main-right').outerWidth( $(window
).width() - $('.logged-in .main-left').width() - 50 );
293 $('.cbi-section .table').each(function(){
294 var thisTr
= $(this).children('.tr').get(0);
295 var td
= $(thisTr
).children('.td').get(0);
296 var th
= $(thisTr
).children('.th').get(0)
297 var a
= window
.getComputedStyle(thisTr
, ':before').getPropertyValue('content');
300 if( th
&& a
!= 'none' ){
301 $(th
).css('border-top-left-radius', '0');
302 }else if( td
&& a
!= 'none' ){
303 $(td
).css('border-top-left-radius', '0');
308 $('.lang_enNetwork #cbi-samba-sambashare .table').wrap('<div class="table-container"></div>');