Skip to content

Commit

Permalink
Merge pull request #35 from themyth92/feature/upgradePackage
Browse files Browse the repository at this point in the history
Upgrade vulnerable package
  • Loading branch information
themyth92 authored Aug 16, 2019
2 parents cd0d997 + b2b7588 commit da31429
Show file tree
Hide file tree
Showing 5 changed files with 1,914 additions and 2,187 deletions.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"name": "ngx-lightbox",
"version": "2.0.1",
"version": "2.0.2",
"description": "A port >= angular5 for lightbox2",
"main": "index.js",
"dependencies": {},
"devDependencies": {
"@angular-devkit/build-angular": "~0.801.2",
"@angular/cli": "^8.0.1",
"@angular/common": "^8.0.0",
"@angular/compiler": "^8.0.0",
Expand All @@ -23,14 +24,13 @@
"karma-phantomjs-launcher": "^1.0.4",
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^3.0.5",
"ngx-lightbox": "^2.0.0",
"phantomjs-prebuilt": "^2.1.16",
"rxjs": "^6.5.2",
"tslint": "^5.17.0",
"typescript": "3.4.5",
"webpack": "^4.33.0",
"zone.js": "^0.9.1",
"@angular-devkit/build-angular": "~0.801.2",
"ngx-lightbox": "^2.0.0"
"zone.js": "^0.9.1"
},
"scripts": {
"start": "./node_modules/.bin/ng serve",
Expand Down
3 changes: 2 additions & 1 deletion src/lightbox-event.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Observable, Subject } from 'rxjs';

import { Injectable } from '@angular/core';
import { Subject, Observable } from 'rxjs';

