Cộng Đồng MyBB Việt Nam
[Tutorial] Hướng dẫn sửa lỗi edit popup menu bị missing hoặc offset quá nhiều - Phiên bản in

+- Cộng Đồng MyBB Việt Nam (https://congdong.mybb.vn)
+-- Diễn đàn: Thư Viện MyBB (https://congdong.mybb.vn/Forum-thu-vien-mybb)
+--- Diễn đàn: Tutorials (https://congdong.mybb.vn/Forum-tutorials)
+--- Chủ đề: [Tutorial] Hướng dẫn sửa lỗi edit popup menu bị missing hoặc offset quá nhiều (/Thread-tutorial-huong-dan-sua-loi-edit-popup-menu-bi-missing-hoac-offset-qua-nhieu)



Hướng dẫn sửa lỗi edit popup menu bị missing hoặc offset quá nhiều - JLP423 - 03-07-2025

Trong phiên bản mybb 1.8, cái file jquery.plugins.min.js không thiết lập sai vị trí của popup của cái edit button nếu diễn đàn được đặt trong position:relative, nên khi bạn bấm nút edit, bạn sẽ ko thấy cái quickedit popup đâu.
Đây là 2 cách sửa nhanh, hy vọng 1 trong 2 sẽ giúp bạn giải quyết vấn đề

Cách 1: Thêm đoạn này vào headerinclude:
 
Code: 
<script>
  
  (function($){
    var current_popup = '';
    var PopupMenu = function(el, close_in_popupmenu)
    {
        var el = $(el);
        var popup = this;
        var popup_menu = $("#" + el.attr('id') + "_popup");
        if(typeof close_in_popupmenu == 'undefined')
        {
            var close_in_popupmenu = true;
        }
        // Opening Popup
        this.open = function(e)
        {
            e.preventDefault();

            if(popup_menu.is(':visible'))
            {
                popup.close();
                return;
            }

            // Setup popup menu
            var offset = el.offset();
            offset.top += el.outerHeight();

            // We only adjust if it goes out of the page (?)
            if((el.offset().left + popup_menu.outerWidth()) > $(window).width())
                var adjust = popup_menu.outerWidth() - el.outerWidth();
            else
                var adjust = 0;

            popup_menu.css({
                position: 'absolute',
            });

            popup_menu.show();

            // Closes the popup if we click outside the button (this doesn't seem to work properly - couldn't find any solutions that actually did - if we click the first item on the menu)
            // Credits: http://stackoverflow.com/questions/1160880/detect-click-outside-element
            $('body, .popup_item').bind('click.close_popup', function(e) {
                if(close_in_popupmenu)
                {
                    if($(e.target).closest("#" + el.attr('id')).length == 0) {
                        popup.close();
                    }
                }
                else
                {
                    if($(e.target).closest("#" + el.attr('id')).length == 0 && $(e.target).closest("#" + el.attr('id') + '_popup').length == 0) {
                        popup.close();
                    }
                }
            });
        }
        this.close = function(e)
        {
            popup_menu.hide();
        }
    }
    $.fn.popupMenu = function(close_in_popupmenu)
    {
        return this.each(function()
        {
            var popup = new PopupMenu(this, close_in_popupmenu);
            $(this).click(popup.open);
        });
    }
})(jQuery);
</script>

Nếu cách trên không thành, thì Cách 2:
  1. Xóa hoặc đổi tên file jscripts/jquery.plugins.min.js
  2. Tạo một copy của file jscripts/jquery.plugins.js và đổi tên thành jscripts/jquery.plugins.min.js
  3. Mở file vừa tạo và đổi tên và tìm
    Code: 
                // Setup popup menu
                var offset = el.offset();
                offset.top += el.outerHeight();

  4. Thay thế bằng
    Code: 
                // Setup popup menu
                var offset = el.offset();
                // WoM fix edit popup menu start
                var el_parent = el.get(0).parentNode;
                var popup_parent = popup_menu.get(0).parentNode;
                if (el_parent === popup_parent)
                {
                  offset = el.position();
                }
                // WoM fix edit popup menu end
                offset.top += el.outerHeight();

  5. Lưu file lại

Nguồn: https://community.mybb.com/thread-160142-post-1197221.html#pid1197221