mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-29 08:34:54 +00:00
Refactor out show/hide loading spinner
Change-Id: If505a46f54921ce4742ecfed598eb07a9ba5e3eb
This commit is contained in:
parent
e144e55972
commit
841dfda98d
|
@ -339,8 +339,7 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var $spinner = $( '<div class="mw-viewPageTarget-loading"></div>' );
|
init.showLoading();
|
||||||
$( '#firstHeading' ).prepend( $spinner );
|
|
||||||
|
|
||||||
if ( window.history.pushState && uri.query.veaction !== 'edit' ) {
|
if ( window.history.pushState && uri.query.veaction !== 'edit' ) {
|
||||||
//Set veaction to edit
|
//Set veaction to edit
|
||||||
|
@ -352,7 +351,7 @@
|
||||||
|
|
||||||
getTarget().done( function ( target ) {
|
getTarget().done( function ( target ) {
|
||||||
ve.track( 'Edit', { action: 'edit-link-click' } );
|
ve.track( 'Edit', { action: 'edit-link-click' } );
|
||||||
target.activate().always( function () { $spinner.remove(); } );
|
target.activate().always( init.hideLoading.bind( init ) );
|
||||||
} );
|
} );
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -361,8 +360,7 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var $spinner = $( '<div class="mw-viewPageTarget-loading"></div>' );
|
init.showLoading();
|
||||||
$( '#firstHeading' ).prepend( $spinner );
|
|
||||||
if ( window.history.pushState && uri.query.veaction !== 'edit' ) {
|
if ( window.history.pushState && uri.query.veaction !== 'edit' ) {
|
||||||
window.history.pushState( { tag: 'visualeditor' }, document.title, this.href );
|
window.history.pushState( { tag: 'visualeditor' }, document.title, this.href );
|
||||||
}
|
}
|
||||||
|
@ -372,8 +370,21 @@
|
||||||
getTarget().done( function ( target ) {
|
getTarget().done( function ( target ) {
|
||||||
ve.track( 'Edit', { action: 'section-edit-link-click' } );
|
ve.track( 'Edit', { action: 'section-edit-link-click' } );
|
||||||
target.saveEditSection( $( e.target ).closest( 'h1, h2, h3, h4, h5, h6' ).get( 0 ) );
|
target.saveEditSection( $( e.target ).closest( 'h1, h2, h3, h4, h5, h6' ).get( 0 ) );
|
||||||
target.activate().always( function () { $spinner.remove(); } );
|
target.activate().always( init.hideLoading.bind( init ) );
|
||||||
} );
|
} );
|
||||||
|
},
|
||||||
|
|
||||||
|
showLoading: function () {
|
||||||
|
if ( !init.$loading ) {
|
||||||
|
init.$loading = $( '<div class="mw-viewPageTarget-loading"></div>' );
|
||||||
|
}
|
||||||
|
$( '#firstHeading' ).prepend( init.$loading );
|
||||||
|
},
|
||||||
|
|
||||||
|
hideLoading: function () {
|
||||||
|
if ( init.$loading ) {
|
||||||
|
init.$loading.detach();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -451,11 +462,10 @@
|
||||||
$( function () {
|
$( function () {
|
||||||
if ( init.isAvailable ) {
|
if ( init.isAvailable ) {
|
||||||
if ( isViewPage && uri.query.veaction === 'edit' ) {
|
if ( isViewPage && uri.query.veaction === 'edit' ) {
|
||||||
var $spinner = $( '<div class="mw-viewPageTarget-loading"></div>' );
|
init.showLoading();
|
||||||
$( '#firstHeading' ).prepend( $spinner );
|
|
||||||
|
|
||||||
getTarget().done( function ( target ) {
|
getTarget().done( function ( target ) {
|
||||||
target.activate().always( function () { $spinner.remove(); } );
|
target.activate().always( init.hideLoading.bind( init ) );
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue