removed mods directory from the ATutor codebase
[atutor.git] / mods / ldap / jscripts / jqgrid / js / grid.treegrid.js
diff --git a/mods/ldap/jscripts/jqgrid/js/grid.treegrid.js b/mods/ldap/jscripts/jqgrid/js/grid.treegrid.js
deleted file mode 100644 (file)
index 0bc7cba..0000000
+++ /dev/null
@@ -1,322 +0,0 @@
-;(function($) {\r
-/*\r
-**\r
- * jqGrid extension - Tree Grid\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
-$.fn.extend({\r
-       setTreeNode : function(rd, row){\r
-               return this.each(function(){\r
-                       var $t = this;\r
-                       if(!$t.grid || !$t.p.treeGrid) { return; }\r
-                       var expCol=0,i=0;\r
-                       if(!$t.p.expColInd) {\r
-                               for (var key in $t.p.colModel){\r
-                                       if($t.p.colModel[key].name == $t.p.ExpandColumn) {\r
-                                               expCol = i;\r
-                                               $t.p.expColInd = expCol;\r
-                                               break;\r
-                                       }\r
-                                       i++;\r
-                               }\r
-                               if(!$t.p.expColInd ) {$t.p.expColInd = expCol;}\r
-                       } else {\r
-                               expCol = $t.p.expColInd;\r
-                       }\r
-                       var level = $t.p.treeReader.level_field;\r
-                       var expanded = $t.p.treeReader.expanded_field;\r
-                       var isLeaf = $t.p.treeReader.leaf_field;\r
-                       row.lft = rd[$t.p.treeReader.left_field];\r
-                       row.rgt = rd[$t.p.treeReader.right_field];\r
-                       row.level = rd[level];\r
-                       if(!rd[isLeaf]) {\r
-                               // NS Model\r
-                               rd[isLeaf] = (parseInt(row.rgt,10) === parseInt(row.lft,10)+1) ? 'true' : 'false';\r
-                       }\r
-                       var curExpand = (rd[expanded] && rd[expanded] == "true") ? true : false;\r
-                       var curLevel = parseInt(row.level,10);\r
-                       var ident,lftpos;\r
-                       if($t.p.tree_root_level === 0) {\r
-                               ident = curLevel+1;\r
-                               lftpos = curLevel;\r
-                       } else {\r
-                               ident = curLevel;\r
-                               lftpos = curLevel -1;\r
-                       }\r
-                       var twrap = document.createElement("div");\r
-                       $(twrap).addClass("tree-wrap").width(ident*18);\r
-                       var treeimg = document.createElement("div");\r
-                       $(treeimg).css("left",lftpos*18);\r
-                       twrap.appendChild(treeimg);\r
-\r
-                       if(rd[isLeaf] == "true") {\r
-                               $(treeimg).addClass("tree-leaf");\r
-                               row.isLeaf = true;\r
-                       } else {\r
-                               if(rd[expanded] == "true") {\r
-                                       $(treeimg).addClass("tree-minus treeclick");\r
-                                       row.expanded = true;\r
-                               } else {\r
-                                       $(treeimg).addClass("tree-plus treeclick");\r
-                                       row.expanded = false;\r
-                               }\r
-                       }\r
-                       if(parseInt(rd[level],10) !== parseInt($t.p.tree_root_level,10)) {                \r
-                               if(!$($t).isVisibleNode(row)){ \r
-                                       $(row).css("display","none");\r
-                               }\r
-                       }\r
-                       var mhtm = $("td:eq("+expCol+")",row).html();\r
-                       var thecell = $("td:eq("+expCol+")",row).html("<span>"+mhtm+"</span>").prepend(twrap);\r
-                       $(".treeclick",thecell).click(function(e){\r
-                               var target = e.target || e.srcElement;\r
-                               var ind =$(target,$t.rows).parents("tr:first")[0].rowIndex;\r
-                               if(!$t.rows[ind].isLeaf){\r
-                                       if($t.rows[ind].expanded){\r
-                                               $($t).collapseRow($t.rows[ind]);\r
-                                               $($t).collapseNode($t.rows[ind]);\r
-                                       } else {\r
-                                               $($t).expandRow($t.rows[ind]);\r
-                                               $($t).expandNode($t.rows[ind]);\r
-                                       }\r
-                               }\r
-                               e.stopPropagation();\r
-                       });\r
-               });\r
-       },\r
-       expandRow: function (record){\r
-               this.each(function(){\r
-                       var $t = this;\r
-                       if(!$t.grid || !$t.p.treeGrid) { return; }\r
-                       var childern = $($t).getNodeChildren(record);\r
-                       //if ($($t).isVisibleNode(record)) {\r
-                       $(childern).each(function(i){\r
-                               $(this).css("display","");\r
-                               if(this.expanded) {\r
-                                       $($t).expandRow(this);\r
-                               }\r
-                       });\r
-                       //}\r
-               });\r
-       },\r
-       collapseRow : function (record) {\r
-               this.each(function(){\r
-                       var $t = this;\r
-                       if(!$t.grid || !$t.p.treeGrid) { return; }\r
-                       var childern = $($t).getNodeChildren(record);\r
-                       $(childern).each(function(i){\r
-                               $(this).css("display","none");\r
-                               $($t).collapseRow(this);\r
-                       });\r
-               });\r
-       },\r
-       // NS model\r
-       getRootNodes : function() {\r
-               var result = [];\r
-               this.each(function(){\r
-                       var $t = this;\r
-                       if(!$t.grid || !$t.p.treeGrid) { return; }\r
-                       $($t.rows).each(function(i){\r
-                               if(parseInt(this.level,10) === parseInt($t.p.tree_root_level,10)) {\r
-                                       result.push(this);\r
-                               }\r
-                       });\r
-               });\r
-               return result;\r
-       },\r
-       getNodeDepth : function(rc) {\r
-               var ret = null;\r
-               this.each(function(){\r
-                       if(!this.grid || !this.p.treeGrid) { return; }\r
-                       ret = parseInt(rc.level,10) - parseInt(this.p.tree_root_level,10);                \r
-               });\r
-               return ret;\r
-       },\r
-       getNodeParent : function(rc) {\r
-               var result = null;\r
-               this.each(function(){\r
-                       if(!this.grid || !this.p.treeGrid) { return; }\r
-                       var lft = parseInt(rc.lft,10), rgt = parseInt(rc.rgt,10), level = parseInt(rc.level,10);\r
-                       $(this.rows).each(function(){\r
-                               if(parseInt(this.level,10) === level-1 && parseInt(this.lft) < lft && parseInt(this.rgt) > rgt) {\r
-                                       result = this;\r
-                                       return false;\r
-                               }\r
-                       });\r
-               });\r
-               return result;\r
-       },\r
-       getNodeChildren : function(rc) {\r
-               var result = [];\r
-               this.each(function(){\r
-                       if(!this.grid || !this.p.treeGrid) { return; }\r
-                       var lft = parseInt(rc.lft,10), rgt = parseInt(rc.rgt,10), level = parseInt(rc.level,10);\r
-                       var ind = rc.rowIndex;\r
-                       $(this.rows).slice(1).each(function(i){\r
-                               if(parseInt(this.level,10) === level+1 && parseInt(this.lft,10) > lft && parseInt(this.rgt,10) < rgt) {\r
-                                       result.push(this);\r
-                               }\r
-                       });\r
-               });\r
-               return result;\r
-       },\r
-       // End NS Model\r
-       getNodeAncestors : function(rc) {\r
-               var ancestors = [];\r
-               this.each(function(){\r
-                       if(!this.grid || !this.p.treeGrid) { return; }\r
-                       var parent = $(this).getNodeParent(rc);\r
-                       while (parent) {\r
-                               ancestors.push(parent);\r
-                               parent = $(this).getNodeParent(parent); \r
-                       }\r
-               });\r
-               return ancestors;\r
-       },\r
-       isVisibleNode : function(rc) {\r
-               var result = true;\r
-               this.each(function(){\r
-                       var $t = this;\r
-                       if(!$t.grid || !$t.p.treeGrid) { return; }\r
-                       var ancestors = $($t).getNodeAncestors(rc);\r
-                       $(ancestors).each(function(){\r
-                               result = result && this.expanded;\r
-                               if(!result) {return false;}\r
-                       });\r
-               });\r
-               return result;\r
-       },\r
-       isNodeLoaded : function(rc) {\r
-               var result;\r
-               this.each(function(){\r
-                       var $t = this;\r
-                       if(!$t.grid || !$t.p.treeGrid) { return; }\r
-                       if(rc.loaded !== undefined) {\r
-                               result = rc.loaded;\r
-                       } else if( rc.isLeaf || $($t).getNodeChildren(rc).length > 0){\r
-                               result = true;\r
-                       } else {\r
-                               result = false;\r
-                       }\r
-               });\r
-               return result;\r
-       },\r
-       expandNode : function(rc) {\r
-               return this.each(function(){\r
-                       if(!this.grid || !this.p.treeGrid) { return; }\r
-                       if(!rc.expanded) {\r
-                               if( $(this).isNodeLoaded(rc) ) {\r
-                                       rc.expanded = true;\r
-                                       $("div.treeclick",rc).removeClass("tree-plus").addClass("tree-minus");\r
-                               } else {\r
-                                       rc.expanded = true;\r
-                                       $("div.treeclick",rc).removeClass("tree-plus").addClass("tree-minus");\r
-                                       this.p.treeANode = rc.rowIndex;\r
-                                       this.p.datatype = this.p.treedatatype;\r
-                                       $(this).setGridParam({postData:{nodeid:rc.id,n_left:rc.lft,n_right:rc.rgt,n_level:rc.level}});\r
-                                       $(this).trigger("reloadGrid");\r
-                                       this.treeANode = 0;\r
-                                       $(this).setGridParam({postData:{nodeid:'',n_left:'',n_right:'',n_level:''}})\r
-                               }\r
-                       }\r
-               });\r
-       },\r
-       collapseNode : function(rc) {\r
-               return this.each(function(){\r
-                       if(!this.grid || !this.p.treeGrid) { return; }\r
-                       if(rc.expanded) {\r
-                               rc.expanded = false;\r
-                               $("div.treeclick",rc).removeClass("tree-minus").addClass("tree-plus");\r
-                       }\r
-               });\r
-       },\r
-       SortTree : function( newDir) {\r
-               return this.each(function(){\r
-                       if(!this.grid || !this.p.treeGrid) { return; }\r
-                       var i, len,\r
-                       rec, records = [],\r
-                       roots = $(this).getRootNodes();\r
-                       // Sorting roots\r
-                       roots.sort(function(a, b) {\r
-                               if (a.sortKey < b.sortKey) {return -newDir;}\r
-                               if (a.sortKey > b.sortKey) {return newDir;}\r
-                               return 0;\r
-                       });\r
-                       // Sorting children\r
-                       for (i = 0, len = roots.length; i < len; i++) {\r
-                               rec = roots[i];\r
-                               records.push(rec);\r
-                               $(this).collectChildrenSortTree(records, rec, newDir);\r
-                       }\r
-                       var $t = this;\r
-                       $.each(records, function(index, row) {\r
-                               $('tbody',$t.grid.bDiv).append(row);\r
-                               row.sortKey = null;\r
-                       });\r
-               });\r
-       },\r
-       collectChildrenSortTree : function(records, rec, newDir) {\r
-               return this.each(function(){\r
-                       if(!this.grid || !this.p.treeGrid) { return; }\r
-                       var i, len,\r
-                       child, \r
-                       children = $(this).getNodeChildren(rec);\r
-                       children.sort(function(a, b) {\r
-                               if (a.sortKey < b.sortKey) {return -newDir;}\r
-                               if (a.sortKey > b.sortKey) {return newDir;}\r
-                               return 0;\r
-                       });\r
-                       for (i = 0, len = children.length; i < len; i++) {\r
-                               child = children[i];\r
-                               records.push(child);\r
-                               $(this).collectChildrenSortTree(records, child,newDir); \r
-                       }\r
-               });\r
-       },\r
-       // experimental \r
-       setTreeRow : function(rowid, data) {\r
-               var nm, success=false;\r
-               this.each(function(){\r
-                       var t = this;\r
-                       if(!t.grid || !t.p.treeGrid) { return false; }\r
-                       if( data ) {\r
-                               var ind = $(t).getInd(t.rows,rowid);\r
-                               if(!ind) {return success;}\r
-                               success=true;\r
-                               $(this.p.colModel).each(function(i){\r
-                                       nm = this.name;\r
-                                       if(data[nm] !== 'undefined') {\r
-                                               if(nm == t.p.ExpandColumn && t.p.treeGrid===true) {\r
-                                                       $("td:eq("+i+") > span:first",t.rows[ind]).html(data[nm]);\r
-                                               } else {\r
-                                                       $("td:eq("+i+")",t.rows[ind]).html(data[nm]);\r
-                                               }\r
-                                               success = true;\r
-                                       }\r
-                               });\r
-                       }\r
-               });\r
-               return success;\r
-       },\r
-       delTreeNode : function (rowid) {\r
-               return this.each(function () {\r
-                       var $t = this;\r
-                       if(!$t.grid || !$t.p.treeGrid) { return; }\r
-                       var rc = $($t).getInd($t.rows,rowid,true);\r
-                       if (rc) {\r
-                               var dr = $($t).getNodeChildren(rc);\r
-                               if(dr.length>0){\r
-                                       for (var i=0;i<dr.length;i++){\r
-                                               $($t).delRowData(dr[i].id);\r
-                                       }\r
-                               }\r
-                               $($t).delRowData(rc.id);\r
-                       }\r
-               });\r
-       }\r
-});\r
-})(jQuery);
\ No newline at end of file