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

Change subject: Make sure popup appears for both classic and wikitext editors
......................................................................

Make sure popup appears for both classic and wikitext editors

Bug: T165003
Change-Id: I4b1c9498df7931643ea3c39d6d2afd9384e47de0
---
M CodeMirror.hooks.php
M extension.json
M resources/ext.CodeMirror.js
3 files changed, 27 insertions(+), 19 deletions(-)


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

diff --git a/CodeMirror.hooks.php b/CodeMirror.hooks.php
index 9c88320..34364fa 100644
--- a/CodeMirror.hooks.php
+++ b/CodeMirror.hooks.php
@@ -127,7 +127,6 @@
         */
        public static function onBeforePageDisplay( OutputPage &$out, Skin 
&$skin ) {
                if ( self::isCodeMirrorEnabled( $out->getContext() ) ) {
-                       $out->enableOOUI();
                        $out->addModules( 'ext.CodeMirror' );
                }
        }
diff --git a/extension.json b/extension.json
index e9fd787..bff8255 100644
--- a/extension.json
+++ b/extension.json
@@ -29,7 +29,7 @@
                                "mediawiki.api",
                                "mediawiki.api.options",
                                "user.options",
-                               "oojs-ui",
+                               "oojs-ui-widgets",
                                "mediawiki.storage"
                        ],
                        "scripts": [
diff --git a/resources/ext.CodeMirror.js b/resources/ext.CodeMirror.js
index abf6a24..aa823ac 100644
--- a/resources/ext.CodeMirror.js
+++ b/resources/ext.CodeMirror.js
@@ -412,6 +412,28 @@
                popup.toggle( true );
        }
 
+       /**
+        * Handle popup. If popup hasn't been shown before, show popup and add 
a localStorage entry.
+        * check it before showing popup in future.
+        */
+       function handlePopup() {
+               popupStatus = mw.storage.get( 'codemirror-try-popup' );
+               // If popup entry isn't in local storage, lets show them the 
popup
+               if ( !popupStatus ) {
+                       mw.storage.set( 'codemirror-try-popup', 1 );
+                       addPopup();
+                       $( '.codemirror-popup-btn-yes' ).click( function () {
+                               $( enableCodeMirror );
+                               $( setCodeEditorPreference( true ) );
+                               $( updateToolbarButton );
+                               popup.toggle( false );
+                       } );
+                       $( '.codemirror-popup-btn-no' ).click( function () {
+                               popup.toggle( false );
+                       } );
+               }
+       }
+
        /* Check if view is in edit mode and that the required modules are 
available. Then, customize the toolbar … */
        if ( $.inArray( mw.config.get( 'wgAction' ), [ 'edit', 'submit' ] ) !== 
-1 ) {
                if ( wikiEditorToolbarEnabled ) {
@@ -432,26 +454,13 @@
                                // We don't know when button will be added, 
wait until the document is ready to update it
                                $( function () {
                                        updateToolbarButton();
-                                       // Is there already a local storage 
entry?
-                                       // If so, we already showed them the 
popup, don't show again
-                                       popupStatus = mw.storage.get( 
'codemirror-try-popup' );
-                                       // If popup entry isn't in local 
storage, lets show them the popup
-                                       if ( !popupStatus ) {
-                                               mw.storage.set( 
'codemirror-try-popup', 1 );
-                                               addPopup();
-                                               $( '.codemirror-popup-btn-yes' 
).click( function () {
-                                                       enableCodeMirror();
-                                                       
setCodeEditorPreference( true );
-                                                       updateToolbarButton();
-                                                       popup.toggle( false );
-                                               } );
-                                               $( '.codemirror-popup-btn-no' 
).click( function () {
-                                                       popup.toggle( false );
-                                               } );
-                                       }
                                } );
                        } );
                }
+               // Wait for DOM before loading our popup
+               $( function() {
+                       handlePopup();
+               } );
        }
 
        // enable CodeMirror

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4b1c9498df7931643ea3c39d6d2afd9384e47de0
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CodeMirror
Gerrit-Branch: master
Gerrit-Owner: Niharika29 <nko...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to