mirror of
https://github.com/niklasvh/html2canvas.git
synced 2023-08-10 21:13:10 +03:00
50 lines
1.5 KiB
JavaScript
50 lines
1.5 KiB
JavaScript
|
function NodeContainer(node, parent) {
|
||
|
this.node = node;
|
||
|
this.parent = parent;
|
||
|
this.stack = null;
|
||
|
this.bounds = null;
|
||
|
this.visible = null;
|
||
|
this.computedStyles = null;
|
||
|
this.styles = {};
|
||
|
}
|
||
|
|
||
|
NodeContainer.prototype.assignStack = function(stack) {
|
||
|
this.stack = stack;
|
||
|
stack.children.push(this);
|
||
|
};
|
||
|
|
||
|
NodeContainer.prototype.isElementVisible = function() {
|
||
|
return this.node.nodeType === Node.TEXT_NODE ? this.parent.visible : (this.css('display') !== "none" && this.css('visibility') !== "hidden" && !this.node.hasAttribute("data-html2canvas-ignore"));
|
||
|
};
|
||
|
|
||
|
NodeContainer.prototype.css = function(attribute) {
|
||
|
if (!this.computedStyles) {
|
||
|
this.computedStyles = this.node.ownerDocument.defaultView.getComputedStyle(this.node, null);
|
||
|
}
|
||
|
|
||
|
return this.styles[attribute] || (this.styles[attribute] = this.computedStyles[attribute]);
|
||
|
};
|
||
|
|
||
|
NodeContainer.prototype.cssInt = function(attribute) {
|
||
|
var value = parseInt(this.css(attribute), 10);
|
||
|
return (Number.isNaN(value)) ? 0 : value; // borders in old IE are throwing 'medium' for demo.html
|
||
|
};
|
||
|
|
||
|
NodeContainer.prototype.cssFloat = function(attribute) {
|
||
|
var value = parseFloat(this.css(attribute));
|
||
|
return (Number.isNaN(value)) ? 0 : value;
|
||
|
};
|
||
|
|
||
|
NodeContainer.prototype.fontWeight = function() {
|
||
|
var weight = this.css("fontWeight");
|
||
|
switch(parseInt(weight, 10)){
|
||
|
case 401:
|
||
|
weight = "bold";
|
||
|
break;
|
||
|
case 400:
|
||
|
weight = "normal";
|
||
|
break;
|
||
|
}
|
||
|
return weight;
|
||
|
};
|