Abort activation when changing to view mode.

Resolves (Bug 44838)

Changes:
* onLoad: Setup only if activating.  Prevents ve from loading after aborted
while activating.

* onViewTabClick: add clause for activating mode.  Calls deactivate with an
override, and exits activating mode.

Change-Id: Ia61cd1d576b63098419474ad58bc01362c08541e
This commit is contained in:
Rob Moen 2013-02-11 11:38:50 -08:00
parent 98a914e9fe
commit 3070d0c56e

View file

@ -296,18 +296,20 @@ ve.init.mw.ViewPageTarget.prototype.deactivate = function ( override ) {
* @param {HTMLElement} dom Parsed DOM from server
*/
ve.init.mw.ViewPageTarget.prototype.onLoad = function ( dom ) {
this.edited = false;
this.setUpSurface( dom );
this.setupToolbarEditNotices();
this.setupToolbarButtons();
this.setupSaveDialog();
this.attachToolbarButtons();
this.attachSaveDialog();
this.restoreScrollPosition();
this.restoreEditSection();
this.setupBeforeUnloadHandler();
this.$document.focus();
this.activating = false;
if ( this.activating ) {
this.edited = false;
this.setUpSurface( dom );
this.setupToolbarEditNotices();
this.setupToolbarButtons();
this.setupSaveDialog();
this.attachToolbarButtons();
this.attachSaveDialog();
this.restoreScrollPosition();
this.restoreEditSection();
this.setupBeforeUnloadHandler();
this.$document.focus();
this.activating = false;
}
};
/**
@ -485,6 +487,10 @@ ve.init.mw.ViewPageTarget.prototype.onViewTabClick = function ( e ) {
this.deactivate();
// Prevent the edit tab's normal behavior
e.preventDefault();
} else if ( this.activating ) {
this.deactivate( true );
this.activating = false;
e.preventDefault();
}
};