/* Request ID: 291f31bbe7f1f1448dd719838c81ce1a (05/17/2024 2:38am) (minifier disabled) (ndVLjoMwDIDhq8yui45gN/cxiUuj5jVOAprbD2kKmKWzaKXfi0+OCGJcgMZ1XetvcM4NqMtozYLrEyyOKhCOLuhiMbVIikzMaYxkFsg4YPr5/hp7lQnUC72WK6CyWUz+O6R9IKfqDiWmy05bd0A2zIyp1YMUmrhSs4Mp1mI2nkn7RI5pgkc+pZZyBhf0jGkpZx6I+lTe1YGY+n8gtTqQQI4hteTIDNtzIcO2OSYdmA0TWEa17oAo8HeipZwxDmZ2spYdjJ8JtblcHzbrAFMqfK93yhkLfi6XEx4TOea2LUxgb+w+kFMe15OpISfi5Vix70jRguLKOzsYCtf3dR/Iqd9i1AvUtsapsZkcrHeQULGLeUzkWEIg9TyklnImA/sO1ZATJert634qn+6AEhJjajXkds9DfhY3eTD2fvsH) */ "use strict"; function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = babelHelpers.getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = babelHelpers.getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return babelHelpers.possibleConstructorReturn(this, result); }; } function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } /* LiveWhale Private JS */ /* by White Whale Web Services */ // On every private load (backend or pages editor) (function (LW, $) { // lib functions available to private environments LW.lib = LW.lib || {}; /** * livewhale.lib.pubSub * * pub/sub implementation for the livewhale.eventHub. It is also used to extend objects that * require pub/sub with something like: _.extend(target_object, livewhale.lib.pubSub()); * * @returns {Object} */ LW.lib.pubSub = function () { var o = $({}); return { bind: function bind() { o.on.apply(o, arguments); }, unbind: function unbind() { o.off.apply(o, arguments); }, trigger: function trigger() { o.trigger.apply(o, arguments); } }; }; /** * event hub used for messaging throughout LiveWhale */ LW.eventHub = LW.lib.pubSub(); /** * livewhale.lib.PubSub * * class based pub/sub implementation designed to be extended * call super() in the constructor of class that extends it */ var PubSub = /*#__PURE__*/function () { function PubSub() { babelHelpers.classCallCheck(this, PubSub); this.pubsub = $({}); } babelHelpers.createClass(PubSub, [{ key: "bind", value: function bind() { this.pubsub.on.apply(this.pubsub, arguments); } }, { key: "unbind", value: function unbind() { this.pubsub.off.apply(this.pubsub, arguments); } }, { key: "trigger", value: function trigger() { this.pubsub.trigger.apply(this.pubsub, arguments); } }]); return PubSub; }(); LW.lib.PubSub = PubSub; /** * method for getting LW ajax urls with function name and params as object * * func: ajax function name * params: object containing additional parameters * page_url: optional page to make request to, /livewhale/backend.php by default */ LW.lib.getAjaxUrl = function (func, params, page_url) { var page = page_url ? page_url : '/livewhale/backend.php'; var url = page + '?livewhale=ajax&function=' + func; if ($.isPlainObject(params) && !$.isEmptyObject(params)) { url += '&' + $.param(params); } return url; }; LW.lib.openAltTextOverlay = function (id, alt) { if (!id) { return; } alt = alt ? $('
').html(alt).text() // strip html from alt text : 'This image has no description (ALT text) saved.'; /* var $footer = '
' + '' + 'or cancel' + '
'; */ $('
').html('

' + alt + '

