-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
63 changed files
with
1,376 additions
and
1,315 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { ManifestEntryRequest } from './manifest-entry-request'; |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { ChangeDetectorRef, Injectable } from '@angular/core'; | ||
import { BehaviorSubject } from 'rxjs'; | ||
|
||
export interface CdRefBindingSubject { | ||
subject: BehaviorSubject<any>; | ||
cdRef: ChangeDetectorRef; | ||
} | ||
|
||
/** | ||
* A registry for AngularJS binding subjects. | ||
*/ | ||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class NgBindingsService { | ||
|
||
private readonly subjects: { [key: string]: Array<CdRefBindingSubject> }; | ||
|
||
constructor() { | ||
this.subjects = {}; | ||
} | ||
|
||
putSubject(key: string, subject: CdRefBindingSubject): Array<CdRefBindingSubject> { | ||
let subjects = this.subjects[key]; | ||
if (!subjects) { | ||
subjects = []; | ||
this.subjects[key] = subjects; | ||
} | ||
this.subjects[key].push(subject); | ||
|
||
return this.subjects[key]; | ||
} | ||
|
||
} |
This file contains 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
This file contains 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
22 changes: 22 additions & 0 deletions
22
projects/wvr-elements/src/lib/shared/directives/wvr-content-projection.directive.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { AfterViewInit, Directive, ElementRef, Input } from '@angular/core'; | ||
import { projectSourceContent } from '../utility'; | ||
|
||
@Directive({ | ||
selector: '[wvrContentProjection]' | ||
}) | ||
export class WvrContentProjectionDirective implements AfterViewInit { | ||
|
||
@Input('wvrContentProjection') parentElementRef: ElementRef; | ||
|
||
/* tslint:disable-next-line:no-input-rename */ | ||
@Input('template') template: string; | ||
|
||
constructor(private readonly elementRef: ElementRef) { | ||
|
||
} | ||
|
||
ngAfterViewInit(): void { | ||
projectSourceContent(this.elementRef, this.parentElementRef, `template[${this.template}]`); | ||
} | ||
|
||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export { obtainConfigPath, registerWeaverElements, showWeaverElements, weaverBootstrap, WvrElementDesc } from './bootstrap.utility'; | ||
export { debounce } from './decorators.utilty'; | ||
export { preserveContent, projectContent, projectSourceContent } from './projection.utility'; | ||
export { wvrCompile, wvrParseProjectedContent } from './template.utility'; | ||
export { wvrTimeout } from './timing.utility'; |
52 changes: 52 additions & 0 deletions
52
projects/wvr-elements/src/lib/shared/utility/projection.utility.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { ElementRef } from '@angular/core'; | ||
|
||
const projectContent = (elementRef: ElementRef, templateSelector: string, targetSelector: string): void => { | ||
const element: Element = elementRef.nativeElement.querySelector(targetSelector); | ||
project(element, elementRef, templateSelector); | ||
}; | ||
|
||
const projectSourceContent = (elementRef: ElementRef, sourceElementRef: ElementRef, templateSelector: string): void => { | ||
const element: Element = elementRef.nativeElement; | ||
project(element, sourceElementRef, templateSelector); | ||
}; | ||
|
||
const project = (element: Element, sourceElementRef: ElementRef, templateSelector: string): void => { | ||
const templates: Array<HTMLTemplateElement> = Array.from(sourceElementRef.nativeElement.querySelectorAll(templateSelector)); | ||
if (!!element) { | ||
templates.forEach((template: HTMLTemplateElement) => { | ||
const clone: Node = template.children.length === 0 && template.content.children.length > 0 | ||
? template.content.cloneNode(true) | ||
: template; | ||
Array.from((clone as Element).children) | ||
.forEach((elem: Element) => { | ||
element.appendChild(elem); | ||
}); | ||
}); | ||
} | ||
// hide target element if nothing to project | ||
if (!!element && !templates.length) { | ||
(element as HTMLElement).hidden = true; | ||
} | ||
}; | ||
|
||
const preserveContent = (elementRef: ElementRef, templateSelector: string, targetSelector: string): void => { | ||
const element: Element = elementRef.nativeElement.querySelector(targetSelector); | ||
const template: HTMLTemplateElement = elementRef.nativeElement.querySelector(templateSelector); | ||
if (!!element && !!template) { | ||
Array.from(element.children) | ||
.filter((elem: Element) => elem.nodeName !== 'TEMPLATE') | ||
.forEach((elem: Element) => { | ||
if (template.children.length) { | ||
template.replaceChild(elem, template.children[0]); | ||
} else { | ||
template.appendChild(elem); | ||
} | ||
}); | ||
} | ||
}; | ||
|
||
export { | ||
projectContent, | ||
projectSourceContent, | ||
preserveContent | ||
}; |
Oops, something went wrong.