Changeset 1664

Show
Ignore:
Timestamp:
08/26/08 22:49:30 (3 months ago)
Author:
mdawaffe
Message:

use wp-lists for forum adds. allow setting of forum_parent during ajax add. Fixes #946

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/bb-admin/admin-ajax.php

    r1618 r1664  
    174174        $forums_count = 2; // Hack 
    175175 
     176        $data = bb_forum_row( $forum_id, false, true ); 
     177 
     178        $forum = get_forum( $forum_id ); 
     179        if ( $forum->forum_parent ) { 
     180                $siblings = get_forums( $forum->forum_parent ); 
     181                $last_sibling = array_pop( $siblings ); 
     182                if ( $last_sibling->forum_id == $forum_id ) 
     183                        $last_sibling = array_pop( $siblings ); 
     184                if ( $last_sibling ) { 
     185                        $position = "forum-$last_sibling->forum_id"; 
     186                } else { 
     187                        $position = "+forum-$forum->forum_parent"; 
     188                        $data = "<ul id='forum-root-$forum->forum_parent' class='list-block holder'>$data</ul>"; 
     189                } 
     190        } else { 
     191                $position = 1; 
     192        } 
     193 
    176194        $x = new WP_Ajax_Response( array( 
    177195                'what' => 'forum', 
    178196                'id' => $forum_id, 
    179                 'data' => bb_forum_row( $forum_id, false, true ) 
     197                'data' => $data, 
     198                'position' => $position 
    180199        ) ); 
    181200        $x->send(); 
  • trunk/bb-admin/admin-functions.php

    r1649 r1664  
    683683        $action = $forum_id ? 'update' : 'add'; 
    684684?> 
    685 <form method="post" id="<?php echo $action; ?>-forum" action="<?php bb_uri('bb-admin/bb-forum.php', null, BB_URI_CONTEXT_FORM_ACTION + BB_URI_CONTEXT_BB_ADMIN); ?>"
     685<form method="post" id="<?php echo $action; ?>-forum" action="<?php bb_uri('bb-admin/bb-forum.php', null, BB_URI_CONTEXT_FORM_ACTION + BB_URI_CONTEXT_BB_ADMIN); ?>" class="add:forum-list:"
    686686        <fieldset> 
    687687        <table><col /><col style="width: 80%" /> 
     
    698698                </tr> 
    699699                <tr id="forum-parent-row"><th scope="row"><label for="forum_parent"><?php _e('Forum Parent:'); ?></label></th> 
    700                         <td><?php bb_forum_dropdown( array('cut_branch' => $forum_id, 'id' => 'forum_parent', 'none' => true, 'selected' => $forum_id ? get_forum_parent( $forum_id ) : 0, 'disable_categories' => 0) ); ?></td> 
     700                        <td><?php bb_forum_dropdown( array( 
     701                                        'cut_branch' => $forum_id, 
     702                                        'id' => 'forum_parent', 
     703                                        'none' => true, 
     704                                        'selected' => $forum_id ? get_forum_parent( $forum_id ) : 0, 
     705                                        'disable_categories' => 0 
     706                        ) ); ?></td> 
    701707                </tr> 
    702708                <tr id="forum-position-row"><th scope="row"><label for="forum-order"><?php _e('Position:'); ?></label></th> 
  • trunk/bb-admin/content-forums.php

    r1616 r1664  
    7171 
    7272<?php if ( bb_forums( 'type=list&walker=BB_Walker_ForumAdminlistitems' ) ) : ?> 
    73 <ul id="the-list" class="list-block holder widefat"> 
     73<ul id="forum-list" class="list:forum list-block holder widefat"> 
    7474        <li class="thead list-block"><div class="list-block"><?php _e('Name &#8212; Description'); ?></div></li> 
    7575<?php while ( bb_forum() ) : ?> 
  • trunk/bb-admin/js/content-forums.js

    r1616 r1664  
    2121 
    2222        recolor: function() { 
    23                 $('#the-list li:gt(0)').css( 'background-color', '' ).filter(':even').removeClass('alt').end().filter(':odd').addClass('alt'); 
     23                $('#forum-list li:gt(0)').css( 'background-color', '' ).filter(':even').removeClass('alt').end().filter(':odd').addClass('alt'); 
    2424        }, 
    2525 
     
    4444        serialize: function () { 
    4545                h = ''; 
    46                 $('#the-list, #the-list ul').each( function() { 
     46                $('#forum-list, #forum-list ul').each( function() { 
    4747                        var i = this.id; 
    4848                        $('#' + i + '> .forum').each( function () { 
    4949                                if (h.length > 0) 
    5050                                        h += '&'; 
    51                                 var root = 'the-list' == i ? 0 : i.split('-')[2]; 
     51                                var root = 'forum-list' == i ? 0 : i.split('-')[2]; 
    5252                                h += 'root[' + root + '][]=' + this.id.split('-')[1]; 
    5353                        } ); 
     
    6464                this.editText = div.childNodes[0].nodeValue; 
    6565                div = null; 
    66                 $('#the-list').after("<p class='submit'><input type='button' id='forum-order-edit' value='" + this.editText + "' /></p>"); 
     66                $('#forum-list').after("<p class='submit'><input type='button' id='forum-order-edit' value='" + this.editText + "' /></p>"); 
    6767 
    68                 $('#forum-parent-row, #forum-position-row').remove(); 
    69  
    70                 $('#add-forum').submit( function() { 
    71                         theList.alt = 'alt'; 
    72                         theList.showLink = 0; 
    73                         theList.addComplete = function() { 
    74                                 if ( bbSortForums.saveText == $('#forum-order-edit').val() ) { 
    75                                         var last = $('#the-list li:last').find('div.alignright').after(bbSortForums.handle).end()[0]; 
    76                                         $('#the-list').SortableAddItem(last); 
    77                                 } 
    78                         } 
    79                         theList.ajaxAdder( 'forum', 'add-forum' ); 
    80                         return false; 
    81                 } ); 
     68                $('#forum-position-row').remove(); 
    8269 
    8370                $('#forum-order-edit').toggle( function() { 
    8471                        $(this).val(bbSortForums.saveText); 
    85                         $('#the-list li:gt(0) div.alignright').after(bbSortForums.handle); 
    86                         $('#the-list').Sortable( bbSortForums.sortCfg ); 
     72                        $('#forum-list li:gt(0) div.alignright').after(bbSortForums.handle); 
     73                        $('#forum-list').Sortable( bbSortForums.sortCfg ); 
    8774                }, function() { 
    8875                        $(this).val(bbSortForums.editText); 
     
    9077 
    9178                        var hash = bbSortForums.serialize(); 
    92                         hash += '&' + $.SortSerialize('the-list').hash.replace(/the-list/g, 'order').replace(/forum-/g, '') 
    93                         $('#the-list').SortableDestroy(); 
     79                        hash += '&' + $.SortSerialize('forum-list').hash.replace(/forum-list/g, 'order').replace(/forum-/g, '') 
     80                        $('#forum-list').SortableDestroy(); 
    9481 
    9582                        $.post( 
     
    142129bbSortForums.init(); 
    143130 
     131$('#forum-list').wpList(); 
     132 
    144133} ); 
  • trunk/bb-admin/style.css

    r1651 r1664  
    754754} 
    755755 
    756 ul#the-list.list-block
     756ul#the-list.list-block, ul#forum-list.list-block
    757757        padding: 0; 
    758758} 
  • trunk/bb-includes/js/wp-lists.js

    r1511 r1664  
    270270                                s.pos = s.pos.substr(1); 
    271271                                ba = 'before'; 
     272                        } else if ( '+' == s.pos.substr(0,1) ) { 
     273                                s.pos = s.pos.substr(1); 
     274                                ba = 'append'; 
    272275                        } 
    273276                        var ref = list.find( '#' + s.pos ); 
  • trunk/bb-includes/script-loader.php

    r1616 r1664  
    1515                'broken' => __('An unidentified error has occurred.') 
    1616        ) ); 
    17         $scripts->add( 'wp-lists',         $scripts->base_url . 'js/wp-lists.js', array('wp-ajax-response','jquery-color'), '20080411' ); 
     17        $scripts->add( 'wp-lists',         $scripts->base_url . 'js/wp-lists.js', array('wp-ajax-response','jquery-color'), '20080826' ); 
    1818        $scripts->localize( 'wp-lists', 'wpListL10n', array( 
    1919                'url' => $scripts->base_url_admin . 'admin-ajax.php' 
     
    3232        )); 
    3333        $scripts->add( 'profile-edit',   $scripts->base_url . 'js/profile-edit.js', array('password-strength-meter'), '20080721' ); 
    34         $scripts->add( 'content-forums', $scripts->base_url_admin . 'js/content-forums.js', array('listman', 'interface'), '20080801' ); 
     34        $scripts->add( 'content-forums', $scripts->base_url_admin . 'js/content-forums.js', array('wp-lists', 'interface'), '20080826' ); 
    3535        $scripts->localize( 'content-forums', 'bbSortForumsL10n', array( 
    3636                'handleText' => __('drag'),