# bbp-core/2.4.0/assets/frontend/js/custom.js

Forumax – AI Powered Advanced Community Forum Plugin, version 2.4.0. 174 lines.

- Page: https://pluginprobe.com/plugins/bbp-core/2.4.0/code/assets/frontend/js/custom.js
- Raw: https://pluginprobe.com/plugins/bbp-core/2.4.0/raw/assets/frontend/js/custom.js
- Modified: 2026-06-10T13:02:40+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/bbp-core/2.4.0/code/assets/frontend/js/custom.js#L10-L20`.

```javascript
; (function ($) {

    $(document).ready(function () {

        // Initialize frmx-nice-select on all bbPress/Forumax select elements
        if (typeof $.fn.frmxNiceSelect === 'function') {
            // Initialize on all forum form selects
            $('.bbp-form select, .bbp-topic-form select, .bbp-reply-form select, .bbp-forum-form select').frmxNiceSelect();

            // Initialize on specific select elements (only if they are actual select elements)
            $('select#bbp_forum_id, select#bbp_stick_topic_select, select#bbp_topic_status_select, select#sort-replies').frmxNiceSelect();
            $('select#bbp_destination_topic, select#bbp_forum_parent_id, select#bbp_forum_status, select#bbp_forum_visibility').frmxNiceSelect();

            // Initialize on admin dropdown menus (only select elements)
            $('select.bbp-admin-dropdown-menu').frmxNiceSelect();

            // Enhance admin dropdown items with data-action attributes and SVG icons.
            frmxEnhanceAdminDropdowns();
        }

        /**
         * Inject data-action attributes and SVG icons into NiceSelect admin dropdown items.
         *
         * NiceSelect does not copy data-action from <option> elements, so we cross-reference
         * by index and manually apply them to the rendered .option list items.
         */
        function frmxEnhanceAdminDropdowns() {
            var iconMap = {
                edit:    '<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/></svg>',
                move:    '<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="5 9 2 12 5 15"/><polyline points="9 5 12 2 15 5"/><polyline points="15 19 12 22 9 19"/><polyline points="19 9 22 12 19 15"/><line x1="2" y1="12" x2="22" y2="12"/><line x1="12" y1="2" x2="12" y2="22"/></svg>',
                split:   '<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M16 3h5v5"/><path d="M8 3H3v5"/><path d="M12 22v-8.3a4 4 0 0 0-1.172-2.872L3 3"/><path d="m15 9 6-6"/></svg>',
                close:   '<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="11" width="18" height="11" rx="2" ry="2"/><path d="M7 11V7a5 5 0 0 1 10 0v4"/></svg>',
                stick:   '<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="12" y1="17" x2="12" y2="22"/><path d="M5 17h14v-1.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V6h1a2 2 0 0 0 0-4H8a2 2 0 0 0 0 4h1v4.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24Z"/></svg>',
                merge:   '<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M8 3H5a2 2 0 0 0-2 2v3"/><path d="M21 8V5a2 2 0 0 0-2-2h-3"/><path d="M3 16v3a2 2 0 0 0 2 2h3"/><path d="M16 21h3a2 2 0 0 0 2-2v-3"/></svg>',
                trash:   '<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/><line x1="10" y1="11" x2="10" y2="17"/><line x1="14" y1="11" x2="14" y2="17"/></svg>',
                spam:    '<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="4.93" y1="4.93" x2="19.07" y2="19.07"/></svg>',
                approve: '<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/><polyline points="9 12 11 14 15 10"/></svg>',
                reply:   '<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 17 4 12 9 7"/><path d="M20 18v-2a4 4 0 0 0-4-4H4"/></svg>'
            };

            $('.bbp-admin-links-dropdown').each(function () {
                var $dropdown = $(this);
                var $select   = $dropdown.find('select');
                var $niceSelect = $dropdown.find('.frmx-nice-select');

                if (!$select.length || !$niceSelect.length) {
                    return;
                }

                var $options    = $select.find('option');
                var $listItems  = $niceSelect.find('.list .option');

                $listItems.each(function (i) {
                    var $li      = $(this);
                    var $origOpt = $options.eq(i);
                    var action   = $origOpt.data('action');

                    if (!action) {
                        return;
                    }

                    // Apply data-action to the NiceSelect list item for CSS targeting.
                    $li.attr('data-action', action);

                    // Convert separator items into visual dividers.
                    if (action === 'separator') {
                        $li.addClass('frmx-dropdown-separator').html('<hr/>');
                        return;
                    }

                    // Prepend SVG icon if available.
                    if (iconMap[action]) {
                        var text = $li.text();
                        $li.html('<span class="frmx-dropdown-icon">' + iconMap[action] + '</span><span class="frmx-dropdown-label">' + text + '</span>');
                    }
                });
            });
        }

        // Expose for re-use after AJAX re-initializations.
        window.frmxEnhanceAdminDropdowns = frmxEnhanceAdminDropdowns;

        // Toggle dropdown - using frmx- prefixed classes to avoid theme conflicts
        $('.forumax-sort-lists .frmx-dropdown-toggle').on('click', function (e) {
            e.preventDefault();
            e.stopPropagation(); // prevent document click

            const $currentMenu = $(this).siblings('.frmx-dropdown-menu');

            // Close all others
            $('.forumax-sort-lists .frmx-dropdown-menu').not($currentMenu).removeClass('frmx-show');

            // Toggle current
            $currentMenu.toggleClass('frmx-show');
            
            // Update aria-expanded attribute
            $(this).attr('aria-expanded', $currentMenu.hasClass('frmx-show'));
        });

        // Allow clicks inside dropdown (including links)
        $('.forumax-sort-lists .frmx-dropdown-menu').on('click', function (e) {
            // Only prevent propagation if not clicking a link
            if (!$(e.target).is('a')) {
                e.stopPropagation();
            }
        });

        // Click outside → close all dropdowns
        $(document).on('click', function () {
            $('.forumax-sort-lists .frmx-dropdown-menu').removeClass('frmx-show');
            $('.forumax-sort-lists .frmx-dropdown-toggle').attr('aria-expanded', 'false');
        });

        // Forumax Social Share Modal
        $(document).on('click', '.modal-toggle[data-id="forumax_share_modal"]', function (e) {
            e.preventDefault();
            $('#forumax_share_modal').fadeIn();
        });

        $(document).on('click', '#forumax_share_modal .forumax-close, #forumax_share_modal .forumax-modal-overlay', function () {
            $('#forumax_share_modal').fadeOut();
        });

        // Forumax Copy Link Logic
        $('#forumax_share_modal .share-this-doc').on('click', function () {
            var copyText = $(this).closest('.copy-url-wrap').find('input.word-wrap');
            var $sourceToast = $(this).siblings('.forumax-link-copied-wrap');

            // Remove any existing active toasts to prevent duplicates
            $('.forumax-link-copied-wrap.active-body-toast').remove();

            // Clone to body to escape modal stacking context
            var $toast = $sourceToast.clone();
            $toast.addClass('active-body-toast');
            $toast.appendTo('body');

            copyText.select();
            document.execCommand("copy");

            // Feedback: Show toast
            $toast.fadeIn().css('display', 'flex');

            // Hide after 3 seconds AND remove
            setTimeout(function () {
                $toast.fadeOut(function () {
                    $(this).remove();
                });
            }, 3000);
        });

        // Close Toast manually
        $('body').on('click', '.forumax-link-copied-wrap .close-notice', function () {
            $(this).closest('.forumax-link-copied-wrap').fadeOut(function () {
                $(this).remove();
            });
        });

        // Open specific social links in a popup window
        $('#forumax_share_modal .social-links a').on('click', function (e) {
            var href = $(this).attr('href');
            // If it's a mailto link, let it behave normally
            if (href.indexOf('mailto:') === 0) {
                return;
            }
            e.preventDefault();
            var width = 600;
            var height = 400;
            var left = (screen.width - width) / 2;
            var top = (screen.height - height) / 2;
            window.open(href, 'sharer', 'toolbar=0,status=0,width=' + width + ',height=' + height + ',top=' + top + ',left=' + left);
        });
    });

})(jQuery);
```
