/
socks.element.html.js
65 lines (51 loc) · 1.55 KB
/
socks.element.html.js
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
* Socks .Element.HTML
*
* Copyright (c) 2009 Peter Jihoon Kim
*
* Licensed under the MIT License (MIT-LICENSE.txt)
*
* http://wiki.github.com/petejkim/socks
*
*/
(function(Socks){
Socks.Element.HTML = function(parent, style, text) {
this._socks_type = 'Socks.Element.HTML';
this._elementId = window.Socks._nextElementId++;
this._parent = parent;
// create style object
this._style = new Socks.Style();
// innerHTML
this._innerHTML = (text !== undefined ? text : '');
// create element in the DOM
this._createElement();
// set styles
this.setStyle(style);
};
Socks.Element.HTML.prototype = new Socks.Element.Control();
Socks.Element.HTML.prototype._createElement = function() {
if(this._element === undefined) {
this._element = document.createElement('div');
this._element.innerHTML = this._innerHTML;
this._element.style.zIndex = 1;
// set layout related styles
this._setLayout();
// insert the element into the parent
this._insertIntoParent(this._element);
} else {
this._element.innerHTML = this._innerHTML;
this.setStyle(this.getStyle());
}
return this._element;
};
Socks.Element.HTML.prototype.getHTML = function() {
return this._innerHTML;
};
Socks.Element.HTML.prototype.setHTML = function(html) {
this._innerHTML = html.toString();
if(this._element !== undefined) {
this._element.innerHTML = this._innerHTML;
}
return this;
};
})(window.SOCKS);