Add sorting to gallery. Props AaronCampbell. fixes #6988
git-svn-id: http://svn.automattic.com/wordpress/trunk@7974 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
5f8d0313a8
commit
8f2a589e21
|
@ -63,7 +63,7 @@ ul#widget-list li.widget-list-item h4.widget-title {
|
|||
color: #000;
|
||||
}
|
||||
|
||||
ul.widget-control-list .sorthelper {
|
||||
.sorthelper {
|
||||
background-color: #ccf3fa;
|
||||
}
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ ul#widget-list li.widget-list-item h4.widget-title {
|
|||
color: #000;
|
||||
}
|
||||
|
||||
ul.widget-control-list .sorthelper {
|
||||
.sorthelper {
|
||||
background-color: #ccf3fa;
|
||||
}
|
||||
|
||||
|
|
|
@ -216,6 +216,7 @@ abbr.required {
|
|||
}
|
||||
|
||||
#media-upload .media-item {
|
||||
cursor:move;
|
||||
position: relative;
|
||||
border-bottom-width: 1px;
|
||||
border-bottom-style: solid;
|
||||
|
|
|
@ -199,6 +199,8 @@ function media_upload_form_handler() {
|
|||
$post['post_title'] = $attachment['post_title'];
|
||||
if ( isset($attachment['post_excerpt']) )
|
||||
$post['post_excerpt'] = $attachment['post_excerpt'];
|
||||
if ( isset($attachment['menu_order']) )
|
||||
$post['menu_order'] = $attachment['menu_order'];
|
||||
|
||||
$post = apply_filters('attachment_fields_to_save', $post, $attachment);
|
||||
|
||||
|
@ -399,6 +401,7 @@ function media_upload_gallery() {
|
|||
$errors = $return;
|
||||
}
|
||||
|
||||
wp_enqueue_script('admin-gallery');
|
||||
return wp_iframe( 'media_upload_gallery_form', $errors );
|
||||
}
|
||||
|
||||
|
@ -535,6 +538,10 @@ function get_attachment_fields_to_edit($post, $errors = null) {
|
|||
</script>\n",
|
||||
'helps' => __('Enter a link URL or click above for presets.'),
|
||||
),
|
||||
'menu_order' => array(
|
||||
'label' => __('Order'),
|
||||
'value' => $edit_post->menu_order
|
||||
),
|
||||
);
|
||||
|
||||
foreach ( get_attachment_taxonomies($post) as $taxonomy ) {
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
jQuery(function($) {
|
||||
var gallerySortable;
|
||||
var gallerySortableInit = function() {
|
||||
gallerySortable = $('#media-items').sortable( {
|
||||
items: '.media-item',
|
||||
placeholder: 'sorthelper',
|
||||
update: galleryReorder
|
||||
} );
|
||||
}
|
||||
|
||||
// When an update has occurred, adjust the order for each item
|
||||
var galleryReorder = function(e, sort) {
|
||||
jQuery.each(sort['instance'].toArray(), function(i, id) {
|
||||
jQuery('#' + id + ' .menu_order input')[0].value = i;
|
||||
});
|
||||
}
|
||||
|
||||
// initialize sortable
|
||||
gallerySortableInit();
|
||||
});
|
Loading…
Reference in New Issue