1- <?php
2- global $ themeSwitcherAdded ;
3- $ iframeWidth = 400 ;
4- $ iframeHeight = 200 ;
5- $ zoom = 0.7 ;
6- if (!isset ($ themeSwitcherAdded )) {
7- $ themeSwitcherAdded = 1 ;
8- ?>
9- <style>
10- .openThemeOptionsUL {
11- top: auto;
12- max-height: 250px;
13- overflow-y: auto;
14- width: 100%;
15- margin-left: -100%;
16- margin-top: -26px;
17- overflow-x: visible;
18- }
19-
20- .openThemeOptionsUL li .fas {
21- display: none;
22- }
23-
24- .openThemeOptionsUL li.active .far {
25- display: none;
26- }
27-
28- .openThemeOptionsUL li.active .fas {
29- display: inline-block;
30- }
31-
32- #sideBarContainer .openThemeOptionsUL {
33- margin: 0;
34- }
35-
36- #showThemeIframeDiv {
37- position: fixed;
38- top: 70px;
39- left: 50%;
40- margin-left: -<?php echo $ iframeWidth / 2 ; ?> px;
41- background-color: #000;
42- -webkit-box-shadow: 0 0 5px 2px #000;
43- /* Safari 3-4, iOS 4.0.2 - 4.2, Android 2.3+ */
44- -moz-box-shadow: 0 0 5px 2px #000;
45- /* Firefox 3.5 - 3.6 */
46- box-shadow: 0 0 5px 2px #000;
47- /* Opera 10.5, IE 9, Firefox 4+, Chrome 6+, iOS 5 */
48- z-index: 2000;
49- width: <?php echo $ iframeWidth ; ?> px;
50- height: <?php echo $ iframeHeight ; ?> px;
51- padding: 0;
52- overflow: hidden;
53- }
54-
55- #frame {
56- width: <?php echo $ iframeWidth / $ zoom ; ?> px;
57- height: <?php echo $ iframeHeight / $ zoom ; ?> px;
58- border: 1px solid black;
59- }
60-
61- #frame {
62- -ms-zoom: <?php echo $ zoom ; ?> ;
63- -moz-transform: scale(<?php echo $ zoom ; ?> );
64- -moz-transform-origin: 0 0;
65- -o-transform: scale(<?php echo $ zoom ; ?> );
66- -o-transform-origin: 0 0;
67- -webkit-transform: scale(<?php echo $ zoom ; ?> );
68- -webkit-transform-origin: 0 0;
69- }
70- </style>
71- <script>
72- $(document).ready(function() {
73- $(window).click(function() {
74- $('.openThemeOptions').next('ul').hide();
75- $('#showThemeIframeDiv').fadeOut();
76- });
77- $('.liThemes').click(function(event) {
78- event.stopPropagation();
79- });
80- $('.openThemeOptions').on("click", function(e) {
81- $(this).next('ul').toggle();
82- if (!$(this).next('ul').is(":visible")) {
83- $('#showThemeIframeDiv').fadeOut();
84- }
85- e.stopPropagation();
86- e.preventDefault();
87- });
88-
89- $('body').append('<div id="showThemeIframeDiv" style="display:none;"></div>');
90- setInterval(function() {
91- if (!$('.openThemeOptions').is(":visible")) {
92- $('#showThemeIframeDiv').fadeOut();
93- }
94- }, 1000);
95- });
96-
97- function showThemeIframe(name) {
98- $('#showThemeIframeDiv').fadeIn();
99- $('#showThemeIframeDiv').html('<iframe id="frame" frameBorder="0" width="100%" height="250px" src="' + webSiteRootURL + 'view/css/custom/theme.php?theme=' + name + '" ></iframe>');
100- }
101-
102-
103- function changeTheme(name) {
104- $('.liThemes').removeClass('active');
105- $('#li' + name).addClass('active');
106- $('#customCSS').attr('href', webSiteRootURL + 'view/css/custom/' + name + '.css');
107- Cookies.set('customCSS', name, {
108- path: '/',
109- expires: 365
110- });
111- }
112- </script>
113- <?php
114- }
115- $ aClass = "" ;
116- $ keyComplement = "" ;
117- if ($ navBarButtons ) {
118- $ aClass = "btn btn-default btn-block " ;
119- $ keyComplement .= "navBarButtons " ;
120- }
121- ?>
122- <li class="dropdown-submenu" style="position: relative;">
123- <a class="openThemeOptions <?php echo $ aClass ; ?> " tabindex="-1" href="#">
124- <i class="fas fa-adjust"></i>
125- <span class="menuLabel">
126- <?php echo __ ("Change theme " ); ?>
127- </span>
128- </a>
129- <ul class="dropdown-menu openThemeOptionsUL">
130- <?php
131- $ themes = Gallery::getThemes ();
132- $ curentTheme = getCurrentTheme ();
133- foreach ($ themes as $ key => $ value ) {
134- $ k = $ key . $ keyComplement ;
135- $ class = "" ;
136- if ($ curentTheme == $ value ['name ' ]) {
137- $ class = "active " ;
138- }
139-
140- echo '<li class=" ' . $ class . ' liThemes" id="li ' . $ value ['name ' ] . '" ><a class="openThemeOptionsSub" tabindex="-1" href="#" '
141- . 'onmouseover="showThemeIframe( \'' . $ value ['name ' ] . '\');" '
142- . 'onclick="changeTheme( \'' . $ value ['name ' ] . '\');" '
143- . '><i class="far fa-images"></i><i class="fas fa-image"></i> ' . $ value ['label ' ] . '</a></li> ' ;
144- }
145- ?>
146- </ul>
147- </li>
1+ <?php
2+ global $ themeSwitcherAdded ;
3+ $ iframeWidth = 400 ;
4+ $ iframeHeight = 200 ;
5+ $ zoom = 0.7 ;
6+ if (!isset ($ themeSwitcherAdded )) {
7+ $ themeSwitcherAdded = 1 ;
8+ ?>
9+ <style>
10+ .openThemeOptionsUL {
11+ top: auto;
12+ max-height: 250px;
13+ overflow-y: auto;
14+ width: 100%;
15+ margin-left: -100%;
16+ margin-top: -26px;
17+ overflow-x: visible;
18+ }
19+
20+ .openThemeOptionsUL li .fas {
21+ display: none;
22+ }
23+
24+ .openThemeOptionsUL li.active .far {
25+ display: none;
26+ }
27+
28+ .openThemeOptionsUL li.active .fas {
29+ display: inline-block;
30+ }
31+
32+ #sideBarContainer .openThemeOptionsUL {
33+ margin: 0;
34+ }
35+
36+ #showThemeIframeDiv {
37+ position: fixed;
38+ top: 70px;
39+ left: 50%;
40+ margin-left: -<?php echo $ iframeWidth / 2 ; ?> px;
41+ background-color: #000;
42+ -webkit-box-shadow: 0 0 5px 2px #000;
43+ /* Safari 3-4, iOS 4.0.2 - 4.2, Android 2.3+ */
44+ -moz-box-shadow: 0 0 5px 2px #000;
45+ /* Firefox 3.5 - 3.6 */
46+ box-shadow: 0 0 5px 2px #000;
47+ /* Opera 10.5, IE 9, Firefox 4+, Chrome 6+, iOS 5 */
48+ z-index: 2000;
49+ width: <?php echo $ iframeWidth ; ?> px;
50+ height: <?php echo $ iframeHeight ; ?> px;
51+ padding: 0;
52+ overflow: hidden;
53+ }
54+
55+ #frame {
56+ width: <?php echo $ iframeWidth / $ zoom ; ?> px;
57+ height: <?php echo $ iframeHeight / $ zoom ; ?> px;
58+ border: 1px solid black;
59+ }
60+
61+ #frame {
62+ -ms-zoom: <?php echo $ zoom ; ?> ;
63+ -moz-transform: scale(<?php echo $ zoom ; ?> );
64+ -moz-transform-origin: 0 0;
65+ -o-transform: scale(<?php echo $ zoom ; ?> );
66+ -o-transform-origin: 0 0;
67+ -webkit-transform: scale(<?php echo $ zoom ; ?> );
68+ -webkit-transform-origin: 0 0;
69+ }
70+ </style>
71+ <script>
72+ $(document).ready(function() {
73+ $(window).click(function() {
74+ $('.openThemeOptions').next('ul').hide();
75+ $('#showThemeIframeDiv').fadeOut();
76+ });
77+ $('.liThemes').click(function(event) {
78+ event.stopPropagation();
79+ });
80+ $('.openThemeOptions').on("click", function(e) {
81+ $(this).next('ul').toggle();
82+ if (!$(this).next('ul').is(":visible")) {
83+ $('#showThemeIframeDiv').fadeOut();
84+ }
85+ e.stopPropagation();
86+ e.preventDefault();
87+ });
88+
89+ $('body').append('<div id="showThemeIframeDiv" style="display:none;"></div>');
90+ setInterval(function() {
91+ if (!$('.openThemeOptions').is(":visible")) {
92+ $('#showThemeIframeDiv').fadeOut();
93+ }
94+ }, 1000);
95+ });
96+
97+ function showThemeIframe(name) {
98+ $('#showThemeIframeDiv').fadeIn();
99+ $('#showThemeIframeDiv').html('<iframe id="frame" frameBorder="0" width="100%" height="250px" src="' + webSiteRootURL + 'view/css/custom/theme.php?theme=' + name + '" ></iframe>');
100+ }
101+
102+
103+ function applyThemeFromCookie() {
104+ var customCSSCookie = Cookies.get('customCSS');
105+ if (customCSSCookie) {
106+ // Fix CSS link (covers bfcache restore; initial load is handled by inline script in head.php)
107+ var currentHref = $('#customCSS').attr('href') || '';
108+ if (currentHref.indexOf('/' + customCSSCookie + '.css') === -1) {
109+ $('#customCSS').attr('href', webSiteRootURL + 'view/css/custom/' + customCSSCookie + '.css');
110+ }
111+ // Fix active menu item to reflect the locally stored theme
112+ $('.liThemes').removeClass('active');
113+ $('#li' + customCSSCookie).addClass('active');
114+ }
115+ }
116+
117+ function changeTheme(name) {
118+ $('.liThemes').removeClass('active');
119+ $('#li' + name).addClass('active');
120+ $('#customCSS').attr('href', webSiteRootURL + 'view/css/custom/' + name + '.css');
121+ Cookies.set('customCSS', name, {
122+ path: '/',
123+ expires: 365
124+ });
125+ }
126+
127+ $(document).ready(function() {
128+ if (typeof Cookies !== 'undefined') {
129+ applyThemeFromCookie();
130+ }
131+ });
132+
133+ window.addEventListener('pageshow', function(event) {
134+ if (event.persisted && typeof Cookies !== 'undefined') {
135+ applyThemeFromCookie();
136+ }
137+ });
138+ </script>
139+ <?php
140+ }
141+ $ aClass = "" ;
142+ $ keyComplement = "" ;
143+ if ($ navBarButtons ) {
144+ $ aClass = "btn btn-default btn-block " ;
145+ $ keyComplement .= "navBarButtons " ;
146+ }
147+ ?>
148+ <li class="dropdown-submenu" style="position: relative;">
149+ <a class="openThemeOptions <?php echo $ aClass ; ?> " tabindex="-1" href="#">
150+ <i class="fas fa-adjust"></i>
151+ <span class="menuLabel">
152+ <?php echo __ ("Change theme " ); ?>
153+ </span>
154+ </a>
155+ <ul class="dropdown-menu openThemeOptionsUL">
156+ <?php
157+ $ themes = Gallery::getThemes ();
158+ $ curentTheme = getCurrentTheme ();
159+ foreach ($ themes as $ key => $ value ) {
160+ $ k = $ key . $ keyComplement ;
161+ $ class = "" ;
162+ if ($ curentTheme == $ value ['name ' ]) {
163+ $ class = "active " ;
164+ }
165+
166+ echo '<li class=" ' . $ class . ' liThemes" id="li ' . $ value ['name ' ] . '" ><a class="openThemeOptionsSub" tabindex="-1" href="#" '
167+ . 'onmouseover="showThemeIframe( \'' . $ value ['name ' ] . '\');" '
168+ . 'onclick="changeTheme( \'' . $ value ['name ' ] . '\');" '
169+ . '><i class="far fa-images"></i><i class="fas fa-image"></i> ' . $ value ['label ' ] . '</a></li> ' ;
170+ }
171+ ?>
172+ </ul>
173+ </li>
0 commit comments