Plugin Directory

Changeset 3105619

Timestamp:
06/21/2024 10:48:33 AM (7 weeks ago)
Author:
whiteshadow
Message:

Make the "drag items to the top level" feature available in the free version.

This was previously limited to the Pro version, now it also works in the free version. Basically, a user can move a submenu item to the top menu level by dragging it to the bottom of the top level menu list.

Location:
admin-menu-editor/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • admin-menu-editor/trunk/includes/editor-page.php

    r2980009 r3105619  
    234234        </div>
    235235
     236
    236237        <?php do_action('admin_menu_editor-container', 'menu'); ?>
    237238    </div>
  • admin-menu-editor/trunk/js/menu-editor.js

    r3105004 r3105619  
    50685068     *************************************************************************/
    50695069
    5070     if (wsEditorData.wsMenuEditorPro) {
    5071         //Allow the user to drag sub-menu items to the top level.
    5072         $('#ws_top_menu_dropzone').droppable({
    5073             'hoverClass' : 'ws_dropzone_hover',
    5074             'activeClass' : 'ws_dropzone_active',
    5075 
    5076             'accept' : (function(thing){
    5077                 return thing.hasClass('ws_item');
    5078             }),
    5079 
    5080             'drop' : (function(event, ui){
    5081                 const firstColumn = menuPresenter.getColumnImmediate(1);
    5082                 if (!firstColumn) {
    5083                     return;
    5084                 }
    5085                 const nextColumn = menuPresenter.getColumnImmediate(firstColumn.level + 1);
    5086 
    5087                 const droppedItemData = readItemState(ui.draggable);
    5088                 const newItemNodes = firstColumn.pasteItem(droppedItemData, null);
    5089 
    5090                 //If the item was originally a top level menu, also move its original submenu items.
    5091                 if ((getFieldValue(droppedItemData, 'parent') === null) && (newItemNodes.submenu)) {
    5092                     const droppedItemFile = getFieldValue(droppedItemData, 'file');
    5093                     const nearbyItems = $(ui.draggable).siblings('.ws_item');
    5094                     nearbyItems.each(function() {
    5095                         const containerNode = $(this),
    5096                             submenuItem = containerNode.data('menu_item');
    5097 
    5098                         //Was this item originally a child of the dragged menu?
    5099                         if (getFieldValue(submenuItem, 'parent') === droppedItemFile) {
    5100                             nextColumn.pasteItem(submenuItem, null, newItemNodes.submenu);
    5101                             if ( !event.ctrlKey ) {
    5102                                 menuPresenter.destroyItem(containerNode);
    5103                             }
     5070    //Allow the user to drag sub-menu items to the top level.
     5071    $('#ws_top_menu_dropzone').droppable({
     5072        'hoverClass' : 'ws_dropzone_hover',
     5073        'activeClass' : 'ws_dropzone_active',
     5074
     5075        'accept' : (function(thing){
     5076            return thing.hasClass('ws_item');
     5077        }),
     5078
     5079        'drop' : (function(event, ui){
     5080            const firstColumn = menuPresenter.getColumnImmediate(1);
     5081            if (!firstColumn) {
     5082                return;
     5083            }
     5084            const nextColumn = menuPresenter.getColumnImmediate(firstColumn.level + 1);
     5085
     5086            const droppedItemData = readItemState(ui.draggable);
     5087            const newItemNodes = firstColumn.pasteItem(droppedItemData, null);
     5088
     5089            //If the item was originally a top level menu, also move its original submenu items.
     5090            if ((getFieldValue(droppedItemData, 'parent') === null) && (newItemNodes.submenu)) {
     5091                const droppedItemFile = getFieldValue(droppedItemData, 'file');
     5092                const nearbyItems = $(ui.draggable).siblings('.ws_item');
     5093                nearbyItems.each(function() {
     5094                    const containerNode = $(this),
     5095                        submenuItem = containerNode.data('menu_item');
     5096
     5097                    //Was this item originally a child of the dragged menu?
     5098                    if (getFieldValue(submenuItem, 'parent') === droppedItemFile) {
     5099                        nextColumn.pasteItem(submenuItem, null, newItemNodes.submenu);
     5100                        if ( !event.ctrlKey ) {
     5101                            menuPresenter.destroyItem(containerNode);
    51045102                        }
    5105                     });
    5106                 }
    5107 
    5108                 if ( !event.ctrlKey ) {
    5109                     menuPresenter.destroyItem(ui.draggable);
    5110                 }
    5111             })
    5112         });
    5113     }
     5103                    }
     5104                }
     5105            }
     5106
     5107           
     5108               
     5109            }
     5110        })
     5111    }
    51145112
    51155113    /******************************************************************
Note: See TracChangeset for help on using the changeset viewer.