jenkins-bot has submitted this change and it was merged.

Change subject: Replace Mantle's EventEmitter with oojs's
......................................................................


Replace Mantle's EventEmitter with oojs's

Requires I89056c47fa14af3d7ba8cd326bcd84302353fe0c in oojs

Change-Id: I960592a3e8f3c853ee676fc6e983beda1b39563e
---
M includes/Resources.php
M javascripts/common/eventemitter.js
2 files changed, 12 insertions(+), 66 deletions(-)

Approvals:
  Jdlrobson: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/Resources.php b/includes/Resources.php
index 16548c7..6586312 100644
--- a/includes/Resources.php
+++ b/includes/Resources.php
@@ -67,6 +67,7 @@
        'ext.mantle.oo' => $wgMantleResourceBoilerplate + array(
                'dependencies' => array(
                        'ext.mantle.modules',
+                       'oojs',
                ),
                'scripts' => array(
                        'javascripts/common/Class.js',
diff --git a/javascripts/common/eventemitter.js 
b/javascripts/common/eventemitter.js
index 9e7f37e..858937c 100644
--- a/javascripts/common/eventemitter.js
+++ b/javascripts/common/eventemitter.js
@@ -1,75 +1,20 @@
-( function( M, $ ) {
+/*global OO */
+( function( M, $, OO ) {
 
        var Class = M.require( 'Class' ), EventEmitter;
 
-       function callbackProxy( callback ) {
-               return function() {
-                       var args = Array.prototype.slice.call( arguments, 1 );
-                       callback.apply( callback, args );
-               };
-       }
-
-       /**
-        * @class
-        * @extends Class
-        */
-       EventEmitter = Class.extend( {
-               /**
-                * Bind a callback to the event.
-                *
-                * @method
-                * @param {string} event Event name.
-                * @param {Function} callback Callback to be bound.
-                */
-               on: function( event, callback ) {
-                       $( this ).on( event, callbackProxy( callback ) );
-                       return this;
-               },
-
-               /**
-                * Bind a callback to the event and run it only once.
-                *
-                * @method
-                * @param {string} event Event name.
-                * @param {Function} callback Callback to be bound.
-                */
-               one: function( event, callback ) {
-                       $( this ).one( event, callbackProxy( callback ) );
-                       return this;
-               },
-
-               /**
-                * Emit an event. This causes all bound callbacks to be run.
-                *
-                * @method
-                * @param {string} event Event name.
-                * @param {*} [arguments] Optional arguments to be passed to 
callbacks.
-                */
-               emit: function( event /* , arg1, arg2, ... */ ) {
-                       var args = Array.prototype.slice.call( arguments, 1 );
-                       // use .triggerHandler() for emitting events to avoid 
accidentally
-                       // invoking object's functions, e.g. don't call 
obj.something() when
-                       // doing obj.emit( 'something' )
-                       $( this ).triggerHandler( event, args );
-                       return this;
-               },
-
-               /**
-                * Remove a callback.
-                *
-                * @name EventEmitter.prototype.off
-                * @method
-                * @param {string} event Event name.
-                */
-               off: function( event ) {
-                       $( this ).off( event );
-                       return this;
-               }
-       } );
+       // HACK: wrap around oojs's EventEmitter
+       // This needs some hackery to make oojs's
+       // and Mantle's different OO models get along,
+       // and we need to alias one() to once().
+       EventEmitter = Class.extend( $.extend( {
+               initialize: OO.EventEmitter,
+               one: OO.EventEmitter.prototype.once
+       }, OO.EventEmitter.prototype ) );
 
        M.define( 'eventemitter', EventEmitter );
        // FIXME: if we want more of M's functionality in loaded in <head>,
        // move this to a separate file
        $.extend( mw.mantle, new EventEmitter() );
 
-}( mw.mantle, jQuery ) );
+}( mw.mantle, jQuery, OO ) );

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I960592a3e8f3c853ee676fc6e983beda1b39563e
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/Mantle
Gerrit-Branch: master
Gerrit-Owner: Catrope <roan.katt...@gmail.com>
Gerrit-Reviewer: Jdlrobson <jrob...@wikimedia.org>
Gerrit-Reviewer: Jforrester <jforres...@wikimedia.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