Catrope has uploaded a new change for review.

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


Change subject: Use .done()/.fail() instead of 'success'/'error'
......................................................................

Use .done()/.fail() instead of 'success'/'error'

'success' and 'error' are deprecated.

Also make all generateContents() promises abortable.

Change-Id: I8f95e9386f7749e635ce3715389896a0ccdb7523
---
M modules/ve-mw/ce/nodes/ve.ce.MWExtensionNode.js
M modules/ve-mw/ce/nodes/ve.ce.MWImageNode.js
M modules/ve-mw/ce/nodes/ve.ce.MWTransclusionNode.js
M modules/ve-mw/init/ve.init.mw.Target.js
M modules/ve-mw/ui/dialogs/ve.ui.MWMetaDialog.js
5 files changed, 41 insertions(+), 39 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor 
refs/changes/19/90319/1

diff --git a/modules/ve-mw/ce/nodes/ve.ce.MWExtensionNode.js 
b/modules/ve-mw/ce/nodes/ve.ce.MWExtensionNode.js
index ffd39a8..dc3c195 100644
--- a/modules/ve-mw/ce/nodes/ve.ce.MWExtensionNode.js
+++ b/modules/ve-mw/ce/nodes/ve.ce.MWExtensionNode.js
@@ -53,14 +53,16 @@
 
 /** */
 ve.ce.MWExtensionNode.prototype.generateContents = function ( config ) {
-       var deferred = $.Deferred(),
+       var xhr,
+               deferred = $.Deferred(),
+               promise = deferred.promise(),
                mwData = this.getModel().getAttribute( 'mw' ),
                extsrc = config && config.extsrc !== undefined ? config.extsrc 
: mwData.body.extsrc,
                attrs = config && config.attrs || mwData.attrs,
                extensionNode = $( document.createElement( 
this.getModel().getExtensionName() ) )
                        .attr( attrs ).text( extsrc );
 
-       $.ajax( {
+       xhr = $.ajax( {
                'url': mw.util.wikiScript( 'api' ),
                'data': {
                        'action': 'visualeditor',
@@ -74,10 +76,12 @@
                'type': 'POST',
                // Wait up to 100 seconds before giving up
                'timeout': 100000,
-               'cache': 'false',
-               'success': ve.bind( this.onParseSuccess, this, deferred ),
-               'error': ve.bind( this.onParseError, this, deferred )
-       } );
+               'cache': 'false'
+       } )
+               .done( ve.bind( this.onParseSuccess, this, deferred ) )
+               .fail( ve.bind( this.onParseError, this, deferred ) );
+
+       promise.abort = ve.bind( xhr.abort, xhr );
        return deferred.promise();
 };
 
diff --git a/modules/ve-mw/ce/nodes/ve.ce.MWImageNode.js 
b/modules/ve-mw/ce/nodes/ve.ce.MWImageNode.js
index 2d945d1..f908937 100644
--- a/modules/ve-mw/ce/nodes/ve.ce.MWImageNode.js
+++ b/modules/ve-mw/ce/nodes/ve.ce.MWImageNode.js
@@ -74,10 +74,10 @@
                // TODO: Only use JSON-P for cross-domain.
                // jQuery has this logic built-in (if url is not same-origin ..)
                // but isn't working for some reason.
-               'dataType': 'jsonp',
-               'success': ve.bind( this.onParseSuccess, this, deferred ),
-               'error': ve.bind( this.onParseError, this, deferred )
-       } );
+               'dataType': 'jsonp'
+       } )
+               .done( ve.bind( this.onParseSuccess, this, deferred ) )
+               .fail( ve.bind( this.onParseError, this, deferred ) );
 
        promise.abort = ve.bind( xhr.abort, xhr );
        return promise;
diff --git a/modules/ve-mw/ce/nodes/ve.ce.MWTransclusionNode.js 
b/modules/ve-mw/ce/nodes/ve.ce.MWTransclusionNode.js
index d6763d4..2ba34d1 100644
--- a/modules/ve-mw/ce/nodes/ve.ce.MWTransclusionNode.js
+++ b/modules/ve-mw/ce/nodes/ve.ce.MWTransclusionNode.js
@@ -58,7 +58,7 @@
 
 /** */
 ve.ce.MWTransclusionNode.prototype.generateContents = function ( config ) {
-       var xhr, promise, deferred = $.Deferred();
+       var xhr, deferred = $.Deferred(), promise = deferred.promise();
        xhr = $.ajax( {
                'url': mw.util.wikiScript( 'api' ),
                'data': {
@@ -73,14 +73,12 @@
                'type': 'POST',
                // Wait up to 100 seconds before giving up
                'timeout': 100000,
-               'cache': 'false',
-               'success': ve.bind( this.onParseSuccess, this, deferred ),
-               'error': ve.bind( this.onParseError, this, deferred )
-       } );
-       promise = deferred.promise();
-       promise.abort = function () {
-               xhr.abort();
-       };
+               'cache': 'false'
+       } )
+               .done( ve.bind( this.onParseSuccess, this, deferred ) )
+               .fail( ve.bind( this.onParseError, this, deferred ) );
+
+       promise.abort = ve.bind( xhr.abort, xhr );
        return promise;
 };
 
