home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Blogs / wordpress2.6.exe / wordpress2.6 / wp-admin / js / gallery.js < prev    next >
Encoding:
JavaScript  |  2008-07-10  |  684 b   |  29 lines

  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. });
  29.