r106432 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r106431‎ | r106432 | r106433 >
Date:14:24, 16 December 2011
Author:santhosh
Status:ok
Tags:
Comment:
it is not possible to stop propagation of live events. changed to delegage.
Merged the two live bindings to single.
And prevented hiding the menu if clicked.
Modified paths:
  • /trunk/extensions/Narayam/resources/ext.narayam.core.js (modified) (history)

Diff [purge]

Index: trunk/extensions/Narayam/resources/ext.narayam.core.js
@@ -558,11 +558,6 @@
559559 return null;
560560 }
561561
562 - // Event listener for scheme selection.
563 - $( '.narayam-scheme', $( '#narayam-menu-items > ul')[0] ).live( 'click', function() {
564 - that.setScheme( $( this ).val() );
565 - } );
566 -
567562 // Build enable/disable checkbox and label
568563 var $checkbox = $( '<input type="checkbox" id="narayam-toggle" />' );
569564 $checkbox
@@ -607,16 +602,17 @@
608603 }
609604
610605 // Event listener for scheme selection - dynamic loading of rules.
611 - $( '.narayam-scheme', $('.narayam-scheme-dynamic-item') ).live( 'click', function() {
 606+ $narayamMenuItems.delegate( 'input:radio', 'click', function( ) {
612607 that.setScheme( $( this ).val() );
613 - // rebuild the menu items with recent items.
614 - $( '#narayam-menu' ).html( $.narayam.buildMenuItems() );
615 - $( '#narayam-menu-items' ).css( 'left', $('li#pt-narayam').offset().left );
616 - $( '#narayam-' + $( this ).val() ).prop( 'checked', true );
617 - if ( enabled ) {
618 - $( '#narayam-toggle' ).prop( 'checked', true );
 608+ if ( $( this ).parent().hasClass( 'narayam-scheme-dynamic-item' ) ){
 609+ // rebuild the menu items with recent items.
 610+ $( '#narayam-menu' ).html( $.narayam.buildMenuItems() );
 611+ $( '#narayam-menu-items' ).css( 'left', $( 'li#pt-narayam' ).offset().left );
 612+ $( '#narayam-' + $( this ).val() ).prop( 'checked', true );
 613+ if ( enabled ) {
 614+ $( '#narayam-toggle' ).prop( 'checked', true );
 615+ }
619616 }
620 - event.stopPropagation();
621617 } );
622618
623619 var helppage = mw.config.get( 'wgNarayamHelpPage' );
@@ -700,7 +696,9 @@
701697 $menu.removeClass( 'open' );
702698 $menu.hide();
703699 } );
704 -
 700+ $menu.click( function( event ) {
 701+ event.stopPropagation();
 702+ } );
705703 // Workaround for IE bug - activex components like input fields
706704 // coming on top of everything.
707705 // TODO: is there a better solution other than hiding it on hover?

Status & tagging log