removed mods directory from the ATutor codebase
[atutor.git] / mods / ldap / jscripts / jqgrid / js / grid.celledit.js
diff --git a/mods/ldap/jscripts/jqgrid/js/grid.celledit.js b/mods/ldap/jscripts/jqgrid/js/grid.celledit.js
deleted file mode 100644 (file)
index bd45cdc..0000000
+++ /dev/null
@@ -1,406 +0,0 @@
-;(function($){\r
-/*\r
-**\r
- * jqGrid extension for cellediting Grid Data\r
- * Tony Tomov tony@trirand.com\r
- * http://trirand.com/blog/ \r
- * Dual licensed under the MIT and GPL licenses:\r
- * http://www.opensource.org/licenses/mit-license.php\r
- * http://www.gnu.org/licenses/gpl.html\r
-**/ \r
-/**\r
- * all events and options here are aded anonynous and not in the base grid\r
- * since the array is to big. Here is the order of execution.\r
- * From this point we use jQuery isFunction\r
- * beforeEditCell,\r
- * onSelectCell (used only for noneditable cels)\r
- * afterEditCell,\r
- * beforeSaveCell, (called before validation of values if any)\r
- * beforeSubmitCell (if cellsubmit remote (ajax))\r
- * afterSubmitCell(if cellsubmit remote (ajax)),\r
- * afterSaveCell,\r
- * errorCell,\r
- * Options\r
- * cellsubmit (remote,clientArray) (added in grid options)\r
- * cellurl\r
-* */\r
-$.fn.extend({\r
-       editCell : function (iRow,iCol, ed, fg){\r
-               return this.each(function (){\r
-                       var $t = this, nm, tmp,cc;\r
-                       if (!$t.grid || $t.p.cellEdit !== true) {return;}\r
-                       var currentFocus = null;\r
-                       // I HATE IE\r
-                       if ($.browser.msie && $.browser.version <=6 && ed===true && fg===true) {\r
-                               iCol = getAbsoluteIndex($t.rows[iRow],iCol);\r
-                       }\r
-                       // select the row that can be used for other methods\r
-                       $t.p.selrow = $t.rows[iRow].id;\r
-                       if (!$t.p.knv) {$($t).GridNav();}\r
-                       // check to see if we have already edited cell\r
-                       if ($t.p.savedRow.length>0) {\r
-                               // prevent second click on that field and enable selects\r
-                               if (ed===true ) {\r
-                                       if(iRow == $t.p.iRow && iCol == $t.p.iCol){\r
-                                               return;\r
-                                       }\r
-                               }\r
-                               // if so check to see if the content is changed\r
-                               var vl = $("td:eq("+$t.p.savedRow[0].ic+")>#"+$t.p.savedRow[0].id+"_"+$t.p.savedRow[0].name,$t.rows[$t.p.savedRow[0].id]).val();\r
-                               if ($t.p.savedRow[0].v !=  vl) {\r
-                                       // save it\r
-                                       $($t).saveCell($t.p.savedRow[0].id,$t.p.savedRow[0].ic)\r
-                               } else {\r
-                                       // restore it\r
-                                       $($t).restoreCell($t.p.savedRow[0].id,$t.p.savedRow[0].ic);\r
-                               }\r
-                       } else {\r
-                               window.setTimeout(function () { $("#"+$t.p.knv).attr("tabindex","-1").focus();},0);\r
-                       }\r
-                       nm = $t.p.colModel[iCol].name;\r
-                       if (nm=='subgrid') {return;}\r
-                       if ($t.p.colModel[iCol].editable===true && ed===true) {\r
-                               cc = $("td:eq("+iCol+")",$t.rows[iRow]);\r
-                               if(parseInt($t.p.iCol)>=0  && parseInt($t.p.iRow)>=0) {\r
-                                       $("td:eq("+$t.p.iCol+")",$t.rows[$t.p.iRow]).removeClass("edit-cell");\r
-                               }\r
-                               $(cc).addClass("edit-cell");\r
-                               tmp = $(cc).html().replace(/\&nbsp\;/ig,'');\r
-                               var opt = $.extend($t.p.colModel[iCol].editoptions || {} ,{id:iRow+"_"+nm,name:nm});\r
-                               if (!$t.p.colModel[iCol].edittype) {$t.p.colModel[iCol].edittype = "text";}\r
-                               var elc = createEl($t.p.colModel[iCol].edittype,opt,tmp,cc);\r
-                               if ($.isFunction($t.p.beforeEditCell)) {\r
-                                       $t.p.beforeEditCell($t.rows[iRow].id,nm,tmp,iRow,iCol);\r
-                               }\r
-                               $(cc).html("").append(elc);\r
-                               window.setTimeout(function () { $(elc).focus();},0);\r
-                               $t.p.savedRow.push({id:iRow,ic:iCol,name:nm,v:tmp});\r
-                               $("input, select, textarea",cc).bind("keydown",function(e) { \r
-                                       if (e.keyCode === 27) {$($t).restoreCell(iRow,iCol);} //ESC\r
-                                       if (e.keyCode === 13) {$($t).saveCell(iRow,iCol);}//Enter\r
-                                       if (e.keyCode == 9)  {$($t).nextCell(iRow,iCol);} //Tab\r
-                                       e.stopPropagation();\r
-                               });\r
-                               if ($.isFunction($t.p.afterEditCell)) {\r
-                                       $t.p.afterEditCell($t.rows[iRow].id,nm,tmp,iRow,iCol);\r
-                               }\r
-                       } else {\r
-                               if (parseInt($t.p.iCol)>=0  && parseInt($t.p.iRow)>=0) {\r
-                                       $("td:eq("+$t.p.iCol+")",$t.rows[$t.p.iRow]).removeClass("edit-cell");\r
-                               }\r
-                               $("td:eq("+iCol+")",$t.rows[iRow]).addClass("edit-cell");\r
-                               if ($.isFunction($t.p.onSelectCell)) {\r
-                                       tmp = $("td:eq("+iCol+")",$t.rows[iRow]).html().replace(/\&nbsp\;/ig,'');\r
-                                       $t.p.onSelectCell($t.rows[iRow].id,nm,tmp,iRow,iCol);\r
-                               }\r
-                       }\r
-                       $t.p.iCol = iCol; $t.p.iRow = iRow;\r
-                       // IE 6 bug \r
-                       function getAbsoluteIndex(t,relIndex) \r
-                       { \r
-                               var countnotvisible=0; \r
-                               var countvisible=0; \r
-                               for (i=0;i<t.cells.length;i++) { \r
-                                       var cell=t.cells(i); \r
-                                       if (cell.style.display=='none') countnotvisible++; else countvisible++; \r
-                                       if (countvisible>relIndex) return i; \r
-                               } \r
-                               return i; \r
-                       }\r
-               });\r
-       },\r
-       saveCell : function (iRow, iCol){\r
-               return this.each(function(){\r
-                       var $t= this, nm, fr=null;\r
-                       if (!$t.grid || $t.p.cellEdit !== true) {return;}\r
-                       for( var k=0;k<$t.p.savedRow.length;k++) {\r
-                               if ( $t.p.savedRow[k].id===iRow) {fr = k; break;}\r
-                       };\r
-                       if(fr != null) {\r
-                               var cc = $("td:eq("+iCol+")",$t.rows[iRow]);\r
-                               nm = $t.p.colModel[iCol].name;\r
-                               var v,v2;\r
-                               switch ($t.p.colModel[iCol].edittype) {\r
-                                       case "select":\r
-                                               v = $("#"+iRow+"_"+nm+">option:selected",$t.rows[iRow]).val();\r
-                                               v2 = $("#"+iRow+"_"+nm+">option:selected",$t.rows[iRow]).text();\r
-                                               break;\r
-                                       case "checkbox":\r
-                                               var cbv = $t.p.colModel[iCol].editoptions.value.split(":") || ["Yes","No"];\r
-                                               v = $("#"+iRow+"_"+nm,$t.rows[iRow]).attr("checked") ? cbv[0] : cbv[1];\r
-                                               v2=v;\r
-                                               break;\r
-                                       case "password":\r
-                                       case "text":\r
-                                       case "textarea":\r
-                                               v = $("#"+iRow+"_"+nm,$t.rows[iRow]).val();\r
-                                               v2=v;\r
-                                               break;\r
-                               }\r
-                               // The common approach is if nothing changed do not do anything\r
-                               if (v2 != $t.p.savedRow[fr].v){\r
-                                       if ($.isFunction($t.p.beforeSaveCell)) {\r
-                                               var vv = $t.p.beforeSaveCell($t.rows[iRow].id,nm, v, iRow,iCol);\r
-                                               if (vv) {v = vv;}\r
-                                       }                               \r
-                                       var cv = checkValues(v,iCol,$t);\r
-                                       if(cv[0] === true) {\r
-                                               var addpost = {};\r
-                                               if ($.isFunction($t.p.beforeSubmitCell)) {\r
-                                                       addpost = $t.p.beforeSubmitCell($t.rows[iRow].id,nm, v, iRow,iCol);\r
-                                                       if (!addpost) {addpost={};}\r
-                                               }\r
-                                               if ($t.p.cellsubmit == 'remote') {\r
-                                                       if ($t.p.cellurl) {\r
-                                                               var postdata = {};\r
-                                                               postdata[nm] = v;\r
-                                                               postdata["id"] = $t.rows[iRow].id;\r
-                                                               postdata = $.extend(addpost,postdata);\r
-                                                               $.ajax({\r
-                                                                       url: $t.p.cellurl,\r
-                                                                       data :postdata,\r
-                                                                       type: "POST",\r
-                                                                       complete: function (result, stat) {\r
-                                                                               if (stat == 'success') {\r
-                                                                                       if ($.isFunction($t.p.afterSubmitCell)) {\r
-                                                                                               var ret = $t.p.afterSubmitCell(result,postdata.id,nm,v,iRow,iCol);\r
-                                                                                               if(ret && ret[0] === true) {\r
-                                                                                                       $(cc).empty().html(v2 || "&nbsp;");\r
-                                                                                                       $(cc).addClass("dirty-cell");\r
-                                                                                                       $($t.rows[iRow]).addClass("edited");\r
-                                                                                                       if ($.isFunction($t.p.afterSaveCell)) {\r
-                                                                                                               $t.p.afterSaveCell($t.rows[iRow].id,nm, v, iRow,iCol);\r
-                                                                                                       }\r
-                                                                                                       $t.p.savedRow.splice(fr,1);\r
-                                                                                               } else {\r
-                                                                                                       info_dialog($.jgrid.errors.errcap,ret[1],$.jgrid.edit.bClose, $t.p.imgpath);\r
-                                                                                                       $($t).restoreCell(iRow,iCol);\r
-                                                                                               }\r
-                                                                                       } else {\r
-                                                                                               $(cc).empty().html(v2 || "&nbsp;");\r
-                                                                                               $(cc).addClass("dirty-cell");\r
-                                                                                               $($t.rows[iRow]).addClass("edited");\r
-                                                                                               if ($.isFunction($t.p.afterSaveCell)) {\r
-                                                                                                       $t.p.afterSaveCell($t.rows[iRow].id,nm, v, iRow,iCol);\r
-                                                                                               }\r
-                                                                                               $t.p.savedRow.splice(fr,1);\r
-                                                                                       }\r
-                                                                               }\r
-                                                                       },\r
-                                                                       error:function(res,stat){\r
-                                                                               if ($.isFunction($t.p.errorCell)) {\r
-                                                                                       $t.p.errorCell(res,stat);\r
-                                                                               } else {\r
-                                                                                       info_dialog($.jgrid.errors.errcap,res.status+" : "+res.statusText+"<br/>"+stat,$.jgrid.edit.bClose, $t.p.imgpath);\r
-                                                                                       $($t).restoreCell(iRow,iCol);\r
-                                                                               }\r
-                                                                       }\r
-                                                               });\r
-                                                       } else {\r
-                                                               try {\r
-                                                                       info_dialog($.jgrid.errors.errcap,$.jgrid.errors.nourl,$.jgrid.edit.bClose, $t.p.imgpath);\r
-                                                                       $($t).restoreCell(iRow,iCol);\r
-                                                               } catch (e) {}\r
-                                                       }\r
-                                               }\r
-                                               if ($t.p.cellsubmit == 'clientArray') {\r
-                                                       $(cc).empty().html(v2 || "&nbsp;");\r
-                                                       $(cc).addClass("dirty-cell");\r
-                                                       $($t.rows[iRow]).addClass("edited");\r
-                                                       if ($.isFunction($t.p.afterSaveCell)) {\r
-                                                               $t.p.afterSaveCell($t.rows[iRow].id,nm, v, iRow,iCol);\r
-                                                       }\r
-                                                       $t.p.savedRow.splice(fr,1);\r
-                                               }\r
-                                       } else {\r
-                                               try {\r
-                                                       window.setTimeout(function(){info_dialog($.jgrid.errors.errcap,v+" "+cv[1],$.jgrid.edit.bClose, $t.p.imgpath)},100);\r
-                                                       $($t).restoreCell(iRow,iCol);\r
-                                               } catch (e) {}\r
-                                       }\r
-                               } else {\r
-                                       $($t).restoreCell(iRow,iCol);\r
-                               }\r
-                       }\r
-                       if ($.browser.opera) {\r
-                               $("#"+$t.p.knv).attr("tabindex","-1").focus();\r
-                       } else {\r
-                               window.setTimeout(function () { $("#"+$t.p.knv).attr("tabindex","-1").focus();},0);\r
-                       }\r
-               });\r
-       },\r
-       nextCell : function (iRow,iCol) {\r
-               return this.each(function (){\r
-                       var $t = this, nCol=false, tmp;\r
-                       if (!$t.grid || $t.p.cellEdit !== true) {return;}\r
-                       // try to find next editable cell\r
-                       for (var i=iCol+1; i<$t.p.colModel.length; i++) {\r
-                               if ( $t.p.colModel[i].editable ===true) {\r
-                                       nCol = i; break;\r
-                               }\r
-                       }\r
-                       if(nCol !== false) {\r
-                               $($t).saveCell(iRow,iCol);\r
-                               $($t).editCell(iRow,nCol,true);\r
-                       } else {\r
-                               if ($t.p.savedRow.length >0) {\r
-                                       $($t).saveCell(iRow,iCol);\r
-                               }\r
-                       }\r
-               });\r
-       },\r
-       restoreCell : function(iRow, iCol) {\r
-               return this.each(function(){\r
-                       var $t= this, nm, fr=null;\r
-                       if (!$t.grid || $t.p.cellEdit !== true ) {return;}\r
-                       for( var k=0;k<$t.p.savedRow.length;k++) {\r
-                               if ( $t.p.savedRow[k].id===iRow) {fr = k; break;}\r
-                       }\r
-                       if(fr != null) {\r
-                               var cc = $("td:eq("+iCol+")",$t.rows[iRow]);\r
-                               try {\r
-                                       // old date picker\r
-                                       $.datepicker.hideDatepicker();\r
-                               } catch (e) {\r
-                                       $.datepicker._hideDatepicker();\r
-                               }\r
-                               $(":input",cc).unbind();\r
-                               nm = $t.p.colModel[iCol].name;\r
-                               $(cc).empty()\r
-                               .html($t.p.savedRow[fr].v || "&nbsp;");\r
-                               //$t.p.savedRow.splice(fr,1);\r
-                               $t.p.savedRow = [];\r
-                               \r
-                       }\r
-                       window.setTimeout(function () { $("#"+$t.p.knv).attr("tabindex","-1").focus();},0);\r
-               });\r
-       },\r
-       GridNav : function() {\r
-               return this.each(function () {\r
-                       var  $t = this;\r
-                       if (!$t.grid || $t.p.cellEdit !== true ) {return;}\r
-                       // trick to process keydown on non input elements\r
-                       $t.p.knv = $("table:first",$t.grid.bDiv).attr("id") + "_kn";\r
-                       var selection = $("<span style='width:0px;height:0px;background-color:black;' tabindex='0'><span tabindex='-1' style='width:0px;height:0px;background-color:grey' id='"+$t.p.knv+"'></span></span>");\r
-                       $(selection).insertBefore($t.grid.cDiv);\r
-                       $("#"+$t.p.knv).focus();\r
-                       $("#"+$t.p.knv).keydown(function (e){\r
-                               switch (e.keyCode) {\r
-                                       case 38:\r
-                                               if ($t.p.iRow-1 >=1 ) {\r
-                                                       scrollGrid($t.p.iRow-1,$t.p.iCol,'vu');\r
-                                                       $($t).editCell($t.p.iRow-1,$t.p.iCol,false);\r
-                                               }\r
-                                       break;\r
-                                       case 40 :\r
-                                               if ($t.p.iRow+1 <=  $t.rows.length-1) {\r
-                                                       scrollGrid($t.p.iRow+1,$t.p.iCol,'vd');\r
-                                                       $($t).editCell($t.p.iRow+1,$t.p.iCol,false);\r
-                                               }\r
-                                       break;\r
-                                       case 37 :\r
-                                               if ($t.p.iCol -1 >=  0) {\r
-                                                       var i = findNextVisible($t.p.iCol-1,'lft');\r
-                                                       scrollGrid($t.p.iRow, i,'h');\r
-                                                       $($t).editCell($t.p.iRow, i,false);\r
-                                               }\r
-                                       break;\r
-                                       case 39 :\r
-                                               if ($t.p.iCol +1 <=  $t.p.colModel.length-1) {\r
-                                                       var i = findNextVisible($t.p.iCol+1,'rgt');\r
-                                                       scrollGrid($t.p.iRow,i,'h');\r
-                                                       $($t).editCell($t.p.iRow,i,false);\r
-                                               }\r
-                                       break;\r
-                                       case 13:\r
-                                               if ($t.p.iCol && $t.p.iRow) {\r
-                                                       $($t).editCell($t.p.iRow,$t.p.iCol,true);\r
-                                               }\r
-                                       break;\r
-                               }\r
-                               return false;\r
-                       });\r
-                       function scrollGrid(iR, iC, tp){\r
-                               if (tp.substr(0,1)=='v') {\r
-                                       var ch = $($t.grid.bDiv)[0].clientHeight;\r
-                                       var st = $($t.grid.bDiv)[0].scrollTop;\r
-                                       var nROT = $t.rows[iR].offsetTop+$t.rows[iR].clientHeight;\r
-                                       var pROT = $t.rows[iR].offsetTop;\r
-                                       if(tp == 'vd') {\r
-                                               if(nROT >= ch) {\r
-                                                       $($t.grid.bDiv)[0].scrollTop = $($t.grid.bDiv)[0].scrollTop + $t.rows[iR].clientHeight;\r
-                                               }\r
-                                       }\r
-                                       if(tp == 'vu'){\r
-                                               if (pROT < st) {\r
-                                                       $($t.grid.bDiv)[0].scrollTop = $($t.grid.bDiv)[0].scrollTop - $t.rows[iR].clientHeight;\r
-                                               }\r
-                                       }\r
-                               }\r
-                               if(tp=='h') {\r
-                                       var cw = $($t.grid.bDiv)[0].clientWidth;\r
-                                       var sl = $($t.grid.bDiv)[0].scrollLeft;\r
-                                       var nCOL = $t.rows[iR].cells[iC].offsetLeft+$t.rows[iR].cells[iC].clientWidth;\r
-                                       var pCOL = $t.rows[iR].cells[iC].offsetLeft;\r
-                                       if(nCOL >= cw+parseInt(sl)) {\r
-                                               $($t.grid.bDiv)[0].scrollLeft = $($t.grid.bDiv)[0].scrollLeft + $t.rows[iR].cells[iC].clientWidth;\r
-                                       } else if (pCOL < sl) {\r
-                                               $($t.grid.bDiv)[0].scrollLeft = $($t.grid.bDiv)[0].scrollLeft - $t.rows[iR].cells[iC].clientWidth;\r
-                                       }\r
-                               }\r
-                       };\r
-                       function findNextVisible(iC,act){\r
-                               var ind;\r
-                               if(act == 'lft') {\r
-                                       ind = iC+1;\r
-                                       for (var i=iC;i>=0;i--){\r
-                                               if ($t.p.colModel[i].hidden !== true) {\r
-                                                       ind = i;\r
-                                                       break;\r
-                                               }\r
-                                       }\r
-                               }\r
-                               if(act == 'rgt') {\r
-                                       ind = iC-1;\r
-                                       for (var i=iC; i<$t.p.colModel.length;i++){\r
-                                               if ($t.p.colModel[i].hidden !== true) {\r
-                                                       ind = i;\r
-                                                       break;\r
-                                               }                                               \r
-                                       }\r
-                               }\r
-                               return ind;\r
-                       };\r
-               });\r
-       },\r
-       getChangedCells : function (mthd) {\r
-               var ret=[];\r
-               if (!mthd) {mthd='all';}\r
-               this.each(function(){\r
-                       var $t= this;\r
-                       if (!$t.grid || $t.p.cellEdit !== true ) {return;}\r
-                       $($t.rows).slice(1).each(function(j){\r
-                               var res = {};\r
-                               if ($(this).hasClass("edited")) {\r
-                                       $('td',this).each( function(i) {\r
-                                               nm = $t.p.colModel[i].name;\r
-                                               if ( nm !== 'cb' && nm !== 'subgrid') {\r
-                                                       if (mthd=='dirty') {\r
-                                                               if ($(this).hasClass('dirty-cell')) {\r
-                                                                       res[nm] = $(this).html().replace(/\&nbsp\;/ig,'');\r
-                                                               }\r
-                                                       } else {\r
-                                                               res[nm] = $(this).html().replace(/\&nbsp\;/ig,'');\r
-                                                       }\r
-                                               }\r
-                                       });\r
-                                       res["id"] = this.id;\r
-                                       ret.push(res);\r
-                               }\r
-                       })\r
-               });\r
-               return ret;\r
-       }\r
-/// end  cell editing\r
-});\r
-})(jQuery);\r