@angular/common#DOCUMENT TypeScript Examples

The following examples show how to use @angular/common#DOCUMENT. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: monaco-editor-base.component.ts    From ng-util with MIT License 6 votes vote down vote up
constructor(
    protected el: ElementRef<HTMLElement>,
    @Inject(NU_MONACO_EDITOR_CONFIG) config: NuMonacoEditorConfig,
    @Inject(DOCUMENT) protected doc: any,
    protected ngZone: NgZone,
  ) {
    this._config = { baseUrl: 'https://cdn.jsdelivr.net/npm/monaco-editor/min', ...config };
    this.options = this._config.defaultOptions!;
  }
Example #2
Source File: icon-register.service.ts    From alauda-ui with MIT License 6 votes vote down vote up
ICON_REGISTER_SERVICE_PROVIDER = {
  provide: IconRegisterService,
  deps: [
    [new Optional(), new SkipSelf(), IconRegisterService],
    [new Optional(), DOCUMENT],
    [new Optional(), HttpClient],
  ],
  useFactory: ICON_REGISTER_PROVIDER_FACTORY,
}
Example #3
Source File: title.service.ts    From blockcore-hub with MIT License 6 votes vote down vote up
constructor(
        private readonly router: Router,
        private setup: SetupService,
        @Inject(DOCUMENT) private readonly document: any,
        @Optional() @Inject(APP_TITLE) private readonly appTitle: any) {

        if (!TitleService.singletonInstance) {
            this.initialize();
            TitleService.singletonInstance = this;
        }

        return TitleService.singletonInstance;
    }
Example #4
Source File: table.ts    From halstack-angular with Apache License 2.0 6 votes vote down vote up
constructor(
    protected readonly _differs: IterableDiffers,
    protected readonly _changeDetectorRef: ChangeDetectorRef,
    protected readonly _elementRef: ElementRef,
    @Attribute("role") role: string,
    @Optional() protected readonly _dir: Directionality,
    @Inject(DOCUMENT) _document: any,
    private resolver: ComponentFactoryResolver,
    private paginationService: PaginationService,
    private sortService: SortService
  ) {
    if (!role) {
      this._elementRef.nativeElement.setAttribute("role", "grid");
    }

    this._document = _document;
    this._isNativeHtmlTable =
      this._elementRef.nativeElement.nodeName === "TABLE";

    this.setClassName();
  }
Example #5
Source File: round-progress.service.ts    From Elastos.Essentials.App with MIT License 6 votes vote down vote up
constructor(@Optional() @Inject(DOCUMENT) document: any) {
    this.supportsSvg = !!(
      document &&
      document.createElementNS &&
      document.createElementNS('http://www.w3.org/2000/svg', 'svg').createSVGRect
    );

    this.base = document && document.head.querySelector('base');
    this.hasPerf =
      typeof window !== 'undefined' &&
      window.performance &&
      window.performance.now &&
      typeof window.performance.now() === 'number';
  }
Example #6
Source File: title.service.ts    From EXOS-Core with MIT License 6 votes vote down vote up
constructor(
        private readonly router: Router,
        @Inject(DOCUMENT) private readonly document: any,
        @Optional() @Inject(APP_TITLE) private readonly appTitle: any) {

        if (!TitleService.singletonInstance) {
            this.initialize();
            TitleService.singletonInstance = this;
        }

        return TitleService.singletonInstance;
    }
Example #7
Source File: app.module.ts    From geonetwork-ui with GNU General Public License v2.0 6 votes vote down vote up
constructor(
    translate: TranslateService,
    router: Router,
    @Inject(DOCUMENT) private document: Document
  ) {
    translate.setDefaultLang(getDefaultLang())
    translate.use(getLangFromBrowser() || getDefaultLang())
    ThemeService.applyCssVariables(
      getThemeConfig().PRIMARY_COLOR,
      getThemeConfig().SECONDARY_COLOR,
      getThemeConfig().MAIN_COLOR,
      getThemeConfig().BACKGROUND_COLOR,
      getThemeConfig().MAIN_FONT,
      getThemeConfig().TITLE_FONT,
      getThemeConfig().FONTS_STYLESHEET_URL
    )
    ThemeService.generateBgOpacityClasses(
      'primary',
      getThemeConfig().PRIMARY_COLOR,
      [10, 25]
    )

    router.events
      .pipe(filter((e: Event): e is Scroll => e instanceof Scroll))
      .subscribe((e) => {
        if (e.position) {
          // backward navigation
        } else {
          if (e.routerEvent.url.startsWith(`/${ROUTER_ROUTE_DATASET}`)) {
            const recordPageElement = document.getElementById('record-page')
            if (recordPageElement) {
              recordPageElement.scrollTo({
                top: 0,
              })
            }
          }
        }
      })
  }
