Resources/public/js/jquery.columnmanager.iri.js
author cavaliet
Wed, 07 Dec 2011 17:19:10 +0100
changeset 54 ec51b9f4695f
permissions -rwxr-xr-x
Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
54
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
     1
/*
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
     2
 * jQuery columnManager plugin
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
     3
 * Version: 0.2.5
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
     4
 *
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
     5
 * Copyright (c) 2007 Roman Weich
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
     6
 * http://p.sohei.org
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
     7
 *
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
     8
 * Dual licensed under the MIT and GPL licenses 
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
     9
 * (This means that you can choose the license that best suits your project, and use it accordingly):
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    10
 *   http://www.opensource.org/licenses/mit-license.php
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    11
 *   http://www.gnu.org/licenses/gpl.html
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    12
 *
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    13
 * Changelog: 
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    14
 * v 0.2.5 - 2008-01-17
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    15
 *	-change: added options "show" and "hide". with these functions the user can control the way to show or hide the cells
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    16
 *	-change: added $.fn.showColumns() and $.fn.hideColumns which allows to explicitely show or hide any given number of columns
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    17
 * v 0.2.4 - 2007-12-02
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    18
 *	-fix: a problem with the on/off css classes when manually toggling columns which were not in the column header list
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    19
 *	-fix: an error in the createColumnHeaderList function incorectly resetting the visibility state of the columns
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    20
 *	-change: restructured some of the code
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    21
 * v 0.2.3 - 2007-12-02
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    22
 *	-change: when a column header has no text but some html markup as content, the markup is used in the column header list instead of "undefined"
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    23
 * v 0.2.2 - 2007-11-27
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    24
 *	-change: added the ablity to change the on and off CSS classes in the column header list through $().toggleColumns()
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    25
 *	-change: to avoid conflicts with other plugins, the table-referencing data in the column header list is now stored as an expando and not in the class name as before
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    26
 * v 0.2.1 - 2007-08-14
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    27
 *	-fix: handling of colspans didn't work properly for the very first spanning column
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    28
 *	-change: altered the cookie handling routines for easier management
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    29
 * v 0.2.0 - 2007-04-14
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    30
 *	-change: supports tables with colspanned and rowspanned cells now
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    31
 * v 0.1.4 - 2007-04-11
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    32
 *	-change: added onToggle option to specify a custom callback function for the toggling over the column header list
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    33
 * v 0.1.3 - 2007-04-05
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    34
 *	-fix: bug when saving the value in a cookie
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    35
 *	-change: toggleColumns takes a number or an array of numbers as argument now
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    36
 * v 0.1.2 - 2007-04-02
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    37
 * 	-change: added jsDoc style documentation and examples
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    38
 * 	-change: the column index passed to toggleColumns() starts at 1 now (conforming to the values passed in the hideInList and colsHidden options)
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    39
 * v 0.1.1 - 2007-03-30
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    40
 * 	-change: changed hideInList and colsHidden options to hold integer values for the column indexes to be affected
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    41
 *	-change: made the toggleColumns function accessible through the jquery object, to toggle the state without the need for the column header list
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    42
 *	-fix: error when not finding the passed listTargetID in the dom
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    43
 * v 0.1.0 - 2007-03-27
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    44
 */
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    45
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    46
(function($) 
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    47
{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    48
	var defaults = {
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    49
		listTargetID : null,
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    50
		onClass : '',
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    51
		offClass : '',
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    52
		hideInList: [],
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    53
		colsHidden: [],
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    54
		saveState: false,
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    55
		onToggle: null,
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    56
		show: function(cell){
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    57
			showCell(cell);
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    58
		},
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    59
		hide: function(cell){
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    60
			hideCell(cell);
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    61
		}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    62
	};
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    63
	
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    64
	var idCount = 0;
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    65
	var cookieName = 'columnManagerC';
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    66
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    67
	/**
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    68
	 * Saves the current state for the table in a cookie.
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    69
	 * @param {element} table	The table for which to save the current state.
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    70
	 */
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    71
	var saveCurrentValue = function(table)
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    72
	{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    73
		var val = '', i = 0, colsVisible = table.cMColsVisible;
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    74
		if ( table.cMSaveState && table.id && colsVisible && $.cookie )
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    75
		{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    76
			for ( ; i < colsVisible.length; i++ )
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    77
			{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    78
				val += ( colsVisible[i] == false ) ? 0 : 1;
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    79
			}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    80
			$.cookie(cookieName + table.id, val, {expires: 9999});
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    81
		}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    82
	};
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    83
	
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    84
	/**
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    85
	 * Hides a cell.
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    86
	 * It rewrites itself after the browsercheck!
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    87
	 * @param {element} cell	The cell to hide.
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    88
	 */
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    89
	var hideCell = function(cell)
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    90
	{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    91
		if ( jQuery.browser.msie )
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    92
		{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    93
			(hideCell = function(c)
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    94
			{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    95
				c.style.setAttribute('display', 'none');
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    96
			})(cell);
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    97
		}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    98
		else
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
    99
		{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   100
			(hideCell = function(c)
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   101
			{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   102
				c.style.display = 'none';
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   103
			})(cell);
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   104
		}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   105
	};
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   106
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   107
	/**
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   108
	 * Makes a cell visible again.
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   109
	 * It rewrites itself after the browsercheck!
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   110
	 * @param {element} cell	The cell to show.
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   111
	 */
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   112
	var showCell = function(cell)
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   113
	{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   114
		if ( jQuery.browser.msie )
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   115
		{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   116
			(showCell = function(c)
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   117
			{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   118
				c.style.setAttribute('display', 'block');
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   119
			})(cell);
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   120
		}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   121
		else
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   122
		{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   123
			(showCell = function(c)
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   124
			{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   125
				c.style.display = 'table-cell';
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   126
			})(cell);
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   127
		}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   128
	};
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   129
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   130
	/**
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   131
	 * Returns the visible state of a cell.
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   132
	 * It rewrites itself after the browsercheck!
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   133
	 * @param {element} cell	The cell to test.
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   134
	 */
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   135
	var cellVisible = function(cell)
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   136
	{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   137
		if ( jQuery.browser.msie )
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   138
		{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   139
			return (cellVisible = function(c)
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   140
			{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   141
				return c.style.getAttribute('display') != 'none';
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   142
			})(cell);
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   143
		}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   144
		else
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   145
		{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   146
			return (cellVisible = function(c)
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   147
			{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   148
				return c.style.display != 'none';
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   149
			})(cell);
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   150
		}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   151
	};
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   152
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   153
	/**
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   154
	 * Returns the cell element which has the passed column index value.
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   155
	 * @param {element} table	The table element.
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   156
	 * @param {array} cells		The cells to loop through.
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   157
	 * @param {integer} col	The column index to look for.
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   158
	 */
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   159
	var getCell = function(table, cells, col)
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   160
	{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   161
		for ( var i = 0; i < cells.length; i++ )
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   162
		{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   163
			if ( cells[i].realIndex === undefined ) //the test is here, because rows/cells could get added after the first run
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   164
			{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   165
				fixCellIndexes(table);
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   166
			}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   167
			if ( cells[i].realIndex == col )
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   168
			{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   169
				return cells[i];
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   170
			}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   171
		}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   172
		return null;
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   173
	};
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   174
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   175
	/**
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   176
	 * Calculates the actual cellIndex value of all cells in the table and stores it in the realCell property of each cell.
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   177
	 * Thats done because the cellIndex value isn't correct when colspans or rowspans are used.
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   178
	 * Originally created by Matt Kruse for his table library - Big Thanks! (see http://www.javascripttoolbox.com/)
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   179
	 * @param {element} table	The table element.
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   180
	 */
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   181
	var fixCellIndexes = function(table) 
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   182
	{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   183
		var rows = table.rows;
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   184
		var len = rows.length;
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   185
		var matrix = [];
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   186
		for ( var i = 0; i < len; i++ )
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   187
		{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   188
			var cells = rows[i].cells;
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   189
			var clen = cells.length;
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   190
			for ( var j = 0; j < clen; j++ )
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   191
			{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   192
				var c = cells[j];
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   193
				var rowSpan = c.rowSpan || 1;
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   194
				var colSpan = c.colSpan || 1;
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   195
				var firstAvailCol = -1;
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   196
				if ( !matrix[i] )
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   197
				{ 
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   198
					matrix[i] = []; 
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   199
				}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   200
				var m = matrix[i];
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   201
				// Find first available column in the first row
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   202
				while ( m[++firstAvailCol] ) {}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   203
				c.realIndex = firstAvailCol;
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   204
				for ( var k = i; k < i + rowSpan; k++ )
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   205
				{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   206
					if ( !matrix[k] )
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   207
					{ 
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   208
						matrix[k] = []; 
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   209
					}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   210
					var matrixrow = matrix[k];
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   211
					for ( var l = firstAvailCol; l < firstAvailCol + colSpan; l++ )
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   212
					{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   213
						matrixrow[l] = 1;
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   214
					}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   215
				}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   216
			}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   217
		}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   218
	};
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   219
	
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   220
	/**
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   221
	 * Manages the column display state for a table.
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   222
	 *
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   223
	 * Features:
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   224
	 * Saves the state and recreates it on the next visit of the site (requires cookie-plugin).
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   225
	 * Extracts all headers and builds an unordered(<UL>) list out of them, where clicking an list element will show/hide the matching column.
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   226
	 *
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   227
	 * @param {map} options		An object for optional settings (options described below).
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   228
	 *
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   229
	 * @option {string} listTargetID	The ID attribute of the element the column header list will be added to.
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   230
	 *						Default value: null
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   231
	 * @option {string} onClass		A CSS class that is used on the items in the column header list, for which the column state is visible 
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   232
	 *						Works only with listTargetID set!
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   233
	 *						Default value: ''
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   234
	 * @option {string} offClass		A CSS class that is used on the items in the column header list, for which the column state is hidden.
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   235
	 *						Works only with listTargetID set!
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   236
	 *						Default value: ''
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   237
	 * @option {array} hideInList	An array of numbers. Each column with the matching column index won't be displayed in the column header list.
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   238
	 *						Index starting at 1!
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   239
	 *						Default value: [] (all columns will be included in the list)
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   240
	 * @option {array} colsHidden	An array of numbers. Each column with the matching column index will get hidden by default.
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   241
	 *						The value is overwritten when saveState is true and a cookie is set for this table.
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   242
	 *						Index starting at 1!
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   243
	 *						Default value: []
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   244
	 * @option {boolean} saveState	Save a cookie with the sate information of each column.
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   245
	 *						Requires jQuery cookie plugin.
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   246
	 *						Default value: false
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   247
	 * @option {function} onToggle	Callback function which is triggered when the visibility state of a column was toggled through the column header list.
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   248
	 *						The passed parameters are: the column index(integer) and the visibility state(boolean).
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   249
	 *						Default value: null
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   250
	 *
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   251
	 * @option {function} show		Function which is called to show a table cell.
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   252
	 *						The passed parameters are: the table cell (DOM-element).
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   253
	 *						Default value: a functions which simply sets the display-style to block (visible)
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   254
	 *
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   255
	 * @option {function} hide		Function which is called to hide a table cell.
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   256
	 *						The passed parameters are: the table cell (DOM-element).
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   257
	 *						Default value: a functions which simply sets the display-style to none (invisible)
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   258
	 *
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   259
	 * @example $('#table').columnManager([listTargetID: "target", onClass: "on", offClass: "off"]);
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   260
	 * @desc Creates the column header list in the element with the ID attribute "target" and sets the CSS classes for the visible("on") and hidden("off") states.
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   261
	 *
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   262
	 * @example $('#table').columnManager([listTargetID: "target", hideInList: [1, 4]]);
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   263
	 * @desc Creates the column header list in the element with the ID attribute "target" but without the first and fourth column.
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   264
	 *
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   265
	 * @example $('#table').columnManager([listTargetID: "target", colsHidden: [1, 4]]);
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   266
	 * @desc Creates the column header list in the element with the ID attribute "target" and hides the first and fourth column by default.
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   267
	 *
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   268
	 * @example $('#table').columnManager([saveState: true]);
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   269
	 * @desc Enables the saving of visibility informations for the columns. Does not create a column header list! Toggle the columns visiblity through $('selector').toggleColumns().
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   270
	 *
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   271
	 * @type jQuery
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   272
	 *
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   273
	 * @name columnManager
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   274
	 * @cat Plugins/columnManager
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   275
	 * @author Roman Weich (http://p.sohei.org)
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   276
	 */
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   277
	$.fn.columnManager = function(options)
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   278
	{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   279
		var settings = $.extend({}, defaults, options);
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   280
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   281
		/**
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   282
		 * Creates the column header list.
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   283
		 * @param {element} table	The table element for which to create the list.
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   284
		 */
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   285
		var createColumnHeaderList = function(table)
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   286
		{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   287
			if ( !settings.listTargetID )
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   288
			{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   289
				return;
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   290
			}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   291
			var $target = $('#' + settings.listTargetID);
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   292
			if ( !$target.length )
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   293
			{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   294
				return;
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   295
			}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   296
			//select headrow - when there is no thead-element, use the first row in the table
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   297
			var headRow = null;
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   298
			if ( table.tHead && table.tHead.length )
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   299
			{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   300
				headRow = table.tHead.rows[0];
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   301
			}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   302
			else if ( table.rows.length )
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   303
			{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   304
				headRow = table.rows[0];
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   305
			}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   306
			else
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   307
			{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   308
				return; //no header - nothing to do
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   309
			}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   310
			var cells = headRow.cells;
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   311
			if ( !cells.length )
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   312
			{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   313
				return; //no header - nothing to do
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   314
			}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   315
			//create list in target element
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   316
			var $list = null;
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   317
			if ( $target.get(0).nodeName.toUpperCase() == 'UL' )
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   318
			{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   319
				$list = $target;
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   320
			}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   321
			else
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   322
			{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   323
				$list = $('<ul></ul>');
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   324
				$target.append($list);
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   325
			}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   326
			var colsVisible = table.cMColsVisible;
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   327
			//create list elements from headers
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   328
			for ( var i = 0; i < cells.length; i++ )
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   329
			{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   330
				if ( $.inArray(i + 1, settings.hideInList) >= 0 )
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   331
				{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   332
					continue;
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   333
				}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   334
				colsVisible[i] = ( colsVisible[i] !== undefined ) ? colsVisible[i] : true;
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   335
				var text = $(cells[i]).text(), 
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   336
					addClass;
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   337
				if ( !text.length )
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   338
				{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   339
					text = $(cells[i]).html();
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   340
					if ( !text.length ) //still nothing?
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   341
					{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   342
						text = 'undefined';
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   343
					}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   344
				}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   345
				if ( colsVisible[i] && settings.onClass )
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   346
				{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   347
					addClass = settings.onClass;
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   348
				}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   349
				else if ( !colsVisible[i] && settings.offClass )
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   350
				{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   351
					addClass = settings.offClass;
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   352
				}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   353
				var $li = $('<li class="' + addClass + '">' + text + '</li>').click(toggleClick);
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   354
				$li[0].cmData = {id: table.id, col: i};
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   355
				$list.append($li);
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   356
			}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   357
			// START modifications IRI
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   358
			$list.append('<li class="">----------</li>');
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   359
			var $li = $('<li class="wikitag_reinit">Colonnes initiales</li>').click(toggleClick);
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   360
			$li[0].cmData = {id: table.id, col: "reinit"};
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   361
			$list.append($li);
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   362
			// END modifications IRI
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   363
			table.cMColsVisible = colsVisible;
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   364
		};
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   365
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   366
		/**
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   367
		 * called when an item in the column header list is clicked
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   368
		 */
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   369
		var toggleClick = function()
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   370
		{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   371
			//get table id and column name
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   372
			var data = this.cmData;
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   373
			if ( data && data.id && (data.col >= 0 || data.col=="reinit") )
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   374
			{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   375
				// START modifications IRI
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   376
				if(data.col=="reinit"){
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   377
					// BE CAREFUL : the var columsToHide needs to be defined. It is usually because columsToHide is often needed at columnManager initialisation.
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   378
					var $table = $('#' + data.id);
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   379
					var opt = {listTargetID:settings.listTargetID, onClass:settings.onClass, offClass:settings.offClass};
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   380
					if($table){
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   381
						$table.showColumns(null, opt);
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   382
						if(columsToHide){
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   383
							$table.hideColumns(columsToHide, opt);
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   384
						}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   385
					}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   386
				}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   387
				else{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   388
					// END modifications IRI
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   389
					var colNum = data.col, 
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   390
						$table = $('#' + data.id);
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   391
					if ( $table.length )
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   392
					{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   393
						$table.toggleColumns([colNum + 1], settings);
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   394
						//set the appropriate classes to the column header list
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   395
						var colsVisible = $table.get(0).cMColsVisible;
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   396
						if ( settings.onToggle )
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   397
						{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   398
							settings.onToggle.apply($table.get(0), [colNum + 1, colsVisible[colNum]]);
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   399
						}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   400
					}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   401
				}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   402
			}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   403
		};
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   404
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   405
		/**
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   406
		 * Reads the saved state from the cookie.
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   407
		 * @param {string} tableID	The ID attribute from the table.
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   408
		 */
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   409
		var getSavedValue = function(tableID)
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   410
		{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   411
			var val = $.cookie(cookieName + tableID);
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   412
			if ( val )
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   413
			{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   414
				var ar = val.split('');
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   415
				for ( var i = 0; i < ar.length; i++ )
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   416
				{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   417
					ar[i] &= 1;
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   418
				}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   419
				return ar;
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   420
			}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   421
			return false;
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   422
		};
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   423
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   424
        return this.each(function()
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   425
        {
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   426
			this.id = this.id || 'jQcM0O' + idCount++; //we need an id for the column header list stuff
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   427
			var i, 
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   428
				colsHide = [], 
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   429
				colsVisible = [];
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   430
			//fix cellIndex values
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   431
			fixCellIndexes(this);
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   432
			//some columns hidden by default?
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   433
			if ( settings.colsHidden.length )
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   434
			{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   435
				for ( i = 0; i < settings.colsHidden.length; i++ )
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   436
				{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   437
					colsVisible[settings.colsHidden[i] - 1] = true;
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   438
					colsHide[settings.colsHidden[i] - 1] = true;
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   439
				}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   440
			}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   441
			//get saved state - and overwrite defaults
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   442
			if ( settings.saveState )
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   443
			{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   444
				var colsSaved = getSavedValue(this.id);
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   445
				if ( colsSaved && colsSaved.length )
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   446
				{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   447
					for ( i = 0; i < colsSaved.length; i++ )
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   448
					{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   449
						colsVisible[i] = true;
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   450
						colsHide[i] = !colsSaved[i];
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   451
					}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   452
				}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   453
				this.cMSaveState = true;
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   454
			}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   455
			//assign initial colsVisible var to the table (needed for toggling and saving the state)
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   456
			this.cMColsVisible = colsVisible;
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   457
			//something to hide already?
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   458
			if ( colsHide.length )
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   459
			{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   460
				var a = [];
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   461
				for ( i = 0; i < colsHide.length; i++ )
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   462
				{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   463
					if ( colsHide[i] )
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   464
					{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   465
						a[a.length] = i + 1;
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   466
					}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   467
				}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   468
				if ( a.length )
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   469
				{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   470
					$(this).toggleColumns(a);
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   471
				}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   472
			}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   473
			//create column header list
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   474
			createColumnHeaderList(this);
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   475
        }); 
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   476
	};
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   477
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   478
	/**
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   479
	 * Shows or hides table columns.
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   480
	 *
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   481
	 * @param {integer|array} columns		A number or an array of numbers. The display state(visible/hidden) for each column with the matching column index will get toggled.
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   482
	 *							Column index starts at 1! (see the example)
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   483
	 *
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   484
	 * @param {map} options		An object for optional settings to handle the on and off CSS classes in the column header list (options described below).
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   485
	 * @option {string} listTargetID	The ID attribute of the element with the column header.
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   486
	 * @option {string} onClass		A CSS class that is used on the items in the column header list, for which the column state is visible 
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   487
	 * @option {string} offClass		A CSS class that is used on the items in the column header list, for which the column state is hidden.
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   488
	 * @option {function} show		Function which is called to show a table cell.
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   489
	 * @option {function} hide		Function which is called to hide a table cell.
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   490
	 *
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   491
	 * @example $('#table').toggleColumns([2, 4], {hide: function(cell) { $(cell).fadeOut("slow"); }});
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   492
	 * @before <table id="table">
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   493
	 *   			<thead>
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   494
	 *   				<th>one</th
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   495
	 *   				<th>two</th
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   496
	 *   				<th>three</th
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   497
	 *   				<th>four</th
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   498
	 *   			</thead>
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   499
	 * 		   </table>
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   500
	 * @desc Toggles the visible state for the columns "two" and "four". Use custom function to fade the cell out when hiding it.
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   501
	 *
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   502
	 * @example $('#table').toggleColumns(3, {listTargetID: 'theID', onClass: 'vis'});
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   503
	 * @before <table id="table">
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   504
	 *   			<thead>
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   505
	 *   				<th>one</th
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   506
	 *   				<th>two</th
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   507
	 *   				<th>three</th
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   508
	 *   				<th>four</th
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   509
	 *   			</thead>
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   510
	 * 		   </table>
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   511
	 * @desc Toggles the visible state for column "three" and sets or removes the CSS class 'vis' to the appropriate column header according to the visibility of the column.
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   512
	 *
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   513
	 * @type jQuery
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   514
	 *
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   515
	 * @name toggleColumns
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   516
	 * @cat Plugins/columnManager
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   517
	 * @author Roman Weich (http://p.sohei.org)
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   518
	 */
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   519
	$.fn.toggleColumns = function(columns, cmo)
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   520
	{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   521
        return this.each(function() 
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   522
        {
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   523
			var i, toggle, di, 
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   524
				rows = this.rows, 
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   525
				colsVisible = this.cMColsVisible;
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   526
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   527
			if ( !columns )
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   528
				return;
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   529
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   530
			if ( columns.constructor == Number )
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   531
				columns = [columns];
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   532
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   533
			if ( !colsVisible )
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   534
				colsVisible = this.cMColsVisible = [];
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   535
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   536
			//go through all rows in the table and hide the cells
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   537
			for ( i = 0; i < rows.length; i++ )
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   538
			{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   539
				var cells = rows[i].cells;
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   540
				for ( var k = 0; k < columns.length; k++ )
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   541
				{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   542
					var col = columns[k] - 1;
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   543
					if ( col >= 0 )
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   544
					{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   545
						//find the cell with the correct index
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   546
						var c = getCell(this, cells, col);
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   547
						//cell not found - maybe a previous one has a colspan? - search it!
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   548
						if ( !c )
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   549
						{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   550
							var cco = col;
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   551
							while ( cco > 0 && !(c = getCell(this, cells, --cco)) ) {} //find the previous cell
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   552
							if ( !c )
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   553
							{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   554
								continue;
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   555
							}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   556
						}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   557
						//set toggle direction
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   558
						if ( colsVisible[col] == undefined )//not initialized yet
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   559
						{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   560
							colsVisible[col] = true;
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   561
						}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   562
						if ( colsVisible[col] )
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   563
						{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   564
							toggle = cmo && cmo.hide ? cmo.hide : hideCell;
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   565
							di = -1;
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   566
						}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   567
						else
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   568
						{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   569
							toggle = cmo && cmo.show ? cmo.show : showCell;
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   570
							di = 1;
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   571
						}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   572
						if ( !c.chSpan )
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   573
						{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   574
							c.chSpan = 0;
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   575
						}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   576
						//the cell has a colspan - so dont show/hide - just change the colspan
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   577
						if ( c.colSpan > 1 || (di == 1 && c.chSpan && cellVisible(c)) )
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   578
						{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   579
							//is the colspan even reaching this cell? if not we have a rowspan -> nothing to do
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   580
							if ( c.realIndex + c.colSpan + c.chSpan - 1 < col )
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   581
							{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   582
								continue;
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   583
							}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   584
							c.colSpan += di;
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   585
							c.chSpan += di * -1;
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   586
						}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   587
						else if ( c.realIndex + c.chSpan < col )//a previous cell was found, but doesn't affect this one (rowspan)
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   588
						{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   589
							continue;
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   590
						}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   591
						else //toggle cell
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   592
						{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   593
							toggle(c);
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   594
						}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   595
					}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   596
				}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   597
			}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   598
			//set the colsVisible var
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   599
			for ( i = 0; i < columns.length; i++ )
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   600
			{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   601
				this.cMColsVisible[columns[i] - 1] = !colsVisible[columns[i] - 1];
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   602
				//set the appropriate classes to the column header list, if the options have been passed
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   603
				if ( cmo && cmo.listTargetID && ( cmo.onClass || cmo.offClass ) )
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   604
				{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   605
					var onC = cmo.onClass, offC = cmo.offClass, $li;
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   606
					if ( colsVisible[columns[i] - 1] )
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   607
					{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   608
						onC = offC;
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   609
						offC = cmo.onClass;
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   610
					}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   611
					$li = $("#" + cmo.listTargetID + " li").filter(function(){return this.cmData && this.cmData.col == columns[i] - 1;});
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   612
					if ( onC )
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   613
					{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   614
						$li.removeClass(onC);
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   615
					}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   616
					if ( offC )
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   617
					{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   618
						$li.addClass(offC);
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   619
					}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   620
				}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   621
			}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   622
			saveCurrentValue(this);
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   623
		});
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   624
	};
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   625
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   626
	/**
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   627
	 * Shows all table columns.
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   628
	 * When columns are passed through the parameter only the passed ones become visible.
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   629
	 *
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   630
	 * @param {integer|array} columns		A number or an array of numbers. Each column with the matching column index will become visible.
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   631
	 *							Column index starts at 1!
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   632
	 *
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   633
	 * @param {map} options		An object for optional settings which will get passed to $().toggleColumns().
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   634
	 *
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   635
	 * @example $('#table').showColumns();
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   636
	 * @desc Sets the visibility state of all hidden columns to visible.
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   637
	 *
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   638
	 * @example $('#table').showColumns(3);
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   639
	 * @desc Show column number three.
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   640
	 *
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   641
	 * @type jQuery
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   642
	 *
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   643
	 * @name showColumns
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   644
	 * @cat Plugins/columnManager
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   645
	 * @author Roman Weich (http://p.sohei.org)
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   646
	 */
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   647
	$.fn.showColumns = function(columns, cmo)
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   648
	{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   649
        return this.each(function() 
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   650
        {
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   651
			var i,
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   652
				cols = [],
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   653
				cV = this.cMColsVisible;
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   654
			if ( cV )
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   655
			{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   656
				if ( columns && columns.constructor == Number ) 
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   657
					columns = [columns];
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   658
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   659
				for ( i = 0; i < cV.length; i++ )
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   660
				{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   661
					//if there were no columns passed, show all - or else show only the columns the user wants to see
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   662
					if ( !cV[i] && (!columns || $.inArray(i + 1, columns) > -1) )
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   663
						cols.push(i + 1);
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   664
				}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   665
				
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   666
				$(this).toggleColumns(cols, cmo);
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   667
			}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   668
		});
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   669
	};
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   670
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   671
	/**
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   672
	 * Hides table columns.
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   673
	 *
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   674
	 * @param {integer|array} columns		A number or an array of numbers. Each column with the matching column index will get hidden.
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   675
	 *							Column index starts at 1!
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   676
	 *
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   677
	 * @param {map} options		An object for optional settings which will get passed to $().toggleColumns().
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   678
	 *
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   679
	 * @example $('#table').hideColumns(3);
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   680
	 * @desc Hide column number three.
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   681
	 *
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   682
	 * @type jQuery
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   683
	 *
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   684
	 * @name hideColumns
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   685
	 * @cat Plugins/columnManager
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   686
	 * @author Roman Weich (http://p.sohei.org)
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   687
	 */
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   688
	$.fn.hideColumns = function(columns, cmo)
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   689
	{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   690
        return this.each(function() 
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   691
        {
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   692
			var i,
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   693
				cols = columns,
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   694
				cV = this.cMColsVisible;
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   695
			if ( cV )
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   696
			{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   697
				if ( columns.constructor == Number ) 
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   698
					columns = [columns];
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   699
				cols = [];
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   700
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   701
				for ( i = 0; i < columns.length; i++ )
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   702
				{
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   703
					if ( cV[columns[i] - 1] || cV[columns[i] - 1] == undefined )
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   704
						cols.push(columns[i]);
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   705
				}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   706
				
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   707
			}
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   708
			$(this).toggleColumns(cols, cmo);
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   709
		});
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   710
	};
ec51b9f4695f Upgrade column management with possibility to return to the initial columns. Little debug in all tag list.
cavaliet
parents:
diff changeset
   711
})(jQuery);