Subversion Repositories DevTools

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
119 ghuddy 1
<%
2
'=============================================================
3
'//
4
'//							TabControl
5
'//
6
'// version: 		2.0
7
'//	last modified: 	28-Apr-2005 14:38 by Sasha Vukovic
8
'=============================================================
9
%>
10
<%
11
Class TabControl
12
 
13
	Private mArrDef()
14
	Private mobjDefMap
15
	Private mobjTemplateManager
16
	Private mTabStyle
17
	Private mNumOfTabAttribute
18
	Private mLastTabAttributeInx
19
	Private mSelectedTabInx
20
 
21
	Private mPreCodeTemplate
22
	Private mPostCodeTemplate
23
	Private mSelectedTabTemplate
24
	Private mDeselectedTabTemplate
25
	Private mDisabledTabTemplate
26
	Private mSelectedTabCSS
27
	Private mDeselectedTabCSS
28
 
29
	Private mInxTabName
30
	Private mInxTabLink
31
	Private mInxJavaScript
32
	Private mInxImgSelected
33
	Private mInxImgDeselected
34
	Private mInxImgDisabled
35
	Private mInxHint
36
	Private mInxForceDisable
37
 
38
 
39
	Public Property Let TemplateDoc( sTemplate ) 
40
		mobjTemplateManager.TemplateDoc = sTemplate
41
 
42
	End Property 
43
 
44
 
45
	Public Property Let TabStyle( sStyleId ) 
46
		' Set mTabStyle value
47
		mTabStyle = sStyleId
48
 
49
		' Set Templates
50
		mPreCodeTemplate		= mobjTemplateManager.getElementValue ( mTabStyle &"/PreTabsCode" )
51
		mSelectedTabTemplate	= mobjTemplateManager.getElementValue ( mTabStyle &"/TabSelected" )
52
		mDeselectedTabTemplate	= mobjTemplateManager.getElementValue ( mTabStyle &"/TabDeselected" )
53
		mDisabledTabTemplate	= mobjTemplateManager.getElementValue ( mTabStyle &"/TabDisabled" )
54
		mPostCodeTemplate		= mobjTemplateManager.getElementValue ( mTabStyle &"/PostTabsCode" )
55
		mSelectedTabCSS			= mobjTemplateManager.getElementValue ( mTabStyle &"/TabSelectedCSS" )
56
		mDeselectedTabCSS		= mobjTemplateManager.getElementValue ( mTabStyle &"/TabDeselectedCSS" )
57
 
58
	End Property 
59
 
60
	'-----------------------------------------------------------------------------------------------------------------
61
	Public Sub SetImgSelected ( sTabName, sImgSelected )
62
		mArrDef ( mInxImgSelected, CInt( mobjDefMap.Item ( CStr( sTabName ) ) ) ) = sImgSelected
63
 
64
	End Sub
65
	'-----------------------------------------------------------------------------------------------------------------
66
	Public Sub SetImgDeselected ( sTabName, sImgDeselected )
67
		mArrDef ( mInxImgDeselected, CInt( mobjDefMap.Item ( CStr( sTabName ) ) ) ) = sImgDeselected
68
 
69
	End Sub
70
	'-----------------------------------------------------------------------------------------------------------------
71
	Public Sub SetHint ( sTabName, sHint )
72
		mArrDef ( mInxHint, CInt( mobjDefMap.Item ( CStr( sTabName ) ) ) ) = sHint
73
 
74
	End Sub
75
	'-----------------------------------------------------------------------------------------------------------------
76
	Public Sub SelectByIndex ( nTabInx )
77
		mSelectedTabInx = CInt( nTabInx )
78
 
79
	End Sub
80
	'-----------------------------------------------------------------------------------------------------------------
81
	Public Sub SelectByName ( sTabName )
82
		Call SelectByIndex (  CInt( mobjDefMap.Item ( CStr( sTabName ) ) )  )
83
 
84
	End Sub
85
	'-----------------------------------------------------------------------------------------------------------------
86
	Public Sub DisableByIndex ( nTabInx )
87
		mArrDef ( mInxForceDisable, nTabInx ) = enumDB_YES
88
 
89
	End Sub
90
	'-----------------------------------------------------------------------------------------------------------------
91
	Public Sub DisableByName ( sTabName )
92
		Call DisableByIndex (  CInt( mobjDefMap.Item ( CStr( sTabName ) ) )  )
93
 
94
	End Sub
95
	'-----------------------------------------------------------------------------------------------------------------
96
	Public Sub EnableByIndex ( nTabInx )
97
		mArrDef ( mInxForceDisable, nTabInx ) = ""
98
 
99
	End Sub
100
	'-----------------------------------------------------------------------------------------------------------------
101
	Public Sub EnableByName ( sTabName )
102
		Call EnableByIndex (  CInt( mobjDefMap.Item ( CStr( sTabName ) ) )  )
103
 
104
	End Sub
105
	'-----------------------------------------------------------------------------------------------------------------
106
	Private Sub Add ( aTabDef )
107
		Dim newArrayDim, attrInx
108
 
109
		newArrayDim = UBound ( mArrDef, 2 ) + 1
110
 
111
		ReDim Preserve mArrDef( mNumOfTabAttribute, newArrayDim )
112
 
113
		mobjDefMap.Add Cstr( aTabDef( mInxTabName ) ), CStr( newArrayDim - 1 )
114
 
115
 