').overlay({ destroyOnClose: true, autoOpen: true, closeOnBodyClick: true, size: 'medium', zIndex: 1160, closeSelector: '.lw_cancel', title: 'Image Description (ALT text)' // footer: $footer }); }; var CropDialog = /*#__PURE__*/function (_PubSub) { babelHelpers.inherits(CropDialog, _PubSub); var _super = _createSuper(CropDialog); function CropDialog(options) { var _this; babelHelpers.classCallCheck(this, CropDialog); // initialize PubSub _this = _super.call(this); // options _this.options = _.extend({ title: 'Crop image', aspect_ratio: null, custom_aspect_ratio: null, hide_aspect_ratio_menu: false, size: 'medium' }, options); _this.jcrop_api = null; _this.coords = null; _this.aspect_ratio = _this.options.aspect_ratio; _this.init(); return _this; } babelHelpers.createClass(CropDialog, [{ key: "init", value: function init() { var _this2 = this; var that = this; var html, $overlay, footer, $footer; html = '
' + '
' + '
' + '
Lock aspect ratio:' + ''; $.each(LW.image_crop_aspect_ratios, function (key, value) { html += ''; }); html += '
' + '
' + '
' + '' + ''; footer = '
' + '' + 'or cancel and close' + '
'; $footer = $(footer); $overlay = this.$overlay = $(html).overlay({ autoOpen: false, destroyOnClose: false, size: this.options.size, closeSelector: '.lw_cancel a', title: this.options.title, footer: $footer, customClass: 'lw_crop_overlay', zIndex: 1305, close: $.proxy(this._close, this) }); // show/hide aspect ratio controls if (this.options.hide_aspect_ratio_menu) { this.$overlay.find('#lw_image_crop_ar').hide(); } else { this.$overlay.find('#lw_image_crop_ar').show(); } this.$preview = $overlay.find('#lw_image_crop_preview_image'); this.$ar_checkboxes = $overlay.find('#lw_image_crop_ar input[type=checkbox]'); // save! $footer.on('click', '.btn-primary', function (e) { e.preventDefault(); that.saveCrop(); return true; }); // aspect ratio checkbox click handler $overlay.on('click', '#lw_image_crop_ar input[type=checkbox]', function () { var $this = $(this); var $label = $this.closest('label'); if ($this.prop('checked')) { // remove any other selected item $label.siblings().removeClass('selected').find('input[type=checkbox]').prop('checked', false); $label.addClass('selected'); // set jcrop aspect ratio option that.setAspectRatio($this.val()); } else { $label.removeClass('selected'); that.setAspectRatio(''); } return true; }); // a11y: map enter key to click $overlay.on('keydown', '#lw_image_crop_ar label', function (e) { switch (e.which) { case 13: // Enter $(this).find('input').click(); break; case 37: // Left Arrow $(this).prev().focus(); break; case 39: // Right Arrow $(this).next().focus(); break; } }); // set custom aspect ratio when cropper ready if (this.options.custom_aspect_ratio) { this.bind('ready', function () { if (_this2.jcrop_api) { _this2.setAspectRatio(_this2.options.custom_aspect_ratio); } }); } } // valid values are 'orig' or '\d:\d' }, { key: "setAspectRatio", value: function setAspectRatio(string_ar) { var ar = 0; this.aspect_ratio = string_ar; if (string_ar === 'orig') { ar = this.width / this.height; } else if (string_ar.match(/^\d+:\d+$/)) { ar = parseInt(string_ar.split(':')[0], 10) / parseInt(string_ar.split(':')[1], 10); } this.jcrop_api.setOptions({ aspectRatio: ar }); } }, { key: "setCropSelect", value: function setCropSelect(coords) { this.jcrop_api.setSelect(coords); } // set the crop region (called during jcrop onSelect and onChange) }, { key: "setCropCoords", value: function setCropCoords(c) { this.coords = c; this.trigger('set', [{ coords: c }]); } }, { key: "setPreviewImage", value: function setPreviewImage(url) { var preview_url, preview_width, preview_height; if (this.height >= this.width) { preview_height = this.options.size === 'large' ? 578 : 500; preview_width = Math.round(preview_height * (this.width / this.height)); } else { preview_width = this.options.size === 'large' ? 868 : 500; preview_height = Math.round(preview_width * (this.height / this.width)); } preview_url = url.replace(/\/(?=[^/]*$)/, "/width/" + preview_width + "/height/" + preview_height + "/"); this.$preview.attr('src', preview_url).width(preview_width).height(preview_height); } }, { key: "initCropper", value: function initCropper(coords) { var that = this, preview_width = this.$preview.width(), preview_height = this.$preview.height(), width_ratio = preview_width / this.width, height_ratio = preview_height / this.height, crop_coords; if (!_.isArray(coords) || coords.length !== 4) { if (preview_width > preview_height) { crop_coords = [(preview_width - preview_height) / 2, 0, (preview_width - preview_height) / 2 + preview_height, preview_height]; } else { crop_coords = [0, (preview_height - preview_width) / 2, preview_width, (preview_height - preview_width) / 2 + preview_width]; } } else { crop_coords = [Math.round(coords[0] * width_ratio), Math.round(coords[1] * height_ratio), Math.round(coords[2] * width_ratio), Math.round(coords[3] * height_ratio)]; } // initialize jcrop this.$preview.Jcrop({ aspectRatio: 0, keySupport: true, trueSize: [this.width, this.height], setSelect: crop_coords, onSelect: $.proxy(this.setCropCoords, this), onChange: $.proxy(this.setCropCoords, this), onRelease: function onRelease(c) {} }, function () { var api = that.jcrop_api = this; if (that.aspect_ratio) { that.$ar_checkboxes.each(function () { if ($(this).val() === that.aspect_ratio) { $(this).trigger('click'); } }); } // a11y: make handles keyboard focusable and add SR labels var shifted = null; // save shift key status var $handles = $('.jcrop-handle'); var $handle_container = $('.jcrop-handle').parent(); var handle_order = ['nw-resize', 'n-resize', 'ne-resize', 'w-resize', 'e-resize', 'sw-resize', 's-resize', 'se-resize']; var handle_label = ['top left corner', 'top side', 'top right corner', 'left side', 'right side', 'bottom left corner', 'bottom side', 'bottom right corner']; function moveCropHandle(which, direction) { var current = api.tellSelect(); // get current coordinates var amount_to_move = shifted ? 25 : 2; // in pixels (modified with shift key), min 2 for retina. var move_x = null, move_y = null; // set up which x/y variables we'll be moving if (which.charAt(0) == 'n') { move_y = 'y'; } else if (which.charAt(0) == 's') { move_y = 'y2'; } if (which.includes('w-')) { move_x = 'x'; } else if (which.includes('e-')) { move_x = 'x2'; } // Apply the changes switch (direction) { case 'left': if (move_x) { current[move_x] = current[move_x] - amount_to_move; } break; case 'right': if (move_x) { current[move_x] = current[move_x] + amount_to_move; } break; case 'up': if (move_y) { current[move_y] = current[move_y] - amount_to_move; } break; case 'down': if (move_y) { current[move_y] = current[move_y] + amount_to_move; } break; } if (shifted) { api.animateTo([current['x'], current['y'], current['x2'], current['y2']]); // animate to the new coords } else { api.setSelect([current['x'], current['y'], current['x2'], current['y2']]); // move to the new coords } } $handles.attr('tabindex', '0').each(function () { var which_handle = $(this).css('cursor'); // detect cursor type $(this).attr('aria-label', 'Move ' + handle_label[handle_order.indexOf(which_handle)] + ' of crop area').attr('data-handle-type', which_handle).attr('data-handle-order', handle_order.indexOf(which_handle)).addClass(which_handle).on('keydown', function (e) { switch (e.which) { case 37: // Left Arrow e.preventDefault(); moveCropHandle(which_handle, 'left'); break; case 39: // Right Arrow e.preventDefault(); moveCropHandle(which_handle, 'right'); break; case 38: // Up Arrow e.preventDefault(); moveCropHandle(which_handle, 'up'); break; case 40: // Down Arrow e.preventDefault(); moveCropHandle(which_handle, 'down'); break; } }).on('keyup keydown', function (e) { shifted = e.shiftKey; }); // track shift key }); // Re-order handles into logical tab order $handle_container.find('.jcrop-handle').sort(function (a, b) { return +a.getAttribute('data-handle-order') - +b.getAttribute('data-handle-order'); }).appendTo($handle_container); that.trigger('ready'); }); } }, { key: "open", value: function open(url, width, height, coords) { var that = this; this.width = width; this.height = height; // open the overlay and set the preview src this.$overlay.overlay('open'); // initialize jcrop when image preview finishes loading this.setPreviewImage(url); this.$preview.parent().imagesLoaded(function () { that.initCropper(coords); }); } }, { key: "saveCrop", value: function saveCrop() { var c = this.coords, coords; if (_.isPlainObject(c) && _.keys(c).length === 6) { coords = [c.x, c.y, c.x2, c.y2]; } this.trigger('save', [{ coords: coords, aspect_ratio: this.aspect_ratio }]); this.$overlay.overlay('close'); } }, { key: "_close", value: function _close() { this.coords = null; this.$ar_checkboxes.prop('checked', false); if (this.jcrop_api) { this.jcrop_api.destroy(); this.jcrop_api = null; } this.$preview.removeAttr('src'); } }]); return CropDialog; }(PubSub); LW.lib.CropDialog = CropDialog; /** * Generic cropper * @constructor * @param {integer} preview_width - width of the preview (only required if preview_height not set) * @param {integer} preview_height - height of the preview (only required if preview_width not set) * @param {string} src [null] - image src * @param {string} width [null] - image width * @param {string} height [null] - image height */ function Cropper(preview_width) { var preview_height = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; var src = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; var width = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; var height = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null; this.preview_width = preview_width; this.preview_height = preview_height; this.src = src; this.width = width; this.height = height; this.coords = null; } _.extend(Cropper.prototype, LW.lib.pubSub(), { open: function open() { var _this3 = this; // initialize on first open if (!this.crop_dialog) { this.crop_dialog = new LW.lib.CropDialog({ hide_aspect_ratio_menu: false, title: 'Crop image' }); this.crop_dialog.bind('save', function (e, data) { _this3.setCrop(data.coords); }); } this.crop_dialog.open(this.src, this.width, this.height, this.coords); }, setImage: function setImage(src, width, height) { this.src = src; this.width = width; this.height = height; this.resetCoords(); }, resetCoords: function resetCoords() { this.coords = null; }, getPreviewHeight: function getPreviewHeight(coords) { var crop_width = coords[2] - coords[0]; var crop_height = coords[3] - coords[1]; return this.preview_width * (crop_height / crop_width); }, getPreviewWidth: function getPreviewWidth(coords) { var crop_width = coords[2] - coords[0]; var crop_height = coords[3] - coords[1]; return this.preview_height * (crop_width / crop_height); }, setCrop: function setCrop(coords) { // do nothing if we have the wrong data if (!_.isArray(coords) || coords.length !== 4) { return; } this.coords = coords; var preview_width, preview_height; if (this.preview_width && !this.preview_height) { preview_width = this.preview_width; preview_height = this.getPreviewHeight(coords); } if (this.preview_height && !this.preview_width) { preview_height = this.preview_height; preview_width = this.getPreviewWidth(coords); } // trigger crop event this.trigger('crop', [{ src: this.src, preview_width: preview_width, preview_height: preview_height, width: this.width, height: this.height, coords: coords }]); } }); LW.lib.Cropper = Cropper; var toolbar = { init: function init() { var $toolbar = this.$toolbar = $('#lw-toolbar'); // do nothing if toolbar doesn't exist on pages if (!$toolbar.length) { return; } this.initGroupSwitcher(); this.addDropdownHandlers(); this.adjustToolboxColumns(); this.initSearch(); this.initMobile(); // remove hidden front/back-end elements for screen readers if ($toolbar.hasClass('lw-toolbar-backend')) { $toolbar.find('.lw-frontend-only').remove(); } else { $toolbar.find('.lw-backend-only').remove(); } // set focus on first form or search field when clicking Toolbox / Your Content / Search Content LW.eventHub.bind('toolbarOpen', function (e, $nav_item) { if ($nav_item.find('.lw-dropdown-menu .lw-group-switcher, .lw-dropdown-menu a, .lw-dropdown-menu input, .lw-dropdown-menu textarea').first().is('input,textarea')) { // if first field is input or textarea $nav_item.find('.lw-dropdown-menu input, .lw-dropdown-menu textarea').first().trigger('focus'); // focus it } return true; }); $toolbar.show(); }, initGroupSwitcher: function initGroupSwitcher() { if (LW.group_fullname && LW.group_title_native !== LW.group_fullname) { // if page group is different from your group $('.current-page-group').addClass('visible').html('Current Page Owner: ' + LW.group_fullname + '').show(); } else { $('.current-page-group').hide(); } var $filter = $('#lw-group-filter').attr('role', 'application'); $('.lw-group-switcher .no-results').hide(); $('.lw-group-switcher li').attr('data-show-filtered', 'true'); // start filters as all showing // add aria-live region $('
').appendTo($('.lw-group-switcher')); // if top groups are set, move to top if (!_.isEmpty(LW.top_groups)) { $('
    ').insertBefore('.lw-group-switcher div ul'); _.each(LW.top_groups, function (group_id) { $('.lw-group-switcher div.all-groups').find('a[href$="group=' + group_id + '"]').parent().appendTo($('.lw-group-switcher div.all-groups ul.top-groups')); $('.lw-group-switcher div.recent-groups').find('a[href$="group=' + group_id + '"]').parent().appendTo($('.lw-group-switcher div.recent-groups ul.top-groups')); }); } function setActiveGroup($li) { var $dropdown = $('.lw-group-switcher div.lw-dropdown-menu-inner'), dropdown_height = $dropdown.outerHeight(), current_scroll = $dropdown.scrollTop(), li_position = $li.position().top, li_offset = $li.offset().top; $li.addClass('active'); if (li_position + current_scroll < 160 && current_scroll > 0) { // if focused item is near top, scroll to top $dropdown.scrollTop(0); } else if (li_offset < 40 || li_offset > dropdown_height + 30) { // if focused item isn't in view, scroll to it $li[0].scrollIntoView(); } $('.lw-group-switcher div.system-groups a').prepend('System group: '); // set aria-live announcement $('#sr-group-switcher').text('Press Enter to switch to group: ' + $li.text()); } $filter.on('focusin input', function () { // filter to only show results matching what has been typed var filter_text = $(this).val().toLowerCase(), $dropdown = $('.lw-group-switcher div.lw-dropdown-menu'); if (!$dropdown.attr('data-width')) { $dropdown.attr('data-width', $dropdown.outerWidth()).css('width', $dropdown.outerWidth()); // lock dropdown width once you start using it to avoid jitter } if (filter_text.length < 1) { $('.lw-group-switcher li').removeClass('active').show().attr('data-show-filtered', 'true'); $('.lw-group-switcher div.recent-groups').show(); $('.lw-group-switcher .no-results').hide(); $dropdown.attr('data-width', '').css('width', ''); $('#sr-group-switcher').text('Switch to a group by starting to type it\'s name, or use the tab or arrow keys to choose from all your groups.'); $('.current-page-group.visible').show(); } else { $('.lw-group-switcher div.recent-groups').hide(); $('.lw-group-switcher div.recent-groups li').attr('data-show-filtered', 'false'); $('.lw-group-switcher li').removeClass('active'); $('.current-page-group.visible').hide(); // don't show page owner when filtering $('.lw-group-switcher div.all-groups li, .lw-group-switcher div.system-groups li').each(function () { if ($(this).text().toLowerCase().search(filter_text) > -1) { $(this).show().attr('data-show-filtered', 'true'); } else { $(this).hide().attr('data-show-filtered', 'false'); } }); if ($('.lw-group-switcher li:visible').length) { $('.lw-group-switcher .no-results').hide(); setActiveGroup($('.lw-group-switcher li:visible:first')); } else { $('.lw-group-switcher .no-results').show(); $('#sr-group-switcher').text('No groups found matching text: "' + filter_text + '"'); } } }); $filter.on('keydown', function (e) { // filter to go to active result when Enter is pressed var filter_text = $(this).val().toLowerCase(), current_index = $('[data-show-filtered=true]').index($('.active')), number_showing = $('[data-show-filtered=true]').length, new_index; switch (e.which) { case 13: // Enter e.preventDefault(); var href = $('.lw-group-switcher li.active a').attr('href'); if (href) { // go to link if it exists document.location.href = href; } break; case 38: // Up Arrow case 40: // Down Arrow e.preventDefault(); if (filter_text.length < 1 && $('.lw-group-switcher li.active').length < 1) { // if none selected new_index = e.which == 40 ? 0 : number_showing - 1; // pick first or last item based on arrow setActiveGroup($('[data-show-filtered=true]').eq(new_index)); } else if (number_showing > 1) { if (e.which == 40) { new_index = current_index + 1 == number_showing ? 0 : current_index + 1; } else { new_index = current_index - 1 == -1 ? number_showing - 1 : current_index - 1; } setActiveGroup($('[data-show-filtered=true]').eq(new_index)); $('[data-show-filtered=true]').eq(current_index).removeClass('active'); } break; } }); $('.lw-group-switcher li a').on('focusin', function (e) { // match focus and active status $('.lw-group-switcher li').removeClass('active'); setActiveGroup($(this).parent()); }); // add handler if user has switch perms var $body = $('body'); if (!$body.hasClass('has_core_admin') && !$body.hasClass('has_core_switch') && !$body.hasClass('has_core_submissions') && !$body.hasClass('has_custom_core_switch')) { // remove dropdown functionality if user is not a group switcher $('.lw-group-switcher').removeClass('lw-dropdown-menu').addClass('lw-not-switchable'); $('.lw-group-switcher > a').contents().unwrap(); $('.lw-group-switcher .lw-dropdown-menu').remove(); } }, initSearch: function initSearch() { $('form#content-search').on('submit', function (e) { e.preventDefault(); var $this = $(this); var search = $this.find('#search_query').val(); var params = $('body.admin-user').length || LW.pages_editor && LW.pages_editor.is_admin ? '&results[]=1&results[]=2&results[]=4' : '&results[]=1'; document.location.href = '/livewhale/?search=' + search + params + ($('body.calendar').length ? '&types[]=events' : ''); return true; }); }, initMobile: function initMobile() { var $toolbar = this.$toolbar; var $collapse = $toolbar.find('#lw-toolbar-collapse'); $toolbar.on('click', '.lw-navbar-toggle', function (e) { if (!$collapse.is(':visible')) { e.stopPropagation(); $collapse.addClass('open'); $(this).attr('aria-expanded', 'true'); // add handler to close menu on next click $('body').one('click', function () { $collapse.removeClass('open'); $('.lw-navbar-toggle').attr('aria-expanded', 'false'); }); } }); }, addDropdownHandlers: function addDropdownHandlers() { var $toolbar = this.$toolbar; // disable Bootstrap dropdown functionality - in case site employs BS // $toolbar.find('.lw-dropdown-toggle').addClass('disabled'); var closeDropdowns = function closeDropdowns() { // remove close on click handler from body $(document).off('click', closeDropdowns); // remove close on escape handler from dropdowns $toolbar.find('.lw-dropdown').off('keydown'); // remove backdrop added in mobile context $toolbar.find('.lw-dropdown-backdrop').remove(); // close all toolbar dropdowns $toolbar.find('.lw-dropdown-toggle').each(function () { var $this = $(this); var $parent = $this.closest('.lw-dropdown'); if (!$parent.hasClass('open')) { return; } $this.attr('aria-expanded', 'false'); $parent.removeClass('open'); }); }; // prevent clicks within dropdown from closing menu $toolbar.on('click', '.lw-dropdown-menu', function (e) { e.stopPropagation(); }); $toolbar.on('click', '.lw-dropdown-toggle', function (e) { e.preventDefault(); e.stopPropagation(); var $this = $(this); var $parent = $this.closest('.lw-dropdown'); if (!$parent.hasClass('open')) { closeDropdowns(); if ('ontouchstart' in document.documentElement && !$parent.closest('.navbar-nav').length) { // if mobile we use a backdrop because click events don't delegate $(document.createElement('div')).addClass('dropdown-backdrop').insertAfter($(this)).on('click', closeDropdowns); } $(document).on('click', closeDropdowns); // Close dropdown on escape key $parent.on('keydown', function (e) { if (e.keyCode === 27) { closeDropdowns(); $parent.find('.lw-dropdown-toggle').trigger('focus'); } }); $this.trigger('focus').attr('aria-expanded', 'true'); $parent.toggleClass('open'); LW.eventHub.trigger('toolbarOpen', [$parent]); } else { closeDropdowns(); } }); }, adjustToolboxColumns: function adjustToolboxColumns() { var $dropdown = this.$toolbar.find('.lw-toolbox .lw-dropdown-menu'); var $columns = $dropdown.find('> .row > div'); // remove empty columns $columns.each(function () { var $this = $(this); if ($this.find('> ul').is(':empty')) { $this.remove(); } }); var col_cnt = $columns.length; var menu_width = 600; $dropdown.css('min-width', menu_width * (col_cnt / 3) + 'px'); var col_class; switch (col_cnt) { case 4: col_class = 'col-sm-3'; break; case 3: col_class = 'col-sm-4'; break; case 2: col_class = 'col-sm-6'; break; default: col_class = 'col-sm-12'; break; } // remove old column class and add new $columns.removeClass(function (index, class_name) { return (class_name.match(/(^|\s)col-sm-\S+/g) || []).join(' '); }).addClass(col_class); } }; // on doc ready $(function () { // add whiteout div LW.whiteout = $('