Sha256: e3aa8942a1a1aba2d37aef61f44fc800cf6231de17bf82cdf467a79380511c5e

Contents?: true

Size: 1.57 KB

Versions: 32

Compression:

Stored size: 1.57 KB

Contents

(function($){
		  
jQuery.fn.alreadyGrid = function( /* Object literal */ options )
{
  opts = $j.extend( $j.fn.alreadyGrid.defaults, options );
  
  // Set up check box events
  checkAllBox = $j( '.' + opts.check_all_class );
  checkboxes = $j( '.' + opts.checkbox_class );
  $j( 'document' ).ready( updateSelecteds );
  checkAllBox.click( checkAllClicked );
  checkboxes.click( checkboxClicked );
  
  return jQuery;
}
  
/* *************** public *************** */

jQuery.fn.alreadyGrid.defaults = 
{ 
  paginate: true,
  checkboxes: false,
  checkbox_class: 'chk',
  check_all_class: 'checkAll'
}; 

/* *************** private *************** */

checkAllClicked = function( /* jquery Event */ e )
{
  if( $j( this ).is(':checked') )
  {
    //$j( '.' + opts.checkbox_class ).click();
    checkboxes.attr( 'checked', true );
    checkboxes.parent().parent().addClass( 'selected' );
  }
  else
  {
    checkboxes.attr( 'checked', false );
    checkboxes.parent().parent().removeClass( 'selected' );
  }
};

checkboxClicked = function( /* jquery Event */ e )
{
  if( $j( this ).is(':checked') )
    $j( this ).parent().parent().addClass( 'selected' );
  else
  {
    $j( this ).parent().parent().removeClass( 'selected' );
    if( checkAllBox.is(':checked') )
    {
      checkAllBox.attr( 'checked', false );  
    }      
  }
};

/* Used after load to update selected based on check boxes when the 
 * grid loads. */
updateSelecteds = function( /* jquery Event */ e )
{
  var checkboxes = $j( "." + opts.checkbox_class + "[checked]");
  checkboxes.parent().parent().addClass( 'selected' );
};

})(jQuery);

Version data entries

32 entries across 12 versions & 2 rubygems

Version Path
midas-g_already_grid-1.0.0 rails_generators/already_grid_assets/templates/jquery-already_grid-0.1.js
midas-g_already_grid-1.0.0 rails_generators/already_grid_assets/templates/jquery-already_grid-0.1.min.js
midas-g_already_grid-1.0.1 rails_generators/already_grid_assets/templates/jquery-already_grid-0.1.js
midas-g_already_grid-1.0.1 rails_generators/already_grid_assets/templates/jquery-already_grid-0.1.min.js
midas-g_already_grid-1.0.2 rails_generators/already_grid_assets/templates/jquery-already_grid-0.1.min.js
midas-g_already_grid-1.0.2 rails_generators/already_grid_assets/templates/jquery-already_grid-0.1.js
midas-g_already_grid-1.0.3 rails_generators/already_grid_assets/templates/jquery-already_grid-0.1.js
midas-g_already_grid-1.0.3 rails_generators/already_grid_assets/templates/jquery-already_grid-0.1.min.js
midas-g_already_grid-1.0.4 rails_generators/already_grid_assets/templates/jquery-already_grid-0.1.js
midas-g_already_grid-1.0.4 rails_generators/already_grid_assets/templates/jquery-already_grid-0.1.min.js
g_already_grid-1.1.0 rails_generators/already_grid_assets/templates/jquery-already_grid-0.1.min.js
g_already_grid-1.1.0 lib/generators/already_grid_assets/templates/jquery-already_grid-0.1.js
g_already_grid-1.1.0 lib/generators/already_grid_assets/templates/jquery-already_grid-0.1.min.js
g_already_grid-1.1.0 rails_generators/already_grid_assets/templates/jquery-already_grid-0.1.js
g_already_grid-1.0.10 lib/generators/already_grid_assets/templates/jquery-already_grid-0.1.js
g_already_grid-1.0.10 lib/generators/already_grid_assets/templates/jquery-already_grid-0.1.min.js
g_already_grid-1.0.10 rails_generators/already_grid_assets/templates/jquery-already_grid-0.1.js
g_already_grid-1.0.10 rails_generators/already_grid_assets/templates/jquery-already_grid-0.1.min.js
g_already_grid-1.0.9 rails_generators/already_grid_assets/templates/jquery-already_grid-0.1.min.js
g_already_grid-1.0.9 rails_generators/already_grid_assets/templates/jquery-already_grid-0.1.js