Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Add click event to the image
this._renderer.setStyle(img, 'cursor', 'pointer');
this._renderer.setProperty(img, 'onclick', () => this._lightbox.open(i, this.gallerize));
return img;
}),
tap((img: HTMLImageElement) => images.push(new ImageItem(img.src, img.src))),
finalize(() => galleryRef.load(images))
);
} else {
return empty();
}
})
).subscribe();
// Observe content changes
if (isPlatformBrowser(this.platform)) {
this.observer = new MutationObserver(() => this.gallerizer$.next());
this.observer.observe(this._el.nativeElement, { childList: true, subtree: true });
}
}
lookupStyle(element, styleName, inlineOnly = false) {
/** @type {?} */
let value = '';
if (element) {
/** @type {?} */
let immediateValue = value = this.lookupInlineStyle(element, styleName);
if (!immediateValue) {
if (isPlatformBrowser(this._platformId)) {
if (!inlineOnly) {
value = getComputedStyle(element).getPropertyValue(styleName);
}
}
else {
if (this._serverModuleLoaded) {
value = this._serverStylesheet.getStyleForElement(element, styleName);
}
}
}
}
// Note: 'inline' is the default of all elements, unless UA stylesheet overrides;
// in which case getComputedStyle() should determine a valid value.
return value ? value.trim() : '';
}
/**
public isTablet(userAgent = this.userAgent) {
if (
isPlatformBrowser(this.platformId) &&
(
!!this.reTree.test(this.userAgent, Constants.TABLETS_RE['iPad']) ||
(navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1)
)
) {
return true;
}
const match = Object.keys(Constants.TABLETS_RE).find((mobile) => {
return !!this.reTree.test(userAgent, Constants.TABLETS_RE[mobile]);
});
return !!match;
};
constructor(
@Inject(PLATFORM_ID) private platformId: Object,
@Inject(APP_ID) private appId: string) {
const platform = isPlatformBrowser(platformId) ?
'in the browser' : 'on the server';
console.log(`Running ${platform} with appId=${appId}`);
}
}
getUserInfo() {
if (isPlatformBrowser(this.platformId)) {
let token = localStorage.getItem('auth');
if (token) {
let tokenParts = token.split('.');
return JSON.parse(atob(tokenParts[1]));
} else {
return null;
}
}
}
private storeCarouselData(): void {
if (isPlatformBrowser(this.platformId)) {
this.data.deviceWidth = window.innerWidth;
} else {
this.data.deviceWidth = 1200;
}
this.data.carouselWidth = this.carouselMain.offsetWidth;
if (this.data.type === 'responsive') {
this.data.deviceType =
this.data.deviceWidth >= 1200
? 'lg'
: this.data.deviceWidth >= 992
? 'md'
: this.data.deviceWidth >= 768
? 'sm'
: 'xs';
scrollToAnchor(hash: string, smooth = true) {
if (hash && isPlatformBrowser(this.platformId)) {
const element = document.querySelector('#' + hash);
if (element) {
element.scrollIntoView({
behavior: smooth ? 'smooth' : 'auto',
block: 'start',
});
}
}
}
constructor(private _element: ElementRef, @Inject(NativeWindowService) private _window: NativeWindowRef, @Inject(PLATFORM_ID) private platformId) {
if (isPlatformBrowser(platformId)) {
this.subscribeForScrollEvent();
}
}
constructor(public authService: AuthService, @Inject(PLATFORM_ID) private platformId: Object) {
this.providers = this.config.providers;
if (isPlatformBrowser(this.platformId)) {
this.providers.forEach((provider: LoginProvider, key: string) => provider.initialize());
}
}
private get isBrowser(): boolean {
return isPlatformBrowser(this._platformId);
}