Hello Niharika29, jenkins-bot, Kaldari,

I'd like you to do a code review.  Please visit

    https://gerrit.wikimedia.org/r/362336

to review the following change.


Change subject: Revert "Show a popup for first time Codemirror users"
......................................................................

Revert "Show a popup for first time Codemirror users"

This reverts commit 99e31d152fa5945f7f56a9b168cb4dd337f63654.

This commit breaks extension and contains security issues.

Change-Id: I6bbe966673dabd047e9543cbeb47c157e2cbf814
---
M CodeMirror.hooks.php
M extension.json
M i18n/en.json
M i18n/qqq.json
M resources/ext.CodeMirror.js
D resources/modules/popup.less
6 files changed, 9 insertions(+), 112 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CodeMirror 
refs/changes/36/362336/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 db9d5af..a24dd9c 100644
--- a/extension.json
+++ b/extension.json
@@ -28,23 +28,16 @@
                                "jquery.textSelection",
                                "mediawiki.api",
                                "mediawiki.api.options",
-                               "user.options",
-                               "oojs-ui"
+                               "user.options"
                        ],
                        "scripts": [
                                "ext.CodeMirror.js"
                        ],
                        "styles": [
-                               "ext.CodeMirror.less",
-                               "modules/popup.less"
+                               "ext.CodeMirror.less"
                        ],
                        "messages": [
-                               "codemirror-toggle-label",
-                               "codemirror-popup-syntax",
-                               "codemirror-popup-highlighting",
-                               "codemirror-popup-desc",
-                               "codemirror-popup-btn-yes",
-                               "codemirror-popup-btn-no"
+                               "codemirror-toggle-label"
                        ]
                },
                "ext.CodeMirror.lib": {
diff --git a/i18n/en.json b/i18n/en.json
index ee0733b..9087119 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -7,10 +7,5 @@
        "codemirror-desc": "Provides syntax highlighting in wikitext editor",
        "codemirror-toggle-label": "Syntax highlighting",
        "codemirror-beta-title": "Syntax highlighting",
-       "codemirror-beta-desc": "Syntax highlighting makes editing easier by 
using color and shade to visually separate article text from the code for 
links, references and templates.",
-       "codemirror-popup-syntax": "Syntax",
-       "codemirror-popup-highlighting": "Highlighting",
-       "codemirror-popup-desc": "Syntax highlighting will help you easily 
distinguish different parts of your edit by color coding them.",
-       "codemirror-popup-btn-yes": "Try it",
-       "codemirror-popup-btn-no": "No, thank you"
+       "codemirror-beta-desc": "Syntax highlighting makes editing easier by 
using color and shade to visually separate article text from the code for 
links, references and templates."
 }
diff --git a/i18n/qqq.json b/i18n/qqq.json
index ba7c0c1..9496c89 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -10,10 +10,5 @@
        "codemirror-desc": "{{desc|name=Code 
Mirror|url=https://www.mediawiki.org/wiki/Extension:CodeMirror}}\n\nAdditional 
info: Discription of \"Syntax highlighting\" in 
wiki\n[[mw:Extension:SyntaxHighlight GeSHi]]",
        "codemirror-toggle-label": "Title tooltip for button to toggle 
CodeMirror in the editing toolbar.",
        "codemirror-beta-title": "Title for syntax highlighting beta feature",
-       "codemirror-beta-desc": "Description for syntax highlight beta feature",
-       "codemirror-popup-syntax": "This message is combined with the message 
{{msg-mw|codemirror-popup-highlighting}} to form the title \"Syntax 
Highlighting\" (with the two words having different styling).",
-       "codemirror-popup-highlighting": "This message is combined with the 
message {{msg-mw|codemirror-popup-syntax}} to form the title \"Syntax 
Highlighting\" (with the two words having different styling).",
-       "codemirror-popup-desc": "Description of the syntax highlighting 
feature in the popup",
-       "codemirror-popup-btn-yes": "Text on the button for trying out 
codemirror",
-       "codemirror-popup-btn-no": "Text on the button for dismissing popup"
+       "codemirror-beta-desc": "Description for syntax highlight beta feature"
 }
