Kaldari has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/389641 )

Change subject: Moving code for adding the toolbar button to its own function
......................................................................

Moving code for adding the toolbar button to its own function

This is to make the code more readable and easier to follow.

Change-Id: I6972038ca8a45bf3d0c119e93cf1af70dd424a82
---
M resources/ext.CodeMirror.js
1 file changed, 33 insertions(+), 26 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CodeMirror 
refs/changes/41/389641/1

diff --git a/resources/ext.CodeMirror.js b/resources/ext.CodeMirror.js
index aedb1b6..1afaf89 100644
--- a/resources/ext.CodeMirror.js
+++ b/resources/ext.CodeMirror.js
@@ -351,6 +351,38 @@
        }
 
        /**
+        * Adds CodeMirror button to the toolbar
+        */
+       function addToolbarButton() {
+               // Check if the user is using the enhanced editing toolbar 
(supplied by the
+               // WikiEditor extension) or the default editing toolbar 
(supplied by core).
+               if ( wikiEditorToolbarEnabled ) {
+                       // They are using the enhanced editing toolbar.
+                       mw.loader.using( 'ext.wikiEditor.toolbar', function () {
+                               // Add CodeMirror button to the enhanced 
editing toolbar.
+                               $( addCodeMirrorToWikiEditor );
+                       } );
+               } else {
+                       // They are using the default editing toolbar.
+                       mw.loader.using( 'mediawiki.toolbar', function () {
+                               // Add CodeMirror button to the default editing 
toolbar.
+                               mw.toolbar.addButton( {
+                                       speedTip: mw.msg( 
'codemirror-toggle-label' ),
+                                       imageId: 'mw-editbutton-codemirror',
+                                       onClick: function () {
+                                               switchCodeMirror();
+                                               return false;
+                                       }
+                               } );
+                               // We don't know when button will be added, 
wait until the document is ready to update it
+                               $( function () {
+                                       updateToolbarButton();
+                               } );
+                       } );
+               }
+       }
+
+       /**
         * Updates CodeMirror button on the toolbar according to the current 
state (on/off)
         */
        function updateToolbarButton() {
@@ -500,32 +532,7 @@
 
        // If view is in edit mode, add the button to the toolbar.
        if ( $( '#wpTextbox1' ).length ) {
-               // Check if the user is using the enhanced editing toolbar 
(supplied by the
-               // WikiEditor extension) or the default editing toolbar 
(supplied by core).
-               if ( wikiEditorToolbarEnabled ) {
-                       // They are using the enhanced editing toolbar.
-                       mw.loader.using( 'ext.wikiEditor.toolbar', function () {
-                               // Add CodeMirror button to the enhanced 
editing toolbar.
-                               $( addCodeMirrorToWikiEditor );
-                       } );
-               } else {
-                       // They are using the default editing toolbar.
-                       mw.loader.using( 'mediawiki.toolbar', function () {
-                               // Add CodeMirror button to the default editing 
toolbar.
-                               mw.toolbar.addButton( {
-                                       speedTip: mw.msg( 
'codemirror-toggle-label' ),
-                                       imageId: 'mw-editbutton-codemirror',
-                                       onClick: function () {
-                                               switchCodeMirror();
-                                               return false;
-                                       }
-                               } );
-                               // We don't know when button will be added, 
wait until the document is ready to update it
-                               $( function () {
-                                       updateToolbarButton();
-                               } );
-                       } );
-               }
+               addToolbarButton();
 
                // Don't show popup if CM already enabled
                if ( !useCodeMirror ) {

-- 
To view, visit https://gerrit.wikimedia.org/r/389641
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6972038ca8a45bf3d0c119e93cf1af70dd424a82
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CodeMirror
Gerrit-Branch: master
Gerrit-Owner: Kaldari <[email protected]>

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

Reply via email to