staaky (owner)

Revisions

gist: 32900 Download_button fork
public
Public Clone URL: git://gist.github.com/32900.git
Text only
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
  getHiddenDimensions: function(element) {
    element = $(element);
    var check = element.ancestors(),
        restore = [],
        styles = [];
    check.push(element);
 
    // All *Width and *Height properties give 0 on elements with display none,
    // or when ancestors have display none, so enable those temporarily
    check.each(function(c) {
      if (c != element && c.visible()) return;
      restore.push(c);
      styles.push({
        display: c.getStyle('display'),
        position: c.getStyle('position'),
        visibility: c.getStyle('visibility')
      });
      c.setStyle({display: 'block', position: 'absolute', visibility: 'visible'});
    });
 
    var dimensions = {width: element.clientWidth, height: element.clientHeight};
    restore.each(function(r, index) {
      r.setStyle(styles[index]);
    });
    return dimensions;
  }