/[drupal]/contributions/themes/agregado/script.js
ViewVC logotype

Contents of /contributions/themes/agregado/script.js

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download) (as text)
Tue Dec 23 14:32:10 2008 UTC (11 months ago) by ktleow
Branch: MAIN
CVS Tags: DRUPAL-6--2-0-BETA1, DRUPAL-6--2-0-BETA2, DRUPAL-6--2-0-BETA3, HEAD
File MIME type: text/javascript
*** empty log message ***
1 /*****************************************************************************
2 Son of Suckerfish Dropdowns
3 http://htmldog.com/articles/suckerfish/dropdowns/
4
5 With mouse out delay from the article here
6 http://blog.peter-ryan.co.uk/2007/12/08/suckerfish-menus-with-hide-delay/
7 *****************************************************************************/
8 sfHover = function() {
9 var timeout = 600;
10 var cssClass = "sfhover";
11
12 var queue = [];
13 var reCSS = new RegExp( "\\b" + cssClass + "\\b" );
14 var sfEls = document.getElementById( "primary" ).getElementsByTagName( "li" );
15
16 for( var i = 0; i < sfEls.length; i++ ) {
17 // Mouseover and mouseout handlers for regular mouse based interface.
18 sfEls[ i ].onmouseover = function() {
19 queueFlush();
20 this.className += " " + cssClass;
21 }
22 sfEls[ i ].onmouseout = function() {
23 queue.push( [ setTimeout( queueTimeout, timeout ), this ] );
24 }
25
26 // Focus and blur handlers for keyboard based navigation.
27 sfEls[ i ].onfocus = function() {
28 queueFlush();
29 this.className += " " + cssClass;
30 }
31 sfEls[ i ].onblur = function() {
32 queue.push( [ setTimeout( queueTimeout, timeout ), this ] );
33 }
34
35 // Click event handler needed for tablet type interfaces (e.g. Apple iPhone).
36 sfEls[ i ].onclick = function( e ) {
37 if( this.className.search( reCSS ) == -1 ) {
38 // CSS not set, so clear all sibling (and decendants) menus, and then set CSS on this menu...
39 var elems = this.parentNode.getElementsByTagName( "li" );
40 for( var i = 0; i < elems.length; i++ ) {
41 elems[ i ].className = elems[ i ].className.replace( reCSS, "" );
42 }
43 this.className += " " + cssClass;
44 } else {
45 // CSS already set, so clear all decendant menus and then this menu...
46 var elems = this.getElementsByTagName( "li" );
47 for( var i = 0; i < elems.length; i++ ) {
48 elems[ i ].className = elems[ i ].className.replace( reCSS, "" );
49 }
50 this.className = this.className.replace( reCSS, "" );
51 }
52 if( e && e.stopPropagation )
53 e.stopPropagation();
54 else
55 window.event.cancelBubble = true;
56 }
57 }
58
59 queueFlush = function () {
60 while( queue.length ) {
61 clearTimeout( queue[ 0 ][ 0 ] );
62 queueTimeout();
63 }
64 }
65
66 queueTimeout = function() {
67 if( queue.length ) {
68 var el = queue.shift()[ 1 ];
69 el.className = el.className.replace( reCSS, "" );
70 }
71 }
72 }
73
74 function addLoadEvent( func ) {
75 var oldonload = window.onload;
76 if( typeof window.onload != 'function' ) {
77 window.onload = func;
78 } else {
79 window.onload = function() {
80 oldonload();
81 func();
82 }
83 }
84 }
85
86 addLoadEvent( sfHover );

  ViewVC Help
Powered by ViewVC 1.1.2