2008-05-21 20:29:46 +02:00
|
|
|
jQuery(function($) {
|
|
|
|
var gallerySortable;
|
|
|
|
var gallerySortableInit = function() {
|
|
|
|
gallerySortable = $('#media-items').sortable( {
|
|
|
|
items: '.media-item',
|
|
|
|
placeholder: 'sorthelper',
|
2008-07-10 05:49:52 +02:00
|
|
|
axis: 'y',
|
|
|
|
distance: 2,
|
2008-05-21 20:29:46 +02:00
|
|
|
update: galleryReorder
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
|
|
|
|
// When an update has occurred, adjust the order for each item
|
|
|
|
var galleryReorder = function(e, sort) {
|
2008-07-05 07:01:28 +02:00
|
|
|
jQuery.each(sort['element'].sortable('toArray'), function(i, id) {
|
2008-07-10 05:49:52 +02:00
|
|
|
jQuery('#' + id + ' .menu_order input')[0].value = (1+i);
|
2008-05-21 20:29:46 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// initialize sortable
|
|
|
|
gallerySortableInit();
|
|
|
|
});
|
2008-07-10 05:49:52 +02:00
|
|
|
|
|
|
|
jQuery(document).ready(function($){
|
|
|
|
$('.menu_order_input').each(function(){
|
|
|
|
if ( this.value == '0' ) this.value = '';
|
|
|
|
});
|
|
|
|
});
|