[ Index ]

PHP Cross Reference of Mambo 4.6.5

[ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/administrator/components/com_languages/ -> tables.js (source)

   1  
   2      function dump(variable) {
   3          if(!variable) return false;
   4          debugwin = window.open('', 'debugwin', 'left=0,top=0,width=300,height=700,scrollbars=yes,status=no,resizable=yes');
   5          debugwin.document.write("<html><head><title>Javascript Debug Window</title></head><body>");
   6          debugwin.document.write("Variable information for variable: "+typeof(variable)+" ("+variable.constructor+")<br />");
   7          for (var prop in variable) {
   8              debugwin.document.writeln('"'+prop+'" => ' + variable[prop] + '<br /> ');
   9          }
  10          debugwin.document.close();
  11      }
  12      function isset(variable){return(typeof(window.variable)!='undefined');}
  13  
  14      function Table(tblid)
  15      {
  16          var tbl = document.getElementById(tblid);
  17          var rows = tbl.tBodies[0].rows;
  18          var active_row = null;
  19          var handlers = new Array();
  20          tbl.init = function() {
  21              for (var i = 0; i < rows.length; i++) {
  22                  rows[i].parity    = i % 2;
  23                  rows[i].default_class = rows[i].className;
  24                  rows[i].onmouseover =  function(){
  25                      if (active_row != this) {
  26                          this.style.backgroundColor = '#6699cc';
  27                          this.className = 'hover';
  28                      }
  29                  };
  30                  rows[i].onmouseout  =  function () {
  31                      if (active_row != this) {
  32                          this.style.backgroundColor = this.parity ? '#F5F5F5' : '#ffffff';
  33                          this.className = this.default_class;
  34                      }
  35                  };
  36                  rows[i].onmousedown =  function () {
  37                      if (active_row == this) {
  38                          active_row = null;
  39                          this.onmouseover();
  40                      }
  41                      else {
  42                          var last_active = active_row;
  43                          active_row = this;
  44                          if (last_active != null) {
  45                              last_active.onmouseout();
  46                          }
  47                          active_row.style.backgroundColor = '#4C7DAB';
  48                          active_row.className = 'active';
  49                      }
  50                  };
  51                  rows[i].ischecked  =  function() {
  52                      var checkbox = this.getElementsByTagName('input')[0];
  53                      if (checkbox.checked) {
  54                          checkbox.checked = false;
  55                          document.adminForm.boxchecked.value = 0;
  56                      } else {
  57                          checkbox.checked = true;
  58                          document.adminForm.boxchecked.value = 1;
  59                      }
  60                  };
  61                  rows[i].onmouseout();
  62              }
  63          }
  64  
  65          this.makeSortable = function(idxSort,sortProps){
  66              var arrMethods = sortProps.split(",");
  67              var arrHead = tbl.getElementsByTagName('thead')[0].getElementsByTagName('th');
  68              var arrow = document.createElement("span");
  69              for(var i=0;i<arrHead.length;i++){
  70                  if(arrHead[i].className == 'input') {
  71                      continue;
  72                  }
  73                  arrHead[i].onclick =  function(){
  74                      intCol = this.cellIndex;
  75                      strMethod = arrMethods[intCol];
  76                      var arrRows = rows;
  77                      intDir = (arrHead[intCol].className=="asc")?-1:1;
  78                      arrHead[intCol].className = (arrHead[intCol].className=="asc")?"des":"asc";
  79                      txt = getInnerText(this);
  80                      arrow.innerHTML = (intDir > 0) ? '&nbsp;&nbsp;&uarr;' : '&nbsp;&nbsp;&darr;';
  81                      this.appendChild(arrow);
  82                      for(var i=0;i<arrHead.length;i++){
  83                      if(i!=intCol){arrHead[i].className="";}
  84                      }
  85                      var arrRowsSort = new Array();
  86                      for(var i=0;i<arrRows.length;i++){
  87                          arrRowsSort[i]=arrRows[i].cloneNode(true);
  88                          if(active_row == arrRows[i]) {
  89                              active_row = arrRowsSort[i];
  90                          }
  91                      }
  92                      arrRowsSort.sort(sort2dFnc);
  93                      for(var i=0;i<arrRows.length;i++){
  94                          arrRows[i].parentNode.replaceChild(arrRowsSort[i],arrRows[i]);
  95                      }
  96                      this.parentNode.parentNode.parentNode.init();
  97                  }
  98              }
  99          }
 100  
 101  
 102          function getInnerText(el) {
 103          if (typeof el == "string") {return el};
 104          if (typeof el == "undefined") { return el };
 105              if (el.innerText) return el.innerText;
 106              var str = "";
 107              var cs = el.childNodes;
 108              for (var i = 0; i < cs.length; i++) {
 109                  switch (cs[i].nodeType) {
 110                      case 1: //ELEMENT_NODE
 111                      str += getInnerText(cs[i]);
 112                      break;
 113                      case 3:    //TEXT_NODE
 114                      str += cs[i].nodeValue;
 115                      break;
 116                  }
 117              }
 118              return str;
 119          }
 120  
 121          function sort2dFnc(a,b){
 122              var col = intCol;
 123              var dir = intDir;
 124              var aCell = getInnerText(a.getElementsByTagName("td")[col]);
 125              var bCell = getInnerText(b.getElementsByTagName("td")[col]);
 126  
 127              switch (strMethod){
 128                  case "int":
 129                      aCell = parseInt(aCell);
 130                      bCell = parseInt(bCell);
 131                  break;
 132                  case "float":
 133                      aCell = parseFloat(aCell);
 134                      bCell = parseFloat(bCell);
 135                  break;
 136                  case "date":
 137                      aCell = new Date(aCell);
 138                      bCell = new Date(bCell);
 139                  break;
 140              }
 141              return (aCell>bCell)?dir:(aCell<bCell)?-dir:0;
 142          }
 143          tbl.init();
 144      }