Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search terms in URL #623

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ src/themes
## Misc
#################

examples
Thumbs.db
Desktop.ini
.DS_Store
Expand Down
60 changes: 36 additions & 24 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions src/URLDataProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@ export default class URLDataProvider extends UVDataProvider {
return Utils.Urls.getHashParameter(key, document) || defaultValue;
}

public set(key: string, value: string): void {
if (!this.readonly) {
public set(key: string, value: string): void {
if (value) {
Utils.Urls.setHashParameter(key, value.toString(), document);
} else {
Utils.Urls.setHashParameter(key, '', document);
}
}
}
}
}
19 changes: 18 additions & 1 deletion src/extensions/uv-av-extension/dependencies.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/extensions/uv-default-extension/dependencies.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/extensions/uv-mediaelement-extension/dependencies.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/extensions/uv-pdf-extension/dependencies.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/extensions/uv-seadragon-extension/dependencies.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/extensions/uv-virtex-extension/dependencies.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 15 additions & 1 deletion src/modules/uv-searchfooterpanel-module/FooterPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {ISeadragonExtension} from "../../extensions/uv-seadragon-extension/ISead
import {Mode} from "../../extensions/uv-seadragon-extension/Mode";
import {AnnotationResults} from "../uv-shared-module/AnnotationResults";
import {UVUtils} from "../uv-shared-module/Utils";
import URLDataProvider from "../../URLDataProvider";
import AnnotationGroup = Manifold.AnnotationGroup;

export class FooterPanel extends BaseFooterPanel {
Expand Down Expand Up @@ -34,6 +35,8 @@ export class FooterPanel extends BaseFooterPanel {
currentPlacemarkerIndex: number;
placemarkerTouched: boolean = false;
terms: string;
searchUrl: string | null;
urlDataProvider: URLDataProvider;

constructor($element: JQuery) {
super($element);
Expand All @@ -45,6 +48,9 @@ export class FooterPanel extends BaseFooterPanel {

super.create();

this.urlDataProvider = new URLDataProvider(true);
this.searchUrl = this.urlDataProvider.get('search', '');

$.subscribe(BaseEvents.CANVAS_INDEX_CHANGED, () => {
this.canvasIndexChanged();
this.setCurrentSearchResultPlacemarker();
Expand Down Expand Up @@ -156,7 +162,7 @@ export class FooterPanel extends BaseFooterPanel {
var that = this;

this.$searchButton.on('click', (e: any) => {
e.preventDefault();
e.preventDefault();
this.search(this.$searchText.val());
});

Expand Down Expand Up @@ -200,6 +206,7 @@ export class FooterPanel extends BaseFooterPanel {
this.$clearSearchResultsButton.on('click', (e: any) => {
e.preventDefault();
$.publish(BaseEvents.CLEAR_ANNOTATIONS);
this.urlDataProvider.set('search', '');
});

// hide search options if not enabled/supported.
Expand Down Expand Up @@ -255,6 +262,11 @@ export class FooterPanel extends BaseFooterPanel {
this.$pagePositionMarker.hide();
this.$pagePositionLabel.hide();
}
//If search term exists in url, call search
if(this.searchUrl !== null && this.searchUrl !== "" && this.searchUrl !== undefined){
this.$searchText.val(this.searchUrl);
this.search(this.searchUrl);
}
}

isSearchEnabled(): boolean {
Expand Down Expand Up @@ -377,6 +389,8 @@ export class FooterPanel extends BaseFooterPanel {

this.terms = terms;

this.urlDataProvider.set('search', this.$searchText.val());

if (this.terms === '' || this.terms === this.content.enterKeyword) {
this.extension.showMessage(this.config.modules.genericDialogue.content.emptyValue, function(){
this.$searchText.focus();
Expand Down