1 // Set expiration date for cookies
3 date.setTime(date.getTime()+(365*24*60*60*1000));
4 var expiration = date.toGMTString();
7 function hideColumns(){
8 valCookie = $.cookie("showColumns");
10 valCookie = valCookie.split("/");
11 $("#showall").removeAttr("checked").parent().removeClass("selected");
12 for( i=0; i<valCookie.length; i++ ){
13 if(valCookie[i] !== ''){
14 index = valCookie[i] - 2;
15 $("#itemst td:nth-child("+valCookie[i]+"),#itemst th:nth-child("+valCookie[i]+")").toggle();
16 $("#checkheader"+index).removeAttr("checked").parent().removeClass("selected");
22 function hideColumn(num) {
23 $("#hideall,#showall").removeAttr("checked").parent().removeClass("selected");
24 valCookie = $.cookie("showColumns");
25 // set the index of the table column to hide
26 $("#"+num).parent().removeClass("selected");
27 var hide = Number(num.replace("checkheader","")) + 2;
28 // hide header and cells matching the index
29 $("#itemst td:nth-child("+hide+"),#itemst th:nth-child("+hide+")").toggle();
30 // set or modify cookie with the hidden column's index
32 valCookie = valCookie.split("/");
34 for( $i=0; $i<valCookie.length; $i++ ){
35 if (hide == valCookie[i]) {
42 var cookieString = valCookie.join("/");
43 $.cookie("showColumns", cookieString, { expires : date });
46 $.cookie("showColumns", hide, { expires : date });
50 // Array Remove - By John Resig (MIT Licensed)
51 // http://ejohn.org/blog/javascript-array-remove/
52 Array.prototype.remove = function(from, to) {
53 var rest = this.slice((to || from) + 1 || this.length);
54 this.length = from < 0 ? this.length + from : from;
55 return this.push.apply(this, rest);
58 function showColumn(num){
59 $("#hideall").removeAttr("checked").parent().removeClass("selected");
60 $("#"+num).parent().addClass("selected");
61 valCookie = $.cookie("showColumns");
62 // set the index of the table column to hide
63 show = Number(num.replace("checkheader","")) + 2;
64 // hide header and cells matching the index
65 $("#itemst td:nth-child("+show+"),#itemst th:nth-child("+show+")").toggle();
66 // set or modify cookie with the hidden column's index
68 valCookie = valCookie.split("/");
70 for( i=0; i<valCookie.length; i++ ){
71 if (show == valCookie[i]) {
77 var cookieString = valCookie.join("/");
78 $.cookie("showColumns", cookieString, { expires : date });
82 function showAllColumns(){
83 $("#selections").checkCheckboxes();
84 $("#selections span").addClass("selected");
85 $("#itemst td:nth-child(2),#itemst tr th:nth-child(2)").nextAll().show();
86 $.cookie("showColumns",null);
87 $("#hideall").removeAttr("checked").parent().removeClass("selected");
89 function hideAllColumns(){
90 $("#selections").unCheckCheckboxes();
91 $("#selections span").removeClass("selected");
92 $("#itemst td:nth-child(2),#itemst th:nth-child(2)").nextAll().hide();
93 $("#hideall").attr("checked","checked").parent().addClass("selected");
94 var cookieString = allColumns.join("/");
95 $.cookie("showColumns", cookieString, { expires : date });
98 $(document).ready(function() {
100 $("#itemst").dataTable($.extend(true, {}, dataTablesDefaults, {
103 { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false }
107 $("#selectallbutton").click(function(){
108 $("#itemst").checkCheckboxes();
111 $("#clearallbutton").click(function(){
112 $("#itemst").unCheckCheckboxes();
115 $("#clearonloanbutton").click(function(){
116 $("#itemst input[name='itemnumber'][data-is-onloan='1']").each(function(){
117 $(this).attr('checked', false);
121 $("#selections input").change(function(e){
122 var num = $(this).attr("id");
123 if(num == 'showall'){
126 } else if(num == 'hideall'){
130 if($(this).attr("checked")){