Browse Source

Merge pull request #16908 from abpframework/masum/window-service

AngularUI: Created window service
pull/16924/head
Mahmut Gundogdu 3 years ago
committed by GitHub
parent
commit
f25afed93a
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      npm/ng-packs/packages/core/src/lib/directives/caps-lock.directive.ts
  2. 1
      npm/ng-packs/packages/core/src/lib/services/index.ts
  3. 20
      npm/ng-packs/packages/core/src/lib/services/window.service.ts

4
npm/ng-packs/packages/core/src/lib/directives/caps-lock.directive.ts

@ -5,7 +5,7 @@ import { Directive, EventEmitter, HostListener, Output } from '@angular/core';
selector: '[abpCapsLock]',
})
export class TrackCapsLockDirective {
@Output('abpCapsLock') capsLock = new EventEmitter<Boolean>();
@Output('abpCapsLock') capsLock = new EventEmitter<boolean>();
@HostListener('window:keydown', ['$event'])
onKeyDown(event: KeyboardEvent): void {
@ -17,7 +17,7 @@ export class TrackCapsLockDirective {
}
isCapsLockOpen(e): boolean {
var s = String.fromCharCode(e.which);
const s = String.fromCharCode(e.which);
if (
(s.toUpperCase() === s && s.toLowerCase() !== s && e.shiftKey) ||
(s.toUpperCase() !== s && s.toLowerCase() === s && e.shiftKey) ||

1
npm/ng-packs/packages/core/src/lib/services/index.ts

@ -19,3 +19,4 @@ export * from './session-state.service';
export * from './subscription.service';
export * from './track-by.service';
export * from './local-storage.service';
export * from './window.service';

20
npm/ng-packs/packages/core/src/lib/services/window.service.ts

@ -0,0 +1,20 @@
import { Injectable, inject } from '@angular/core';
import { DOCUMENT } from '@angular/common';
@Injectable({ providedIn: 'root' })
export class AbpWindowService {
protected readonly window = inject(DOCUMENT).defaultView;
protected readonly navigator = this.window.navigator;
copyToClipboard(text: string): Promise<void> {
return this.navigator.clipboard.writeText(text);
}
open(url?: string | URL, target?: string, features?: string): Window {
return this.window.open(url, target, features);
}
reloadPage(): void {
this.window.location.reload();
}
}
Loading…
Cancel
Save