Version 2.3.6
This commit is contained in:
1 parent
a3bb603c96
commit
19b38c7c74
764 files changed
+143731
-118164
No files matched your search
@@ -0,0 +1,311 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// IPS JS: Cell select
|
||||
// (c) 2005 Invision Power Services, Inc.
|
||||
// http://www.invisionpower.com
|
||||
// Matt Mecham (29/11/05)
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
var _cell_select;
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// Initiate object
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function cell_select()
|
||||
{
|
||||
/**
|
||||
* CSS: Table cell row OFF
|
||||
*
|
||||
* @var INT
|
||||
*/
|
||||
this.css_row_off = 'tablerow1';
|
||||
|
||||
/**
|
||||
* CSS: Table cell row ON
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
this.css_row_on = 'tablerow2selected';
|
||||
|
||||
/**
|
||||
* String: TR row ID part
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
this.row_tr_id = 'arow';
|
||||
|
||||
/**
|
||||
* String: Checkbox ID part
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
this.row_checkbox_id = 'acid';
|
||||
|
||||
/**
|
||||
* String: ID name of toggle all box
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
this.toggle_all_name = 'cellselect-cball';
|
||||
|
||||
/**
|
||||
* String: ID of toggle all box
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
this.toggle_all_id = '';
|
||||
|
||||
/**
|
||||
* String: Flag to see if we have a toggle all box
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
this.toggle_all_flag = 0;
|
||||
|
||||
/**
|
||||
* Array: Selected IDs array
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
this.selected_ids = new Array();
|
||||
|
||||
/**
|
||||
* Array: Total possible cbs
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
this.total_ids = 0;
|
||||
|
||||
/**
|
||||
* Store CSS rows for the original row
|
||||
*/
|
||||
this.store_css_row = new Array();
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// Initiate object
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
cell_select.prototype.init = function()
|
||||
{
|
||||
//----------------------------------
|
||||
// Check for toggle all box
|
||||
//----------------------------------
|
||||
|
||||
try
|
||||
{
|
||||
this.toggle_all_id = document.getElementById( this.toggle_all_name );
|
||||
this.toggle_all_flag = 1;
|
||||
this.toggle_all_id.checked = false;
|
||||
}
|
||||
catch(error)
|
||||
{
|
||||
this.toggle_all_flag = 0;
|
||||
}
|
||||
|
||||
//----------------------------------
|
||||
// Check checked boxes
|
||||
//----------------------------------
|
||||
|
||||
var checkboxes = document.getElementsByTagName('INPUT');
|
||||
|
||||
_cell_select = this;
|
||||
|
||||
//----------------------------------
|
||||
// Sort through and grab links
|
||||
//----------------------------------
|
||||
|
||||
for ( var i = 0 ; i < checkboxes.length ; i++ )
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( ! checkboxes[i].id )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( checkboxes[i].getAttribute('type') != 'checkbox' )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
catch(error)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var cbid = checkboxes[i].id;
|
||||
var cbname = cbid.replace( /^(.*)-(\d+)$/, "$1" );
|
||||
var cbnum = this.get_id_from_text( checkboxes[i].id );
|
||||
|
||||
//----------------------------------
|
||||
// Work with it?
|
||||
//----------------------------------
|
||||
|
||||
if ( cbname == this.row_checkbox_id )
|
||||
{
|
||||
if ( checkboxes[i].getAttribute('checked') || checkboxes[i].checked )
|
||||
{
|
||||
this.row_change_color( cbnum );
|
||||
this.selected_ids[ cbnum ] = 1;
|
||||
this.total_ids++;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.selected_ids[ cbnum ] = 0;
|
||||
this.total_ids++;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// Toggle all row has been clicked
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
cell_select.prototype.row_toggle_all = function()
|
||||
{
|
||||
//----------------------------------
|
||||
// Using a toggle all?
|
||||
//----------------------------------
|
||||
|
||||
if ( ! this.toggle_all_flag )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//----------------------------------
|
||||
// Grab initial state
|
||||
//----------------------------------
|
||||
|
||||
var checkstate = this.toggle_all_id.checked;
|
||||
|
||||
//----------------------------------
|
||||
// Spread the love
|
||||
//----------------------------------
|
||||
|
||||
var checkboxes = document.getElementsByTagName('INPUT');
|
||||
|
||||
//----------------------------------
|
||||
// Sort through and grab links
|
||||
//----------------------------------
|
||||
|
||||
for ( var i = 0 ; i < checkboxes.length ; i++ )
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( ! checkboxes[i].id )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( checkboxes[i].getAttribute('type') != 'checkbox' )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
catch(error)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var cbid = checkboxes[i].id;
|
||||
var cbname = cbid.replace( /^(.*)-(\d+)$/, "$1" );
|
||||
var cbnum = this.get_id_from_text( checkboxes[i].id );
|
||||
|
||||
//----------------------------------
|
||||
// Work with it?
|
||||
//----------------------------------
|
||||
|
||||
if ( cbname == this.row_checkbox_id )
|
||||
{
|
||||
checkboxes[i].checked = checkstate;
|
||||
this.selected_ids[ cbnum ] = checkstate ? 0 : 1;
|
||||
this.row_change_color( cbnum );
|
||||
this.selected_ids[ cbnum ] = checkstate ? 1 : 0;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// A row has been clicked
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
cell_select.prototype.row_clicked = function( row_id )
|
||||
{
|
||||
//----------------------------------
|
||||
// Change color
|
||||
//----------------------------------
|
||||
|
||||
this.row_change_color( row_id );
|
||||
|
||||
//----------------------------------
|
||||
// Reset flag
|
||||
//----------------------------------
|
||||
|
||||
this.selected_ids[ row_id ] = ( this.selected_ids[ row_id ] ) ? 0 : 1;
|
||||
|
||||
//----------------------------------
|
||||
// Test toggle all box
|
||||
//----------------------------------
|
||||
|
||||
if ( this.toggle_all_flag )
|
||||
{
|
||||
var c = 0;
|
||||
|
||||
for( var i in this.selected_ids )
|
||||
{
|
||||
if ( this.selected_ids[i] )
|
||||
{
|
||||
c++;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------
|
||||
// Number of 'on' not equal to total?
|
||||
//----------------------------------
|
||||
|
||||
if ( c != this.total_ids )
|
||||
{
|
||||
this.toggle_all_id.checked = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.toggle_all_id.checked = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// Change color
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
cell_select.prototype.row_change_color = function( row_id )
|
||||
{
|
||||
//----------------------------------
|
||||
// Get Row TDs...
|
||||
//----------------------------------
|
||||
|
||||
var tds = document.getElementById( this.row_tr_id + '-' + row_id ).getElementsByTagName('TD');
|
||||
|
||||
//----------------------------------
|
||||
// Sort through and grab links
|
||||
//----------------------------------
|
||||
|
||||
var _cell = ( this.store_css_row[ row_id ] ) ? this.store_css_row[ row_id ] : this.css_row_off;
|
||||
|
||||
for ( var i = 0 ; i < tds.length ; i++ )
|
||||
{
|
||||
tds[i].className = ( this.selected_ids[ row_id ] ) ? _cell : this.css_row_on;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// Grab ID from string
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
cell_select.prototype.get_id_from_text = function( id )
|
||||
{
|
||||
return id.replace( /.*(?:\-|_)(\d+)/, "$1" );
|
||||
};
|
||||
Reference in new issue
Block a user