-
Notifications
You must be signed in to change notification settings - Fork 0
/
trivantis-image.js
238 lines (209 loc) · 6.68 KB
/
trivantis-image.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
235
236
237
238
/**************************************************
Trivantis (http://www.trivantis.com)
**************************************************/
var ocmOrig = document.oncontextmenu
var ocmNone = new Function( "return false" )
// Image Object
function ObjImage(n,i,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.hasOnUp = false
this.hasOnRUp = false
this.isChoice = false
this.obj = this.name+"Object"
this.alreadyActioned = false;
eval(this.obj+"=this")
this.imgSrc = i
if ( d!=null && d!="undefined" )
this.divTag = d;
else
this.divTag = "div";
this.addClasses = cl;
}
function ObjImageActionGoTo( destURL, destFrame ) {
this.objLyr.actionGoTo( destURL, destFrame );
}
function ObjImageActionGoToNewWindow( destURL, name, props ) {
this.objLyr.actionGoToNewWindow( destURL, name, props );
}
function ObjImageActionPlay( ) {
this.objLyr.actionPlay();
}
function ObjImageActionStop( ) {
this.objLyr.actionStop();
}
function ObjImageActionShow( ) {
if( !this.isVisible() )
this.onShow();
}
function ObjImageActionHide( ) {
if( this.isVisible() )
this.onHide();
}
function ObjImageActionLaunch( ) {
this.objLyr.actionLaunch();
}
function ObjImageActionExit( ) {
this.objLyr.actionExit();
}
function ObjImageActionChangeContents( newImage ) {
//ie6 deals with transparent png's differently.
if(is.ie6)
{
if(this.imgSrc.indexOf('.png') == this.imgSrc.length-4){
this.objLyr.styObj.filter = "";
this.objLyr.doc.images[this.name+"Img"].style.filter = "";
}
if(newImage.indexOf('.png') == newImage.length-4){
this.objLyr.doc.images[this.name+"Img"].style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=0)";
this.objLyr.styObj.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+newImage+"',sizingMethod='scale')";
}
}
this.objLyr.doc.images[this.name+"Img"].src = newImage
}
function ObjImageActionTogglePlay( ) {
this.objLyr.actionTogglePlay();
}
function ObjImageActionToggleShow( ) {
if(this.objLyr.isVisible()) this.actionHide();
else this.actionShow();
}
function ObjImageSizeTo( w, h ){
this.w = w
this.h = h
this.build()
this.activate()
this.objLyr.clipTo( 0, w, h, 0 )
}
{ // Setup prototypes
var p=ObjImage.prototype
p.build = ObjImageBuild
p.init = ObjImageInit
p.activate = ObjImageActivate
p.up = ObjImageUp
p.down = ObjImageDown
p.over = ObjImageOver
p.out = ObjImageOut
p.capture = 0
p.onOver = new Function()
p.onOut = new Function()
p.onSelect = new Function()
p.onDown = new Function()
p.onUp = new Function()
p.onRUp = new Function()
p.actionGoTo = ObjImageActionGoTo
p.actionGoToNewWindow = ObjImageActionGoToNewWindow
p.actionPlay = ObjImageActionPlay
p.actionStop = ObjImageActionStop
p.actionShow = ObjImageActionShow
p.actionHide = ObjImageActionHide
p.actionLaunch = ObjImageActionLaunch
p.actionExit = ObjImageActionExit
p.actionChangeContents = ObjImageActionChangeContents
p.actionTogglePlay = ObjImageActionTogglePlay
p.actionToggleShow = ObjImageActionToggleShow
p.writeLayer = ObjImageWriteLayer
p.onShow = ObjImageOnShow
p.onHide = ObjImageOnHide
p.isVisible = ObjImageIsVisible
p.sizeTo = ObjImageSizeTo
p.onSelChg = new Function()
}
function ObjImageBuild() {
this.css = buildCSS(this.name,this.x,this.y,this.w,this.h,this.v,this.z)
this.div = '<' + this.divTag + ' id="'+this.name+'"'
if( this.addClasses ) this.div += ' class="'+this.addClasses+'"'
this.div += '></' + this.divTag +'>\n'
this.divInt = '<a name="'+this.name+'anc"'
if( this.hasOnUp ) this.divInt += ' href="javascript:void(null)"'
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.imgSrc
if( this.altName ) this.divInt += '" alt="'+this.altName
else if( this.altName != null ) this.divInt += '" alt="'
this.divInt += '" width='+this.w+' height='+this.h
var addStyle = ''
if( this.x != null ) addStyle += 'position:absolute;'
if( this.hasOnUp || this.isChoice ) addStyle += ' cursor:pointer"'
if( addStyle != '') this.divInt += ' style="' + addStyle + '"'
this.divInt += ' border=0></a>'
}
function ObjImageInit() {
this.objLyr = new ObjLayer(this.name)
}
function ObjImageActivate() {
if( this.objLyr && this.objLyr.styObj && !this.alreadyActioned )
if( this.v ) this.actionShow()
if( this.capture & 4 ) {
this.objLyr.ele.onUp = new Function(this.obj+".onUp(); return false;")
this.objLyr.ele.onmousedown = new Function("event", this.obj+".down(event); return false;")
this.objLyr.ele.onmouseup = new Function("event", this.obj+".up(event); return false;")
this.objLyr.ele.onkeydown = ObjImageKeyDown
}
if( this.capture & 1 ) this.objLyr.ele.onmouseover = new Function(this.obj+".over(); return false;")
if( this.capture & 2 ) this.objLyr.ele.onmouseout = new Function(this.obj+".out(); return false;")
if( is.ns5 ) this.objLyr.ele.innerHTML = this.divInt
else this.objLyr.write( this.divInt );
}
function ObjImageDown(e) {
if( is.ie ) e = event
if( is.ie && !is.ieMac && e.button!=1 && e.button!=2 ) return
if( is.ieMac && e.button != 0 ) return
if( is.ns && e.button!=0 && e.button!=2 ) return
this.onSelect()
this.onDown()
}
function ObjImageKeyDown(e) {
var keyVal = 0
if( is.ie ) e = event
keyVal = e.keyCode
if( keyVal == 13 || keyVal == 32 )
{ this.onUp(); return false; }
}
function ObjImageUp(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( !is.ieMac && !is.nsMac && e && e.button==2 )
{
if( this.hasOnRUp )
{
document.oncontextmenu = ocmNone
this.onRUp()
setTimeout( "document.oncontextmenu = ocmOrig", 100)
}
}
else if( this.hasOnUp )
this.onUp()
}
function ObjImageOver() {
this.onOver()
}
function ObjImageOut() {
this.onOut()
}
function ObjImageWriteLayer( newContents ) {
if (this.objLyr) this.objLyr.write( newContents )
}
function ObjImageOnShow() {
this.alreadyActioned = true;
this.objLyr.actionShow();
if( this.matchObj )
this.drawLine();
}
function ObjImageOnHide() {
this.alreadyActioned = true;
this.objLyr.actionHide();
if( this.matchLine )
this.matchLine.ResizeTo( -10, -10, -10, -10 );
}
function ObjImageIsVisible() {
return this.objLyr.isVisible()
}