Example #8
Source File: dialog.service.ts    From mysteryofthreebots with Apache License 2.0 6 votes vote down vote up
constructor(
    rendererFactory: RendererFactory2,
    private readonly resolver: ComponentFactoryResolver,
    private readonly injector: Injector,
    private readonly appRef: ApplicationRef,
    @Inject(DOCUMENT) private readonly document: HTMLDocument
  ) {
    this.renderer = rendererFactory.createRenderer(null, null);
    this.handleCloseDialog = this.handleCloseDialog.bind(this);
  }
Example #9
Source File: color-picker.component.ts    From angular-material-components with MIT License 6 votes vote down vote up
constructor(private _dialog: MatDialog,
    private _overlay: Overlay,
    private _zone: NgZone,
    private _adapter: ColorAdapter,
    @Optional() private _dir: Directionality,
    @Inject(NGX_MAT_COLOR_PICKER_SCROLL_STRATEGY) scrollStrategy: any,
    @Optional() @Inject(DOCUMENT) private _document: any,
    private _viewContainerRef: ViewContainerRef) {
    this._scrollStrategy = scrollStrategy;
  }
Example #10
Source File: datetime-picker.component.ts    From ngx-mat-datetime-picker with MIT License 6 votes vote down vote up
constructor(private _dialog: MatDialog,
    private _overlay: Overlay,
    private _ngZone: NgZone,
    private _viewContainerRef: ViewContainerRef,
    @Inject(MAT_DATEPICKER_SCROLL_STRATEGY) scrollStrategy: any,
    @Optional() private _dateAdapter: NgxMatDateAdapter<D>,
    @Optional() private _dir: Directionality,
    @Optional() @Inject(DOCUMENT) private _document: any) {
    if (!this._dateAdapter) {
      throw createMissingDateImplError('NgxMatDateAdapter');
    }

    this._scrollStrategy = scrollStrategy;
  }
Example #11
Source File: core.module.ts    From ng-ant-admin with MIT License 6 votes vote down vote up
@NgModule({
  providers: [
    {provide: RouteReuseStrategy, useClass: SimpleReuseStrategy, deps: [DOCUMENT, ScrollService]},
    {provide: NZ_I18N, useValue: zh_CN}
  ],
})
export class CoreModule {
  constructor(@Optional() @SkipSelf() parentModule: CoreModule) {
    if (parentModule) {
      throw new Error(`CoreModule has already been loaded. Import Core modules in the AppModule only.`);
    }
  }
}
Example #12
Source File: ino-elements.module.ts    From elements with MIT License 6 votes vote down vote up
static forRoot(
    config?: InoElementsConfig
  ): ModuleWithProviders<InoElementsModule> {
    return {
      ngModule: InoElementsModule,
      providers: [
        {
          provide: ConfigToken,
          useValue: config,
        },
        {
          provide: APP_INITIALIZER,
          useFactory: appInitialize,
          multi: true,
          deps: [ConfigToken, DOCUMENT, NgZone],
        },
      ],
    };
  }
Example #13
Source File: theme.service.ts    From 1hop with MIT License 6 votes vote down vote up
constructor(
        @Inject(DOCUMENT) private document: Document
    ) {

        const mode = localStorage.getItem('mode') ? localStorage.getItem('mode') : 'dark';
        this.isDarkMode = mode === 'dark';

        this.document.body.classList.add(mode + '-mode');
    }
