mirror of
https://github.com/WordPress/WordPress.git
synced 2024-08-20 12:54:00 +02:00
git-svn-id: http://svn.automattic.com/wordpress/trunk@8304 1a063a9b-81f0-0310-95a4-ce76da25c4cd
29 lines
684 B
JavaScript
29 lines
684 B
JavaScript
jQuery(function($) {
|
|
var gallerySortable;
|
|
var gallerySortableInit = function() {
|
|
gallerySortable = $('#media-items').sortable( {
|
|
items: '.media-item',
|
|
placeholder: 'sorthelper',
|
|
axis: 'y',
|
|
distance: 2,
|
|
update: galleryReorder
|
|
} );
|
|
}
|
|
|
|
// When an update has occurred, adjust the order for each item
|
|
var galleryReorder = function(e, sort) {
|
|
jQuery.each(sort['element'].sortable('toArray'), function(i, id) {
|
|
jQuery('#' + id + ' .menu_order input')[0].value = (1+i);
|
|
});
|
|
}
|
|
|
|
// initialize sortable
|
|
gallerySortableInit();
|
|
});
|
|
|
|
jQuery(document).ready(function($){
|
|
$('.menu_order_input').each(function(){
|
|
if ( this.value == '0' ) this.value = '';
|
|
});
|
|
});
|