This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Directive, ElementRef, AfterViewInit } from '@angular/core'; | |
| @Directive({ | |
| selector: '[trapFocus]' | |
| }) | |
| export class TrapFocusDirective implements AfterViewInit { | |
| constructor(private el: ElementRef) {} | |
| ngAfterViewInit() { | |
| this.trapFocus(this.el.nativeElement); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Pipe, PipeTransform } from '@angular/core'; | |
| import * as CryptoJS from 'crypto-js'; | |
| const key = 'TUc0emRqRXpkdw=='; | |
| @Pipe({name: 'encrypted'}) | |
| export class EncryptPipe implements PipeTransform { | |
| transform(value: string) { | |
| if (value) { | |
| return CryptoJS.AES.encrypt(value, key).toString(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Pipe, PipeTransform } from '@angular/core'; | |
| import * as CryptoJS from 'crypto-js'; | |
| const key = 'TUc0emRqRXpkdw=='; // btoa(btoa(myKey)); | |
| @Pipe({name: 'encrypted'}) | |
| export class EncryptPipe implements PipeTransform { | |
| transform(value: string) { | |
| if (value) { | |
| return CryptoJS.AES.encrypt(value, key).toString(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Component, Output, EventEmitter } from '@angular/core'; | |
| const DAY_MS = 60 * 60 * 24 * 1000; | |
| @Component({ | |
| selector: 'my-calendar', | |
| templateUrl: './calendar.component.html', | |
| styleUrls: [ './calendar.component.scss' ] | |
| }) | |
| export class CalendarComponent { | |
| dates: Array<Date>; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { trigger, transition, style, animate, query, stagger } from '@angular/animations'; | |
| export const fadeAnimation = trigger('fadeAnimation', [ | |
| transition(':enter', [ | |
| style({ opacity: 0 }), animate('300ms', style({ opacity: 1 }))] | |
| ), | |
| transition(':leave', | |
| [style({ opacity: 1 }), animate('300ms', style({ opacity: 0 }))] | |
| ) | |
| ]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import {Directive, Component, Input, ViewContainerRef, TemplateRef, AfterViewInit} from '@angular/core'; | |
| @Directive({selector: '[inView]'}) | |
| export class InView implements AfterViewInit { | |
| alreadyRendered: boolean; // cheking if visible already | |
| constructor( | |
| private vcRef: ViewContainerRef, | |
| private tplRef: TemplateRef<any> | |
| ) {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * @license | |
| * Copyright Google LLC All Rights Reserved. | |
| * | |
| * Use of this source code is governed by an MIT-style license that can be | |
| * found in the LICENSE file at https://angular.io/license | |
| */ | |
| import {Directive, EmbeddedViewRef, Input, TemplateRef, ViewContainerRef, ɵstringify as stringify} from '@angular/core'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var i; | |
| document.write('<h2>local storage</h2>'); | |
| for (i = 0; i < localStorage.length; i++) { | |
| const key = localStorage.key(i); | |
| const value = localStorage.getItem(key); | |
| document.write(`<li> <b>${key}</b>: ${value}</li>`); | |
| } | |
| document.write('<h2>session storage</h2>'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function getPosition (el) { | |
| const rect = el.getBoundingClientRect(); | |
| const x = rect.left + window.scrollX; | |
| const y = rect.top + window.scrollY; | |
| return { x, y }; | |
| } | |
| function getCenterPosition (el) { | |
| const rect = el.getBoundingClientRect(); | |
| const x = rect.left + window.scrollX + (rect.width / 2); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const ts = require('typescript'); | |
| class TypescriptParser { | |
| constructor(code) { | |
| const sourceFile = ts.createSourceFile('temp.ts', code, ts.ScriptTarget.Latest); | |
| this.rootNode = this.getRecursiveFrom(sourceFile, sourceFile); | |
| } | |
| getRecursiveFrom(node, sourceFile) { | |
| const syntaxKind = ts.SyntaxKind[node.kind]; |