116
		For attrInx = 0 To mLastTabAttributeInx
117
			mArrDef ( attrInx, 	newArrayDim - 1 ) = aTabDef ( attrInx )
118
		Next
119
 
120
	End Sub
121
	'-----------------------------------------------------------------------------------------------------------------
122
	Public Sub AddTabDefnition ( aTabDef )
123
		Dim attrInx, LastElemnt
124
 
125
		LastElemnt = UBound( aTabDef )
126
 
127
		For attrInx = 0 To LastElemnt Step mNumOfTabAttribute
128
			Call Add ( 	Array ( aTabDef( attrInx ), _
129
							    aTabDef( attrInx+1 ), _
130
								aTabDef( attrInx+2 ), _
131
								aTabDef( attrInx+3 ), _
132
								aTabDef( attrInx+4 ), _
133
								aTabDef( attrInx+5 ), _
134
								aTabDef( attrInx+6 ), _
135
								aTabDef( attrInx+7 ) _
136
							  ) _
137
					)
138
		Next
139
 
140
	End Sub
141
	'-----------------------------------------------------------------------------------------------------------------
142
	Public Sub Render ()
143
		Dim tabInx, LastElemnt, tabImgSelect, tabImgDiselect, tabImgDisable, tabHint
144
 
145
		LastElemnt = UBound( mArrDef, 2 ) - 1
146
 
147
 
148
		Response.write mPreCodeTemplate
149
 
150
		For tabInx = 0 To LastElemnt
151
			tabImgSelect 	= ""
152
			tabImgDiselect 	= ""
153
			tabImgDisable	= ""
154
			tabHint			= ""
155
 
156
			If mArrDef ( mInxImgSelected, tabInx ) <> "" Then 		tabImgSelect = "<img src='"& mArrDef ( mInxImgSelected, tabInx ) &"' border='0' align='absmiddle'>&nbsp;"
157
			If mArrDef ( mInxImgDeselected, tabInx ) <> "" Then 	tabImgDiselect = "<img src='"& mArrDef ( mInxImgDeselected, tabInx ) &"' border='0' align='absmiddle'>&nbsp;"
158
			If mArrDef ( mInxImgDisabled, tabInx ) <> "" Then 		tabImgDisable = "<img src='"& mArrDef ( mInxImgDisabled, tabInx ) &"' border='0' align='absmiddle'>&nbsp;"
159
			If mArrDef ( mInxHint, tabInx ) <> "" Then tabHint = "title='"& mArrDef ( mInxHint, tabInx ) &"'"
160
 
161
			If mArrDef ( mInxForceDisable, tabInx ) = enumDB_YES Then
162
				Response.write ApplyTemplate( tabImgDisable & mArrDef ( mInxTabName, tabInx ), mDisabledTabTemplate )
163
 
164
			Else
165
				If tabInx = mSelectedTabInx Then
166
					Response.write ApplyTemplate( "<a href='"& mArrDef ( mInxTabLink, tabInx ) &"' class='"& mSelectedTabCSS &"' "& tabHint  &" "&  mArrDef ( mInxJavaScript, tabInx ) &">"& tabImgSelect & mArrDef ( mInxTabName, tabInx ) &"</a>", mSelectedTabTemplate )
167
 
168
				Else
169
					Response.write ApplyTemplate( "<a href='"& mArrDef ( mInxTabLink, tabInx ) &"' class='"& mDeselectedTabCSS &"' "& tabHint  &" "&  mArrDef ( mInxJavaScript, tabInx ) &">"& tabImgDiselect & mArrDef ( mInxTabName, tabInx ) &"</a>", mDeselectedTabTemplate )
170
 
171
				End If
172
 
173
			End If
174
 
175
		Next
176
 
177
		Response.write mPostCodeTemplate
178
 
179
	End Sub
180
	'-----------------------------------------------------------------------------------------------------------------
181
	Private Function ApplyTemplate ( sText, sTemplate )
182
		ApplyTemplate = Replace ( sTemplate, "%TEXT%", sText )
183
	End Function
184
	'-----------------------------------------------------------------------------------------------------------------
185
	Private Sub Class_Initialize()
186
		'// Perform action on creation of object. e.g. Set myObj = New ThisClassName
187
		Set mobjDefMap = CreateObject("Scripting.Dictionary")
188
		Set mobjTemplateManager = New TemplateManager
189
 
190
		mNumOfTabAttribute = 8  	' Number of attributes in array which define one tab.
191
 
192
		ReDim mArrDef ( mNumOfTabAttribute, 0 )
193
		mInxTabName			= 0
194
		mInxTabLink			= 1
195
		mInxJavaScript		= 2
196
		mInxImgSelected		= 3
197
		mInxImgDeselected	= 4
198
		mInxImgDisabled		= 5
199
		minxHint			= 6
200
		mInxForceDisable	= 7
201
		mLastTabAttributeInx = mNumOfTabAttribute - 1
202
 
203
		mSelectedTabInx = 0			' Select first tab by default
204
 
205
	End Sub
206
	'-----------------------------------------------------------------------------------------------------------------
207
	Private Sub Class_Terminate()
208
		'// Perform action on object disposal. e.g. Set myObj = Nothing
209
		Set mobjDefMap = Nothing
210
		Set mobjTemplateManager = Nothing
211
	End Sub
212
	'-----------------------------------------------------------------------------------------------------------------
213
End Class
214
%>