Subversion Repositories DevTools

Rev

Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed

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