Files
2025-12-19 00:26:08 -08:00

148 lines
3.2 KiB
JavaScript

//------------------------------------------------------------------------------
// IPS JS: HIERARCHICAL DISPLAY FUNCTIONS
// (c) 2005 Invision Power Services, Inc.
// http://www.invisionpower.com
// Matt Mecham (13/12/05)
//------------------------------------------------------------------------------
function hierarchical()
{
/**
* Class variables.
*
* @var string Cookie name
* @var string Refresh display URL
* @var string First part of the image ID title string
*/
this.cookie_name = '';
this.location_url = '';
this.toggle_image_id_name = 'hier-toggle';
/**
* INIT: Grabs IDs from the HTML and
* sets up the various functions
*/
this.init = function()
{
//-----------------------------------------
// Do DIVs
//-----------------------------------------
var divs = document.getElementsByTagName('IMG');
//----------------------------------
// Sort through and grab links
//----------------------------------
for ( var i = 0 ; i < divs.length ; i++ )
{
try
{
if ( ! divs[i].id )
{
continue;
}
}
catch(error)
{
continue;
}
var divid = divs[i].id;
var divname = ipsclass.get_name_from_text( divid );
var divnum = ipsclass.get_id_from_text( divid );
//----------------------------------
// Work with it?
//----------------------------------
if ( divname == this.toggle_image_id_name )
{
divs[i].style.cursor = 'pointer';
divs[i].toggle_image_id_name = this.toggle_image_id_name;
divs[i].location_url = this.location_url;
divs[i].cookie_name = this.cookie_name;
divs[i].toggle_id = divnum;
divs[i].onclick = hierarchical_events.prototype.toggle_folder;
}
}
};
}
/**
* Wrapper function
*/
function hierarchical_events()
{
}
/**
* Toggle Folder Action
* @param object Event Object
*/
hierarchical_events.prototype.toggle_folder = function( e )
{
//-----------------------------------------
// Check..
//-----------------------------------------
if ( ! this.cookie_name )
{
return false;
}
//-----------------------------------------
// Cancel event bubbling
//-----------------------------------------
e = ipsclass.cancel_bubble(e, true);
//-----------------------------------------
// Set up
//-----------------------------------------
var saved = new Array();
var clean = new Array();
var found_id = 0;
//-----------------------------------
// Get any saved info
//-----------------------------------
if ( tmp = ipsclass.my_getcookie( this.cookie_name ) )
{
saved = tmp.split(",");
}
//-----------------------------------
// Remove bit if exists
//-----------------------------------
for( i = 0 ; i < saved.length; i++ )
{
if ( saved[i] != this.toggle_id && saved[i] != "" )
{
clean[clean.length] = saved[i];
}
else if ( saved[i] == this.toggle_id )
{
found_id = 1;
}
}
//-----------------------------------
// Not found the ID, so add it
//-----------------------------------
if ( ! found_id )
{
clean[ clean.length ] = this.toggle_id;
}
ipsclass.my_setcookie( this.cookie_name, clean.join(','), 1 );
ipsclass.location_jump( this.location_url, true );
};