JAL-1807 includes ?j2sdebug flag and DebugJS._(msg)
[jalviewjs.git] / bin / swingjs / api / DOMNode.js
1 Clazz.declarePackage ("swingjs.api");
2 c$ = Clazz.declareType (swingjs.api, "DOMNode");
3 c$.createElement = Clazz.defineMethod (c$, "createElement", 
4 function (key, id) {
5 var obj = null;
6 {
7 obj = document.createElement(key);
8 obj.id = id;
9 }return obj;
10 }, "~S,~S");
11 c$.getParent = Clazz.defineMethod (c$, "getParent", 
12 function (obj) {
13 {
14 return obj.parentNode;
15 }}, "swingjs.api.DOMNode");
16 c$.remove = Clazz.defineMethod (c$, "remove", 
17 function (obj) {
18 {
19 try {
20 var p = obj.parentNode;
21 p.removeNode(obj);
22 } catch(e) {};
23 return p;
24 }}, "swingjs.api.DOMNode");
25 c$.add = Clazz.defineMethod (c$, "add", 
26 function (parent, child) {
27 {
28 parent && parent.appendChild(child);
29 }}, "swingjs.api.DOMNode,swingjs.api.DOMNode");
30 c$.getAttr = Clazz.defineMethod (c$, "getAttr", 
31 function (obj, attr) {
32 {
33 if (obj)return obj[attr];
34 }}, "swingjs.api.DOMNode,~S");
35 Clazz.defineMethod (c$, "getStyle", 
36 function (style) {
37 {
38 if (obj)return obj.style[style];
39 }}, "~S");
40 c$.setAttr = Clazz.defineMethod (c$, "setAttr", 
41 function (obj, attr, val) {
42 {
43 obj[attr] = (val == "TRUE" ? true : val);
44 }return obj;
45 }, "swingjs.api.DOMNode,~S,~O");
46 c$.setStyles = Clazz.defineMethod (c$, "setStyles", 
47 function (obj, attr) {
48 {
49 for (var i = 0; i < attr.length;) {
50 //System.out.println(["DOMNode.setStyles ",attr[i],attr[i+1]])
51 ;
52 obj.style[attr[i++]] = attr[i++]; }
53 }return obj;
54 }, "swingjs.api.DOMNode,~A");
55 c$.setSize = Clazz.defineMethod (c$, "setSize", 
56 function (obj, width, height) {
57 return swingjs.api.DOMNode.setStyles (obj, ["width", width + "px", "height", height + "px"]);
58 }, "swingjs.api.DOMNode,~N,~N");