2018-12-12 18:37:19 +00:00
|
|
|
/**
|
|
|
|
* @module gateway/reference
|
|
|
|
*/
|
|
|
|
|
2019-01-24 15:33:29 +00:00
|
|
|
import { previewTypes } from '../preview/model';
|
|
|
|
|
2018-12-12 18:37:19 +00:00
|
|
|
const mw = mediaWiki,
|
|
|
|
$ = jQuery;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return {Gateway}
|
|
|
|
*/
|
|
|
|
export default function createReferenceGateway() {
|
|
|
|
/**
|
|
|
|
* @param {mw.Title} title
|
|
|
|
* @returns {AbortPromise<PreviewModel>}
|
|
|
|
*/
|
2019-01-23 16:50:19 +00:00
|
|
|
function fetchPreviewForTitle( title ) {
|
2018-12-12 18:37:19 +00:00
|
|
|
const id = title.getFragment();
|
|
|
|
|
|
|
|
return $.Deferred().resolve( {
|
2019-01-23 19:26:48 +00:00
|
|
|
title: mw.msg( 'popups-refpreview-footnote' ),
|
2019-01-28 12:22:31 +00:00
|
|
|
url: `#${ id }`,
|
2018-12-12 18:37:19 +00:00
|
|
|
// TODO: Can probably be removed
|
|
|
|
// languageCode: 'en',
|
|
|
|
// languageDirection: 'ltr',
|
2019-01-28 12:22:31 +00:00
|
|
|
extract: $( `#${ $.escapeSelector( id ) } .reference-text` ).html(),
|
2018-12-12 18:37:19 +00:00
|
|
|
type: previewTypes.TYPE_REFERENCE
|
|
|
|
// TODO: Can probably be removed
|
|
|
|
// thumbnail: '',
|
|
|
|
// pageId: '0'
|
|
|
|
} ).promise( { abort() {} } );
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
2019-01-23 16:50:19 +00:00
|
|
|
fetchPreviewForTitle
|
2018-12-12 18:37:19 +00:00
|
|
|
};
|
|
|
|
}
|