-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrivantis-button.js
234 lines (206 loc) · 6.43 KB
/
trivantis-button.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
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
/**************************************************
Trivantis (http://www.trivantis.com)
**************************************************/
var ocmOrig = document.oncontextmenu
var ocmNone = new Function( "return false" )
// Button Object
function ObjButton(n,a,x,y,w,h,v,z,d,cl) {
this.name = n
this.altName = a
this.x = x
this.y = y
this.w = w
this.h = h
this.v = v
this.z = z
this.obj = this.name+"Object"
this.alreadyActioned = false;
eval(this.obj+"=this")
if ( d != 'undefined' && d!=null )
this.divTag = d;
else
this.divTag = "div";
this.addClasses = cl;
}
function ObjButtonActionGoTo( destURL, destFrame ) {
this.objLyr.actionGoTo( destURL, destFrame );
}
function ObjButtonActionGoToNewWindow( destURL, name, props ) {
this.objLyr.actionGoToNewWindow( destURL, name, props );
}
function ObjButtonActionPlay( ) {
this.objLyr.actionPlay();
}
function ObjButtonActionStop( ) {
this.objLyr.actionStop();
}
function ObjButtonActionShow( ) {
if( !this.isVisible() )
this.onShow();
}
function ObjButtonActionHide( ) {
if( this.isVisible() )
this.onHide();
}
function ObjButtonActionLaunch( ) {
this.objLyr.actionLaunch();
}
function ObjButtonActionExit( ) {
this.objLyr.actionExit();
}
function ObjButtonActionChangeContents( ) {
this.objLyr.actionChangeContents();
}
function ObjButtonActionTogglePlay( ) {
this.objLyr.actionTogglePlay();
}
function ObjButtonActionToggleShow( ) {
if(this.objLyr.isVisible()) this.actionHide();
else this.actionShow();
}
function ObjButtonSizeTo( w, h ) {
this.w = w
this.h = h
this.build()
this.activate()
this.objLyr.clipTo( 0, w, h, 0 )
}
{// Setup prototypes
var p=ObjButton.prototype
p.checkbox = false
p.setImages = ObjButtonSetImages
p.build = ObjButtonBuild
p.init = ObjButtonInit
p.activate = ObjButtonActivate
p.down = ObjButtonDown
p.up = ObjButtonUp
p.over = ObjButtonOver
p.out = ObjButtonOut
p.change = ObjButtonChange
p.capture = 0
p.onDown = new Function()
p.onUp = new Function()
p.onOver = new Function()
p.onOut = new Function()
p.onSelect = new Function()
p.onDeselect = new Function()
p.actionGoTo = ObjButtonActionGoTo
p.actionGoToNewWindow = ObjButtonActionGoToNewWindow
p.actionPlay = ObjButtonActionPlay
p.actionStop = ObjButtonActionStop
p.actionShow = ObjButtonActionShow
p.actionHide = ObjButtonActionHide
p.actionLaunch = ObjButtonActionLaunch
p.actionExit = ObjButtonActionExit
p.actionChangeContents = ObjButtonActionChangeContents
p.actionTogglePlay = ObjButtonActionTogglePlay
p.actionToggleShow = ObjButtonActionToggleShow
p.writeLayer = ObjButtonWriteLayer
p.onShow = ObjButtonOnShow
p.onHide = ObjButtonOnHide
p.isVisible = ObjButtonIsVisible
p.sizeTo = ObjButtonSizeTo
p.onSelChg = new Function()
}
function ObjButtonSetImages(imgOff,imgOn,imgRoll,dir) {
if (!dir) dir = ''
this.imgOffSrc = imgOff?dir+imgOff:''
this.imgOnSrc = imgOn?dir+imgOn:''
this.imgRollSrc = imgRoll?dir+imgRoll:''
}
function ObjButtonBuild() {
this.css = buildCSS(this.name,this.x,this.y,this.w,this.h,this.v,this.z)
this.div = '<' + this.divTag + ' id="'+this.name+'" style="text-indent:0;"'
if( this.addClasses ) this.div += ' class="'+this.addClasses+'"'
this.div += '></' + this.divTag + '>\n'
this.divInt = '<a name="'+this.name+'anc" href="javascript:if( ' + this.name + '.hasOnUp ) ' + this.name + '.onUp()"'
if( this.altName ) this.divInt += ' title="'+this.altName+'"'
else if( this.altName != null ) this.divInt += ' title=""'
this.divInt += '><img name="'+this.name+'Img" src="'+this.imgOffSrc
if( this.altName ) this.divInt += '" alt="'+this.altName
else if( this.altName != null ) this.divInt += '" alt="'
this.divInt += '" width='+this.w+' height='+this.h+' border=0'
this.divInt += ' style="cursor:pointer"'
this.divInt += '></a>'
}
function ObjButtonInit() {
this.objLyr = new ObjLayer(this.name)
}
function ObjButtonActivate() {
if( this.objLyr && this.objLyr.styObj && !this.alreadyActioned ) {
if( this.v ) this.actionShow()
}
if(!is.iOS)//bug11459
{
this.objLyr.ele.onUp = new Function(this.obj+".onUp(); return false;")
this.objLyr.ele.onmouseout = new Function(this.obj+".out(); return false;")
this.objLyr.ele.onmousedown = new Function("event", this.obj+".down(event); return false;")
this.objLyr.ele.onmouseover = new Function(this.obj+".over(); return false;")
this.objLyr.ele.onmouseup = new Function("event", this.obj+".up(event); return false;")
}
if( is.ns5 ) this.objLyr.ele.innerHTML = this.divInt
else this.objLyr.write( this.divInt );
}
function ObjButtonDown(e) {
if( is.ie ) e = event
if( is.ie && !is.ieMac && e && e.button!=1 && e.button!=2 ) return
if( is.ns && !is.nsMac && e && e.button!=0 && e.button!=2 ) return
if (this.selected) {
this.selected = false
if (this.imgOnSrc) this.change(this.imgOnSrc)
this.onDeselect()
}
else {
if (this.checkbox) this.selected = true
if (this.imgOnSrc) this.change(this.imgOnSrc)
this.onSelect()
}
this.onDown()
}
function ObjButtonUp(e) {
if( is.ie ) e = event
if( (is.ie || is.nsMac) && !e ) return
if( is.ie && !is.ieMac && e && e.button!=1 && e.button!=2 ) return
if( is.ns && !is.nsMac && e && e.button!=0 && e.button!=2 ) return
if (!this.selected) {
if (this.imgRollSrc) this.change(this.imgRollSrc)
else if (this.imgOnSrc) this.change(this.imgOffSrc)
}
if( !is.ieMac && !is.nsMac && e && e.button==2 )
{
if( this.hasOnRUp )
{
document.oncontextmenu = ocmNone
this.onRUp()
setTimeout( "document.oncontextmenu = ocmOrig", 100)
}
}
}
function ObjButtonOver() {
if (this.imgRollSrc && !this.selected) this.change(this.imgRollSrc)
this.onOver()
}
function ObjButtonOut() {
if (this.imgRollSrc && !this.selected) this.change(this.imgOffSrc)
this.onOut()
}
function ObjButtonChange(img) {
if (this.objLyr) this.objLyr.doc.images[this.name+"Img"].src = img
}
function ObjButtonWriteLayer( newContents ) {
if (this.objLyr) this.objLyr.write( newContents )
}
function ObjButtonOnShow() {
this.alreadyActioned = true;
this.objLyr.actionShow();
}
function ObjButtonOnHide() {
this.alreadyActioned = true;
this.objLyr.actionHide();
}
function ObjButtonIsVisible() {
if( this.objLyr.isVisible() )
return true;
else
return false;
}