mirror of
https://github.com/niklasvh/html2canvas.git
synced 2023-08-10 21:13:10 +03:00
30 lines
783 B
JavaScript
30 lines
783 B
JavaScript
function TextContainer(node, parent) {
|
|
NodeContainer.call(this, node, parent);
|
|
}
|
|
|
|
TextContainer.prototype = Object.create(NodeContainer.prototype);
|
|
|
|
TextContainer.prototype.applyTextTransform = function() {
|
|
this.node.data = this.transform(this.parent.css("textTransform"));
|
|
};
|
|
|
|
TextContainer.prototype.transform = function(transform) {
|
|
var text = this.node.data;
|
|
switch(transform){
|
|
case "lowercase":
|
|
return text.toLowerCase();
|
|
case "capitalize":
|
|
return text.replace(/(^|\s|:|-|\(|\))([a-z])/g, capitalize);
|
|
case "uppercase":
|
|
return text.toUpperCase();
|
|
default:
|
|
return text;
|
|
}
|
|
};
|
|
|
|
function capitalize(m, p1, p2) {
|
|
if (m.length > 0) {
|
|
return p1 + p2.toUpperCase();
|
|
}
|
|
}
|