Skip to content

Commit 6488156

Browse files
authored
Some clean up of JS. (#179)
Some cleanup and formating of the Javascript related to windows.
1 parent 3779e8b commit 6488156

File tree

2 files changed

+41
-37
lines changed

2 files changed

+41
-37
lines changed

index.windows.js

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class PSPDFKitView extends React.Component {
5050
};
5151

5252
_onDataReturned = event => {
53-
let { requestId, result, error } = event.nativeEvent;
53+
let {requestId, result, error} = event.nativeEvent;
5454
let promise = this._requestMap[requestId];
5555
if (result) {
5656
promise.resolve(result);
@@ -63,35 +63,35 @@ class PSPDFKitView extends React.Component {
6363
/**
6464
* Enters the annotation creation mode, showing the annotation creation toolbar.
6565
*/
66-
enterAnnotationCreationMode = function () {
66+
enterAnnotationCreationMode() {
6767
UIManager.dispatchViewManagerCommand(
6868
findNodeHandle(this.refs.pdfView),
6969
UIManager.RCTPSPDFKitView.Commands.enterAnnotationCreationMode,
7070
[]
7171
);
72-
};
72+
}
7373

7474
/**
7575
* Exits the currently active mode, hiding all active sub-toolbars.
7676
*/
77-
exitCurrentlyActiveMode = function () {
77+
exitCurrentlyActiveMode() {
7878
UIManager.dispatchViewManagerCommand(
7979
findNodeHandle(this.refs.pdfView),
8080
UIManager.RCTPSPDFKitView.Commands.exitCurrentlyActiveMode,
8181
[]
8282
);
83-
};
83+
}
8484

8585
/**
8686
* Saves the currently opened document.
8787
*/
88-
saveCurrentDocument = function () {
88+
saveCurrentDocument() {
8989
UIManager.dispatchViewManagerCommand(
9090
findNodeHandle(this.refs.pdfView),
9191
UIManager.RCTPSPDFKitView.Commands.saveCurrentDocument,
9292
[]
9393
);
94-
};
94+
}
9595

9696
/**
9797
* Gets all annotations from a specific page.
@@ -101,13 +101,13 @@ class PSPDFKitView extends React.Component {
101101
* @returns a promise resolving an array with the following structure:
102102
* {'annotations' : [instantJson]}
103103
*/
104-
getAnnotations = function (pageIndex) {
104+
getAnnotations(pageIndex) {
105105
let requestId = this._nextRequestId++;
106106
let requestMap = this._requestMap;
107107

108108
// We create a promise here that will be resolved once onDataReturned is called.
109-
let promise = new Promise(function (resolve, reject) {
110-
requestMap[requestId] = { resolve: resolve, reject: reject };
109+
let promise = new Promise((resolve, reject) => {
110+
requestMap[requestId] = {resolve: resolve, reject: reject};
111111
});
112112

113113
UIManager.dispatchViewManagerCommand(
@@ -117,34 +117,34 @@ class PSPDFKitView extends React.Component {
117117
);
118118

119119
return promise;
120-
};
120+
}
121121

122122
/**
123123
* Adds a new annotation to the current document.
124124
*
125125
* @param annotation InstantJson of the annotation to add with the format of
126126
* https://pspdfkit.com/guides/windows/current/importing-exporting/instant-json/#instant-annotation-json-api
127127
*/
128-
addAnnotation = function (annotation) {
128+
addAnnotation(annotation) {
129129
UIManager.dispatchViewManagerCommand(
130130
findNodeHandle(this.refs.pdfView),
131131
UIManager.RCTPSPDFKitView.Commands.addAnnotation,
132132
[annotation]
133133
);
134-
};
134+
}
135135

136136
/**
137137
* Gets toolbar items currently shown.
138138
*
139139
* @return Receives an array of https://pspdfkit.com/api/web/PSPDFKit.ToolbarItem.html.
140140
*/
141-
getToolbarItems = function () {
141+
getToolbarItems() {
142142
let requestId = this._nextRequestId++;
143143
let requestMap = this._requestMap;
144144

145145
// We create a promise here that will be resolved once onDataReturned is called.
146-
let promise = new Promise(function (resolve, reject) {
147-
requestMap[requestId] = { resolve: resolve, reject: reject };
146+
let promise = new Promise((resolve, reject) => {
147+
requestMap[requestId] = {resolve: resolve, reject: reject};
148148
});
149149

150150
UIManager.dispatchViewManagerCommand(
@@ -154,7 +154,7 @@ class PSPDFKitView extends React.Component {
154154
);
155155

156156
return promise;
157-
};
157+
}
158158

159159
/**
160160
* Set toolbar items currently shown.
@@ -165,13 +165,13 @@ class PSPDFKitView extends React.Component {
165165
* For more advance features please refer to
166166
* https://pspdfkit.com/guides/web/current/customizing-the-interface/customizing-the-toolbar/.
167167
*/
168-
setToolbarItems = function (toolbarItems) {
168+
setToolbarItems(toolbarItems) {
169169
let requestId = this._nextRequestId++;
170170
let requestMap = this._requestMap;
171171

172172
// We create a promise here that will be resolved once onDataReturned is called.
173-
let promise = new Promise(function (resolve, reject) {
174-
requestMap[requestId] = { resolve: resolve, reject: reject };
173+
let promise = new Promise((resolve, reject) => {
174+
requestMap[requestId] = {resolve: resolve, reject: reject};
175175
});
176176

177177
UIManager.dispatchViewManagerCommand(
@@ -181,7 +181,7 @@ class PSPDFKitView extends React.Component {
181181
);
182182

183183
return promise;
184-
};
184+
}
185185
}
186186

187187
PSPDFKitView.propTypes = {

samples/Catalog/Catalog.windows.js

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// This notice may not be removed from this file.
77
//
88

9-
import React, { Component } from "react";
9+
import React, {Component} from "react";
1010
import {
1111
StyleSheet,
1212
Text,
@@ -17,14 +17,14 @@ import {
1717
NativeModules,
1818
Button
1919
} from "react-native";
20-
import { StackNavigator } from "react-navigation";
20+
import {StackNavigator} from "react-navigation";
2121
import PSPDFKitView from "react-native-pspdfkit";
2222

2323
const PSPDFKit = NativeModules.ReactPSPDFKit;
2424
const PSPDFKitLibrary = NativeModules.ReactPSPDFKitLibrary;
2525
const RNFS = require("react-native-fs");
2626

27-
import { YellowBox } from "react-native";
27+
import {YellowBox} from "react-native";
2828

2929
YellowBox.ignoreWarnings([
3030
"Warning: Invalid argument supplied to oneOf" // React native windows bug.
@@ -41,7 +41,7 @@ const complexSearchConfiguration = {
4141
maximumPreviewResultsPerDocument: 0,
4242
maximumPreviewResultsTotal: 500,
4343
generateTextPreviews: true,
44-
previewRange: { position: 20, length: 120 }
44+
previewRange: {position: 20, length: 120}
4545
};
4646

4747
const simpleSearch = {
@@ -67,8 +67,12 @@ const examples = [
6767
// See https://docs.microsoft.com/en-us/windows/uwp/files/file-access-permissions
6868
const path = RNFS.MainBundlePath + "\\Assets\\pdf\\Business Report.pdf";
6969
PSPDFKit.Present(path)
70-
.then(() => { alert("File Opened successfully"); })
71-
.catch(error => { alert(error); });
70+
.then(() => {
71+
alert("File Opened successfully");
72+
})
73+
.catch(error => {
74+
alert(error);
75+
});
7276
}
7377
},
7478
{
@@ -223,16 +227,16 @@ class CatalogScreen extends Component<{}> {
223227
renderItem={this._renderRow}
224228
ItemSeparatorComponent={CatalogScreen._renderSeparator}
225229
contentContainerStyle={styles.listContainer}
226-
style={styles.list} />
230+
style={styles.list}/>
227231
</View>
228232
);
229233
}
230234

231235
static _renderSeparator(sectionId, rowId) {
232-
return <View key={rowId} style={styles.separator} />;
236+
return <View key={rowId} style={styles.separator}/>;
233237
}
234238

235-
_renderRow = ({ item, separators }) => {
239+
_renderRow = ({item, separators}) => {
236240
return (
237241
<TouchableHighlight
238242
onPress={() => {
@@ -261,7 +265,7 @@ class PdfViewScreen extends Component<{}> {
261265
/>
262266
<View style={styles.footer}>
263267
<View style={styles.button}>
264-
<Button onPress={() => PSPDFKit.OpenFilePicker()} title="Open" />
268+
<Button onPress={() => PSPDFKit.OpenFilePicker()} title="Open"/>
265269
</View>
266270
<Image
267271
source={require("./assets/logo-flat.png")}
@@ -277,13 +281,13 @@ class PdfViewScreen extends Component<{}> {
277281
}
278282

279283
class PdfViewListenersScreen extends Component<{}> {
280-
static navigationOptions = ({ navigation }) => {
284+
static navigationOptions = ({navigation}) => {
281285
const params = navigation.state.params || {};
282286

283287
return {
284288
title: "Event Listeners",
285289
headerRight: (
286-
<Button onPress={() => params.handleSaveButtonPress()} title="Save" />
290+
<Button onPress={() => params.handleSaveButtonPress()} title="Save"/>
287291
)
288292
};
289293
};
@@ -329,7 +333,7 @@ class PdfViewInstantJsonScreen extends Component<{}> {
329333

330334
render() {
331335
return (
332-
<View style={{ flex: 1 }}>
336+
<View style={{flex: 1}}>
333337
<PSPDFKitView
334338
ref="pdfView"
335339
style={styles.pdfView}
@@ -355,7 +359,7 @@ class PdfViewInstantJsonScreen extends Component<{}> {
355359
title="Get annotations"
356360
/>
357361
</View>
358-
<View style={{ marginLeft: 10 }}>
362+
<View style={{marginLeft: 10}}>
359363
<Button
360364
onPress={() => {
361365
// This adds a new ink annotation to the first page.
@@ -418,11 +422,11 @@ class PdfViewToolbarCustomizationScreen extends Component<{}> {
418422
<Button onPress={() =>
419423
this.refs.pdfView.getToolbarItems().then(toolbarItems => {
420424
alert(JSON.stringify(toolbarItems));
421-
})} title="Get Toolbar Items" />
425+
})} title="Get Toolbar Items"/>
422426
</View>
423427
<View style={styles.button}>
424428
<Button onPress={() =>
425-
this.refs.pdfView.setToolbarItems([{ type: "ink" }])} title="Set Toolbar Items" />
429+
this.refs.pdfView.setToolbarItems([{type: "ink"}])} title="Set Toolbar Items"/>
426430
</View>
427431
</View>
428432
<Image

0 commit comments

Comments
 (0)