mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-09-25 19:26:46 +00:00
Audit target hooks
* Move (de)activationComplete up to ArticleTarget * Mark (de)activate to be deprecated in the future * Fix some properties to ensure target.edited is boolean Change-Id: Ie34139cb68f90f34eb243f1bb964ef578e90dfb2
This commit is contained in:
parent
d8cbff898b
commit
be9c6800ad
|
@ -677,8 +677,6 @@ ve.init.mw.DesktopArticleTarget.prototype.teardown = function ( trackMechanism )
|
|||
$( '.ve-init-mw-desktopArticleTarget-uneditableContent' )
|
||||
.removeClass( 've-init-mw-desktopArticleTarget-uneditableContent' );
|
||||
|
||||
mw.hook( 've.deactivationComplete' ).fire( target.edited );
|
||||
|
||||
if ( !target.isViewPage ) {
|
||||
location.href = target.viewUri.clone().extend( {
|
||||
redirect: mw.config.get( 'wgIsRedirect' ) ? 'no' : undefined
|
||||
|
@ -841,8 +839,6 @@ ve.init.mw.DesktopArticleTarget.prototype.surfaceReady = function () {
|
|||
|
||||
this.activatingDeferred.resolve();
|
||||
this.events.trackActivationComplete();
|
||||
|
||||
mw.hook( 've.activationComplete' ).fire();
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -1124,6 +1120,7 @@ ve.init.mw.DesktopArticleTarget.prototype.setupSkinTabs = function () {
|
|||
.on( 'click.ve-target', this.onViewTabClick.bind( this ) );
|
||||
}
|
||||
|
||||
// Used by Extension:GuidedTour
|
||||
mw.hook( 've.skinTabSetupComplete' ).fire();
|
||||
};
|
||||
|
||||
|
@ -1218,6 +1215,8 @@ ve.init.mw.DesktopArticleTarget.prototype.transformPage = function () {
|
|||
this.updateTabs( true );
|
||||
this.emit( 'transformPage' );
|
||||
|
||||
// TODO: Deprecate in favour of ve.activationComplete
|
||||
// Only used by one gadget
|
||||
mw.hook( 've.activate' ).fire();
|
||||
|
||||
// Move all native content inside the target
|
||||
|
@ -1319,6 +1318,7 @@ ve.init.mw.DesktopArticleTarget.prototype.restorePage = function () {
|
|||
$( '#catlinks' ).replaceWith( this.$originalCategories );
|
||||
}
|
||||
|
||||
// TODO: Deprecate in favour of ve.deactivationComplete
|
||||
mw.hook( 've.deactivate' ).fire();
|
||||
this.emit( 'restorePage' );
|
||||
|
||||
|
|
|
@ -342,7 +342,7 @@ ve.init.mw.ArticleTarget.prototype.loadSuccess = function ( response ) {
|
|||
this.track( 'trace.parseResponse.enter' );
|
||||
this.originalHtml = data.content;
|
||||
this.etag = data.etag;
|
||||
this.fromEditedState = data.fromEditedState;
|
||||
this.fromEditedState = !!data.fromEditedState;
|
||||
this.switched = data.switched || 'wteswitched' in new mw.Uri( location.href ).query;
|
||||
this.doc = this.constructor.static.parseDocument( this.originalHtml, this.getDefaultMode() );
|
||||
|
||||
|
@ -392,7 +392,7 @@ ve.init.mw.ArticleTarget.prototype.parseMetadata = function ( response ) {
|
|||
this.baseTimeStamp = data.basetimestamp;
|
||||
this.startTimeStamp = data.starttimestamp;
|
||||
this.revid = data.oldid;
|
||||
this.preloaded = data.preloaded;
|
||||
this.preloaded = !!data.preloaded;
|
||||
|
||||
this.checkboxesDef = data.checkboxesDef;
|
||||
this.checkboxesMessages = data.checkboxesMessages;
|
||||
|
@ -579,6 +579,8 @@ ve.init.mw.ArticleTarget.prototype.surfaceReady = function () {
|
|||
|
||||
// Parent method
|
||||
ve.init.mw.ArticleTarget.super.prototype.surfaceReady.apply( this, arguments );
|
||||
|
||||
mw.hook( 've.activationComplete' ).fire();
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -1841,7 +1843,8 @@ ve.init.mw.ArticleTarget.prototype.createSurface = function () {
|
|||
* @inheritdoc
|
||||
*/
|
||||
ve.init.mw.ArticleTarget.prototype.teardown = function () {
|
||||
var surface;
|
||||
var surface,
|
||||
target = this;
|
||||
if ( !this.teardownPromise ) {
|
||||
surface = this.getSurface();
|
||||
|
||||
|
@ -1857,7 +1860,9 @@ ve.init.mw.ArticleTarget.prototype.teardown = function () {
|
|||
surface.getModel().disconnect( this );
|
||||
}
|
||||
// Parent method
|
||||
this.teardownPromise = ve.init.mw.ArticleTarget.super.prototype.teardown.call( this );
|
||||
this.teardownPromise = ve.init.mw.ArticleTarget.super.prototype.teardown.call( this ).then( function () {
|
||||
mw.hook( 've.deactivationComplete' ).fire( target.edited );
|
||||
} );
|
||||
}
|
||||
return this.teardownPromise;
|
||||
};
|
||||
|
@ -1981,7 +1986,7 @@ ve.init.mw.ArticleTarget.prototype.isSaveable = function () {
|
|||
// Document was edited
|
||||
surface.getModel().hasBeenModified() ||
|
||||
// Section title (if it exists) was edited
|
||||
( this.sectionTitle && this.sectionTitle.getValue() !== '' );
|
||||
( !!this.sectionTitle && this.sectionTitle.getValue() !== '' );
|
||||
|
||||
return this.edited || this.restoring;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue