Skip to content

Commit

Permalink
docs(examples): Provide example for startAt option (#1080)
Browse files Browse the repository at this point in the history
  • Loading branch information
jstoffan authored and mergify[bot] committed Oct 2, 2019
1 parent c01b1a8 commit 5011b81
Showing 1 changed file with 23 additions and 14 deletions.
37 changes: 23 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,30 +145,39 @@ preview.show(fileId, accessToken, {
| useHotkeys | true | Whether hotkeys (keyboard shortcuts) are enabled |
| fixDependencies | false | Temporarily patches AMD to properly load Preview's dependencies. You may need to enable this if your project uses RequireJS |
| disableEventLog | false | Disables client-side `preview` event log. Previewing with this option enabled will not increment access stats (content access is still logged server-side) |
| fileOptions | {} | Mapping of file ID to file-level options. See the file option table below for details |
| fileOptions | {} | Mapping of file ID to file-level options. See the File Option table below for details |
| previewWMPref | `any` | String value of `all`, `any`, or `none` that sets how previews of watermarked files behave. See https://community.box.com/t5/Sharing-Content-with-Box/Watermarking-Files/ta-p/30766 for more information about watermarking and https://community.box.com/t5/Collaborate-By-Inviting-Others/Understanding-Collaborator-Permission-Levels/ta-p/144 for more information about permissions and collaboration roles.<br><br>`all` forces watermarked previews. If the file type supports watermarking, users with `can_preview` permissions will see a watermarked preview. If the file type cannot be watermarked, no preview is shown.<br><br>`any` is the default watermarking behavior in the Box Web Application. If the file type supports watermarking, users with `can_preview` permissions will see a watermarked preview. If the file type cannot be watermarked, users that have both `can_preview` and `can_upload` permissions will see a non-watermarked preview and no preview otherwise.<br><br>`none` forces non-watermarked previews. Users that have both `can_preview` and `can_upload` permissions will see a non-watermarked preview and no preview otherwise. |
| downloadWM | false | Whether the download of a watermarked file should be watermarked. This option does not affect non-watermarked files. If true, users will be able to download watermarked versions of supported file types as long as they have `can_preview` permissions (any collaboration role except for `Uploader`). |
| responseInterceptor | | Function to intercept responses. For an example see https://codepen.io/box-platform/pen/jLdxEv |
| requestInterceptor | | Function to intercept requests. For an example see https://codepen.io/box-platform/pen/jLdxEv |

| File Option | Description |
| ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| fileVersionId | File version ID to preview. This must be a valid non-current file version ID. Use [Get Versions](https://developer.box.com/reference#view-versions-of-a-file) to fetch a list of file versions |
| startAt | Object with unit and value properties indicating where to start the preview at. Current supported units are 'seconds' for media and 'pages' for documents. |
| File Option | Default | Description |
| ------------- | ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| fileVersionId | (Current) | File version ID to preview. This must be a valid non-current file version ID. Use [Get Versions](https://developer.box.com/reference#view-versions-of-a-file) to fetch a list of file versions |
| startAt | {} | Options for starting location. See the Start At table below for details |

| Start At | Description |
| -------- | ------------------------------------------------------------- |
| unit | Supported values: "pages" for documents; "seconds" for media |
| value | Integer value specifying the start location |

**Example**

This configuration sets version `54321` as the preview version for a file with the ID `12345`:
This configuration will attempt to Preview a non-current version of the given file (a document, in this case) at a specific starting page:

```
const FILE_ID = '12345';
const TOKEN = 'abcdefg';
```javascript
var FILE_ID = '12345';
var TOKEN = 'abcdefg';
preview.show(FILE_ID, TOKEN, {
fileOptions: {
[FILE_ID]: {
fileVersionId: '54321'
}
}
fileOptions: {
[FILE_ID]: {
fileVersionId: '54321',
startAt: {
unit: 'pages',
value: 2,
},
},
},
});
```

Expand Down

0 comments on commit 5011b81

Please sign in to comment.