Skip to content

Commit

Permalink
Chore: Full pass of prettier formatting (#223)
Browse files Browse the repository at this point in the history
Prettier version bump changed some rules
  • Loading branch information
tonyjin authored Jul 18, 2017
1 parent f285ba8 commit 814aa75
Show file tree
Hide file tree
Showing 42 changed files with 141 additions and 86 deletions.
6 changes: 4 additions & 2 deletions src/lib/Fullscreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@ class Fullscreen extends EventEmitter {
isFullscreen(element) {
let fullscreen;
if (this.isSupported()) {
fullscreen = !!(document.fullscreenElement ||
fullscreen = !!(
document.fullscreenElement ||
document.mozFullScreenElement ||
document.webkitFullscreenElement ||
document.msFullscreenElement);
document.msFullscreenElement
);
} else {
fullscreen = element instanceof HTMLElement && element.classList.contains(CLASS_FULLSCREEN);
}
Expand Down
8 changes: 4 additions & 4 deletions src/lib/Preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ const LOG_RETRY_COUNT = 3; // number of times to retry logging preview event
// and not when preview is instantiated, which is too late.
const PREVIEW_LOCATION = findScriptLocation(PREVIEW_SCRIPT_NAME, document.currentScript);

@autobind class Preview extends EventEmitter {
@autobind
class Preview extends EventEmitter {
/** @property {boolean} - Whether preview is open */
open = false;

Expand Down Expand Up @@ -1023,9 +1024,8 @@ const PREVIEW_LOCATION = findScriptLocation(PREVIEW_SCRIPT_NAME, document.curren
* @return {Object} Headers
*/
getRequestHeaders(token) {
const videoHint = Browser.canPlayDash() && !this.disabledViewers.Dash
? X_REP_HINT_VIDEO_DASH
: X_REP_HINT_VIDEO_MP4;
const videoHint =
Browser.canPlayDash() && !this.disabledViewers.Dash ? X_REP_HINT_VIDEO_DASH : X_REP_HINT_VIDEO_MP4;
const headers = {
'X-Rep-Hints': `${X_REP_HINT_BASE}${X_REP_HINT_DOC_THUMBNAIL}${X_REP_HINT_IMAGE}${videoHint}`
};
Expand Down
3 changes: 2 additions & 1 deletion src/lib/annotations/Annotation.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import autobind from 'autobind-decorator';

@autobind class Annotation {
@autobind
class Annotation {
//--------------------------------------------------------------------------
// Typedef
//--------------------------------------------------------------------------
Expand Down
9 changes: 6 additions & 3 deletions src/lib/annotations/AnnotationService.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ const ANONYMOUS_USER = {
name: __('annotation_anonymous_user_name')
};

@autobind class AnnotationService extends EventEmitter {
@autobind
class AnnotationService extends EventEmitter {
//--------------------------------------------------------------------------
// Static
//--------------------------------------------------------------------------
Expand All @@ -23,7 +24,8 @@ const ANONYMOUS_USER = {
static generateID() {
/* eslint-disable */
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {
var r = (Math.random() * 16) | 0, v = c == 'x' ? r : (r & 0x3) | 0x8;
var r = (Math.random() * 16) | 0,
v = c == 'x' ? r : (r & 0x3) | 0x8;
return v.toString(16);
});
/* eslint-enable */
Expand Down Expand Up @@ -248,7 +250,8 @@ const ANONYMOUS_USER = {
* @return {Promise} Promise that resolves with fetched annotations
*/
getReadUrl(fileVersionId, marker = null, limit = null) {
let apiUrl = `${this.api}/2.0/files/${this.fileId}/annotations?version=${fileVersionId}&fields=item,thread,details,message,created_by,created_at,modified_at,permissions`;
let apiUrl = `${this.api}/2.0/files/${this
.fileId}/annotations?version=${fileVersionId}&fields=item,thread,details,message,created_by,created_at,modified_at,permissions`;
if (marker) {
apiUrl += `&marker=${marker}`;
}
Expand Down
3 changes: 2 additions & 1 deletion src/lib/annotations/AnnotationThread.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import * as annotatorUtil from './annotatorUtil';
import { ICON_PLACED_ANNOTATION } from '../icons/icons';
import { STATES, TYPES, CLASS_ANNOTATION_POINT_BUTTON, DATA_TYPE_ANNOTATION_INDICATOR } from './annotationConstants';

@autobind class AnnotationThread extends EventEmitter {
@autobind
class AnnotationThread extends EventEmitter {
//--------------------------------------------------------------------------
// Typedef
//--------------------------------------------------------------------------
Expand Down
3 changes: 2 additions & 1 deletion src/lib/annotations/Annotator.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import {

const CLASS_ANNOTATION_POINT_MODE = 'bp-point-annotation-mode';

@autobind class Annotator extends EventEmitter {
@autobind
class Annotator extends EventEmitter {
//--------------------------------------------------------------------------
// Typedef
//--------------------------------------------------------------------------
Expand Down
3 changes: 2 additions & 1 deletion src/lib/annotations/doc/DocAnnotator.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ function isThreadInHoverState(thread) {
return thread.state === STATES.hover;
}

@autobind class DocAnnotator extends Annotator {
@autobind
class DocAnnotator extends Annotator {
/**
* For tracking the most recent event fired by mouse move event.
*
Expand Down
3 changes: 2 additions & 1 deletion src/lib/annotations/doc/DocHighlightThread.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ const PAGE_PADDING_BOTTOM = 15;
const PAGE_PADDING_TOP = 15;
const HOVER_TIMEOUT_MS = 75;

@autobind class DocHighlightThread extends AnnotationThread {
@autobind
class DocHighlightThread extends AnnotationThread {
/**
* Cached page element for the document.
*
Expand Down
3 changes: 2 additions & 1 deletion src/lib/annotations/doc/DocPointDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import * as docAnnotatorUtil from './docAnnotatorUtil';
const PAGE_PADDING_TOP = 15;
const POINT_ANNOTATION_ICON_DOT_HEIGHT = 8;

@autobind class DocPointDialog extends AnnotationDialog {
@autobind
class DocPointDialog extends AnnotationDialog {
//--------------------------------------------------------------------------
// Abstract Implementations
//--------------------------------------------------------------------------
Expand Down
8 changes: 6 additions & 2 deletions src/lib/annotations/doc/DocPointThread.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ const POINT_ANNOTATION_ICON_HEIGHT = 31;
const POINT_ANNOTATION_ICON_DOT_HEIGHT = 8;
const POINT_ANNOTATION_ICON_WIDTH = 24;

@autobind class DocPointThread extends AnnotationThread {
@autobind
class DocPointThread extends AnnotationThread {
//--------------------------------------------------------------------------
// Public
//--------------------------------------------------------------------------
Expand Down Expand Up @@ -51,7 +52,10 @@ const POINT_ANNOTATION_ICON_WIDTH = 24;
// Position and append to page
this.element.style.left = `${browserX - POINT_ANNOTATION_ICON_WIDTH / 2}px`;
// Add 15px for vertical padding on page
this.element.style.top = `${browserY - POINT_ANNOTATION_ICON_HEIGHT + POINT_ANNOTATION_ICON_DOT_HEIGHT / 2 + PAGE_PADDING_TOP}px`;
this.element.style.top = `${browserY -
POINT_ANNOTATION_ICON_HEIGHT +
POINT_ANNOTATION_ICON_DOT_HEIGHT / 2 +
PAGE_PADDING_TOP}px`;
pageEl.appendChild(this.element);

annotatorUtil.showElement(this.element);
Expand Down
3 changes: 2 additions & 1 deletion src/lib/annotations/image/ImageAnnotator.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ const IMAGE_NODE_NAME = 'img';
// Selector for image container OR multi-image container
const ANNOTATED_ELEMENT_SELECTOR = '.bp-image, .bp-images-wrapper';

@autobind class ImageAnnotator extends Annotator {
@autobind
class ImageAnnotator extends Annotator {
//--------------------------------------------------------------------------
// Abstract Implementations
//--------------------------------------------------------------------------
Expand Down
15 changes: 10 additions & 5 deletions src/lib/annotations/image/ImagePointDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ const PAGE_PADDING_TOP = 15;
const POINT_ANNOTATION_ICON_HEIGHT = 31;
const POINT_ANNOTATION_ICON_DOT_HEIGHT = 8;

@autobind class ImagePointDialog extends AnnotationDialog {
@autobind
class ImagePointDialog extends AnnotationDialog {
//--------------------------------------------------------------------------
// Abstract Implementations
//--------------------------------------------------------------------------
Expand Down Expand Up @@ -45,14 +46,18 @@ const POINT_ANNOTATION_ICON_DOT_HEIGHT = 8;
// Only reposition if one side is past page boundary - if both are,
// just center the dialog and cause scrolling since there is nothing
// else we can do
const pageWidth = imageEl.clientWidth > this.annotatedElement.clientWidth
? imageEl.clientWidth
: this.annotatedElement.clientWidth;
const pageWidth =
imageEl.clientWidth > this.annotatedElement.clientWidth
? imageEl.clientWidth
: this.annotatedElement.clientWidth;
dialogLeftX = annotatorUtil.repositionCaret(this.element, dialogLeftX, dialogWidth, browserX, pageWidth);

// Position the dialog
this.element.style.left = `${dialogLeftX}px`;
this.element.style.top = `${dialogTopY + PAGE_PADDING_TOP - POINT_ANNOTATION_ICON_HEIGHT + POINT_ANNOTATION_ICON_DOT_HEIGHT}px`;
this.element.style.top = `${dialogTopY +
PAGE_PADDING_TOP -
POINT_ANNOTATION_ICON_HEIGHT +
POINT_ANNOTATION_ICON_DOT_HEIGHT}px`;
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/lib/annotations/image/ImagePointThread.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ const POINT_ANNOTATION_ICON_HEIGHT = 31;
const POINT_ANNOTATION_ICON_DOT_HEIGHT = 8;
const POINT_ANNOTATION_ICON_WIDTH = 24;

@autobind class ImagePointThread extends AnnotationThread {
@autobind
class ImagePointThread extends AnnotationThread {
//--------------------------------------------------------------------------
// Abstract Implementations
//--------------------------------------------------------------------------
Expand Down
3 changes: 2 additions & 1 deletion src/lib/viewers/BaseViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ const ANNOTATIONS_CSS = ['annotations.css'];
const LOAD_TIMEOUT_MS = 180000; // 3m
const RESIZE_WAIT_TIME_IN_MILLIS = 300;

@autobind class BaseViewer extends EventEmitter {
@autobind
class BaseViewer extends EventEmitter {
/** @property {Controls} - UI used to interact with the document in the viewer */
controls;

Expand Down
3 changes: 2 additions & 1 deletion src/lib/viewers/box3d/Box3DControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import './Box3DControls.scss';
import { CLASS_HIDDEN } from '../../constants';
import { UIRegistry } from './Box3DUIUtils';

@autobind class Box3DControls extends EventEmitter {
@autobind
class Box3DControls extends EventEmitter {
/** @property {HTMLElement} - Reference to the parent container to nest UI in */
el;

Expand Down
10 changes: 5 additions & 5 deletions src/lib/viewers/box3d/Box3DRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,8 @@ class Box3DRenderer extends EventEmitter {
if (!this.vrCommonLoadPromise) {
if (commonEntities) {
this.vrCommonLoadPromise = this.box3d.addRemoteEntities(
`${this.staticBaseURI}third-party/model3d/${MODEL3D_STATIC_ASSETS_VERSION}/WebVR/${commonEntities}/entities.json`,
`${this
.staticBaseURI}third-party/model3d/${MODEL3D_STATIC_ASSETS_VERSION}/WebVR/${commonEntities}/entities.json`,
{ isExternal: true }
);
} else {
Expand All @@ -518,10 +519,9 @@ class Box3DRenderer extends EventEmitter {
}
if (!this.vrGamepadLoadPromises[controllerName]) {
this.vrCommonLoadPromise.then(() => {
this.vrGamepadLoadPromises[
controllerName
] = this.box3d.addRemoteEntities(
`${this.staticBaseURI}third-party/model3d/${MODEL3D_STATIC_ASSETS_VERSION}/WebVR/${controllerName}/entities.json`,
this.vrGamepadLoadPromises[controllerName] = this.box3d.addRemoteEntities(
`${this
.staticBaseURI}third-party/model3d/${MODEL3D_STATIC_ASSETS_VERSION}/WebVR/${controllerName}/entities.json`,
{ isExternal: true }
);
this.vrGamepadLoadPromises[controllerName].then(onGamepadModelLoad);
Expand Down
3 changes: 2 additions & 1 deletion src/lib/viewers/box3d/Box3DViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ const CLASS_VR_ENABLED = 'vr-enabled';
* This is the entry point for Box3D Preview Base
* @class
*/
@autobind class Box3DViewer extends BaseViewer {
@autobind
class Box3DViewer extends BaseViewer {
/** @property {Box3DRenderer} - Box3DRenderer instance. Renders the 3D scene */
renderer;

Expand Down
3 changes: 2 additions & 1 deletion src/lib/viewers/box3d/model3d/Model3DControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ import { ICON_3D_RESET, ICON_ANIMATION, ICON_GEAR, ICON_PAUSE, ICON_PLAY } from
* Render Mode selection, VR and fullscreen buttons.
* @class
*/
@autobind class Model3DControls extends Box3DControls {
@autobind
class Model3DControls extends Box3DControls {
/** @property {Model3DAnimationClipsPullup} - UI Component for listing and interacting with animation clips */
animationClipsPullup;

Expand Down
2 changes: 1 addition & 1 deletion src/lib/viewers/box3d/model3d/Model3DRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const PREVIEW_CAMERA_QUATERNION = {
x: -0.101,
y: -0.325,
z: -0.035,
w: 0.940
w: 0.94
};

const OPTIMIZE_FRAMETIME_THRESHOLD_REGULAR = 30; // 20 FPS
Expand Down
3 changes: 2 additions & 1 deletion src/lib/viewers/box3d/model3d/Model3DViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ const LOAD_TIMEOUT = 180000; // 3 minutes
* This is the entry point for the model3d preview.
* @class
*/
@autobind class Model3DViewer extends Box3DViewer {
@autobind
class Model3DViewer extends Box3DViewer {
/** @property {Object[]} - List of Box3D instances added to the scene */
instances = [];

Expand Down
3 changes: 2 additions & 1 deletion src/lib/viewers/box3d/model3d/Model3DVrControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ class Model3DVrControls {
*
* @return {void}
*/
@autobind onScaleUpdate() {
@autobind
onScaleUpdate() {
this.vrGamepads[0].getPosition(this.vrWorkVector1);
this.vrGamepads[1].getPosition(this.vrWorkVector2);
const currentScaleDistance = this.vrWorkVector1.sub(this.vrWorkVector2).length();
Expand Down
24 changes: 16 additions & 8 deletions src/lib/viewers/box3d/video360/Video360Viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ class Video360Viewer extends DashViewer {
*
* @inheritdoc
*/
@autobind loadeddataHandler() {
@autobind
loadeddataHandler() {
const { token, apiHost } = this.options;
this.renderer = new Video360Renderer(this.mediaContainerEl, new BoxSDK({ token, apiBase: apiHost }));
this.renderer.on(EVENT_SHOW_VR_BUTTON, this.handleShowVrButton);
Expand Down Expand Up @@ -141,7 +142,8 @@ class Video360Viewer extends DashViewer {
/**
* @inheritdoc
*/
@autobind resize() {
@autobind
resize() {
super.resize();
if (this.renderer) {
this.renderer.resize();
Expand All @@ -155,7 +157,8 @@ class Video360Viewer extends DashViewer {
* @private
* @return {void}
*/
@autobind create360Environment() {
@autobind
create360Environment() {
this.skybox = this.renderer.getScene().getComponentByScriptId('skybox_renderer');

this.videoAsset = this.renderer.getBox3D().createVideo(
Expand Down Expand Up @@ -185,7 +188,8 @@ class Video360Viewer extends DashViewer {
/**
* @inheritdoc
*/
@autobind toggleFullscreen() {
@autobind
toggleFullscreen() {
fullscreen.toggle(this.wrapperEl);
}

Expand All @@ -194,7 +198,8 @@ class Video360Viewer extends DashViewer {
*
* @return {void}
*/
@autobind handleToggleVr() {
@autobind
handleToggleVr() {
this.renderer.toggleVr();

if (!this.renderer.vrEnabled) {
Expand All @@ -214,7 +219,8 @@ class Video360Viewer extends DashViewer {
*
* @return {void}
*/
@autobind handleShowVrButton() {
@autobind
handleShowVrButton() {
this.controls.showVrButton();
}

Expand All @@ -223,7 +229,8 @@ class Video360Viewer extends DashViewer {
*
* @return {void}
*/
@autobind onCanvasMouseDown() {
@autobind
onCanvasMouseDown() {
this.renderer.getBox3D().once('mouseUp', this.onCanvasMouseUp);
}

Expand All @@ -232,7 +239,8 @@ class Video360Viewer extends DashViewer {
*
* @return {void}
*/
@autobind onCanvasMouseUp() {
@autobind
onCanvasMouseUp() {
const input = this.renderer.getInputController();
// Make sure the mouse hasn't moved (within mouse/touch buffer drag allowance)
if (!input.getPreviousMouseDragState() && !input.getPreviousTouchDragState()) {
Expand Down
10 changes: 6 additions & 4 deletions src/lib/viewers/doc/DocBaseViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ const MINIMUM_RANGE_REQUEST_FILE_SIZE_NON_US = 5242880; // 5MB
const DISABLE_RANGE_REQUEST_EXENSIONS = ['xls', 'xlsm', 'xlsx'];
const MOBILE_MAX_CANVAS_SIZE = 2949120; // ~3MP 1920x1536

@autobind class DocBaseViewer extends BaseViewer {
@autobind
class DocBaseViewer extends BaseViewer {
//--------------------------------------------------------------------------
// Public
//--------------------------------------------------------------------------
Expand Down Expand Up @@ -512,9 +513,10 @@ const MOBILE_MAX_CANVAS_SIZE = 2949120; // ~3MP 1920x1536
// smaller chunk size if not. This is using a rough assumption that
// en-US users have higher bandwidth to Box.
if (!rangeChunkSize) {
rangeChunkSize = this.options.location.locale === 'en-US'
? RANGE_REQUEST_CHUNK_SIZE_US
: RANGE_REQUEST_CHUNK_SIZE_NON_US;
rangeChunkSize =
this.options.location.locale === 'en-US'
? RANGE_REQUEST_CHUNK_SIZE_US
: RANGE_REQUEST_CHUNK_SIZE_NON_US;
}

const docInitParams = {
Expand Down
Loading

0 comments on commit 814aa75

Please sign in to comment.