Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
edsilv committed Nov 17, 2017
1 parent 0d2a54f commit 6b893b9
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 30 deletions.
2 changes: 1 addition & 1 deletion examples
Submodule examples updated 2 files
+ uv-3.0.0.zip
+22 −24 uv/uv.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ interface ISettings {
rightPanelOpen?: boolean;
preserveViewport?: boolean;
clickToZoomEnabled?: boolean;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class SeadragonCenterPanel extends CenterPanel {
this.zoomToInitialAnnotation();
});

$.subscribe(BaseEvents.SETTINGS_CHANGED, (e: any, args: any) => {
$.subscribe(BaseEvents.SETTINGS_CHANGED, (e: any, args: ISettings) => {
this.viewer.gestureSettingsMouse.clickToZoom = args.clickToZoomEnabled;
});

Expand Down
51 changes: 24 additions & 27 deletions src/modules/uv-shared-module/AutoComplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ export class AutoComplete {

private _$searchResultsList: JQuery;
private _$searchResultTemplate: JQuery;

// valid keys that are not
private _validKeyDownCodes: number[] = [KeyCodes.KeyDown.Backspace, KeyCodes.KeyDown.Spacebar, KeyCodes.KeyDown.Tab, KeyCodes.KeyDown.LeftArrow, KeyCodes.KeyDown.RightArrow, KeyCodes.KeyDown.Delete];
private _validKeyPressCodes: number[] = [KeyCodes.KeyPress.GraveAccent, KeyCodes.KeyPress.DoubleQuote];
private _lastKeyDownWasValid: boolean = false;

//private _navigationKeyDownCodes: number[] = [KeyCodes.KeyDown.Backspace, KeyCodes.KeyDown.Spacebar, KeyCodes.KeyDown.Tab, KeyCodes.KeyDown.LeftArrow, KeyCodes.KeyDown.RightArrow, KeyCodes.KeyDown.Delete];
//private _validKeyPressCodes: number[] = [KeyCodes.KeyPress.GraveAccent, KeyCodes.KeyPress.DoubleQuote];
//private _lastKeyDownWasNavigation: boolean = false;

constructor(element: JQuery,
autoCompleteFunc: (terms: string, cb: (results: string[]) => void) => void,
Expand Down Expand Up @@ -59,12 +58,10 @@ export class AutoComplete {

const that = this;

// validate

this._$element.on("keydown", function(e: JQueryEventObject) {

const originalEvent: KeyboardEvent = <KeyboardEvent>e.originalEvent;
that._lastKeyDownWasValid = that._isValidKeyDown(originalEvent);
//that._lastKeyDownWasNavigation = that._isNavigationKeyDown(originalEvent);
const charCode: number = Utils.Keyboard.getCharCode(originalEvent);
let cancelEvent: boolean = false;

Expand All @@ -81,17 +78,17 @@ export class AutoComplete {
});

// prevent invalid characters being entered
this._$element.on("keypress", function(e: JQueryEventObject) {
// this._$element.on("keypress", function(e: JQueryEventObject) {

const isValidKeyPress: boolean = that._isValidKeyPress(<KeyboardEvent>e.originalEvent);
// const isValidKeyPress: boolean = that._isValidKeyPress(<KeyboardEvent>e.originalEvent);

if (!(that._lastKeyDownWasValid || isValidKeyPress)) {
e.preventDefault();
return false;
}
// if (!(that._lastKeyDownWasNavigation || isValidKeyPress)) {
// e.preventDefault();
// return false;
// }

return true;
});
// return true;
// });

// auto complete
this._$element.on("keyup", function(e) {
Expand Down Expand Up @@ -147,17 +144,17 @@ export class AutoComplete {
this._hideResults();
}

private _isValidKeyDown(e: KeyboardEvent): boolean {
const isValid: boolean = this._validKeyDownCodes.includes(Utils.Keyboard.getCharCode(e));
return isValid;
}

private _isValidKeyPress(e: KeyboardEvent): boolean {
const charCode: number = Utils.Keyboard.getCharCode(e);
const key: string = String.fromCharCode(charCode);
const isValid: boolean = key.isAlphanumeric() || this._validKeyPressCodes.includes(charCode);
return isValid;
}
// private _isNavigationKeyDown(e: KeyboardEvent): boolean {
// const isNavigationKeyDown: boolean = this._navigationKeyDownCodes.includes(Utils.Keyboard.getCharCode(e));
// return isNavigationKeyDown;
// }

// private _isValidKeyPress(e: KeyboardEvent): boolean {
// const charCode: number = Utils.Keyboard.getCharCode(e);
// const key: string = String.fromCharCode(charCode);
// const isValid: boolean = key.isAlphanumeric() || this._validKeyPressCodes.includes(charCode);
// return isValid;
// }

private _getTerms(): string {
return this._$element.val().trim();
Expand Down

0 comments on commit 6b893b9

Please sign in to comment.