r105868 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r105867‎ | r105868 | r105869 >
Date:12:04, 12 December 2011
Author:santhosh
Status:ok
Tags:
Comment:
Change the behavior of the menu. Show the menu on click, not on hover.
Modified paths:
  • /trunk/extensions/Narayam/resources/ext.narayam.core.css (modified) (history)
  • /trunk/extensions/Narayam/resources/ext.narayam.core.js (modified) (history)

Diff [purge]

Index: trunk/extensions/Narayam/resources/ext.narayam.core.css
@@ -15,8 +15,12 @@
1616 div#narayam-menu {
1717 direction: ltr;
1818 float: left;
 19+ display: none;
1920 }
2021
 22+div#narayam-menu.open {
 23+ display: block;
 24+}
2125 /* @noflip */
2226 body.rtl div#narayam-menu {
2327 direction: rtl;
Index: trunk/extensions/Narayam/resources/ext.narayam.core.js
@@ -578,13 +578,14 @@
579579 var $moreLink = $( '<a>' )
580580 .text( mw.msg( 'narayam-more-imes' ) )
581581 .prop( 'href', '#' )
582 - .click( function() {
 582+ .click( function( event ) {
583583 $('.narayam-scheme-dynamic-item').toggle( 'fast' );
584584 if ( $('li.narayam-more-imes-link').hasClass( 'open' ) ) {
585585 $('li.narayam-more-imes-link').removeClass( 'open' );
586586 } else {
587587 $('li.narayam-more-imes-link').addClass( 'open' );
588588 }
 589+ event.stopPropagation();
589590 } );
590591
591592 $narayamMenuItems.append( $( '<li>' )
@@ -615,6 +616,7 @@
616617 if ( enabled ) {
617618 $( '#narayam-toggle' ).prop( 'checked', true );
618619 }
 620+ event.stopPropagation();
619621 } );
620622
621623 var helppage = mw.config.get( 'wgNarayamHelpPage' );
@@ -658,14 +660,22 @@
659661 $( '#p-personal ul:first' )[fn]( $li );
660662 $( 'body' ).prepend( $menu );
661663 $menu.hide();
662 - $li.hover( function() {
 664+ $li.click( function( event ) {
663665 $menuItemsDiv.css( 'left', $li.offset().left );
664 - $menu.show();
665 - });
666 - $menu.hover( function() {
667 - }, function() {
 666+ if( $menu.hasClass( 'open' ) ){
 667+ $menu.removeClass( 'open' );
 668+ $menu.hide();
 669+ } else {
 670+ $( 'div.open' ).removeClass( 'open' );
 671+ $menu.addClass( 'open' );
 672+ $menu.show();
 673+ event.stopPropagation();
 674+ }
 675+ } );
 676+ $( 'html' ).click( function() {
 677+ $menu.removeClass( 'open' );
668678 $menu.hide();
669 - });
 679+ } );
670680
671681 // Workaround for IE bug - activex components like input fields
672682 // coming on top of everything.

Status & tagging log