Skip to content

Commit

Permalink
New: Make findBar optional (#438)
Browse files Browse the repository at this point in the history
* Update: Make findBar optional
* Update: useFindBar option update
* Update: update readme
* Update: Code Review modifications
* Update: Add conditional with return
* Update: fix merge
  • Loading branch information
georgediaz88 authored and pramodsum committed Oct 27, 2017
1 parent fcd3aad commit 3ea11cc
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/lib/viewers/doc/DocBaseViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,9 @@ class DocBaseViewer extends BaseViewer {
// the file. Users without download permissions shouldn't be able to
// interact with the text layer
const canDownload = checkPermission(this.options.file, PERMISSION_DOWNLOAD);
if (this.getViewerOption('disableFindBar')) {
return;
}
this.findBar = new DocFindBar(this.findBarEl, this.findController, canDownload);
}

Expand Down
3 changes: 3 additions & 0 deletions src/lib/viewers/doc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ The document viewer remembers which page you were viewing upon closing the previ
| Option | Type | Description |
| --- | --- | --- |
| annotations | boolean | Optional. Whether annotations on content are shown. Defaults to false |
| disableFindBar | boolean | Optional. Setting to true will enable the browser's findBar in place of the viewers. Defaults to false |


## Events

Expand Down Expand Up @@ -91,6 +93,7 @@ The presentation viewer remembers which slide you were viewing upon closing the
| Option | Type | Description |
| --- | --- | --- |
| annotations | boolean | Optional. Whether annotations on content are shown. Defaults to false |
| disableFindBar | boolean | Optional. Setting to true will enable the browser's findBar in place of the viewers. Defaults to false |

## Events

Expand Down
11 changes: 11 additions & 0 deletions src/lib/viewers/doc/__tests__/DocBaseViewer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,17 @@ describe('src/lib/viewers/doc/DocBaseViewer', () => {
docBase.initFind();
expect(docBase.pdfViewer.setFindController).to.be.called;
});

it('should not set find bar if viewer option disableFindBar is true', () => {
sandbox.stub(docBase, 'getViewerOption').withArgs('disableFindBar').returns(true);
docBase.initFind();
expect(docBase.findBar).to.be.undefined;
});

it('should set findBar to a function if viewer option disableFindBar is not set', () => {
docBase.initFind();
expect(docBase.findBar).to.be.a.function;
});
});

describe('browserPrint()', () => {
Expand Down

0 comments on commit 3ea11cc

Please sign in to comment.