|
|
@@ -1,47 +1,82 @@
|
|
|
-//for custom JS
|
|
|
-$(document).ready(function() {
|
|
|
- bx_artificer_set_color_scheme_icon();
|
|
|
-});
|
|
|
+function BxArtificerUtils(oOptions)
|
|
|
+{
|
|
|
+ this._sActionUri = oOptions.sActionUri;
|
|
|
+ this._sActionUrl = oOptions.sActionUrl;
|
|
|
+ this._sObject = oOptions.sObject;
|
|
|
+ this._aHtmlIds = undefined == oOptions.aHtmlIds ? {} : oOptions.aHtmlIds;
|
|
|
+ this._sColorScheme = undefined == oOptions.sColorScheme ? 'auto' : oOptions.sColorScheme;
|
|
|
|
|
|
-function bx_artificer_set_color_scheme_html(){
|
|
|
- if (localStorage.theme === 'dark' || (!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches))
|
|
|
- $('html').addClass('dark')
|
|
|
- else
|
|
|
- $('html').removeClass('dark')
|
|
|
+ this.init();
|
|
|
}
|
|
|
|
|
|
-function bx_artificer_set_color_scheme_icon(){
|
|
|
- if (localStorage.theme === 'dark' || (!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
|
|
|
- $('.bx-sb-theme-switcher .sys-icon').addClass('moon').removeClass('sun');
|
|
|
- }
|
|
|
+BxArtificerUtils.prototype.init = function()
|
|
|
+{
|
|
|
+ var $this = this;
|
|
|
|
|
|
- if (localStorage.theme === 'sun' || (!('theme' in localStorage) && !window.matchMedia('(prefers-color-scheme: dark)').matches)) {
|
|
|
- $('.bx-sb-theme-switcher .sys-icon').addClass('sun').removeClass('moon');
|
|
|
- }
|
|
|
-}
|
|
|
+ switch(this._sColorScheme) {
|
|
|
+ case 'auto':
|
|
|
+ window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', event => {
|
|
|
+ $this.setColorSchemeIcon();
|
|
|
+ $this.setColorSchemeHtml();
|
|
|
+ });
|
|
|
+ break;
|
|
|
+
|
|
|
+ case 'light_only':
|
|
|
+ this.setColorScheme(1);
|
|
|
+ break;
|
|
|
|
|
|
-window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', event => {
|
|
|
- bx_artificer_set_color_scheme_icon();
|
|
|
- bx_artificer_set_color_scheme_html();
|
|
|
-});
|
|
|
+ case 'dark_only':
|
|
|
+ this.setColorScheme(2);
|
|
|
+ break;
|
|
|
+ }
|
|
|
|
|
|
-function bx_artificer_set_color_scheme(m){
|
|
|
- switch (m) {
|
|
|
+ this.setColorSchemeHtml();
|
|
|
+
|
|
|
+ $(document).ready(function() {
|
|
|
+ $this.setColorSchemeIcon();
|
|
|
+ });
|
|
|
+};
|
|
|
+
|
|
|
+BxArtificerUtils.prototype.setColorScheme = function(iCode)
|
|
|
+{
|
|
|
+ switch(iCode) {
|
|
|
case 0:
|
|
|
localStorage.removeItem('theme');
|
|
|
break;
|
|
|
+
|
|
|
case 1:
|
|
|
localStorage.theme = 'sun'
|
|
|
break;
|
|
|
+
|
|
|
case 2:
|
|
|
localStorage.theme = 'dark'
|
|
|
break;
|
|
|
}
|
|
|
- bx_artificer_set_color_scheme_icon();
|
|
|
- bx_artificer_set_color_scheme_html();
|
|
|
-}
|
|
|
|
|
|
-function bx_artificer_get_color_scheme_menu(){
|
|
|
+ this.setColorSchemeIcon();
|
|
|
+ this.setColorSchemeHtml();
|
|
|
+};
|
|
|
+
|
|
|
+BxArtificerUtils.prototype.setColorSchemeHtml = function()
|
|
|
+{
|
|
|
+ if (localStorage.theme === 'dark' || (!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches))
|
|
|
+ $('html').addClass('dark')
|
|
|
+ else
|
|
|
+ $('html').removeClass('dark')
|
|
|
+};
|
|
|
+
|
|
|
+BxArtificerUtils.prototype.setColorSchemeIcon = function()
|
|
|
+{
|
|
|
+ if (localStorage.theme === 'dark' || (!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
|
|
|
+ $('.bx-sb-theme-switcher .sys-icon').addClass('moon').removeClass('sun');
|
|
|
+ }
|
|
|
+
|
|
|
+ if (localStorage.theme === 'sun' || (!('theme' in localStorage) && !window.matchMedia('(prefers-color-scheme: dark)').matches)) {
|
|
|
+ $('.bx-sb-theme-switcher .sys-icon').addClass('sun').removeClass('moon');
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+BxArtificerUtils.prototype.getColorSchemeMenu = function() {
|
|
|
$('#bx-sb-theme-switcher-menu').dolPopup({
|
|
|
pointer: {
|
|
|
el: $('.bx-sb-theme-switcher')
|
|
|
@@ -49,9 +84,9 @@ function bx_artificer_get_color_scheme_menu(){
|
|
|
moveToDocRoot: true,
|
|
|
cssClass: 'bx-popup-menu'
|
|
|
});
|
|
|
-}
|
|
|
+};
|
|
|
|
|
|
-function bx_artificer_add_content_panel(sMenu, e, sPosition) {
|
|
|
+BxArtificerUtils.prototype.getAddContentMenu = function(sMenu, e, sPosition) {
|
|
|
$('.bx-popup-applied:visible').dolPopupHide();
|
|
|
|
|
|
var sSidebar = 'account';
|
|
|
@@ -59,6 +94,4 @@ function bx_artificer_add_content_panel(sMenu, e, sPosition) {
|
|
|
bx_sidebar_toggle(sSidebar);
|
|
|
|
|
|
bx_menu_popup_inline(sMenu, e, {});
|
|
|
-}
|
|
|
-
|
|
|
-bx_artificer_set_color_scheme_html();
|
|
|
+};
|