Example #14
Source File: page-visibility.ts    From common with MIT License 6 votes vote down vote up
PAGE_VISIBILITY = new InjectionToken<Observable<boolean>>(
    'Shared Observable based on `document visibility changed`',
    {
        factory: () => {
            const documentRef = inject(DOCUMENT);

            return fromEvent(documentRef, 'visibilitychange').pipe(
                startWith(0),
                map(() => documentRef.visibilityState !== 'hidden'),
                distinctUntilChanged(),
                share(),
            );
        },
    },
)
Example #15
Source File: app.component.ts    From onchat-web with Apache License 2.0 6 votes vote down vote up
constructor(
    public globalData: GlobalData,
    private app: Application,
    private peer: Peer,
    private overlay: Overlay,
    private navCtrl: NavController,
    private userService: UserService,
    private cacheService: CacheService,
    private socket: Socket,
    private onChatService: OnChatService,
    private feedbackService: FeedbackService,
    private messageDescPipe: MessageDescPipe,
    @Inject(WINDOW) private window: Window,
    @Inject(DOCUMENT) private document: Document,
  ) { }
Example #16
Source File: app.component.ts    From open-genes-frontend with Mozilla Public License 2.0 6 votes vote down vote up
constructor(
    @Inject(DOCUMENT) public document: Document,
    private readonly ipRegistryService: IpRegistryService,
    private settingsService: SettingsService,
    private translate: TranslateService,
    private router: Router
  ) {
    // Set app language
    this.translate.addLangs(environment.languages);
    if (localStorage.getItem('lang')) {
      this.lang = localStorage.getItem('lang');
    } else if (navigator.language.substring(0, 2) === 'en' || navigator.language.substring(0, 2) === 'ru') {
      this.lang = navigator.language.substring(0, 2);
    } else {
      this.lang = environment.languages[1];
    }
    this.translate.use(this.lang);
    this.retrievedSettings = this.settingsService.getSettings();
  }
Example #17
Source File: dropdown.service.ts    From sba-angular with MIT License 6 votes vote down vote up
constructor(
        @Inject(DOCUMENT) public readonly document: Document,
        rendererFactory: RendererFactory2
    ) {
        this._events = new Subject<DropdownEvents>();
        this.renderer = rendererFactory.createRenderer(null, null);
        this.unlisteners = [];
        this.unlisteners.push(this.renderer.listen(this.document, "keydown", this.dataApiKeydownHandler));
        this.unlisteners.push(this.renderer.listen(this.document, "click", this.clearMenus));
        this.unlisteners.push(this.renderer.listen(this.document, "keyup", this.clearMenus));
        this.unlisteners.push(this.renderer.listen(this.document, "click", this.toggle));
        this.unlisteners.push(this.renderer.listen(this.document, "click", this.formChildClick));
        this.unlisteners.push(this.renderer.listen(this.document, "wheel", () => {
            this.raiseClear();
            this.raiseActive(false);
        }));
    }
Example #18
Source File: spinner.component.ts    From flingo with MIT License 6 votes vote down vote up
constructor(private router: Router, @Inject(DOCUMENT) private document: Document) {
        this.router.events.subscribe(
            (event) => {
                if (event instanceof NavigationStart) {
                    this.isSpinnerVisible = true;
                } else if (
                    event instanceof NavigationEnd ||
                    event instanceof NavigationCancel ||
                    event instanceof NavigationError
                ) {
                    this.isSpinnerVisible = false;
                }
            },
            () => {
                this.isSpinnerVisible = false;
            }
        );
    }
Example #19
Source File: app.component.ts    From xBull-Wallet with GNU Affero General Public License v3.0 6 votes vote down vote up
constructor(
    @Inject(ENV)
    private readonly env: typeof environment,
    private readonly settingsService: SettingsService,
    private readonly settingsQuery: SettingsQuery,
    private readonly walletsAccountsService: WalletsAccountsService,
    private readonly walletsAccountsQuery: WalletsAccountsQuery,
    private readonly walletsOperationsQuery: WalletsOperationsQuery,
    private readonly alertsLabelsService: AlertsLabelsService,
    private readonly horizonApisQuery: HorizonApisQuery,
    private readonly route: ActivatedRoute,
    @Inject(DOCUMENT)
    private readonly document: Document,
    private readonly renderer2: Renderer2,
    private readonly globalsService: GlobalsService,
    private readonly ngZone: NgZone,
    private readonly translateService: TranslateService,
  ) { }
Example #20
Source File: theme.service.ts    From rubic-app with GNU General Public License v3.0 6 votes vote down vote up
constructor(private readonly store: StoreService, @Inject(DOCUMENT) private document: Document) {
    const localTheme = (this.store.getItem('theme') as Theme) || 'dark';
    this._theme$ = new BehaviorSubject<Theme>(localTheme);

    if (localTheme !== 'dark') {
      this.document.documentElement.classList.toggle('dark');
      this.document.documentElement.classList.toggle('light');
    } else {
      document.getElementsByTagName('html')[0].classList.toggle('dark_colored');
    }
  }