export interface IEvent {
id: number;
Expand Down
22 changes: 12 additions & 10 deletions src/lightbox-overlay.component.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import { Subscription } from 'rxjs';

import { DOCUMENT } from '@angular/common';
import {
AfterViewInit,
Component,
Expand All @@ -6,11 +9,10 @@ import {
Inject,
Input,
OnDestroy,
Renderer
Renderer2,
} from '@angular/core';
import { DOCUMENT } from '@angular/common';
import { LightboxEvent, LIGHTBOX_EVENT, IEvent } from './lightbox-event.service';
import { Subscription } from 'rxjs';

import { IEvent, LIGHTBOX_EVENT, LightboxEvent } from './lightbox-event.service';

@Component({
selector: '[lb-overlay]',
Expand All @@ -26,9 +28,9 @@ export class LightboxOverlayComponent implements AfterViewInit, OnDestroy {
private _subscription: Subscription;
constructor(
private _elemRef: ElementRef,
private _rendererRef: Renderer,
private _rendererRef: Renderer2,
private _lightboxEvent: LightboxEvent,
@Inject(DOCUMENT) private _documentRef: any
@Inject(DOCUMENT) private _documentRef: Document
) {
this.classList = 'lightboxOverlay animation fadeInOverlay';
this._subscription = this._lightboxEvent.lightboxEvent$.subscribe((event: IEvent) => this._onReceivedEvent(event));
Expand All @@ -43,9 +45,9 @@ export class LightboxOverlayComponent implements AfterViewInit, OnDestroy {
public ngAfterViewInit(): void {
const fadeDuration = this.options.fadeDuration;

this._rendererRef.setElementStyle(this._elemRef.nativeElement,
this._rendererRef.setStyle(this._elemRef.nativeElement,
'-webkit-animation-duration', `${fadeDuration}s`);
this._rendererRef.setElementStyle(this._elemRef.nativeElement,
this._rendererRef.setStyle(this._elemRef.nativeElement,
'animation-duration', `${fadeDuration}s`);
this._sizeOverlay();
}
Expand All @@ -63,8 +65,8 @@ export class LightboxOverlayComponent implements AfterViewInit, OnDestroy {
const width = this._getOverlayWidth();
const height = this._getOverlayHeight();

this._rendererRef.setElementStyle(this._elemRef.nativeElement, 'width', `${width}px`);
this._rendererRef.setElementStyle(this._elemRef.nativeElement, 'height', `${height}px`);
this._rendererRef.setStyle(this._elemRef.nativeElement, 'width', `${width}px`);
this._rendererRef.setStyle(this._elemRef.nativeElement, 'height', `${height}px`);
}

private _onReceivedEvent(event: IEvent): void {
Expand Down
78 changes: 39 additions & 39 deletions src/lightbox.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
Input,
OnDestroy,
OnInit,
Renderer,
Renderer2,
SecurityContext,
ViewChild,
} from '@angular/core';
Expand Down Expand Up @@ -58,23 +58,23 @@ export class LightboxComponent implements AfterViewInit, OnDestroy, OnInit {
@Input() currentImageIndex: number;
@Input() options: any;
@Input() cmpRef: any;
@ViewChild('outerContainer', {static: false}) _outerContainerElem: ElementRef;
@ViewChild('container', {static: false}) _containerElem: ElementRef;
@ViewChild('leftArrow', {static: false}) _leftArrowElem: ElementRef;
@ViewChild('rightArrow', {static: false}) _rightArrowElem: ElementRef;
@ViewChild('navArrow', {static: false}) _navArrowElem: ElementRef;
@ViewChild('dataContainer', {static: false}) _dataContainerElem: ElementRef;
@ViewChild('image', {static: false}) _imageElem: ElementRef;
@ViewChild('caption', {static: false}) _captionElem: ElementRef;
@ViewChild('number', {static: false}) _numberElem: ElementRef;
@ViewChild('outerContainer', { static: false }) _outerContainerElem: ElementRef;
@ViewChild('container', { static: false }) _containerElem: ElementRef;
@ViewChild('leftArrow', { static: false }) _leftArrowElem: ElementRef;
@ViewChild('rightArrow', { static: false }) _rightArrowElem: ElementRef;
@ViewChild('navArrow', { static: false }) _navArrowElem: ElementRef;
@ViewChild('dataContainer', { static: false }) _dataContainerElem: ElementRef;
@ViewChild('image', { static: false }) _imageElem: ElementRef;
@ViewChild('caption', { static: false }) _captionElem: ElementRef;
@ViewChild('number', { static: false }) _numberElem: ElementRef;
public content: any;
public ui: any;
private _cssValue: any;
private _event: any;
private _windowRef: any;
constructor(
private _elemRef: ElementRef,
private _rendererRef: Renderer,
private _rendererRef: Renderer2,
private _lightboxEvent: LightboxEvent,
public _lightboxElem: ElementRef,
private _lightboxWindowRef: LightboxWindowRef,
Expand Down Expand Up @@ -263,8 +263,8 @@ export class LightboxComponent implements AfterViewInit, OnDestroy, OnInit {
}
}

this._rendererRef.setElementStyle(this._imageElem.nativeElement, 'width', `${imageWidth}px`);
this._rendererRef.setElementStyle(this._imageElem.nativeElement, 'height', `${imageHeight}px`);
this._rendererRef.setStyle(this._imageElem.nativeElement, 'width', `${imageWidth}px`);
this._rendererRef.setStyle(this._imageElem.nativeElement, 'height', `${imageHeight}px`);
}

this._sizeContainer(imageWidth, imageHeight);
Expand All @@ -281,7 +281,7 @@ export class LightboxComponent implements AfterViewInit, OnDestroy, OnInit {
const viewOffset = windowHeight / 2 - imageHeight / 2;
const topDistance = scrollOffset + viewOffset;

this._rendererRef.setElementStyle(this._lightboxElem.nativeElement, 'top', `${topDistance}px`);
this._rendererRef.setStyle(this._lightboxElem.nativeElement, 'top', `${topDistance}px`);
}

private _sizeContainer(imageWidth: number, imageHeight: number): void {
Expand All @@ -293,8 +293,8 @@ export class LightboxComponent implements AfterViewInit, OnDestroy, OnInit {
this._cssValue.imageBorderWidthTop + this._cssValue.imageBorderWidthBottom;

if (oldWidth !== newWidth || oldHeight !== newHeight) {
this._rendererRef.setElementStyle(this._outerContainerElem.nativeElement, 'width', `${newWidth}px`);
this._rendererRef.setElementStyle(this._outerContainerElem.nativeElement, 'height', `${newHeight}px`);
this._rendererRef.setStyle(this._outerContainerElem.nativeElement, 'width', `${newWidth}px`);
this._rendererRef.setStyle(this._outerContainerElem.nativeElement, 'height', `${newHeight}px`);

// bind resize event to outer container
// use enableTransition to prevent infinite loader
Expand Down Expand Up @@ -327,7 +327,7 @@ export class LightboxComponent implements AfterViewInit, OnDestroy, OnInit {
this._event.transitions = [];
}

this._rendererRef.setElementStyle(this._dataContainerElem.nativeElement, 'width', `${newWidth}px`);
this._rendererRef.setStyle(this._dataContainerElem.nativeElement, 'width', `${newWidth}px`);
this._showImage();
}

Expand Down Expand Up @@ -355,15 +355,15 @@ export class LightboxComponent implements AfterViewInit, OnDestroy, OnInit {
const left = this._windowRef.pageXOffset || this._documentRef.documentElement.scrollLeft;

if (!this.options.centerVertically) {
this._rendererRef.setElementStyle(this._lightboxElem.nativeElement, 'top', `${top}px`);
this._rendererRef.setStyle(this._lightboxElem.nativeElement, 'top', `${top}px`);
}

this._rendererRef.setElementStyle(this._lightboxElem.nativeElement, 'left', `${left}px`);
this._rendererRef.setElementStyle(this._lightboxElem.nativeElement, 'display', 'block');
this._rendererRef.setStyle(this._lightboxElem.nativeElement, 'left', `${left}px`);
this._rendererRef.setStyle(this._lightboxElem.nativeElement, 'display', 'block');

// disable scrolling of the page while open
if (this.options.disableScrolling) {
this._rendererRef.setElementClass(this._documentRef.documentElement, 'lb-disable-scrolling', true);
this._rendererRef.addClass(this._documentRef.documentElement, 'lb-disable-scrolling');
}
}

Expand All @@ -374,36 +374,36 @@ export class LightboxComponent implements AfterViewInit, OnDestroy, OnInit {
const resizeDuration = this.options.resizeDuration;
const fadeDuration = this.options.fadeDuration;

this._rendererRef.setElementStyle(this._lightboxElem.nativeElement,
this._rendererRef.setStyle(this._lightboxElem.nativeElement,
'-webkit-animation-duration', `${fadeDuration}s`);
this._rendererRef.setElementStyle(this._lightboxElem.nativeElement,
this._rendererRef.setStyle(this._lightboxElem.nativeElement,
'animation-duration', `${fadeDuration}s`);
this._rendererRef.setElementStyle(this._outerContainerElem.nativeElement,
this._rendererRef.setStyle(this._outerContainerElem.nativeElement,
'-webkit-transition-duration', `${resizeDuration}s`);
this._rendererRef.setElementStyle(this._outerContainerElem.nativeElement,
this._rendererRef.setStyle(this._outerContainerElem.nativeElement,
'transition-duration', `${resizeDuration}s`);
this._rendererRef.setElementStyle(this._dataContainerElem.nativeElement,
this._rendererRef.setStyle(this._dataContainerElem.nativeElement,
'-webkit-animation-duration', `${fadeDuration}s`);
this._rendererRef.setElementStyle(this._dataContainerElem.nativeElement,
this._rendererRef.setStyle(this._dataContainerElem.nativeElement,
'animation-duration', `${fadeDuration}s`);
this._rendererRef.setElementStyle(this._imageElem.nativeElement,
this._rendererRef.setStyle(this._imageElem.nativeElement,
'-webkit-animation-duration', `${fadeDuration}s`);
this._rendererRef.setElementStyle(this._imageElem.nativeElement,
this._rendererRef.setStyle(this._imageElem.nativeElement,
'animation-duration', `${fadeDuration}s`);
this._rendererRef.setElementStyle(this._captionElem.nativeElement,
this._rendererRef.setStyle(this._captionElem.nativeElement,
'-webkit-animation-duration', `${fadeDuration}s`);
this._rendererRef.setElementStyle(this._captionElem.nativeElement,
this._rendererRef.setStyle(this._captionElem.nativeElement,
'animation-duration', `${fadeDuration}s`);
this._rendererRef.setElementStyle(this._numberElem.nativeElement,
this._rendererRef.setStyle(this._numberElem.nativeElement,
'-webkit-animation-duration', `${fadeDuration}s`);
this._rendererRef.setElementStyle(this._numberElem.nativeElement,
this._rendererRef.setStyle(this._numberElem.nativeElement,
'animation-duration', `${fadeDuration}s`);
}

private _end(): void {
this.ui.classList = 'lightbox animation fadeOut';
if (this.options.disableScrolling) {
this._rendererRef.setElementClass(this._documentRef.documentElement, 'lb-disable-scrolling', false);
this._rendererRef.addClass(this._documentRef.documentElement, 'lb-disable-scrolling');
}
setTimeout(() => {
this.cmpRef.destroy();
Expand Down Expand Up @@ -465,8 +465,8 @@ export class LightboxComponent implements AfterViewInit, OnDestroy, OnInit {
if (this.options.wrapAround) {
if (alwaysShowNav) {
// alternatives this.$lightbox.find('.lb-prev, .lb-next').css('opacity', '1');
this._rendererRef.setElementStyle(this._leftArrowElem.nativeElement, 'opacity', '1');
this._rendererRef.setElementStyle(this._rightArrowElem.nativeElement, 'opacity', '1');
this._rendererRef.setStyle(this._leftArrowElem.nativeElement, 'opacity', '1');
this._rendererRef.setStyle(this._rightArrowElem.nativeElement, 'opacity', '1');
}

// alternatives this.$lightbox.find('.lb-prev, .lb-next').show();
Expand All @@ -478,7 +478,7 @@ export class LightboxComponent implements AfterViewInit, OnDestroy, OnInit {
this._showLeftArrowNav();
if (alwaysShowNav) {
// alternatives this.$lightbox.find('.lb-prev').css('opacity', '1');
this._rendererRef.setElementStyle(this._leftArrowElem.nativeElement, 'opacity', '1');
this._rendererRef.setStyle(this._leftArrowElem.nativeElement, 'opacity', '1');
}
}

Expand All @@ -487,7 +487,7 @@ export class LightboxComponent implements AfterViewInit, OnDestroy, OnInit {
this._showRightArrowNav();
if (alwaysShowNav) {
// alternatives this.$lightbox.find('.lb-next').css('opacity', '1');
this._rendererRef.setElementStyle(this._rightArrowElem.nativeElement, 'opacity', '1');
this._rendererRef.setStyle(this._rightArrowElem.nativeElement, 'opacity', '1');
}
}
}
Expand All @@ -507,7 +507,7 @@ export class LightboxComponent implements AfterViewInit, OnDestroy, OnInit {
}

private _enableKeyboardNav(): void {
this._event.keyup = this._rendererRef.listenGlobal('document', 'keyup', (event: any) => {
this._event.keyup = this._rendererRef.listen('document', 'keyup', (event: any) => {
this._keyboardAction(event);
});
}
Expand Down
Loading

0 comments on commit da31429

Please sign in to comment.