diff options
author | Andreas Unterkircher <unki@netshadow.at> | 2008-03-27 22:59:06 +0100 |
---|---|---|
committer | Andreas Unterkircher <unki@netshadow.at> | 2008-03-27 22:59:06 +0100 |
commit | af0be8f9546fb5dec947be33e465bb6d9e85d0a7 (patch) | |
tree | 46fa7f026d861e54753e78ac8265563b0ddfca36 /autocomplete/js/tabs2.js | |
parent | 2b589908f4624b0ee41217f21d5b0b7cb383d38c (diff) |
issue111, first try of auto completion for tag search box
Signed-off-by: Andreas Unterkircher <unki@netshadow.at>
Diffstat (limited to 'autocomplete/js/tabs2.js')
-rw-r--r-- | autocomplete/js/tabs2.js | 124 |
1 files changed, 124 insertions, 0 deletions
diff --git a/autocomplete/js/tabs2.js b/autocomplete/js/tabs2.js new file mode 100644 index 0000000..9d196c8 --- /dev/null +++ b/autocomplete/js/tabs2.js @@ -0,0 +1,124 @@ +/* +* mo's Tabs script +* +* mo@momche.net +* please keep this disclaimer and send me a message if you intend to use the script +*/ +cMoTabs = new Object() + +cMoTabs.getTabGroup = function( hElement ) +{ + return getParentByTagName( hElement, 'UL' ) +} + +cMoTabs.getTabElement = function( hElement ) +{ + if( hElement == null ) + { + return null + } + try + { + if( typeof hElement.tagName == 'undefined' ) return null + } + catch( hException ) + { + return null + } + return getParentByProperty( hElement, 'className', 'tab' ) +} + + +cMoTabs.setActiveTabElement = function( hTabElement ) +{ + if( hTabElement == null ) + { + return + } + hTabElement.className = 'tabactive' + var hView = document.getElementById( hTabElement.getAttribute( 'tabview' ) ) + if( hView ) + { + hView.style.display = 'block' + } +} + +cMoTabs.setInactiveTabElement = function( hTabElement ) +{ + if( hTabElement == null ) + { + return + } + hTabElement.className = 'tab' + var hView = document.getElementById( hTabElement.getAttribute( 'tabview' ) ) + if( hView ) + { + hView.style.display = 'none' + } +} + +cMoTabs.doTab = function( e ) +{ + cDomEvent.init( e ) + var hTabElement = null + + if( e.type.indexOf( 'keypress' ) > -1 ) + { + if( e.keyCode != 13 ) + { + return + } + } + + hTabElement = cMoTabs.getTabElement( cDomEvent.target ) + + if ( hTabElement != null ) + { + //var hLink = getSubNodeByName( hTabElement, 'a' ) + //hLink.blur() + var hGroup = cMoTabs.getTabGroup( hTabElement ) + if( hGroup.hAcvtiveElm == null ) + { + var hActiveTab = getSubNodeByProperty( hTabElement.parentNode, 'className', 'tabactive' ) + } + else + { + var hActiveTab = hGroup.hAcvtiveElm + } + if( hActiveTab == hTabElement ) + { + } + else + { + cMoTabs.setInactiveTabElement( hActiveTab ) + cMoTabs.setActiveTabElement( hTabElement ) + hGroup.hAcvtiveElm = hTabElement + } + } + return true +} + +cMoTabs.doTabClick = function( e ) +{ + cDomEvent.init( e ) + if( e.preventDefault ) + { + e.preventDefault() + } + e.cancelBubble = false + e.returnValue = false + return false +} + +cMoTabs.init = function( hListItem ) +{ + var hLink = getSubNodeByName( hListItem, 'a' ) + cDomEvent.addEvent( hLink, 'activate', cMoTabs.doTab, false ) + cDomEvent.addEvent( hLink, 'focus', cMoTabs.doTab, false ) + cDomEvent.addEvent( hLink, 'mousedown', cMoTabs.doTab, false ) + cDomEvent.addEvent( hLink, 'keypress', cMoTabs.doTab, false ) + cDomEvent.addEvent( hLink, 'click', cMoTabs.doTabClick, false ) +} + + +cDomExtensionManager.register( new cDomExtension( document, [ "li[tabview]" ], cMoTabs.init ) ) |