Project

General

Profile

Patch #20287 » divgrid.js

public/javascripts/divgrid.js - Frederico Camara, 2015-07-10 21:54

 
1
/* Simple Grid Scripts tables with fixed First Row and Line */
2

    
3
// scrolls first line and row with body
4
// div is this
5
// row is id of row Ex: g_fr
6
// line is id of line Ex: g_fl
7
function g_scroll(div, line, row) {
8
  document.getElementById(line).style.left = - div.scrollLeft + 'px';
9
  document.getElementById(row).style.top = - div.scrollTop + 'px';
10
}
11

    
12
// adjusts width of rows
13
// bli is the block div
14
// fri is the first row div
15
// fli is the first line div
16
// bdi is the body div
17
function g_adjust(bli, fri, fli, bdi) {
18
  var frw = document.getElementById(fri).offsetWidth + "px";
19
  document.getElementById(bli).style.width = frw
20
  var fl = document.getElementById(fli).children;
21
  fl[0].style.width = frw
22
  var bd = document.getElementById(bdi).children;
23
  bd[0].style.width = frw
24
  
25
  for (var i = 1; i < fl.length; ++i) {
26
    s1 = fl[i].offsetWidth;
27
    s2 = bd[i].offsetWidth;
28
    if (s1 > s2) {
29
      bd[i].style.width = s1 + "px"
30
    } else {
31
      fl[i].style.width = s2 + "px"
32
    }
33
  }
34
}
(2-2/18)