SG has uploaded a new change for review.

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


Change subject: Introduce Function.bind polyfill, fix IE8 errors
......................................................................

Introduce Function.bind polyfill, fix IE8 errors

Change-Id: Idcaee919dd03ad89250d0e588b29ba1613d79b82
---
M modules/base/ext.flow.base.js
M modules/discussion/forms.js
M modules/discussion/topic.js
3 files changed, 38 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow 
refs/changes/88/109788/1

diff --git a/modules/base/ext.flow.base.js b/modules/base/ext.flow.base.js
index f4841a1..d283488 100644
--- a/modules/base/ext.flow.base.js
+++ b/modules/base/ext.flow.base.js
@@ -1,5 +1,30 @@
 ( function ( $, mw ) {
 
+// @todo Put this somewhere in mw.core. This is an important polyfill.
+if (!Function.prototype.bind) {
+       Function.prototype.bind = function (oThis) {
+               if (typeof this !== "function") {
+                       // closest thing possible to the ECMAScript 5 internal 
IsCallable function
+                       throw new TypeError("Function.prototype.bind - what is 
trying to be bound is not callable");
+               }
+
+               var aArgs = Array.prototype.slice.call(arguments, 1),
+                       fToBind = this,
+                       fNOP = function () {},
+                       fBound = function () {
+                               return fToBind.apply(this instanceof fNOP && 
oThis
+                                       ? this
+                                       : oThis,
+                                       
aArgs.concat(Array.prototype.slice.call(arguments)));
+                       };
+
+               fNOP.prototype = this.prototype;
+               fBound.prototype = new fNOP();
+
+               return fBound;
+       };
+}
+
 mw.flow = {
 
        'api' : {
diff --git a/modules/discussion/forms.js b/modules/discussion/forms.js
index 1d90171..1bdba9b 100644
--- a/modules/discussion/forms.js
+++ b/modules/discussion/forms.js
@@ -13,7 +13,7 @@
 
                        // init new title interaction
                        if ( $newTopic.length && !$newTopic.data( 
'flow-initialised-new-topic' ) ) {
-                               new mw.flow.action.topic.new();
+                               new mw.flow.action.topic.create();
 
                                $newTopic.data( 'flow-initialised-new-topic', 
true );
                        }
diff --git a/modules/discussion/topic.js b/modules/discussion/topic.js
index 2127023..69d6e5b 100644
--- a/modules/discussion/topic.js
+++ b/modules/discussion/topic.js
@@ -368,7 +368,7 @@
        /**
         * Initialises new topic interaction object.
         */
-       mw.flow.action.topic.new = function () {
+       mw.flow.action.topic.create = function () {
                this.$form = $( '.flow-new-topic-container' );
 
                // fetch workflow parameters
@@ -377,19 +377,19 @@
                // Overload click in textarea, triggering full new topic form
                this.$form.find( '.flow-newtopic-title' )
                        .attr( 'placeholder', mw.msg( 
'flow-newtopic-start-placeholder' ) )
-                       .click( this.new.bind( this ) );
+                       .click( this.create.bind( this ) );
        };
 
        // extend edit action from "shared functionality" mw.flow.action class
-       mw.flow.action.topic.new.prototype = new mw.flow.action();
-       mw.flow.action.topic.new.prototype.constructor = 
mw.flow.action.topic.new;
+       mw.flow.action.topic.create.prototype = new mw.flow.action();
+       mw.flow.action.topic.create.prototype.constructor = 
mw.flow.action.topic.create;
 
        /**
         * Fired when textarea is clicked.
         *
         * @param {Event} e
         */
-       mw.flow.action.topic.new.prototype.new = function ( e ) {
+       mw.flow.action.topic.create.prototype.create = function ( e ) {
                // don't follow link that will lead to &action=new-topic
                e.preventDefault();
 
@@ -408,7 +408,7 @@
        /**
         * Builds the new topic form.
         */
-       mw.flow.action.topic.new.prototype.loadNewForm = function () {
+       mw.flow.action.topic.create.prototype.loadNewForm = function () {
                this.$form.find( '.flow-newtopic-title' )
                        .byteLimit( mw.config.get( 'wgFlowMaxTopicLength' ) )
                        .attr( 'placeholder', mw.msg( 
'flow-newtopic-title-placeholder' ) );
@@ -451,7 +451,7 @@
        /**
         * Destroys the JS magic & restores the form in its original state
         */
-       mw.flow.action.topic.new.prototype.destroyForm = function () {
+       mw.flow.action.topic.create.prototype.destroyForm = function () {
                mw.flow.editor.destroy( this.$form.find( 
'.flow-newtopic-content' ) );
 
                this.$form.find( '.flow-newtopic-step2' )
@@ -490,7 +490,7 @@
         * @param {string} content
         * @return {jQuery.Deferred}
         */
-       mw.flow.action.topic.new.prototype.submitFunction = function ( title, 
content ) {
+       mw.flow.action.topic.create.prototype.submitFunction = function ( 
title, content ) {
                var deferred = mw.flow.api.newTopic(
                        this.workflow,
                        title,
@@ -507,7 +507,7 @@
         *
         * @param {object} output
         */
-       mw.flow.action.topic.new.prototype.render = function ( output ) {
+       mw.flow.action.topic.create.prototype.render = function ( output ) {
                $( output.rendered )
                        .hide()
                        .prependTo( $( '.flow-topics' ) )
@@ -522,7 +522,7 @@
         * @return {array} Array with params, to be fed to validateCallback &
         * submitFunction
         */
-       mw.flow.action.topic.new.prototype.loadParametersCallback = function () 
{
+       mw.flow.action.topic.create.prototype.loadParametersCallback = function 
() {
                var title = this.$form.find( '.flow-newtopic-title' ).val(),
                        content = mw.flow.editor.getContent( this.$form.find( 
'.flow-newtopic-content' ) );
 
@@ -536,14 +536,14 @@
         * @param {string} content
         * @return {bool}
         */
-       mw.flow.action.topic.new.prototype.validateCallback = function ( title, 
content ) {
+       mw.flow.action.topic.create.prototype.validateCallback = function ( 
title, content ) {
                return !!title;
        };
 
        /**
         * @param {jQuery.Deferred}
         */
-       mw.flow.action.topic.new.prototype.promiseCallback = function ( 
deferred ) {
+       mw.flow.action.topic.create.prototype.promiseCallback = function ( 
deferred ) {
                deferred.done( this.destroyForm.bind( this ) );
        };
 } ( jQuery, mediaWiki ) );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Idcaee919dd03ad89250d0e588b29ba1613d79b82
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: SG <[email protected]>

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

Reply via email to