changed git call from https to git readonly
[atutor.git] / mods / ldap / jscripts / jqgrid / js / grid.setcolumns.js
1 ;(function($){\r
2 /**\r
3  * jqGrid extension for manipulating columns properties\r
4  * Piotr Roznicki roznicki@o2.pl\r
5  * http://www.roznicki.prv.pl\r
6  * Dual licensed under the MIT and GPL licenses:\r
7  * http://www.opensource.org/licenses/mit-license.php\r
8  * http://www.gnu.org/licenses/gpl.html\r
9 **/\r
10 $.fn.extend({\r
11         setColumns : function(p) {\r
12                 p = $.extend({\r
13                         top : 0,\r
14                         left: 0,\r
15                         width: 200,\r
16                         height: 195,\r
17                         modal: false,\r
18                         drag: true,\r
19                         closeicon: 'ico-close.gif',\r
20                         beforeShowForm: null,\r
21                         afterShowForm: null,\r
22                         afterSubmitForm: null\r
23                 }, $.jgrid.col, p ||{});\r
24                 return this.each(function(){\r
25                         var $t = this;\r
26                         if (!$t.grid ) { return; }\r
27                         var onBeforeShow = typeof p.beforeShowForm === 'function' ? true: false;\r
28                         var onAfterShow = typeof p.afterShowForm === 'function' ? true: false;\r
29                         var onAfterSubmit = typeof p.afterSubmitForm === 'function' ? true: false;                      \r
30                         if(!p.imgpath) { p.imgpath= $t.p.imgpath; } // Added From Tony Tomov\r
31                         var gID = $("table:first",$t.grid.bDiv).attr("id");\r
32                         var IDs = {themodal:'colmod'+gID,modalhead:'colhd'+gID,modalcontent:'colcnt'+gID};\r
33                         var dtbl = "ColTbl_"+gID;\r
34                         if ( $("#"+IDs.themodal).html() != null ) {\r
35                                 if(onBeforeShow) { p.beforeShowForm($("#"+dtbl)); }\r
36                                 viewModal("#"+IDs.themodal,{modal:p.modal});\r
37                                 if(onAfterShow) { p.afterShowForm($("#"+dtbl)); }\r
38                         } else {\r
39                                 var tbl =$("<table id='"+dtbl+"' class='ColTable'><tbody></tbody></table>");\r
40                                 for(i=0;i<this.p.colNames.length;i++){\r
41                                         if(!$t.p.colModel[i].hidedlg) { // added from T. Tomov\r
42                                                 $(tbl).append("<tr><td ><input type='checkbox' id='col_" + this.p.colModel[i].name + "' class='cbox' value='T' " + \r
43                                                 ((this.p.colModel[i].hidden==undefined)?"checked":"") + "/>" +  "<label for='col_" + this.p.colModel[i].name + "'>" + this.p.colNames[i] + "(" + this.p.colModel[i].name + ")</label></td></tr>");\r
44                                         }\r
45                                 }\r
46                                 var bS  ="<input id='dData' type='button' value='"+p.bSubmit+"'/>";\r
47                                 var bC  ="<input id='eData' type='button' value='"+p.bCancel+"'/>";\r
48                                 $(tbl).append("<tr><td class='ColButton'>"+bS+"&nbsp;"+bC+"</td></tr>");\r
49                                 createModal(IDs,tbl,p,$t.grid.hDiv,$t.grid.hDiv);\r
50                                 if( p.drag) { DnRModal("#"+IDs.themodal,"#"+IDs.modalhead+" td.modaltext"); }\r
51                                 $("#dData","#"+dtbl).click(function(e){\r
52                                         for(i=0;i<$t.p.colModel.length;i++){\r
53                                                 if(!$t.p.colModel[i].hidedlg) { // added from T. Tomov\r
54                                                         if($("#col_" + $t.p.colModel[i].name).attr("checked")) {\r
55                                                                 $($t).showCol($t.p.colModel[i].name);\r
56                                                                 $("#col_" + $t.p.colModel[i].name).attr("defaultChecked",true); // Added from T. Tomov IE BUG\r
57                                                         } else {\r
58                                                                 $($t).hideCol($t.p.colModel[i].name);\r
59                                                                 $("#col_" + $t.p.colModel[i].name).attr("defaultChecked",""); // Added from T. Tomov IE BUG\r
60                                                         }\r
61                                                 }\r
62                                         }\r
63                                         $("#"+IDs.themodal).jqmHide();\r
64                                         if (onAfterSubmit) { p.afterSubmitForm($("#"+dtbl)); }\r
65                                         return false;\r
66                                 });\r
67                                 $("#eData", "#"+dtbl).click(function(e){\r
68                                         $("#"+IDs.themodal).jqmHide();\r
69                                         return false;\r
70                                 });\r
71                                 if(onBeforeShow) { p.beforeShowForm($("#"+dtbl)); }\r
72                                 viewModal("#"+IDs.themodal,{modal:p.modal});\r
73                                 if(onAfterShow) { p.afterShowForm($("#"+dtbl)); }\r
74                         }\r
75                 });\r
76         }\r
77 });\r
78 })(jQuery);