Example #21
Source File: modals.service.ts    From xBull-Wallet with GNU Affero General Public License v3.0 6 votes vote down vote up
constructor(
    @Inject(DOCUMENT)
    private readonly document: Document,
    private readonly rendererFactory: RendererFactory2,
    private readonly appRef: ApplicationRef,
    private readonly componentFactoryResolver: ComponentFactoryResolver,
    private readonly injector: Injector,
  ) {
    this.renderer = rendererFactory.createRenderer(null, null);
  }
Example #22
Source File: brand-icon.component.ts    From canopy with Apache License 2.0 6 votes vote down vote up
constructor(
    private iconRegistry: LgBrandIconRegistry,
    @Inject(DOCUMENT) private document: any,
    private renderer: Renderer2,
    private hostElement: ElementRef,
  ) {
    this.renderer.addClass(
      this.hostElement.nativeElement,
      `lg-brand-icon--${this._size}`,
    );
  }
Example #23
Source File: network-toggle.component.ts    From thorchain-explorer-singlechain with MIT License 6 votes vote down vote up
constructor(@Inject(DOCUMENT) private document: Document) {

    switch (environment.network) {
      case 'TESTNET':
        this.network = THORChainNetwork.TESTNET;
        break;

      default:
        this.network = THORChainNetwork.CHAOSNET;
        break;
    }

  }
Example #24
Source File: emote.component.ts    From App with MIT License 6 votes vote down vote up
constructor(
		@Inject(DOCUMENT) private document: Document,
		private metaService: Meta,
		private restService: RestService,
		private route: ActivatedRoute,
		private router: Router,
		private cdr: ChangeDetectorRef,
		private dialog: MatDialog,
		private appService: AppService,
		private emoteListService: EmoteListService,
		private dataService: DataService,
		public themingService: ThemingService,
		public clientService: ClientService
	) { }
Example #25
Source File: menu-content.directive.ts    From alauda-ui with MIT License 6 votes vote down vote up
constructor(
    private readonly templateRef: TemplateRef<unknown>,
    private readonly appRef: ApplicationRef,
    private readonly viewContainerRef: ViewContainerRef,
    private readonly componentFactoryResolver: ComponentFactoryResolver,
    private readonly injector: Injector,
    @Inject(DOCUMENT) document: any,
  ) {
    this.doc = document;
  }
Example #26
Source File: app.component.ts    From 1x.ag with MIT License 6 votes vote down vote up
constructor(
        protected web3Service: Web3Service,
        protected configurationService: ConfigurationService,
        protected themeService: ThemeService,
        protected swUpdate: SwUpdate,
        protected appRef: ApplicationRef,
        private deviceDetectorService: DeviceDetectorService,
        @Inject(DOCUMENT) private document: Document
    ) {

    }
Example #27
Source File: base-cookie.service.ts    From svvs with MIT License 6 votes vote down vote up
constructor(
    @Inject(DOCUMENT) private document: Document,
    // eslint-disable-next-line @typescript-eslint/ban-types
    @Inject(PLATFORM_ID) private platformId: Object,
    @Inject(REQUEST) @Optional() private request: Request,
    @Inject(RESPONSE) @Optional() private response: Response,
  ) {
    this.isBrowser = isPlatformBrowser(platformId)
  }
Example #28
Source File: app.component.ts    From 1hop with MIT License 6 votes vote down vote up
constructor(
        protected web3Service: Web3Service,
        protected configurationService: ConfigurationService,
        protected themeService: ThemeService,
        protected swUpdate: SwUpdate,
        protected appRef: ApplicationRef,
        @Inject(DOCUMENT) private document: Document
    ) {

    }
Example #29
Source File: dynamic-browser-title.service.ts    From nghacks with MIT License 6 votes vote down vote up
constructor(
    @Optional() private _config: DynamicBrowserTitleConfig,
    private _router: Router,
    @Inject(DOCUMENT) private document: any,
    private _titleService: Title
  ) {
    this._document = this.document as Document;
    this.init();
    const titleElem: HTMLElement = this._document.querySelector('title');
    this._defaultTitle = titleElem?.innerText || '';
  }