http://www.mediawiki.org/wiki/Special:Code/MediaWiki/96186

Revision: 96186
Author:   santhosh
Date:     2011-09-03 14:06:27 +0000 (Sat, 03 Sep 2011)
Log Message:
-----------
Refactor the code for building the menu to buildMenu.

Modified Paths:
--------------
    trunk/extensions/Narayam/js/ext.narayam.core.js

Modified: trunk/extensions/Narayam/js/ext.narayam.core.js
===================================================================
--- trunk/extensions/Narayam/js/ext.narayam.core.js     2011-09-03 13:55:07 UTC 
(rev 96185)
+++ trunk/extensions/Narayam/js/ext.narayam.core.js     2011-09-03 14:06:27 UTC 
(rev 96186)
@@ -385,6 +385,36 @@
         * from a cookie or wgNarayamEnableByDefault
         */
        this.setup = function() {
+               //build the menu.
+               that.buildMenu();
+       
+               // Restore state from cookies
+               var savedScheme = $.cookie( 'narayam-scheme' );
+               if ( savedScheme && savedScheme in schemes ) {
+                       that.setScheme( savedScheme );
+                       $( '#narayam-' + savedScheme ).attr( 'checked', 
'checked' );
+               } else {
+                       //if no saved input scheme, select the first.
+                       $('input.narayam-scheme:first').attr( 'checked', 
'checked' );
+               }
+               var enabledCookie = $.cookie( 'narayam-enabled' );
+               if ( enabledCookie == '1' || ( mw.config.get( 
'wgNarayamEnabledByDefault' ) && enabledCookie !== '0' ) ) {
+                       that.enable();
+               }
+               else {
+                       $( 'li#pt-narayam').addClass( 'narayam-inactive' );
+               }
+               // Renew the narayam-enabled cookie. naraym-scheme is renewed 
by setScheme()
+               if ( enabledCookie ) {
+                       $.cookie( 'narayam-enabled', enabledCookie, { 'path': 
'/', 'expires': 30 } );
+               }
+                       
+       };
+       
+       /*
+        * Construct the menu for Narayam
+        */
+       this.buildMenu = function() {
                var haveSchemes = false;
                // Build schemes option list
                var $ul = $( '<ul/>' );
@@ -458,35 +488,12 @@
                //if rtl, add to the right of top personal links. Else, to the 
left
                var fn = $('body').hasClass( 'rtl' ) ? "append" : "prepend";
                $('#p-personal ul:first')[fn]( $li );
-               
                // Build enable/disable checkbox and label
                $checkbox = $( '<input type="checkbox" id="narayam-toggle" />' 
);
                $checkbox
                        .attr( 'title', mw.msg( 'narayam-checkbox-tooltip' ) )
                        .click( that.toggle );
-               
-               // Restore state from cookies
-               var savedScheme = $.cookie( 'narayam-scheme' );
-               if ( savedScheme && savedScheme in schemes ) {
-                       that.setScheme( savedScheme );
-                       $( '#narayam-' + savedScheme ).attr( 'checked', 
'checked' );
-               } else {
-                       //if no saved input scheme, select the first.
-                       $('input.narayam-scheme:first').attr( 'checked', 
'checked' );
-               }
-               var enabledCookie = $.cookie( 'narayam-enabled' );
-               if ( enabledCookie == '1' || ( mw.config.get( 
'wgNarayamEnabledByDefault' ) && enabledCookie !== '0' ) ) {
-                       that.enable();
-               }
-               else {
-                       $( 'li#pt-narayam').addClass( 'narayam-inactive' );
-               }
-               // Renew the narayam-enabled cookie. naraym-scheme is renewed 
by setScheme()
-               if ( enabledCookie ) {
-                       $.cookie( 'narayam-enabled', enabledCookie, { 'path': 
'/', 'expires': 30 } );
-               }
-                       
-       };
+       }
        
 } )();
 


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to