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