@ -119,26 +119,47 @@ function onShowMoreFiles() {
export function doLoadMoreFiles ( link , diffEnd , callback ) {
export function doLoadMoreFiles ( link , diffEnd , callback ) {
const url = ` ${ link } ?skip-to= ${ diffEnd } &file-only=true ` ;
const url = ` ${ link } ?skip-to= ${ diffEnd } &file-only=true ` ;
loadMoreFiles ( url , callback ) ;
}
function loadMoreFiles ( url , callback ) {
const $target = $ ( 'a#diff-show-more-files' ) ;
if ( $target . hasClass ( 'disabled' ) ) {
callback ( ) ;
return ;
}
$target . addClass ( 'disabled' ) ;
$ . ajax ( {
$ . ajax ( {
type : 'GET' ,
type : 'GET' ,
url ,
url ,
} ) . done ( ( resp ) => {
} ) . done ( ( resp ) => {
if ( ! resp ) {
if ( ! resp ) {
$target . removeClass ( 'disabled' ) ;
callback ( resp ) ;
callback ( resp ) ;
return ;
return ;
}
}
$ ( '#diff-incomplete' ) . replaceWith ( $ ( resp ) . find ( '#diff-file-boxes' ) . children ( ) ) ;
// By simply rerunning the script we add the new data to our existing
// By simply rerunning the script we add the new data to our existing
// pagedata object. this triggers vue and the filetree and filelist will
// pagedata object. this triggers vue and the filetree and filelist will
// render the new elements.
// render the new elements.
$ ( 'body' ) . append ( $ ( resp ) . find ( 'script#diff-data-script' ) ) ;
$ ( 'body' ) . append ( $ ( resp ) . find ( 'script#diff-data-script' ) ) ;
onShowMoreFiles ( ) ;
callback ( resp ) ;
callback ( resp ) ;
} ) . fail ( ( ) => {
} ) . fail ( ( ) => {
$target . removeClass ( 'disabled' ) ;
callback ( ) ;
callback ( ) ;
} ) ;
} ) ;
}
}
export function initRepoDiffShowMore ( ) {
export function initRepoDiffShowMore ( ) {
$ ( document ) . on ( 'click' , 'a.diff-show-more-button' , ( e ) => {
$ ( document ) . on ( 'click' , 'a#diff-show-more-files' , ( e ) => {
e . preventDefault ( ) ;
const $target = $ ( e . target ) ;
loadMoreFiles ( $target . data ( 'href' ) , ( ) => { } ) ;
} ) ;
$ ( document ) . on ( 'click' , 'a.diff-load-button' , ( e ) => {
e . preventDefault ( ) ;
e . preventDefault ( ) ;
const $target = $ ( e . target ) ;
const $target = $ ( e . target ) ;