@@ -58,6 +58,8 @@ import { SvgModuleComponent } from './components/svg/module';
|
|||||||
import { SvgKeyboardWrapComponent } from './components/svg/wrap';
|
import { SvgKeyboardWrapComponent } from './components/svg/wrap';
|
||||||
import { MainAppComponent, appRoutingProviders, routing } from './main-app';
|
import { MainAppComponent, appRoutingProviders, routing } from './main-app';
|
||||||
|
|
||||||
|
import { CancelableDirective } from './directives';
|
||||||
|
|
||||||
import { MapperService } from './services/mapper.service';
|
import { MapperService } from './services/mapper.service';
|
||||||
|
|
||||||
import { KeymapEffects, MacroEffects } from './store/effects';
|
import { KeymapEffects, MacroEffects } from './store/effects';
|
||||||
@@ -121,7 +123,8 @@ const storeConfig = {
|
|||||||
MacroMouseTabComponent,
|
MacroMouseTabComponent,
|
||||||
MacroTextTabComponent,
|
MacroTextTabComponent,
|
||||||
AddOnComponent,
|
AddOnComponent,
|
||||||
SettingsComponent
|
SettingsComponent,
|
||||||
|
CancelableDirective
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
BrowserModule,
|
BrowserModule,
|
||||||
|
|||||||
@@ -1,13 +1,15 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<h1 class="col-xs-12 pane-title">
|
<h1 class="col-xs-12 pane-title">
|
||||||
<i class="fa fa-keyboard-o"></i>
|
<i class="fa fa-keyboard-o"></i>
|
||||||
<input #name class="keymap__name pane-title__name"
|
<input #name cancelable
|
||||||
type="text"
|
class="keymap__name pane-title__name"
|
||||||
value="{{ keymap.name }}"
|
type="text"
|
||||||
(change)="editKeymapName($event.target.value)"
|
value="{{ keymap.name }}"
|
||||||
(keyup.enter)="name.blur()"
|
(change)="editKeymapName($event.target.value)"
|
||||||
|
(keyup.enter)="name.blur()"
|
||||||
/> keymap
|
/> keymap
|
||||||
(<input #abbr class="keymap__abbrev pane-title__abbrev"
|
(<input #abbr cancelable
|
||||||
|
class="keymap__abbrev pane-title__abbrev"
|
||||||
type="text"
|
type="text"
|
||||||
value="{{ keymap.abbreviation }}"
|
value="{{ keymap.abbreviation }}"
|
||||||
(change)="editKeymapAbbr($event.target.value)"
|
(change)="editKeymapAbbr($event.target.value)"
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<h1 class="col-xs-12 pane-title">
|
<h1 class="col-xs-12 pane-title">
|
||||||
<i class="fa fa-play"></i>
|
<i class="fa fa-play"></i>
|
||||||
<input #macroName class="pane-title__name"
|
<input #macroName cancelable
|
||||||
type="text"
|
class="pane-title__name"
|
||||||
value="{{ macro.name }}"
|
type="text"
|
||||||
|
value="{{ macro.name }}"
|
||||||
(change)="editMacroName($event.target.value)"
|
(change)="editMacroName($event.target.value)"
|
||||||
(keyup.enter)="macroName.blur()"
|
(keyup.enter)="macroName.blur()"
|
||||||
/>
|
/>
|
||||||
|
|||||||
21
src/directives/cancelable/cancelable.directive.ts
Normal file
21
src/directives/cancelable/cancelable.directive.ts
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
import { Directive, ElementRef, HostListener, Renderer } from '@angular/core';
|
||||||
|
|
||||||
|
@Directive({
|
||||||
|
selector: '[cancelable]'
|
||||||
|
})
|
||||||
|
export class CancelableDirective {
|
||||||
|
|
||||||
|
private originalValue: string;
|
||||||
|
|
||||||
|
constructor(private elementRef: ElementRef, private renderer: Renderer) { }
|
||||||
|
|
||||||
|
@HostListener('focus') onFocus(): void {
|
||||||
|
this.originalValue = this.elementRef.nativeElement.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@HostListener('keyup.escape') onEscape(): void {
|
||||||
|
this.renderer.setElementProperty(this.elementRef.nativeElement, 'value', this.originalValue);
|
||||||
|
this.renderer.invokeElementMethod(this.elementRef.nativeElement, 'blur');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
1
src/directives/cancelable/index.ts
Normal file
1
src/directives/cancelable/index.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export { CancelableDirective } from './cancelable.directive';
|
||||||
1
src/directives/index.ts
Normal file
1
src/directives/index.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export * from './cancelable';
|
||||||
Reference in New Issue
Block a user