]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/js/gallery.js
Wordpress 2.6.2
[autoinstalls/wordpress.git] / wp-admin / js / gallery.js
1 jQuery(function($) {
2         var gallerySortable;
3         var gallerySortableInit = function() {
4                 gallerySortable = $('#media-items').sortable( {
5                         items: '.media-item',
6                         placeholder: 'sorthelper',
7                         axis: 'y',
8                         distance: 2,
9                         update: galleryReorder
10                 } );
11         }
12
13         // When an update has occurred, adjust the order for each item
14         var galleryReorder = function(e, sort) {
15                 jQuery.each(sort['element'].sortable('toArray'), function(i, id) {
16                         jQuery('#' + id + ' .menu_order input')[0].value = (1+i);
17                 });
18         }
19
20         // initialize sortable
21         gallerySortableInit();
22 });
23
24 jQuery(document).ready(function($){
25         $('.menu_order_input').each(function(){
26                 if ( this.value == '0' ) this.value = '';
27         });
28 });