forked from jaspervanderhoek/JavaConcepts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHelpTextRow.js
More file actions
123 lines (106 loc) · 3.03 KB
/
HelpTextRow.js
File metadata and controls
123 lines (106 loc) · 3.03 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
dojo.provide("HelpText.widget.HelpTextRow");
mxui/widget.declare('HelpText.widget.HelpTextRow', {
addons : [],
inputargs: {
text : '',
startvisible : false,
height : 300,
hideonclick : false,
onclickmf : ''
},
//IMPLEMENTATION
domNode: null,
topic : "CustomWidget/HelpText",
handle : null,
rowNode : null,
targetHeight : 0,
anim : null,
contextobj : null,
postCreate : function(){
logger.debug(this.id + ".postCreate");
dojo.addClass(this.domNode, 'HelpTextRow');
this.createHelp();
this.rowNode = this.findRowNode(this.domNode);
dojo.style(this.domNode, 'maxHeight', this.height + 'px');
dojo.style(this.rowNode, 'height', 'auto'); //follow the animation
this.actRendered();
this.addOnLoad(dojo.hitch(this, this.poststartup));
},
update : function (obj, callback) {
this.contextobj = obj;
callback && callback();
},
poststartup : function() {
if (!this.startvisible) {
dojo.style(this.rowNode, 'display','none');
}
this.stateChange(this.startvisible);
this.handle = dojo.subscribe(this.topic, this, this.stateChange);
},
findRowNode : function(parent) {
var tag = parent.tagName.toLowerCase();
if (tag == 'tr' || tag == 'th')
return parent;
else if (parent.parentNode != null)
return this.findRowNode(parent.parentNode);
throw new Exception(this.id + " Did not found a parent row to show or hide");
},
updateHeight : function(height) {
if (this.anim != null)
this.anim.stop();
this.anim = dojo.animateProperty({
node : this.domNode,
duration : 500,
properties : { height : height },
onEnd : dojo.hitch(this, function() {
if (height == 0)
dojo.style(this.rowNode, 'display', 'none');
})
});
this.anim.play();
},
stateChange : function(newstate) {
if (newstate) {
var boxorig = dojo.marginBox(this.domNode);
dojo.style(this.rowNode, { 'display' : '' });
dojo.style(this.domNode, {'height' : 'auto'});
var box = dojo.marginBox(this.domNode);
if (boxorig.h == 0) //restart animation
dojo.style(this.domNode, { 'height' : '0px'});
if (box.h > 0)
this.updateHeight(Math.min(this.height, box.h));
else
dojo.style(this.domNode, 'height', 'auto');
}
else {
this.updateHeight(0);
}
},
createHelp : function () {
dojo.html.set(this.domNode, this.text);
if (this.hideonclick === true)
this.connect(this.domNode, 'onclick', this.hideHelp);
else if (this.onclickmf != '') {
this.connect(this.domNode, 'onclick', this.executeMF);
}
},
executeMF : function () {
mx.data.action({
error : function() {
logger.error(this.id + "error: XAS error executing microflow");
},
callback : dojo.hitch(this, function() {
}),
actionname : this.onclickmf,
applyto : 'selection',
guids : [mendix/lib/MxObject#getGuid()]
});
},
hideHelp : function() {
this.startvisible = false;
this.stateChange(false);
},
uninitialize : function() {
dojo.unsubscribe(this.handle);
}
});;