diff --git a/modules/ve-mw/init/ve.init.mw.Target.js 
b/modules/ve-mw/init/ve.init.mw.Target.js
index 04e4037..0735ace 100644
--- a/modules/ve-mw/init/ve.init.mw.Target.js
+++ b/modules/ve-mw/init/ve.init.mw.Target.js
@@ -537,10 +537,10 @@
                'type': 'POST',
                // Wait up to 100 seconds before giving up
                'timeout': 100000,
-               'cache': 'false',
-               'success': ve.bind( ve.init.mw.Target.onLoad, this ),
-               'error': ve.bind( ve.init.mw.Target.onLoadError, this )
-       } );
+               'cache': 'false'
+       } )
+               .done( ve.bind( ve.init.mw.Target.onLoad, this ) )
+               .fail( ve.bind( ve.init.mw.Target.onLoadError, this ) );
 
        this.loading.done( function ( data, status, jqxhr ) {
                ve.track( 'performance.parsoid.domLoad', {
@@ -596,10 +596,10 @@
                'dataType': 'json',
                'type': 'POST',
                // Wait up to 100 seconds before giving up
-               'timeout': 100000,
-               'success': ve.bind( ve.init.mw.Target.onSave, this ),
-               'error': ve.bind( ve.init.mw.Target.onSaveError, this )
-       } );
+               'timeout': 100000
+       } )
+               .done( ve.bind( ve.init.mw.Target.onSave, this ) )
+               .fail( ve.bind( ve.init.mw.Target.onSaveError, this ) );
 
        this.saving.done( function ( data, status, jqxhr ) {
                ve.track( 'performance.parsoid.domSave', {
@@ -632,10 +632,10 @@
                'dataType': 'json',
                'type': 'POST',
                // Wait up to 100 seconds before giving up
-               'timeout': 100000,
-               'success': ve.bind( ve.init.mw.Target.onShowChanges, this ),
-               'error': ve.bind( ve.init.mw.Target.onShowChangesError, this )
-       } );
+               'timeout': 100000
+       } )
+               .done( ve.bind( ve.init.mw.Target.onShowChanges, this ) )
+               .fail( ve.bind( ve.init.mw.Target.onShowChangesError, this ) );
 };
 
 /**
@@ -722,9 +722,9 @@
                'type': 'POST',
                // Wait up to 100 seconds before giving up
                'timeout': 100000,
-               'cache': 'false',
-               'success': ve.bind( ve.init.mw.Target.onSerialize, this ),
-               'error': ve.bind( ve.init.mw.Target.onSerializeError, this )
-       } );
+               'cache': 'false'
+       } )
+               .done( ve.bind( ve.init.mw.Target.onSerialize, this ) )
+               .fail( ve.bind( ve.init.mw.Target.onSerializeError, this ) );
        return true;
 };
diff --git a/modules/ve-mw/ui/dialogs/ve.ui.MWMetaDialog.js 
b/modules/ve-mw/ui/dialogs/ve.ui.MWMetaDialog.js
index 25486b5..b272755 100644
--- a/modules/ve-mw/ui/dialogs/ve.ui.MWMetaDialog.js
+++ b/modules/ve-mw/ui/dialogs/ve.ui.MWMetaDialog.js
@@ -350,10 +350,10 @@
                'type': 'POST',
                // Wait up to 100 seconds before giving up
                'timeout': 100000,
-               'cache': 'false',
-               'success': ve.bind( this.onAllLanuageItemsSuccess, this, 
deferred ),
-               'error': ve.bind( this.onAllLanuageItemsError, this, deferred )
-       } );
+               'cache': 'false'
+       } )
+               .done( ve.bind( this.onAllLanuageItemsSuccess, this, deferred ) 
)
+               .fail( ve.bind( this.onAllLanuageItemsError, this, deferred ) );
        return deferred.promise();
 };
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8f95e9386f7749e635ce3715389896a0ccdb7523
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Catrope <[email protected]>

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

Reply via email to