MarkTraceur has submitted this change and it was merged.

Change subject: Add a user preference to enable collaboration by default
......................................................................


Add a user preference to enable collaboration by default

Useful for people who know they'll be collaborating often.

Change-Id: I3acf9bc043958527461810972b318278eb9cb6c0
Bug: 39389
---
M EtherEditor.i18n.php
M EtherEditor.php
M EtherEditorHooks.php
M modules/ext.etherEditor.js
4 files changed, 24 insertions(+), 6 deletions(-)

Approvals:
  MarkTraceur: Verified; Looks good to me, approved
  jenkins-bot: Checked



diff --git a/EtherEditor.i18n.php b/EtherEditor.i18n.php
index 5d4f691..8063d28 100644
--- a/EtherEditor.i18n.php
+++ b/EtherEditor.i18n.php
@@ -36,6 +36,7 @@
        'ethereditor-switch-to-session' => 'Switch to this session',
        'ethereditor-recover-session' => 'Recover this session',
        'ethereditor-leave' => ' Collaboration mode is disabled',
+       'ethereditor-preference-button' => 'Enable EtherEditor by default',
 );
 
 /** Message documentation (Message documentation)
diff --git a/EtherEditor.php b/EtherEditor.php
index 2d1e8f5..faa8ab3 100644
--- a/EtherEditor.php
+++ b/EtherEditor.php
@@ -43,6 +43,7 @@
 
 $wgSpecialPages['EtherEditor'] = 'SpecialEtherEditor';
 $wgSpecialPageGroups['EtherEditor'] = 'pagetools';
+$wgHooks['GetPreferences'][] = 'EtherEditorHooks::getUserPreference';
 
 $wgHooks['UnitTestsList'][] = 'EtherEditorHooks::registerUnitTests';
 
diff --git a/EtherEditorHooks.php b/EtherEditorHooks.php
index 6239eab..60a9720 100644
--- a/EtherEditorHooks.php
+++ b/EtherEditorHooks.php
@@ -79,6 +79,21 @@
        }
 
        /**
+       * Hook: GetUserPreferences
+       * @param User $user
+       * @param array $preferences
+       * @return bool
+       */
+       public static function getUserPreference( $user, &$preferences ) {
+               $preferences['enableether'] = array(
+                       'type' => 'toggle',
+                       'label-message' => 'ethereditor-preference-button',
+                       'section' => 'editing/advancedediting',
+                       );
+               return true;
+       }
+
+       /**
         * EditPage::showEditForm:initial hook
         *
         * Adds the modules to the edit form
diff --git a/modules/ext.etherEditor.js b/modules/ext.etherEditor.js
index bbd8545..22eca60 100644
--- a/modules/ext.etherEditor.js
+++ b/modules/ext.etherEditor.js
@@ -75,7 +75,7 @@
                        return false; // there was an error, clearly, so let's 
quit
                }
                _this.initializeControls( function () {
-                       if ( _this.uri.query.collaborate ) {
+                       if ( _this.uri.query.collaborate || 
mw.user.options.get( 'enableether' ) ) {
                                if ( _this.uri.query.padId ) {
                                        var thepad = false;
                                        for ( var px in _this.pads ) {
@@ -504,7 +504,7 @@
 
                        for ( var i = 2; i < 6; i++ ) {
                                var $headings = $( 'a[rel=heading-' + i + ']' );
-                               $headings.click( ( 
+                               $headings.click( (
                                        function( thisi ) {
                                                return function () {
                                                        _this.sendMessage( { 
heading: thisi } );
@@ -550,15 +550,15 @@
                        /**
                        * Display message that you leave collaborative editor
                        */
-                       var $collabLabel1 = $( '<span 
class="leave-msg"></span>' );
-                       $collabLabel1.text( mw.msg( 'ethereditor-leave' ) );
+                       var $collabLabel = $( '<span class="leave-msg"></span>' 
);
+                       $collabLabel.text( mw.msg( 'ethereditor-leave' ) );
                        $turnOnCollab.click( function () {
                                var $this = $( this );
                                if ( $this.is( ':checked' ) ) {
-                                       $collabLabel1.detach();
+                                       $collabLabel.detach();
                                        _this.enableEther();
                                } else {
-                                       _this.$ctrls.before($collabLabel1);
+                                       _this.$ctrls.before($collabLabel);
                                        _this.disableEther();
                                }
                        } );
@@ -577,6 +577,7 @@
                        _this.$pctrls.attr( 'id', 'ethereditor-pad-ctrls' );
                        _this.$ctrls.append( _this.$pctrls );
 
+
                        var eventHandle = function () {
                                this.selectionStart = 0;
                                this.selectionEnd = $( this ).val().length;

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I3acf9bc043958527461810972b318278eb9cb6c0
Gerrit-PatchSet: 19
Gerrit-Project: mediawiki/extensions/EtherEditor
Gerrit-Branch: master
Gerrit-Owner: SuchetaG <sucheta.ghos...@gmail.com>
Gerrit-Reviewer: MarkTraceur <mtrac...@member.fsf.org>
Gerrit-Reviewer: jenkins-bot

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

Reply via email to