<% '============================================================= '// '// TabControl '// '// version: 2.1 '// last modified: 10-May-2005 17:03 by Sasha Vukovic '============================================================= %> <% Class TabControl Private mArrDef() Private mobjDefMap Private mobjTemplateManager Private mTabStyle Private mNumOfTabAttribute Private mLastTabAttributeInx Private mSelectedTabInx Private mPreCodeTemplate Private mPostCodeTemplate Private mSelectedTabTemplate Private mDeselectedTabTemplate Private mDisabledTabTemplate Private mSelectedTabCSS Private mDeselectedTabCSS Private mInxTabName Private mInxTabLink Private mInxJavaScript Private mInxImgSelected Private mInxImgDeselected Private mInxImgDisabled Private mInxHint Private mInxForceDisable Public Property Let TemplateDoc( sTemplate ) mobjTemplateManager.TemplateDoc = sTemplate End Property Public Property Let TabStyle( sStyleId ) ' Set mTabStyle value mTabStyle = sStyleId ' Set Templates mPreCodeTemplate = mobjTemplateManager.getElementValue ( mTabStyle &"/PreTabsCode" ) mSelectedTabTemplate = mobjTemplateManager.getElementValue ( mTabStyle &"/TabSelected" ) mDeselectedTabTemplate = mobjTemplateManager.getElementValue ( mTabStyle &"/TabDeselected" ) mDisabledTabTemplate = mobjTemplateManager.getElementValue ( mTabStyle &"/TabDisabled" ) mPostCodeTemplate = mobjTemplateManager.getElementValue ( mTabStyle &"/PostTabsCode" ) mSelectedTabCSS = mobjTemplateManager.getElementValue ( mTabStyle &"/TabSelectedCSS" ) mDeselectedTabCSS = mobjTemplateManager.getElementValue ( mTabStyle &"/TabDeselectedCSS" ) End Property '----------------------------------------------------------------------------------------------------------------- Public Sub SetImgSelected ( sTabName, sImgSelected ) mArrDef ( mInxImgSelected, CInt( mobjDefMap.Item ( CStr( sTabName ) ) ) ) = sImgSelected End Sub '----------------------------------------------------------------------------------------------------------------- Public Sub SetImgDeselected ( sTabName, sImgDeselected ) mArrDef ( mInxImgDeselected, CInt( mobjDefMap.Item ( CStr( sTabName ) ) ) ) = sImgDeselected End Sub '----------------------------------------------------------------------------------------------------------------- Public Sub SetHint ( sTabName, sHint ) mArrDef ( mInxHint, CInt( mobjDefMap.Item ( CStr( sTabName ) ) ) ) = sHint End Sub '----------------------------------------------------------------------------------------------------------------- Public Sub SelectByIndex ( nTabInx ) mSelectedTabInx = CInt( nTabInx ) End Sub '----------------------------------------------------------------------------------------------------------------- Public Sub SelectByName ( sTabName ) Call SelectByIndex ( CInt( mobjDefMap.Item ( CStr( sTabName ) ) ) ) End Sub '----------------------------------------------------------------------------------------------------------------- Public Sub DisableByIndex ( nTabInx ) mArrDef ( mInxForceDisable, nTabInx ) = enumDB_YES End Sub '----------------------------------------------------------------------------------------------------------------- Public Sub DisableByName ( sTabName ) Call DisableByIndex ( CInt( mobjDefMap.Item ( CStr( sTabName ) ) ) ) End Sub '----------------------------------------------------------------------------------------------------------------- Public Sub EnableByIndex ( nTabInx ) mArrDef ( mInxForceDisable, nTabInx ) = "" End Sub '----------------------------------------------------------------------------------------------------------------- Public Sub EnableByName ( sTabName ) Call EnableByIndex ( CInt( mobjDefMap.Item ( CStr( sTabName ) ) ) ) End Sub '----------------------------------------------------------------------------------------------------------------- Public Sub Add ( aTabDef ) Dim newArrayDim, attrInx newArrayDim = UBound ( mArrDef, 2 ) + 1 ReDim Preserve mArrDef( mNumOfTabAttribute, newArrayDim ) mobjDefMap.Add Cstr( aTabDef( mInxTabName ) ), CStr( newArrayDim - 1 ) For attrInx = 0 To mLastTabAttributeInx mArrDef ( attrInx, newArrayDim - 1 ) = aTabDef ( attrInx ) Next End Sub '----------------------------------------------------------------------------------------------------------------- Public Sub AddTabDefnition ( aTabDef ) Dim attrInx, LastElemnt LastElemnt = UBound( aTabDef ) For attrInx = 0 To LastElemnt Step mNumOfTabAttribute Call Add ( Array ( aTabDef( attrInx ), _ aTabDef( attrInx+1 ), _ aTabDef( attrInx+2 ), _ aTabDef( attrInx+3 ), _ aTabDef( attrInx+4 ), _ aTabDef( attrInx+5 ), _ aTabDef( attrInx+6 ), _ aTabDef( attrInx+7 ) _ ) _ ) Next End Sub '----------------------------------------------------------------------------------------------------------------- Public Sub Render () Dim tabInx, LastElemnt, tabImgSelect, tabImgDiselect, tabImgDisable, tabHint LastElemnt = UBound( mArrDef, 2 ) - 1 Response.write mPreCodeTemplate For tabInx = 0 To LastElemnt tabImgSelect = "" tabImgDiselect = "" tabImgDisable = "" tabHint = "" If mArrDef ( mInxImgSelected, tabInx ) <> "" Then tabImgSelect = " " If mArrDef ( mInxImgDeselected, tabInx ) <> "" Then tabImgDiselect = " " If mArrDef ( mInxImgDisabled, tabInx ) <> "" Then tabImgDisable = " " If mArrDef ( mInxHint, tabInx ) <> "" Then tabHint = "title='"& mArrDef ( mInxHint, tabInx ) &"'" If mArrDef ( mInxForceDisable, tabInx ) = enumDB_YES Then Response.write ApplyTemplate( tabImgDisable & mArrDef ( mInxTabName, tabInx ), mDisabledTabTemplate ) Else If tabInx = mSelectedTabInx Then Response.write ApplyTemplate( ""& tabImgSelect & mArrDef ( mInxTabName, tabInx ) &"", mSelectedTabTemplate ) Else Response.write ApplyTemplate( ""& tabImgDiselect & mArrDef ( mInxTabName, tabInx ) &"", mDeselectedTabTemplate ) End If End If Next Response.write mPostCodeTemplate End Sub '----------------------------------------------------------------------------------------------------------------- Private Function ApplyTemplate ( sText, sTemplate ) ApplyTemplate = Replace ( sTemplate, "%TEXT%", sText ) End Function '----------------------------------------------------------------------------------------------------------------- Private Sub Class_Initialize() '// Perform action on creation of object. e.g. Set myObj = New ThisClassName Set mobjDefMap = CreateObject("Scripting.Dictionary") Set mobjTemplateManager = New TemplateManager mNumOfTabAttribute = 8 ' Number of attributes in array which define one tab. ReDim mArrDef ( mNumOfTabAttribute, 0 ) mInxTabName = 0 mInxTabLink = 1 mInxJavaScript = 2 mInxImgSelected = 3 mInxImgDeselected = 4 mInxImgDisabled = 5 minxHint = 6 mInxForceDisable = 7 mLastTabAttributeInx = mNumOfTabAttribute - 1 mSelectedTabInx = 0 ' Select first tab by default End Sub '----------------------------------------------------------------------------------------------------------------- Private Sub Class_Terminate() '// Perform action on object disposal. e.g. Set myObj = Nothing Set mobjDefMap = Nothing Set mobjTemplateManager = Nothing End Sub '----------------------------------------------------------------------------------------------------------------- End Class %>