diff --git a/resources/ext.CodeMirror.js b/resources/ext.CodeMirror.js
index 62b6b5f..7f766dd 100644
--- a/resources/ext.CodeMirror.js
+++ b/resources/ext.CodeMirror.js
@@ -1,6 +1,5 @@
 ( function ( mw, $ ) {
-       var origTextSelection, useCodeMirror, codeMirror, api, 
originHooksTextarea,
-               wikiEditorToolbarEnabled, popupStatus = null, popup = false;
+       var origTextSelection, useCodeMirror, codeMirror, api, 
originHooksTextarea, wikiEditorToolbarEnabled;
 
        if ( mw.config.get( 'wgCodeEditorCurrentLanguage' ) ) { // If the 
CodeEditor is used then just exit;
                return;
@@ -386,41 +385,12 @@
                } );
        }
 
-       /**
-        * Add a popup for first time users (T165003)
-        */
-       function addPopup() {
-               this.popuptext = '<div class=\'codemirror-popup-div\'>' +
-                       '<div class=\'codemirror-popup-top\'>{ <span 
class=\'codemirror-popup-color-blue\'>' +
-                       mw.msg( 'codemirror-popup-syntax' ) + '</span> ' +
-                       mw.msg( 'codemirror-popup-highlighting' ) + ' }</div>' +
-                       '<div class=\'codemirror-popup-text\'>' + mw.msg( 
'codemirror-popup-desc' ) + '</div>' +
-                       '<div class=\'codemirror-popup-btn 
codemirror-popup-btn-yes\'>' + mw.msg( 'codemirror-popup-btn-yes' ) + '</div>' +
-                       '<div class=\'codemirror-popup-btn 
codemirror-popup-btn-no\'>' + mw.msg( 'codemirror-popup-btn-no' ) + '</div>' +
-                       '</div>';
-               popup = new OO.ui.PopupWidget( {
-                       $content: $( this.popuptext ),
-                       containerPadding: 80,
-                       $floatableContainer: $( '#mw-editbutton-codemirror' ),
-                       padded: false,
-                       width: 215
-               } );
-               // Add our popup to the body, it will find its correct position 
using $floatableContainer
-               $( 'body' ).append( popup.$element );
-
-               // To display the popup, toggle the visibility to 'true'
-               popup.toggle( true );
-       }
-
        /* 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 ) {
-                       // Add our button
-                       if ( useCodeMirror ) {
-                               $( addCodeMirrorToWikiEditor );
-                       }
+                       // load wikiEditor's toolbar (if not already) and add 
our button
+                       $( '#wpTextbox1' ).on( 
'wikiEditor-toolbar-doneInitialSections', addCodeMirrorToWikiEditor );
                } else {
-                       // Load wikiEditor's toolbar and add our button
                        mw.loader.using( 'mediawiki.toolbar', function () {
                                // If WikiEditor isn't enabled, add CodeMirror 
button to the default wiki editor toolbar
                                mw.toolbar.addButton( {
@@ -432,30 +402,7 @@
                                        }
                                } );
                                // 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 = localStorage.getItem( 
'codemirror-try-popup' );
-                                       // If popup entry isn't in local 
storage, lets show them the popup
-                                       if ( !popupStatus ) {
-                                               try {
-                                                       localStorage.setItem( 
'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 );
-                                                       } );
-                                               } catch ( e ) {
-                                                       // No local storage or 
local storage full, don't show popup
-                                               }
-                                       }
-                               } );
+                               $( function () { updateToolbarButton(); } );
                        } );
                }
        }
@@ -468,5 +415,4 @@
                        enableCodeMirror();
                }
        }
-
 }( mediaWiki, jQuery ) );
diff --git a/resources/modules/popup.less b/resources/modules/popup.less
deleted file mode 100644
index 2cd15ed..0000000
--- a/resources/modules/popup.less
+++ /dev/null
@@ -1,31 +0,0 @@
-.codemirror-popup-div {
-       padding: 14px;
-       text-align: center;
-       font-size: 14px;
-
-       .codemirror-popup-top {
-               font-size: 16px;
-               font-weight: bolder;
-               margin-bottom: 10px;
-       }
-
-       .codemirror-popup-color-blue {
-               color: #1e90ff;
-       }
-
-       .codemirror-popup-btn {
-               font-weight: bolder;
-               margin-top: 5px;
-               cursor: pointer;
-
-               &-yes {
-                       background-color: #4169e1;
-                       color: #fff;
-                       border-radius: 5px;
-                       width: 80px;
-                       margin: auto;
-                       margin-top: 5px;
-                       padding: 5px;
-               }
-       }
-}

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6bbe966673dabd047e9543cbeb47c157e2cbf814
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CodeMirror
Gerrit-Branch: master
Gerrit-Owner: Pastakhov <[email protected]>
Gerrit-Reviewer: Kaldari <[email protected]>
Gerrit-Reviewer: Niharika29 <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to