PageSourceSearch

https://zagranitsa.net/js/maxheight.js

js zagranitsa.net collected 2026-10-04 23:52:27 UTC 3,238 bytes, 92 lines download raw bytes

1var ElementMaxHeight = function() {
2  this.initialize.apply(this, arguments);
3}
4
5ElementMaxHeight.prototype = {
6  initialize: function(className) {
7    this.elements = document.getElementsByClassName(className || 'maxheight');    
8    this.textElement = document.createElement('span');
9    this.textElement.appendChild(document.createTextNode('A'));
10    this.textElement.style.display = 'block';
11    this.textElement.style.position = 'absolute';
12    this.textElement.style.fontSize = '1em';
13    this.textElement.style.top = '-1000px';
14    this.textElement.style.left = '-1000px';
15    document.body.appendChild(this.textElement);
16    this.textElementHeight = document.getDimensions(this.textElement).height;
17    var __object = this;
18    var __checkFontSize = this.checkFontSize;
19    this.checkFontSizeInterval = window.setInterval(function() {return __checkFontSize.apply(__object)}, 500);
20
21    this.expand();
22
23    // Refresh elements height onResize event
24    var __expand = this.expand;
25    if (window.addEventListener) {
26      window.addEventListener('resize', function(event) {return __expand.apply(__object, [( event || window.event)])}, false);
27    } else if (window.attachEvent) {
28      window.attachEvent('onresize', function(event) {return __expand.apply(__object, [( event || window.event)])});
29    }
30  },
31
32  expand: function() {
33    this.reset();
34  	for (var i = 0; i < this.elements.length; i++) {  	
35      this.elements[i].style.height = document.getDimensions(this.elements[i].parentNode).height + 'px';
36  	}
37  },
38
39  reset: function() {
40    for (var i = 0; i < this.elements.length; i++) {    
41      this.elements[i].style.height = 'auto';
42    }
43  },
44
45  checkFontSize: function() {
46  	var height = document.getDimensions(this.textElement).height;
47  	if(this.textElementHeight != height) {
48  		this.textElementHeight = height;
49  		this.expand();
50  	}
51  }  
52}
53
54
55if (!!document.evaluate) {
56  document._getElementsByXPath = function(expression, parentElement) {
57    var results = [];
58    var query = document.evaluate(expression, parentElement || document,
59      null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
60    for (var i = 0, length = query.snapshotLength; i < length; i++)
61      results.push(query.snapshotItem(i));
62    return results;
63  }
64}
65
66document.getElementsByClassName = function(className, parentElement) {
67  if (!!document.evaluate) {
68    var q = ".//*[contains(concat(' ', @class, ' '), ' " + className + " ')]";
69    return document._getElementsByXPath(q, parentElement);
70  } else {
71    var children = (parentElement || document.body).getElementsByTagName('*');
72    var elements = [], child;
73    for (var i = 0, length = children.length; i < length; i++) {
74      child = children[i];
75      if (child.className.length != 0 &&
76          (child.className == className ||
77           child.className.match(new RegExp("(^|\\s)" + className + "(\\s|$)")))) {      
78        elements.push(child);
79      }
80    }
81    return elements;
82  }
83}
84
85document.getDimensions = function (element) {
86  var display = element.style.display;
87  if (display != 'none' && display != null) { // Safari bug
88    return {width: element.offsetWidth, height: element.offsetHeight};
89  }
90
91  return {width: originalWidth, height: originalHeight};
92}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.