// Keep the filter dropdown on screen $('#post-filter').on('shown.bs.dropdown', function() { let dropdown = $(this).find('.dropdown-menu'); $(dropdown) // Remove alignment class to check position .removeClass('dropdown-menu-right') // Assign alignment class if the menu is off-screen .toggleClass('dropdown-menu-right', $(dropdown).is(':off-right')); });
$(input_selector).each(function (index, element) { var $this = $(this); if ($(element).val().length > 0 || $(element).is(':focus') || element.autofocus || $this.attr('placeholder') !== undefined) { $this.siblings('label').addClass('active'); } else if ($(element)[0].validity) { $this.siblings('label').toggleClass('active', $(element)[0].validity.badInput === true); } else { $this.siblings('label').removeClass('active'); } });
$(function () { 'use strict' $('[data-toggle="offcanvas"]').on('click', function () { $('.offcanvas-collapse').toggleClass('open') }) })
// // Disables or enables the toolbar. // // disabled* (boolean) - True to disable, false to enable. // // No return value. // function disableToolbar(disabled) { $('.admin-toolbar').toggleClass('disabled', disabled); }
// Post filter $('#post-filter') // Prevent the dropdown from closing when toggling filters .find('.dropdown-item').on('click', (event) => event.stopPropagation()).end() // Apply filters .find(':checkbox').on('change', () => { let hasFilter = $('#post-filter :checked').length > 0; // Toggle filter icon $('#post-filter').toggleClass('active', hasFilter); // Update posts getPosts(1).then(() => { // Trigger UI update $('#posts').selectable('change'); }); });
self.$document.off('click.chips-select', SELS.CHIP).on('click.chips-select', SELS.CHIP, function(e){ $(SELS.CHIP).removeClass('selected'); $(this).toggleClass('selected'); });
// // Helper classes // /* eslint-env browser, jquery */ $(() => { // Platform classes on <html> $('html') .toggleClass('ios', /iPad|iPhone|iPod/.test(navigator.platform)) .toggleClass('mac', navigator.appVersion.indexOf('Mac') > -1) .toggleClass('linux', navigator.appVersion.indexOf('Linux') > -1) .toggleClass('windows', navigator.appVersion.indexOf('Windows') > -1); // Remove preload class to prevent transitions (see _overrides.scss) $('body').removeClass('preload'); });
/////////////////////////////////////////////////////////////////// // Toggles OSS panel // /////////////////////////////////////////////////////////////////// onToggleOSS () { $('.oss-panel').css({ display: this.$toggleOSS.hasClass('active') ? 'none' : 'block' }) this.$toggleOSS.toggleClass('active') this.viewerPanel.onResize() }
// // Shows the drop zone. // // target* (element) - The target element from a drag event. // // No return value. // function showDropzone(target) { target = $(target).parents().addBack(); clearTimeout(dropzoneTimeout); // Add the active class to the appropriate target ['post:image', 'post:content'].forEach((zone) => { $('#dropzone [data-target="' + zone + '"]') .toggleClass('active', $(target).is('[data-target="' + zone + '"]')); }); $('#dropzone').prop('hidden', false); }
handleLink() { if ($(window).width() < 769) { $('body').toggleClass('show-sidebar'); } }
/** * Toggles layout classes * * @param String cls the layout class to toggle * @returns void */ function changeLayout(cls) { $('body').toggleClass(cls) $layout.fixSidebar() if ($('body').hasClass('fixed') && cls == 'fixed') { $pushMenu.expandOnHover() $layout.activate() } $controlSidebar.fix() }
sidebar({ context }, event) { event.preventDefault(); if ($(window).width() < 769) { $('body').toggleClass('show-sidebar'); } else { $('body').toggleClass('hide-sidebar'); } }
// Dropdowns $('.dropdown') // Move focus to the content editor when opening a dropdown. This prevents text selections from // getting grayed out when working with dropdowns and ensures that formatters are applied to the // correct content region. .on('shown.bs.dropdown', () => contentEditor.focus()) // Keep dropdowns inside the viewport .on('shown.bs.dropdown', function() { let dropdown = $(this).find('.dropdown-menu'); $(dropdown) // Remove alignment class to check position .removeClass('dropdown-menu-right') // Assign alignment class if the menu is off-screen .toggleClass('dropdown-menu-right', $(dropdown).is(':off-right')); });
// Show/hide password fields when [data-toggle-password=".input-selector"] /* eslint-env browser, jquery */ $(() => { $(document).on('click', '[data-toggle-password]', function() { let trigger = this; let icon = $(trigger).find('.fa-eye, .fa-eye-slash'); let target = $(trigger).attr('data-toggle-password'); let type = $(target).prop('type') === 'password' ? 'text' : 'password'; // Toggle the field type $(target).prop('type', type); // Toggle the icon $(icon) .toggleClass('fa-eye', type === 'password') .toggleClass('fa-eye-slash', type !== 'password'); }); });
/////////////////////////////////////////////////////////////////// // Toggles OSS panel // /////////////////////////////////////////////////////////////////// onToggleOSS () { $('.left-panel').css({ display: this.$toggleOSS.hasClass('active') ? 'none' : 'block' }) this.$toggleOSS.toggleClass('active') this.viewerPanel.onResize() }