Skip to content

Commit 56f85cc

Browse files
author
rmpestano
committed
1 parent 93e1000 commit 56f85cc

1 file changed

Lines changed: 65 additions & 48 deletions

File tree

src/main/resources/META-INF/resources/js/admintemplate.js

Lines changed: 65 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,33 @@
11
/* Active menu management */
2-
32
$(document).on("pfAjaxComplete", function () {
43
activateSidebarComponent();
4+
activateResizeOnMenuToggle();
55
});
66

77
$(document).ready(function () {
88
activateSidebarComponent();
99
activateMenu(window.location.pathname, false);
1010
activateMobileBar();
11+
activateResizeOnMenuToggle();
1112
});
1213

1314
$(window).on('resize', function () {
1415
adjustSidebarPosition();
1516
});
1617

18+
function activateResizeOnMenuToggle() {
19+
$("a.sidebar-toggle").on('click', function () {
20+
windowResize();
21+
});
22+
}
23+
24+
function windowResize() {
25+
if(!isMobile() && )
26+
setTimeout(function () {
27+
$(window).trigger('resize');
28+
}, 500);
29+
}
30+
1731
function activateRippleIcons() {
1832
$(document.body).on('mousedown touchstart', '.ui-messages .ui-icon, .ui-growl-item .ui-icon, span.ui-tree-toggler, span.ui-treetable-toggler, div.ui-row-toggler, span.ui-icon-calendar, div.ui-selectcheckboxmenu-trigger span.ui-icon-triangle-1-s, span.ui-icon-circle-close, .ui-panel-titlebar span.ui-icon, .ui-dialog-titlebar span.ui-icon, .ui-paginator span.ui-icon, .ui-autocomplete-dropdown span.ui-icon-triangle-1-s, .ui-selectonemenu-trigger span.ui-icon-triangle-1-s, .ui-spinner-button .ui-icon', null, function (e) {
1933
$(this).addClass("icon-ripple");
@@ -50,8 +64,8 @@ function activateMenu(url, activated) {
5064
//console.log("activePage:" + activePage +" currentPage:" + currentPage);
5165
if (activePage == currentPage) {
5266
$(this).parent().addClass('active');
53-
if(isMobile() && $('#enableMobileHeader').length) {
54-
createMobileHeader($(this).html());
67+
if (isMobile() && $('#enableMobileHeader').length) {
68+
createMobileHeader($(this).html());
5569
}
5670
activated = true;
5771
} else {
@@ -64,7 +78,7 @@ function activateMenu(url, activated) {
6478
var currentPage = stripTrailingSlash($(this).attr('href'));
6579
//console.log("sub-activePage:" + activePage +" sub-currentPage:" + currentPage);
6680
if (activePage == currentPage) {
67-
$(this).parentsUntil( "ul.sidebar-menu", "li.treeview" ).each(function () {
81+
$(this).parentsUntil("ul.sidebar-menu", "li.treeview").each(function () {
6882
$(this).addClass('active');
6983
});
7084
activated = true;
@@ -241,12 +255,14 @@ function removeBodyClass(clazz) {
241255
function collapseSidebar() {
242256
if (!$(document.body).hasClass('sidebar-collapse') && !$(document.body).hasClass('layout-top-nav')) {
243257
$(document.body).addClass('sidebar-collapse')
258+
windowResize();
244259
}
245260
}
246261

247262
function expandSidebar() {
248263
if ($(document.body).hasClass('sidebar-collapse')) {
249264
$(document.body).removeClass('sidebar-collapse');
265+
windowResize();
250266
}
251267
}
252268

@@ -256,6 +272,7 @@ function toggleSidebar() {
256272
} else if (!$(document.body).hasClass('layout-top-nav')) {
257273
$(document.body).addClass('sidebar-collapse')
258274
}
275+
windowResize();
259276
}
260277

261278
function toggleSidebarMini() {
@@ -329,9 +346,9 @@ var scrollTimerNav, lastScrollFireTimeNav = 0;
329346
function activateAutoShowNavbarOnScrollUp() {
330347
var nav = $('.navbar');
331348
if (isMobile() && window.pageYOffset > 150) {
332-
if(nav.hasClass('navbar-static-top')) {
333-
nav.css('display','none');
334-
}
349+
if (nav.hasClass('navbar-static-top')) {
350+
nav.css('display', 'none');
351+
}
335352
updateMobileHeaderVisibility();
336353
setFixedNavbar();
337354
var currentScrollPositionNav = $(this).scrollTop();
@@ -351,10 +368,10 @@ function activateAutoShowNavbarOnScrollUp() {
351368
}
352369

353370
function updateMobileHeaderVisibility() {
354-
if(isMobile() && window.pageYOffset > 150) {
355-
$('.mobile-header').css('display','block');
371+
if (isMobile() && window.pageYOffset > 150) {
372+
$('.mobile-header').css('display', 'block');
356373
} else {
357-
$('.mobile-header').css('display','none');
374+
$('.mobile-header').css('display', 'none');
358375
}
359376
}
360377

@@ -528,30 +545,30 @@ function isLayoutTop() {
528545
//calendar locales, adding only languages supported in AdminFaces: https://adminfaces.github.io/site/docs/latest/#internationalization
529546

530547
PrimeFaces.locales['pt'] = {
531-
closeText : 'Fechar',
532-
prevText : 'Anterior ',
533-
nextText : 'Próximo ',
534-
currentText : 'Hoje ',
535-
monthNames : [ 'Janeiro ', 'Fevereiro ', 'Março ', 'Abril ', 'Maio ', 'Junho ', 'Julho ', 'Agosto ', 'Setembro ', 'Outubro ', 'Novembro ', 'Dezembro ' ],
536-
monthNamesShort : [ 'Jan ', 'Fev ', 'Mar ', 'Abr ', 'Mai ', 'Jun ', 'Jul ', 'Ago ', 'Set ', 'Out ', 'Nov ', 'Dez ' ],
537-
dayNames : [ 'Domingo ', 'Segunda ', 'Terça ', 'Quarta ', 'Quinta ', 'Sexta ', 'Sábado ' ],
538-
dayNamesShort : [ 'Dom ', 'Seg ', 'Ter ', 'Qua ', 'Qui ', 'Sex ', 'Sáb ' ],
539-
dayNamesMin : [ 'D', 'S', 'T', 'Q', 'Q', 'S', 'S' ],
540-
weekHeader : 'Semana ',
541-
firstDay : 0,
542-
isRTL : false,
543-
showMonthAfterYear : false,
544-
yearSuffix : '',
545-
timeOnlyTitle : 'Só Horas ',
546-
timeText : 'Tempo ',
547-
hourText : 'Hora ',
548-
minuteText : 'Minuto ',
549-
secondText : 'Segundo ',
550-
ampm : false,
551-
month : 'Mês ',
552-
week : 'Semana ',
553-
day : 'Dia ',
554-
allDayText : 'Todo o Dia '
548+
closeText: 'Fechar',
549+
prevText: 'Anterior ',
550+
nextText: 'Próximo ',
551+
currentText: 'Hoje ',
552+
monthNames: ['Janeiro ', 'Fevereiro ', 'Março ', 'Abril ', 'Maio ', 'Junho ', 'Julho ', 'Agosto ', 'Setembro ', 'Outubro ', 'Novembro ', 'Dezembro '],
553+
monthNamesShort: ['Jan ', 'Fev ', 'Mar ', 'Abr ', 'Mai ', 'Jun ', 'Jul ', 'Ago ', 'Set ', 'Out ', 'Nov ', 'Dez '],
554+
dayNames: ['Domingo ', 'Segunda ', 'Terça ', 'Quarta ', 'Quinta ', 'Sexta ', 'Sábado '],
555+
dayNamesShort: ['Dom ', 'Seg ', 'Ter ', 'Qua ', 'Qui ', 'Sex ', 'Sáb '],
556+
dayNamesMin: ['D', 'S', 'T', 'Q', 'Q', 'S', 'S'],
557+
weekHeader: 'Semana ',
558+
firstDay: 0,
559+
isRTL: false,
560+
showMonthAfterYear: false,
561+
yearSuffix: '',
562+
timeOnlyTitle: 'Só Horas ',
563+
timeText: 'Tempo ',
564+
hourText: 'Hora ',
565+
minuteText: 'Minuto ',
566+
secondText: 'Segundo ',
567+
ampm: false,
568+
month: 'Mês ',
569+
week: 'Semana ',
570+
day: 'Dia ',
571+
allDayText: 'Todo o Dia '
555572
};
556573

557574
PrimeFaces.locales['es'] = {
@@ -586,18 +603,18 @@ PrimeFaces.locales ['ar'] = {
586603
prevText: 'إلى الخلف',
587604
nextText: 'إلى الأمام',
588605
currentText: 'بداية',
589-
monthNames: ['ديسمبر', 'نوفمبر', 'أكتوبر', 'سبتمبر', 'أغسطس', 'يوليو', 'يونيو', 'مايو', 'ابريل', 'مارس', 'فبراير', 'يناير' ],
590-
monthNamesShort: ['ديسمبر', 'نوفمبر', 'أكتوبر', 'سبتمبر', 'أغسطس', 'يوليو', 'يونيو', 'مايو', 'ابريل', 'مارس', 'فبراير', 'يناير' ],
606+
monthNames: ['ديسمبر', 'نوفمبر', 'أكتوبر', 'سبتمبر', 'أغسطس', 'يوليو', 'يونيو', 'مايو', 'ابريل', 'مارس', 'فبراير', 'يناير'],
607+
monthNamesShort: ['ديسمبر', 'نوفمبر', 'أكتوبر', 'سبتمبر', 'أغسطس', 'يوليو', 'يونيو', 'مايو', 'ابريل', 'مارس', 'فبراير', 'يناير'],
591608
dayNames: ['يوم الأحد‎', 'يوم الإثنين‎', 'يوم الثلاثاء‎', '‏يوم الأَرْبعاء‎', '‏يوم الخَمِيس‎', 'يوم الجُمْعَة‎‎', 'يوم السَّبْت'],
592609
dayNamesShort: ['الأحد‎', 'الإثنين‎', 'الثلاثاء‎', 'الأَرْبعاء‎', 'الخَمِيس‎', 'الجُمْعَة‎‎', 'السَّبْت'],
593610
dayNamesMin: ['الأحد‎', 'الإثنين‎', 'الثلاثاء‎', 'الأَرْبعاء‎', 'الخَمِيس‎', 'الجُمْعَة‎‎', 'السَّبْت'],
594611
weekHeader: 'الأسبوع',
595612
firstDay: 1,
596613
isRTL: false,
597614
showMonthAfterYear: false,
598-
yearSuffix:'' ,
599-
timeOnlyTitle: 'الوقت فقط' ,
600-
timeText: 'الوقت' ,
615+
yearSuffix: '',
616+
timeOnlyTitle: 'الوقت فقط',
617+
timeText: 'الوقت',
601618
hourText: 'ساعة',
602619
minuteText: 'دقيقة',
603620
secondText: 'ثانية',
@@ -613,11 +630,11 @@ PrimeFaces.locales['zh_CN'] = {
613630
prevText: '上个月',
614631
nextText: '下个月',
615632
currentText: '今天',
616-
monthNames: ['一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一月','十二月'],
617-
monthNamesShort: ['一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一月','十二月'],
618-
dayNames: ['星期日','星期一','星期二','星期三','星期四','星期五','星期六'],
619-
dayNamesShort: ['日','一','二','三','四','五','六'],
620-
dayNamesMin: ['日','一','二','三','四','五','六'],
633+
monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
634+
monthNamesShort: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
635+
dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
636+
dayNamesShort: ['日', '一', '二', '三', '四', '五', '六'],
637+
dayNamesMin: ['日', '一', '二', '三', '四', '五', '六'],
621638
weekHeader: '周',
622639
firstDay: 1,
623640
isRTL: false,
@@ -632,23 +649,23 @@ PrimeFaces.locales['zh_CN'] = {
632649
month: '月',
633650
week: '周',
634651
day: '日',
635-
allDayText : '全天'
652+
allDayText: '全天'
636653
};
637654

638655
PrimeFaces.locales ['de'] = {
639656
closeText: 'Schließen',
640657
prevText: 'Zurück',
641658
nextText: 'Weiter',
642-
monthNames: ['Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember' ],
643-
monthNamesShort: ['Jan', 'Feb', 'Mär', 'Apr', 'Mai', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dez' ],
659+
monthNames: ['Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember'],
660+
monthNamesShort: ['Jan', 'Feb', 'Mär', 'Apr', 'Mai', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dez'],
644661
dayNames: ['Sonntag', 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag'],
645662
dayNamesShort: ['Son', 'Mon', 'Die', 'Mit', 'Don', 'Fre', 'Sam'],
646663
dayNamesMin: ['S', 'M', 'D', 'M ', 'D', 'F ', 'S'],
647664
weekHeader: 'Woche',
648665
firstDay: 1,
649666
isRTL: false,
650667
showMonthAfterYear: false,
651-
yearSuffix:'',
668+
yearSuffix: '',
652669
timeOnlyTitle: 'Nur Zeit',
653670
timeText: 'Zeit',
654671
hourText: 'Stunde',

0 commit comments

Comments
 (0)