Update edit link pages. Link categories need work.

git-svn-id: http://svn.automattic.com/wordpress/trunk@6695 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-01-31 20:04:54 +00:00
parent c1a034bcbe
commit 1266b9c53f
5 changed files with 145 additions and 54 deletions

View File

@ -30,26 +30,80 @@ function xfn_check($class, $value = '', $deprecated = '') {
}
?>
<div class="wrap">
<h2><?php echo $heading ?></h2>
<?php echo $form ?>
<?php wp_nonce_field($nonce_action); ?>
<div class="wrap">
<div id="poststuff">
<div id="moremeta">
<div id="grabit" class="dbx-group">
<fieldset id="categorydiv" class="dbx-box">
<h3 class="dbx-handle"><?php _e('Categories') ?></h3>
<div class="dbx-content">
<p id="jaxcat"><?php wp_nonce_field( 'add-link-category', '_ajax_nonce', false ); ?></p>
<ul id="categorychecklist" class="list:link-category"><?php dropdown_link_categories(get_option('default_link_category')); ?></ul>
<div id="namediv">
<h3><?php _e('Name') ?></h3>
<div class="inside">
<input type="text" name="link_name" size="30" tabindex="1" value="<?php echo $link->link_name; ?>" id="link_name" />
</div>
</div>
</fieldset>
<fieldset class="dbx-box">
<h3 class="dbx-handle"><?php _e('Target') ?></h3>
<div class="dbx-content">
<div id="addressdiv">
<h3><?php _e('Address') ?></h3>
<div class="inside">
<input type="text" name="link_url" size="30" tabindex="1" value="<?php echo $link->link_url; ?>" id="link_url" />
</div>
</div>
<div id="descriptiondiv">
<h3><?php _e('Description') ?></h3>
<div class="inside">
<input type="text" name="link_description" size="30" tabindex="1" value="<?php echo $link->link_description; ?>" id="link_description" />
</div>
</div>
<div id="submitpost">
<p class="submit">
<input type="submit" name="save" value="<?php _e('Save'); ?>" style="font-weight: bold;" tabindex="4" />
</p>
</div>
<div id="linkcategorydiv" class="postbox <?php echo postbox_classes('linkcategorydiv'); ?>">
<h3><?php _e('Categories') ?></h3>
<div class="inside">
<div id="category-adder" class="wp-hidden-children">
<h4><a id="category-add-toggle" href="#category-add"><?php _e( '+ Add New Category' ); ?></a></h4>
<p id="category-add" class="wp-hidden-child">
<input type="text" name="newcat" id="newcat" class="form-required form-input-tip" value="<?php _e( 'New category name' ); ?>" />
<?php wp_dropdown_categories( array( 'hide_empty' => 0, 'name' => 'newcat_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => __('Parent category') ) ); ?>
<input type="button" id="category-add-sumbit" class="add:categorychecklist:linkcategorydiv button" value="<?php _e( 'Add' ); ?>" />
<?php wp_nonce_field( 'add-link-category', '_ajax_nonce', false ); ?>
<span id="category-ajax-response"></span>
</p>
</div>
<ul id="category-tabs">
<li class="ui-tabs-selected"><a href="#categories-all"><?php _e( 'All Categories' ); ?></a></li>
<li class="wp-no-js-hidden"><a href="#categories-pop"><?php _e( 'Most Used' ); ?></a></li>
</ul>
<div id="categories-all" class="ui-tabs-panel">
<ul id="categorychecklist" class="list:category categorychecklist form-no-clear">
<?php dropdown_link_categories(); ?>
</ul>
</div>
<div id="categories-pop" class="ui-tabs-panel" style="display: none;">
<ul id="categorychecklist-pop" class="categorychecklist form-no-clear">
<?php wp_popular_categories_checklist(); ?>
</ul>
</div>
</div>
</div>
<h2><?php _e('Advanced Options'); ?></h2>
<div id="linktargetdiv" class="postbox <?php echo postbox_classes('linktargetdiv'); ?>">
<h3><?php _e('Target') ?></h3>
<div class="inside">
<label for="link_target_blank" class="selectit">
<input id="link_target_blank" type="radio" name="link_target" value="_blank" <?php echo(($link->link_target == '_blank') ? 'checked="checked"' : ''); ?> />
<code>_blank</code></label>
@ -60,47 +114,23 @@ function xfn_check($class, $value = '', $deprecated = '') {
<input id="link_target_none" type="radio" name="link_target" value="" <?php echo(($link->link_target == '') ? 'checked="checked"' : ''); ?> />
<?php _e('none') ?></label>
</div>
</fieldset>
</div>
<fieldset class="dbx-box">
<h3 class="dbx-handle"><?php _e('Visible') ?></h3>
<div class="dbx-content">
<div id="linkvisiblediv" class="postbox <?php echo postbox_classes('linkvisiblediv'); ?>">
<h3><?php _e('Visible') ?></h3>
<div class="inside">
<label for="link_visible_yes" class="selectit">
<input id="link_visible_yes" type="radio" name="link_visible" <?php if ($link->link_visible == 'Y') echo "checked='checked'"; ?> value="Y" />
<?php _e('Yes') ?></label>
<label for="link_visible_no" class="selectit">
<input id="link_visible_no" type="radio" name="link_visible" <?php if ($link->link_visible == 'N') echo "checked='checked'"; ?> value="N" />
<?php _e('No') ?></label>
</div>
</fieldset>
</div>
</div>
<table class="editform" width="100%" cellspacing="2" cellpadding="5">
<tr>
<th scope="row" valign="top"><label for="link_name"><?php _e('Name:') ?></label></th>
<td><input type="text" name="link_name" id="link_name" value="<?php echo $link->link_name; ?>" style="width: 95%" /></td>
</tr>
<tr>
<th width="20%" scope="row" valign="top"><label for="link_url"><?php _e('Address:') ?></label></th>
<td width="80%"><input type="text" name="link_url" id="link_url" value="<?php echo $link->link_url; if ( empty( $link->link_url ) ) echo 'http://'; ?>" style="width: 95%" /></td>
</tr>
<tr>
<th scope="row" valign="top"><label for="link_description"><?php _e('Description:') ?></label></th>
<td><input type="text" name="link_description" id="link_description" value="<?php echo $link->link_description; ?>" style="width: 95%" /></td>
</tr>
</table>
<p class="submit">
<input type="submit" name="submit" value="<?php echo $submit_text ?>" />
</p>
<div id="advancedstuff" class="dbx-group" >
<fieldset id="xfn" class="dbx-box">
<h3 class="dbx-handle"><?php _e('Link Relationship (XFN)') ?></h3>
<div class="dbx-content">
<div id="linkxfndiv" class="postbox <?php echo postbox_classes('linkxfndiv'); ?>">
<h3><?php _e('Link Relationship (XFN)') ?></h3>
<div class="inside">
<table class="editform" width="100%" cellspacing="2" cellpadding="5">
<tr>
<th width="20%" scope="row"><?php _e('rel:') ?></th>
@ -209,11 +239,11 @@ function xfn_check($class, $value = '', $deprecated = '') {
</tr>
</table>
</div>
</fieldset>
</div>
<fieldset id="advanced" class="dbx-box">
<h3 class="dbx-handle"><?php _e('Advanced') ?></h3>
<div class="dbx-content">
<div id="linkadvanceddiv" class="postbox <?php echo postbox_classes('linkadvanceddiv'); ?>">
<h3><?php _e('Advanced') ?></h3>
<div class="inside">
<table class="editform" width="100%" cellspacing="2" cellpadding="5">
<tr>
<th width="20%" scope="row"><?php _e('Image Address:') ?></th>
@ -242,7 +272,6 @@ function xfn_check($class, $value = '', $deprecated = '') {
</tr>
</table>
</div>
</fieldset>
</div>
<?php if ( $link_id ) : ?>
@ -253,6 +282,11 @@ function xfn_check($class, $value = '', $deprecated = '') {
<?php else: ?>
<input type="hidden" name="action" value="add" />
<?php endif; ?>
</div>
</div>
</div>
</form>
</div>

54
wp-admin/js/link.js Normal file
View File

@ -0,0 +1,54 @@
addLoadEvent( function() {
// postboxes
add_postbox_toggles();
// category tabs
var categoryTabs = jQuery('#category-tabs').tabs();
// Ajax Cat
var newCat = jQuery('#newcat').one( 'focus', function() { jQuery(this).val( '' ).removeClass( 'form-input-tip' ) } );
jQuery('#category-add-sumbit').click( function() { newCat.focus(); } );
var newCatParent = false;
var newCatParentOption = false;
var noSyncChecks = false; // prophylactic. necessary?
var syncChecks = function() {
if ( noSyncChecks )
return;
noSyncChecks = true;
var th = jQuery(this);
var c = th.is(':checked');
var id = th.val().toString();
jQuery('#in-category-' + id + ', #in-popular-category-' + id).attr( 'checked', c );
noSyncChecks = false;
};
var catAddAfter = function( r, s ) {
if ( !newCatParent ) newCatParent = jQuery('#newcat_parent');
if ( !newCatParentOption ) newCatParentOption = newCatParent.find( 'option[value=-1]' );
jQuery(s.what + ' response_data', r).each( function() {
var t = jQuery(jQuery(this).text());
t.find( 'label' ).each( function() {
var th = jQuery(this);
var val = th.find('input').val();
var id = th.find('input')[0].id
jQuery('#' + id).change( syncChecks );
if ( newCatParent.find( 'option[value=' + val + ']' ).size() )
return;
var name = jQuery.trim( th.text() );
var o = jQuery( '<option value="' + parseInt( val, 10 ) + '"></option>' ).text( name );
newCatParent.prepend( o );
} );
newCatParentOption.attr( 'selected', true );
} );
};
jQuery('#categorychecklist').wpList( {
alt: '',
response: 'category-ajax-response',
addAfter: catAddAfter
} );
jQuery('#category-add-toggle').click( function() {
jQuery(this).parents('div:first').toggleClass( 'wp-hidden-children' );
categoryTabs.tabsClick( 1 );
return false;
} );
jQuery('.categorychecklist :checkbox').change( syncChecks ).filter( ':checked' ).change();
});

View File

@ -11,8 +11,9 @@ wp_reset_vars(array('action', 'cat_id', 'linkurl', 'name', 'image',
'submit', 'order_by', 'links_show_cat_id', 'rating', 'rel',
'notes', 'linkcheck[]'));
if ( current_user_can( 'manage_categories' ) )
wp_enqueue_script( 'ajaxcat' );
wp_enqueue_script('link');
wp_enqueue_script('thickbox');
require('admin-header.php');
?>

View File

@ -83,8 +83,9 @@ switch ($action) {
break;
case 'edit' :
if ( current_user_can( 'manage_categories' ) )
wp_enqueue_script( 'ajaxlinkcat' );
wp_enqueue_script('link');
wp_enqueue_script('thickbox');
$parent_file = 'link-manager.php';
$submenu_file = 'link-manager.php';
$title = __('Edit Link');

View File

@ -142,6 +142,7 @@ class WP_Scripts {
'cancel' => __('Cancel'),
'requestFile' => get_option( 'siteurl' ) . '/wp-admin/admin-ajax.php',
) );
$this->add( 'link', '/wp-admin/js/link.js', array('jquery-ui-tabs', 'wp-lists', 'postbox'), '20080131' );
$this->add( 'media-upload', '/wp-admin/js/media-upload.js', false, '20080109' );
$this->localize( 'upload', 'uploadL10n', array(
'browseTitle' => attribute_escape(__('Browse your files')),