No Description

um-admin-nav-menu.js 1.0KB

123456789101112131415161718192021222324252627282930313233343536
  1. jQuery(document).ready(function ($) {
  2. var template = wp.template( 'um-nav-menus-fields' );
  3. $( document ).on( 'menu-item-added', function ( e, $menuMarkup ) {
  4. var id = $( $menuMarkup ).attr('id').substr(10);
  5. var template_content = template({
  6. menuItemID: id,
  7. restriction_data:{
  8. um_nav_public:0,
  9. um_nav_roles:[]
  10. }
  11. });
  12. if ( $( $menuMarkup ).find( 'fieldset.field-move' ).length > 0 ) {
  13. $( $menuMarkup ).find( 'fieldset.field-move' ).before( template_content );
  14. } else {
  15. $( $menuMarkup ).find( '.menu-item-actions' ).before( template_content );
  16. }
  17. });
  18. $( 'ul#menu-to-edit > li' ).each( function(){
  19. var id = $(this).attr('id').substr(10);
  20. var template_content = template({
  21. menuItemID: id,
  22. restriction_data: um_menu_restriction_data[ id ]
  23. });
  24. if ( $( this ).find( 'fieldset.field-move' ).length > 0 ) {
  25. $( this ).find( 'fieldset.field-move' ).before( template_content );
  26. } else {
  27. $( this ).find( '.menu-item-actions' ).before( template_content );
  28. }
  29. });
  30. });