Skip to content
This repository has been archived by the owner on Mar 29, 2021. It is now read-only.

Commit

Permalink
move all js globals into a single global
Browse files Browse the repository at this point in the history
  • Loading branch information
dsifford committed Sep 17, 2017
1 parent 8b08eca commit 9b28141
Show file tree
Hide file tree
Showing 35 changed files with 303 additions and 284 deletions.
6 changes: 3 additions & 3 deletions lib/fixtures.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const ABT_wp: BackendGlobals.ABT_wp = {
export const wpInfo: ABT.Backend['wp'] = {
abt_url: 'http://localhost:8080/wp-content/plugins/academic-bloggers-toolkit',
home_url: 'http://localhost:8080',
plugins_url: 'http://localhost:8080/wp-content/plugins',
Expand Down Expand Up @@ -26,7 +26,7 @@ export const ABT_wp: BackendGlobals.ABT_wp = {
},
};

export const ABT_Reflist_State: BackendGlobals.ABT_Reflist_State = {
export const state: ABT.Backend['state'] = {
bibOptions: {
heading: 'Bibliography',
style: 'fixed',
Expand Down Expand Up @@ -202,7 +202,7 @@ export const ABT_Reflist_State: BackendGlobals.ABT_Reflist_State = {
},
};

export const ABT_i18n: BackendGlobals.ABT_i18n = {
export const i18n: ABT.Backend['i18n'] = {
misc: {
footnotes: 'Footnotes',
},
Expand Down
15 changes: 10 additions & 5 deletions lib/scripts/before-test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
require('ts-node/register');
const { ABT_i18n, ABT_Reflist_State, ABT_wp } = require('../fixtures.ts');
const { i18n, state, wpInfo } = require('../fixtures.ts');
const styles = require('../../src/vendor/citation-styles.json');
window.ABT_i18n = ABT_i18n;
window.ABT_Reflist_State = ABT_Reflist_State;
window.ABT_wp = ABT_wp;
window.ABT_CitationStyles = styles;
window.ABT = {
state,
i18n,
wp: wpInfo,
styles,
custom_csl: {
label: '',
},
};
137 changes: 137 additions & 0 deletions lib/types/ABT.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,141 @@ declare namespace ABT {
attachInline: boolean;
identifierList: string;
}

interface i18n {
citationTypes: CitationTypes;
errors: {
missingPhpFeatures: 'Your WordPress PHP installation is incomplete. You must have the following PHP extensions enabled to use this feature: "dom", "libxml"';
badRequest: 'Request not valid';
denied: 'Site denied request';
fileExtensionError: 'Invalid file extension. Extension must be .ris, .bib, or .bibtex';
filetypeError: 'The file could not be processed';
identifiersNotFound: {
all: 'No identifiers could be found for your request';
some: 'The following identifiers could not be found';
};
networkError: 'Network Error';
noResults: 'Your search returned 0 results';
prefix: 'Error';
risLeftovers: 'The following references were unable to be processed';
statusError: 'Request returned a non-200 status code';
warnings: {
warning: 'Warning';
reason: 'Reason';
noBib: {
message: 'Cannot create publication list for currently selected citation style';
reason: 'Style does not include bibliography';
};
};
unexpected: {
message: 'An unexpected error occurred';
reportInstructions: 'Please report this error, including the steps taken to trigger it, here: \nhttps://github.com/dsifford/academic-bloggers-toolkit/issues'; // tslint:disable-line
};
};
fieldmaps: FieldMappings;
misc: {
footnotes: 'Footnotes';
};
referenceList: {
menu: {
styleLabels: {
custom: 'Custom Style';
predefined: 'Pre-defined Styles';
};
toggleLabel: 'Toggle menu';
tooltips: {
destroy: 'Delete all references';
help: 'Usage instructions';
importRIS: 'Import references';
refresh: 'Refresh reference list';
staticPubList: 'Insert static publication list';
};
};
citedItems: 'Cited Items';
tooltips: {
add: 'Add reference';
insert: 'Insert selected references';
pin: 'Pin reference list';
remove: 'Remove selected references';
};
uncitedItems: 'Uncited Items';
};
dialogs: {
closeLabel: 'Close dialog';
edit: {
title: 'Edit Reference';
confirm: 'Confirm';
};
import: {
importBtn: 'Import';
title: 'Import References';
upload: 'Choose File';
};
pubmed: {
addReference: 'Select';
next: 'Next';
previous: 'Previous';
search: 'Search';
title: 'Search PubMed';
viewReference: 'View';
};
add: {
buttonRow: {
addManually: 'Add Manually';
addReference: 'Add Reference';
addWithIdentifier: 'Add with Identifier';
insertInline: 'Insert citation inline';
searchPubmed: 'Search PubMed';
};
identifierInput: {
label: 'DOI/PMID/PMCID';
};
manualEntryContainer: {
autocite: 'Autocite';
citationType: 'Citation Type';
ISBN: 'ISBN';
search: 'Search';
URL: 'URL';
};
people: {
add: 'Add Contributor';
contributors: 'Contributors';
given: 'Given Name, M.I.';
surname: 'Surname';
};
title: 'Add References';
};
};
}

interface EditorState {
bibOptions: {
heading: string;
headingLevel: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
style: 'fixed' | 'toggle';
};
cache: {
style: string;
links: LinkStyle;
locale: string;
};
citationByIndex: Citeproc.CitationByIndex;
CSL: {
[id: string]: CSL.Data;
};
}

interface CustomCSL {
CSL?: string;
label: string;
value?: string;
}

interface Backend {
state: ABT.EditorState;
i18n: ABT.i18n;
styles: CitationStyles;
wp: WP_info;
custom_csl: ABT.CustomCSL;
}
}
Loading

0 comments on commit 9b28141

Please sign in to comment.