User Preference to enable EtherEditor by default: Yay! A new Feature

So, EtherEditor is about to see a new feature. Happy News!

There is now a User Preference where users can get EtherEditor by default by just checking a checkbox in the Preference section of their own userspaces.

It was needed, as: 

Having two different entry points / interfaces for editing articles is inconsistent and will confuse users. In addition, if EtherEditor functionality is ever rolled out to a wider audience, having two tabs for edit/collaborate would be unacceptable from a design perspective for the same reas on (on a bigger scale) and we’d have to re-engineer it –> might as well do that engineering now. That said – if it’s easy to simply add a checkbox and split the interfaces, it’s a fine idea for the short-term. My recommendation is to stick to the “Collaboration mode” checkbox since it’s just as discoverable as an extra tab in the site chrome and will do more for consistency in the long-run. It still needs UX improvements, which will happen gradually. 


Now, let‘s look at some code, I wrote:

Define function:  public static function getUserPreference( $user, &$preferences ) {…}

  
Attach hook: $wgHooks[‘GetPreferences’][] = ‘EtherEditorHooks::getUserPreference’;

Code: 
     /**
    * 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;
    }

 

..this adds a checkbox in advanced section of the editing tab of Preferences, which says ‘Enable EtherEditor by default’. 

Which when checked, following part gets executed: 

_this.initializeControls( function () {
            if ( _this.uri.query.collaborate || mw.user.options.get( ‘enableether’ ) ) {
                $( ‘#ethereditor-collab-switch’ ).prop( ‘checked’ , true );
                    _this.enableEther();
                }
                if ( _this.uri.query.padId ) {
                    var thepad = false;
                    for ( var px in _this.pads ) {
                        if ( _this.pads[px].pad_id == _this.uri.query.padId ) {
                            thepad = _this.pads[px];
                            break;
                        }
                    }
                    if ( thepad ) {
                        _this.dbId = thepad.pad_id;
                        _this.padId = thepad.ep_pad_id;
                    }
                }
                _this.authenticateUser( function () {
                    $( ‘#ethereditor-collab-switch’ ).prop( ‘checked’, true );
                    _this.enableEther();
                } );
            }

        } ); 

Which obviously enables the EtherEditor. And thus, user gets the extension enabled by default. 🙂

For a better look at the code, visit my gerrit repository  
 

Leave a Reply

Your email address will not be published. Required fields are marked *