| @@ -1,0 +1,368 @@ | ||
| 1 | +<?php | |
| 2 | +/** | |
| 3 | + * @package VikBooking | |
| 4 | + * @subpackage com_vikbooking | |
| 5 | + * @author Alessio Gaggii - E4J srl | |
| 6 | + * @copyright Copyright (C) 2022 e4j - Extensionsforjoomla.com. All rights reserved. | |
| 7 | + * @license GNU General Public License version 2 or later; see LICENSE | |
| 8 | + * @link https://vikwp.com | |
| 9 | + */ | |
| 10 | + | |
| 11 | +defined('ABSPATH') or die('No script kiddies please!'); | |
| 12 | + | |
| 13 | +/** | |
| 14 | + * Obtain vars from arguments received in the layout file. | |
| 15 | + * This layout file should be called once at most per page. | |
| 16 | + * | |
| 17 | + * @var string $vbo_page the name of the current View in VBO. | |
| 18 | + * @var string $btn_trigger the CSS selector of the button that opens the panel. | |
| 19 | + */ | |
| 20 | +extract($displayData); | |
| 21 | + | |
| 22 | +// make sure the current page name is set and it's a string | |
| 23 | +$vbo_page = isset($vbo_page) ? htmlspecialchars($vbo_page, ENT_QUOTES) : ''; | |
| 24 | + | |
| 25 | +// get the current page and root URIs | |
| 26 | +$vbo_page_uri = htmlspecialchars((string) JUri::getInstance(), ENT_QUOTES); | |
| 27 | +$root_uri = htmlspecialchars(JUri::root(), ENT_QUOTES); | |
| 28 | + | |
| 29 | +/** | |
| 30 | + * We allow to sort the admin widgets. | |
| 31 | + * | |
| 32 | + * @since 1.16.10 (J) - 1.6.10 (WP) | |
| 33 | + */ | |
| 34 | +JHtml::fetch('script', VBO_SITE_URI.'resources/jquery-ui.sortable.min.js'); | |
| 35 | + | |
| 36 | +// get admin widgets helper | |
| 37 | +$widgets_helper = VikBooking::getAdminWidgetsInstance(); | |
| 38 | + | |
| 39 | +// get all widgets by preloading their assets (if any) | |
| 40 | +$admin_widgets = $widgets_helper->getWidgetNames($preload = true); | |
| 41 | + | |
| 42 | +// load current widgets map for this page | |
| 43 | +$current_map = $widgets_helper->getMultitaskingMap($vbo_page); | |
| 44 | + | |
| 45 | +// page active widgets list | |
| 46 | +$active_widgets = []; | |
| 47 | + | |
| 48 | +// check if the notification audio file exists within VCM | |
| 49 | +$notif_audio_path = implode(DIRECTORY_SEPARATOR, [VCM_ADMIN_PATH, 'assets', 'css', 'audio', 'new_notification.mp3']); | |
| 50 | +$notif_audio_url = is_file($notif_audio_path) ? (VCM_ADMIN_URI . implode('/', ['assets', 'css', 'audio', 'new_notification.mp3'])) : null; | |
| 51 | + | |
| 52 | +// theme color preferences | |
| 53 | +$color_scheme = VikBooking::getAppearancePref(); | |
| 54 | +$scheme_name = JText::translate('VBO_APPEARANCE_PREF_AUTO'); | |
| 55 | +$current_mode = 'magic'; | |
| 56 | +if ($color_scheme == 'light') { | |
| 57 | + $scheme_name = JText::translate('VBO_APPEARANCE_PREF_LIGHT'); | |
| 58 | + $current_mode = 'sun'; | |
| 59 | +} elseif ($color_scheme == 'dark') { | |
| 60 | + $scheme_name = JText::translate('VBO_APPEARANCE_PREF_DARK'); | |
| 61 | + $current_mode = 'moon'; | |
| 62 | +} | |
| 63 | + | |
| 64 | +// JS lang vars | |
| 65 | +JText::script('VBO_BROWSER_NOTIFS_ON'); | |
| 66 | +JText::script('VBO_BROWSER_NOTIFS_OFF'); | |
| 67 | +JText::script('VBO_BROWSER_NOTIFS_OFF_HELP'); | |
| 68 | +JText::script('VBO_ADMIN_WIDGET'); | |
| 69 | +JText::script('VBO_CONGRATS'); | |
| 70 | +JText::script('VBO_APPEARANCE_PREF_AUTO'); | |
| 71 | +JText::script('VBO_APPEARANCE_PREF_LIGHT'); | |
| 72 | +JText::script('VBO_APPEARANCE_PREF_DARK'); | |
| 73 | + | |
| 74 | +?> | |
| 75 | + | |
| 76 | +<div class="vbo-sidepanel-wrapper vbo-sidepanel-right vbo-sidepanel-close"> | |
| 77 | + | |
| 78 | + <div class="vbo-sidepanel-container"> | |
| 79 | + | |
| 80 | + <div class="vbo-sidepanel-layouts"> | |
| 81 | + <div class="vbo-sidepanel-dismiss"> | |
| 82 | + <span class="vbo-sidepanel-dismiss-btn"><?php VikBookingIcons::e('times'); ?></span> | |
| 83 | + </div> | |
| 84 | + <div class="vbo-sidepanel-notifications"> | |
| 85 | + <button type="button" class="vbo-sidepanel-notifications-btn"><?php VikBookingIcons::e('bell'); ?></button> | |
| 86 | + </div> | |
| 87 | + <div class="vbo-sidepanel-colorscheme"> | |
| 88 | + <span class="vbo-tooltip vbo-tooltip-bottom vbo-sidepanel-colorscheme-current" data-tooltiptext="<?php echo JHtml::fetch('esc_attr', $scheme_name); ?>"><?php VikBookingIcons::e($current_mode); ?></span> | |
| 89 | + <div class="vbo-sidepanel-colorscheme-list"> | |
| 90 | + <div class="vbo-sidepanel-colorscheme-option<?php echo $color_scheme == 'auto' ? ' vbo-sidepanel-colorscheme-option-active' : ''; ?>" data-scheme="auto"> | |
| 91 | + <span><?php VikBookingIcons::e('magic'); ?> <?php echo JText::translate('VBO_APPEARANCE_PREF_AUTO'); ?></span> | |
| 92 | + </div> | |
| 93 | + <div class="vbo-sidepanel-colorscheme-option<?php echo $color_scheme == 'light' ? ' vbo-sidepanel-colorscheme-option-active' : ''; ?>" data-scheme="light"> | |
| 94 | + <span><?php VikBookingIcons::e('sun'); ?> <?php echo JText::translate('VBO_APPEARANCE_PREF_LIGHT'); ?></span> | |
| 95 | + </div> | |
| 96 | + <div class="vbo-sidepanel-colorscheme-option<?php echo $color_scheme == 'dark' ? ' vbo-sidepanel-colorscheme-option-active' : ''; ?>" data-scheme="dark"> | |
| 97 | + <span><?php VikBookingIcons::e('moon'); ?> <?php echo JText::translate('VBO_APPEARANCE_PREF_DARK'); ?></span> | |
| 98 | + </div> | |
| 99 | + </div> | |
| 100 | + </div> | |
| 101 | + <div class="vbo-sidepanel-layout-type"> | |
| 102 | + <span class="vbo-sidepanel-layout-large"> | |
| 103 | + <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 96.75 75.3"><defs></defs><path d="M87.68,8.65a3.23,3.23,0,0,1,3.23,3.22V66.53a3.23,3.23,0,0,1-3.23,3.23H11.57a3.23,3.23,0,0,1-3.22-3.23V11.87a3.22,3.22,0,0,1,3.22-3.22H87.68m0-7.1H11.57A10.32,10.32,0,0,0,1.25,11.87V66.53A10.32,10.32,0,0,0,11.57,76.85H87.68A10.32,10.32,0,0,0,98,66.53V11.87A10.32,10.32,0,0,0,87.68,1.55Z" transform="translate(-1.25 -1.55)"/><rect id="wide" x="10.15" y="10" width="77.22" height="55.25" rx="4.94"/></svg> | |
| 104 | + </span> | |
| 105 | + <span class="vbo-sidepanel-layout-small"> | |
| 106 | + <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 96.75 75.3"><defs></defs><path d="M87.68,8.65a3.23,3.23,0,0,1,3.23,3.22V66.53a3.23,3.23,0,0,1-3.23,3.23H11.57a3.23,3.23,0,0,1-3.22-3.23V11.87a3.22,3.22,0,0,1,3.22-3.22H87.68m0-7.1H11.57A10.32,10.32,0,0,0,1.25,11.87V66.53A10.32,10.32,0,0,0,11.57,76.85H87.68A10.32,10.32,0,0,0,98,66.53V11.87A10.32,10.32,0,0,0,87.68,1.55Z" transform="translate(-1.25 -1.55)"/><rect id="right" x="48.1" y="12.42" width="35.75" height="50.93" rx="3.23"/></svg> | |
| 107 | + </span> | |
| 108 | + </div> | |
| 109 | + </div> | |
| 110 | + | |
| 111 | + <div class="vbo-sidepanel-body-top"> | |
| 112 | + | |
| 113 | + <div class="vbo-sidepanel-search"> | |
| 114 | + <?php VikBookingIcons::e('search', 'vbo-sidepanel-search-input-icn'); ?> | |
| 115 | + <input id="vbo-sidepanel-search-input" type="text" placeholder="<?php echo htmlspecialchars(JText::translate('VBO_SEARCH_ADMIN_WIDGETS')); ?>" value="" autocomplete="off" /> | |
| 116 | + </div> | |
| 117 | + | |
| 118 | + <div class="vbo-sidepanel-add-widgets"> | |
| 119 | + <?php | |
| 120 | + foreach ($admin_widgets as $k => $admin_widget) { | |
| 121 | + /** | |
| 122 | + * Add widget container must be focusable with "tabindex=-1" so that via JS we will | |
| 123 | + * have the "relatedTarget" event property set to this element when blurring on search field. | |
| 124 | + */ | |
| 125 | + ?> | |
| 126 | + <div class="vbo-sidepanel-add-widget" data-vbowidgetid="<?php echo $admin_widget->id; ?>" tabindex="-1"> | |
| 127 | + <div class="vbo-sidepanel-widget-info"> | |
| 128 | + <div class="vbo-sidepanel-widget-info-det"> | |
| 129 | + <span class="vbo-sidepanel-widget-icn vbo-admin-widget-style-<?php echo $admin_widget->style; ?>"><?php echo $admin_widget->icon; ?></span> | |
| 130 | + <span class="vbo-sidepanel-widget-name"><?php echo $admin_widget->name; ?></span> | |
| 131 | + </div> | |
| 132 | + <div class="vbo-sidepanel-widget-add"> | |
| 133 | + <span class="vbo-widget-render-modal"><?php echo VikBookingIcons::e('far fa-window-restore'); ?></span> | |
| 134 | + <span class="vbo-widget-render-regular"><?php echo VikBookingIcons::e('plus-circle'); ?></span> | |
| 135 | + </div> | |
| 136 | + </div> | |
| 137 | + <div class="vbo-sidepanel-widget-tags" style="display: none;"><?php echo strtolower($admin_widget->name . ' ' . $admin_widget->descr); ?></div> | |
| 138 | + </div> | |
| 139 | + <?php | |
| 140 | + } | |
| 141 | + ?> | |
| 142 | + <div class="vbo-sidepanel-add-widgets-nores" style="display: none;"> | |
| 143 | + <span><?php echo JText::translate('VBONORESULTS'); ?></span> | |
| 144 | + </div> | |
| 145 | + </div> | |
| 146 | + | |
| 147 | + </div> | |
| 148 | + | |
| 149 | + <div class="vbo-sidepanel-active-widgets"> | |
| 150 | + <?php | |
| 151 | + // get multitask data object | |
| 152 | + $multitask_data = VBOMultitaskParser::getInstance($vbo_page, $vbo_page_uri)->getData(); | |
| 153 | + foreach ($current_map as $widget_id) { | |
| 154 | + $widget_instance = $widgets_helper->getWidget($widget_id); | |
| 155 | + if (!$widget_instance) { | |
| 156 | + continue; | |
| 157 | + } | |
| 158 | + // turn on multitask flag | |
| 159 | + $widget_instance->setInMultitask(true); | |
| 160 | + // build widget info object | |
| 161 | + $widget_info = new stdClass; | |
| 162 | + $widget_info->id = $widget_instance->getIdentifier(); | |
| 163 | + $widget_info->name = $widget_instance->getName(); | |
| 164 | + // push widget info object to list | |
| 165 | + $active_widgets[] = $widget_info; | |
| 166 | + ?> | |
| 167 | + <div class="vbo-admin-widgets-widget-output vbo-admin-widgets-container-small" data-vbowidgetid="<?php echo $widget_info->id; ?>"> | |
| 168 | + <div class="vbo-admin-widgets-widget-detach"><?php VikBookingIcons::e('window-restore'); ?></div> | |
| 169 | + <?php $widget_instance->render($multitask_data); ?> | |
| 170 | + </div> | |
| 171 | + <?php | |
| 172 | + } | |
| 173 | + ?> | |
| 174 | + </div> | |
| 175 | + | |
| 176 | + <div class="vbo-sidepanel-shortcut" style="<?php echo $active_widgets ? 'display: none;' : ''; ?>"> | |
| 177 | + <div class="shortcut-keys"> | |
| 178 | + <span class="mod"></span> | |
| 179 | + <span class="key">⏎</span> | |
| 180 | + </div> | |
| 181 | + <div class="shortcut-desc"> | |
| 182 | + <?php echo JText::translate('VBO_KEYBOARD_SHORTCUT'); ?> | |
| 183 | + </div> | |
| 184 | + <div class="shortcut-subdesc"></div> | |
| 185 | + </div> | |
| 186 | + | |
| 187 | + <div class="vbo-sidepanel-edit-widgets"> | |
| 188 | + <div class="vbo-sidepanel-edit-widgets-wrap"> | |
| 189 | + <button class="btn btn-small vbo-sidepanel-edit-widgets-trig" style="<?php echo !count($active_widgets) ? 'display: none;' : ''; ?>"><?php echo JText::translate('VBO_WIDGETS_CUSTWIDGETS'); ?></button> | |
| 190 | + </div> | |
| 191 | + </div> | |
| 192 | + | |
| 193 | + </div> | |
| 194 | + | |
| 195 | +</div> | |
| 196 | + | |
| 197 | +<script type="text/javascript"> | |
| 198 | + jQuery(function() { | |
| 199 | + | |
| 200 | + // inject core properties | |
| 201 | + VBOCore.setOptions({ | |
| 202 | + is_vbo: true, | |
| 203 | + cms: "<?php echo VBOPlatformDetection::isWordPress() ? 'wordpress' : 'joomla'; ?>", | |
| 204 | + widget_ajax_uri: "<?php echo VikBooking::ajaxUrl('index.php?option=com_vikbooking&task=exec_admin_widget'); ?>", | |
| 205 | + assets_ajax_uri: "<?php echo VikBooking::ajaxUrl('index.php?option=com_vikbooking&task=widgets_get_assets'); ?>", | |
| 206 | + multitask_ajax_uri: "<?php echo VikBooking::ajaxUrl('index.php?option=com_vikbooking&task=exec_multitask_widgets'); ?>", | |
| 207 | + watchdata_ajax_uri: "<?php echo VikBooking::ajaxUrl('index.php?option=com_vikbooking&task=widgets_watch_data'); ?>", | |
| 208 | + current_page: "<?php echo $vbo_page; ?>", | |
| 209 | + current_page_uri: "<?php echo $vbo_page_uri; ?>", | |
| 210 | + root_uri: "<?php echo $root_uri; ?>", | |
| 211 | + admin_widgets: <?php echo json_encode($active_widgets); ?>, | |
| 212 | + notif_audio_url: "<?php echo $notif_audio_url; ?>", | |
| 213 | + tn_texts: { | |
| 214 | + notifs_enabled: Joomla.JText._('VBO_BROWSER_NOTIFS_ON'), | |
| 215 | + notifs_disabled: Joomla.JText._('VBO_BROWSER_NOTIFS_OFF'), | |
| 216 | + notifs_disabled_help: Joomla.JText._('VBO_BROWSER_NOTIFS_OFF_HELP'), | |
| 217 | + admin_widget: Joomla.JText._('VBO_ADMIN_WIDGET'), | |
| 218 | + congrats: Joomla.JText._('VBO_CONGRATS'), | |
| 219 | + }, | |
| 220 | + default_loading_body: '<?php VikBookingIcons::e('circle-notch', 'fa-spin fa-fw'); ?>', | |
| 221 | + service_worker_path: '<?php echo VBOWebappServiceworker::getUri(); ?>', | |
| 222 | + service_worker_scope: '<?php echo VBOWebappServiceworker::getScope(); ?>', | |
| 223 | + push: <?php echo json_encode(VBOWebappPush::getConfig()); ?>, | |
| 224 | + }); | |
| 225 | + | |
| 226 | + // initialize multitasking events | |
| 227 | + VBOCore.prepareMultitasking({ | |
| 228 | + selector: ".vbo-sidepanel-wrapper", | |
| 229 | + sclass_l_small: "vbo-sidepanel-right", | |
| 230 | + sclass_l_large: "vbo-sidepanel-large", | |
| 231 | + btn_trigger: "<?php echo $btn_trigger; ?>", | |
| 232 | + search_selector: "#vbo-sidepanel-search-input", | |
| 233 | + search_nores: ".vbo-sidepanel-add-widgets-nores", | |
| 234 | + close_selector: ".vbo-sidepanel-dismiss-btn", | |
| 235 | + t_layout_small: ".vbo-sidepanel-layout-small", | |
| 236 | + t_layout_large: ".vbo-sidepanel-layout-large", | |
| 237 | + wclass_base_sel: ".vbo-admin-widgets-widget-output", | |
| 238 | + wclass_l_small: "vbo-admin-widgets-container-small", | |
| 239 | + wclass_l_large: "vbo-admin-widgets-container-large", | |
| 240 | + addws_selector: ".vbo-sidepanel-add-widgets", | |
| 241 | + addw_selector: ".vbo-sidepanel-add-widget", | |
| 242 | + addwfs_selector: ".vbo-sidepanel-add-widget-focussed", | |
| 243 | + wtags_selector: ".vbo-sidepanel-widget-tags", | |
| 244 | + addw_data_attr: "data-vbowidgetid", | |
| 245 | + actws_selector: ".vbo-sidepanel-active-widgets", | |
| 246 | + editw_selector: ".vbo-sidepanel-edit-widgets-trig", | |
| 247 | + editmode_class: "vbo-admin-widgets-widget-editing", | |
| 248 | + rmwidget_class: "vbo-admin-widgets-widget-remove", | |
| 249 | + rmwidget_icn: '<?php VikBookingIcons::e('times'); ?>', | |
| 250 | + dtcwidget_class: "vbo-admin-widgets-widget-detach", | |
| 251 | + dtctarget_class: "vbo-admin-widget-head", | |
| 252 | + dtcwidget_icn: '<?php VikBookingIcons::e('far fa-window-restore'); ?>', | |
| 253 | + notif_selector: ".vbo-sidepanel-notifications-btn", | |
| 254 | + notif_on_class: "vbo-sidepanel-notifications-on", | |
| 255 | + notif_off_class: "vbo-sidepanel-notifications-off", | |
| 256 | + }); | |
| 257 | + | |
| 258 | + // install Service Worker | |
| 259 | + VBOCore.installServiceWorker().then((registration) => { | |
| 260 | + VBOCore.handlePushSubscription(registration).then((subscription) => { | |
| 261 | + console.info('Push notifications are enabled'); | |
| 262 | + }).catch((error) => { | |
| 263 | + console.warn(error); | |
| 264 | + }); | |
| 265 | + }).catch((error) => { | |
| 266 | + console.warn(error); | |
| 267 | + }); | |
| 268 | + | |
| 269 | + // color scheme preferences | |
| 270 | + jQuery('.vbo-sidepanel-colorscheme-current').on('click', function() { | |
| 271 | + jQuery('.vbo-sidepanel-colorscheme-list').toggleClass('vbo-sidepanel-colorscheme-list-show'); | |
| 272 | + }); | |
| 273 | + | |
| 274 | + // color scheme selection | |
| 275 | + jQuery('.vbo-sidepanel-colorscheme-option').on('click', function() { | |
| 276 | + let set_mode = jQuery(this).attr('data-scheme'); | |
| 277 | + | |
| 278 | + let vbo_css_base_uri = '<?php echo VBO_ADMIN_URI . (VBOPlatformDetection::isWordPress() ? 'resources/' : '') . 'vbo-appearance-%s.css'; ?>'; | |
| 279 | + let vbo_css_base_id = 'vbo-css-appearance-'; | |
| 280 | + let vcm_css_base_id = 'vcm-css-appearance-'; | |
| 281 | + let vbo_css_modes = { | |
| 282 | + auto: vbo_css_base_uri.replace('%s', 'auto'), | |
| 283 | + dark: vbo_css_base_uri.replace('%s', 'dark'), | |
| 284 | + light: null, | |
| 285 | + }; | |
| 286 | + let vbo_mode_texts = { | |
| 287 | + auto: Joomla.JText._('VBO_APPEARANCE_PREF_AUTO'), | |
| 288 | + dark: Joomla.JText._('VBO_APPEARANCE_PREF_DARK'), | |
| 289 | + light: Joomla.JText._('VBO_APPEARANCE_PREF_LIGHT'), | |
| 290 | + }; | |
| 291 | + let vbo_mode_icons = { | |
| 292 | + auto: '<?php VikBookingIcons::e('magic') ?>', | |
| 293 | + dark: '<?php VikBookingIcons::e('moon') ?>', | |
| 294 | + light: '<?php VikBookingIcons::e('sun') ?>', | |
| 295 | + }; | |
| 296 | + | |
| 297 | + if (!vbo_css_modes.hasOwnProperty(set_mode)) { | |
| 298 | + return false; | |
| 299 | + } | |
| 300 | + | |
| 301 | + // toggle active class | |
| 302 | + jQuery('.vbo-sidepanel-colorscheme-option').removeClass('vbo-sidepanel-colorscheme-option-active'); | |
| 303 | + jQuery(this).addClass('vbo-sidepanel-colorscheme-option-active'); | |
| 304 | + | |
| 305 | + // adjust current preference content | |
| 306 | + jQuery('.vbo-sidepanel-colorscheme-current') | |
| 307 | + .attr('data-tooltiptext', vbo_mode_texts[set_mode]) | |
| 308 | + .html(vbo_mode_icons[set_mode]); | |
| 309 | + | |
| 310 | + // set/unset CSS files from DOM | |
| 311 | + for (let app_mode in vbo_css_modes) { | |
| 312 | + if (!vbo_css_modes.hasOwnProperty(app_mode) || !vbo_css_modes[app_mode]) { | |
| 313 | + continue; | |
| 314 | + } | |
| 315 | + if (app_mode == set_mode) { | |
| 316 | + // set this CSS file | |
| 317 | + jQuery('head').append('<link rel="stylesheet" id="' + vbo_css_base_id + app_mode + '" href="' + vbo_css_modes[app_mode] + '" media="all">'); | |
| 318 | + } else { | |
| 319 | + // unset this CSS file | |
| 320 | + if (jQuery('link#' + vbo_css_base_id + app_mode).length) { | |
| 321 | + jQuery('link#' + vbo_css_base_id + app_mode).remove(); | |
| 322 | + } else if (jQuery('link#' + vbo_css_base_id + app_mode + '-css').length) { | |
| 323 | + // WP framework may add "-css" as suffix to the given ID | |
| 324 | + jQuery('link#' + vbo_css_base_id + app_mode + '-css').remove(); | |
| 325 | + } | |
| 326 | + // check if the VCM related CSS file should be unset too | |
| 327 | + if (jQuery('link#' + vcm_css_base_id + app_mode).length) { | |
| 328 | + jQuery('link#' + vcm_css_base_id + app_mode).remove(); | |
| 329 | + } else if (jQuery('link#' + vcm_css_base_id + app_mode + '-css').length) { | |
| 330 | + // WP framework may add "-css" as suffix to the given ID | |
| 331 | + jQuery('link#' + vcm_css_base_id + app_mode + '-css').remove(); | |
| 332 | + } | |
| 333 | + } | |
| 334 | + } | |
| 335 | + | |
| 336 | + // close menu-list | |
| 337 | + jQuery('.vbo-sidepanel-colorscheme-list').removeClass('vbo-sidepanel-colorscheme-list-show'); | |
| 338 | + | |
| 339 | + // silently update configuration value | |
| 340 | + VBOCore.doAjax( | |
| 341 | + "<?php echo VikBooking::ajaxUrl('index.php?option=com_vikbooking&task=configuration.update'); ?>", | |
| 342 | + { | |
| 343 | + settings: { | |
| 344 | + appearance_pref: set_mode, | |
| 345 | + } | |
| 346 | + }, | |
| 347 | + (success) => { | |
| 348 | + // do nothing | |
| 349 | + }, | |
| 350 | + (error) => { | |
| 351 | + console.error(error); | |
| 352 | + } | |
| 353 | + ); | |
| 354 | + }); | |
| 355 | + | |
| 356 | + // subscribe to the multitask-panel-close event to dismiss the color scheme selection menu | |
| 357 | + document.addEventListener(VBOCore.multitask_close_event, function() { | |
| 358 | + if (jQuery('.vbo-sidepanel-colorscheme-list-show').length) { | |
| 359 | + jQuery('.vbo-sidepanel-colorscheme-list-show').removeClass('vbo-sidepanel-colorscheme-list-show'); | |
| 360 | + } | |
| 361 | + }); | |
| 362 | + | |
| 363 | + // dinamycally change the shortcut modifier depending on the OS | |
| 364 | + const isMacOs = navigator.platform.toUpperCase().indexOf('MAC') === 0; | |
| 365 | + jQuery('.vbo-sidepanel-shortcut .shortcut-keys .mod').text(isMacOs ? '⌘' : '⌃'); | |
| 366 | + jQuery('.vbo-sidepanel-shortcut .shortcut-subdesc').text(isMacOs ? '(CMD + ENTER)' : '(CTRL + ENTER)'); | |
| 367 | + }); | |
| 368 | +</script> | |