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").prop("checked", false).parent().removeClass("selected");
12 for( i=0; i<valCookie.length; i++ ){
13 if(valCookie[i] !== ''){
14 index = valCookie[i] - 3;
15 $("#itemst td:nth-child("+valCookie[i]+"),#itemst th:nth-child("+valCookie[i]+")").toggle();
16 $("#checkheader"+index).prop("checked", false).parent().removeClass("selected");
22 function hideColumn(num) {
23 $("#hideall,#showall").prop("checked", false).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","")) + 3;
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, path: '/' });
46 $.cookie("showColumns", hide, { expires : date, path: '/' });
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").prop("checked", false).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","")) + 3;
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, path: '/' });
82 function showAllColumns(){
83 $("#selections").checkCheckboxes();
84 $("#selections span").addClass("selected");
85 $("#itemst td:nth-child(3),#itemst tr th:nth-child(3)").nextAll().show();
86 $.removeCookie("showColumns", { path: '/' });
87 $("#hideall").prop("checked", false).parent().removeClass("selected");
89 function hideAllColumns(){
90 $("#selections").unCheckCheckboxes();
91 $("#selections span").removeClass("selected");
92 $("#itemst td:nth-child(3),#itemst th:nth-child(3)").nextAll().hide();
93 $("#hideall").prop("checked", true).parent().addClass("selected");
94 var cookieString = allColumns.join("/");
95 $.cookie("showColumns", cookieString, { expires : date, path: '/' });
98 $(document).ready(function() {
100 $("#itemst").dataTable($.extend(true, {}, dataTablesDefaults, {
103 { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false },
104 { "sType": "anti-the", "aTargets" : [ "anti-the" ] }
108 $("#selectallbutton").click(function(){
109 $("#itemst").checkCheckboxes();
112 $("#clearallbutton").click(function(){
113 $("#itemst").unCheckCheckboxes();
116 $("#clearonloanbutton").click(function(){
117 $("#itemst input[name='itemnumber'][data-is-onloan='1']").each(function(){
118 $(this).prop('checked', false);
122 $("#selections input").change(function(e){
123 var num = $(this).attr("id");
124 if(num == 'showall'){
127 } else if(num == 'hideall'){
131 if($(this).prop("checked")){