Skip to content

Commit

Permalink
library documentation with typedoc #58
Browse files Browse the repository at this point in the history
  • Loading branch information
Ks89 committed May 29, 2017
1 parent c5ba3a4 commit 9fba849
Showing 1 changed file with 56 additions and 6 deletions.
62 changes: 56 additions & 6 deletions src/components/modal-gallery.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ import { Subscription } from 'rxjs/Subscription';

import { KeyboardService } from './keyboard.service';

/**
* Enum `Action` with a list of possible actions.
*/
export enum Action {
NORMAL, // default value
CLICK, // mouse click
Expand All @@ -40,6 +43,9 @@ export enum Action {
LOAD
}

/**
* Class `ImageModalEvent` that represents the Event after an action `action` and its result.
*/
export class ImageModalEvent {
action: Action;
result: number | boolean;
Expand All @@ -50,6 +56,10 @@ export class ImageModalEvent {
}
}

/**
* Class `Image` that represents an Image with both image and thumb paths, also with a description and an external url.
* The only required value is the image path `img`.
*/
export class Image {
img: string;
thumb?: string;
Expand All @@ -64,6 +74,9 @@ export class Image {
}
}

/**
* Enum `Keyboard` with keys and their relative key codes.
*/
export enum Keyboard {
ESC = 27,
LEFT_ARROW = 37,
Expand All @@ -72,19 +85,29 @@ export enum Keyboard {
DOWN_ARROW = 40
}

/**
* Interface `Description` to change the description, either with a full custom
* description or with a small and simple customization.
*/
export interface Description {
customFullDescription?: string;
imageText?: string;
numberSeparator?: string;
beforeTextDescription?: string;
}

/**
* Interface `ButtonsConfig` to show/hide buttons.
*/
export interface ButtonsConfig {
download?: boolean;
extUrl?: boolean;
close?: boolean;
}

/**
* Interface `KeyboardConfig` to assign custom keys to ESC, RIGHT and LEFT keyboard's actions.
*/
export interface KeyboardConfig {
esc?: number;
right?: number;
Expand All @@ -98,27 +121,40 @@ export interface KeyboardConfig {
templateUrl: 'modal-gallery.html'
})
export class AngularModalGallery implements OnInit, OnDestroy, OnChanges {
/**
* Array or Observable input that represets a list of Images use to show both the
* thumbs gallery and the modal gallery.
*/
@Input() modalImages: Observable<Array<Image>> | Array<Image>;
@Input() imagePointer: number;
@Input() downloadable: boolean = false;
@Input() description: Description;

// used only inside ngInit to create configButtons used into upper-buttons
/**
* Object of type `ButtonsConfig` to show/hide buttons.
* This is used only inside `ngOnInit()` to create `configButtons` used into upper-buttons
*/
@Input() buttonsConfig: ButtonsConfig;

/**
* Object of type `KeyboardConfig` to assign custom keys to ESC, RIGHT and LEFT keyboard's actions.
*/
@Input() keyboardConfig: KeyboardConfig;


/**
* enableCloseOutside's input to enable modal-gallery close behaviour while clicking
* on the semi-transparent background. Disabled by default.
* on the semi-transparent background. Disabled by default.
*/
@Input() enableCloseOutside: boolean = false;

/*
/**
* deprecated both showDownloadButton and showExtUrlButton
*/
@Input() showDownloadButton: boolean = false; // deprecated
/**
* deprecated both showDownloadButton and showExtUrlButton
*/
@Input() showExtUrlButton: boolean = false; // deprecated

@Output() close: EventEmitter<ImageModalEvent> = new EventEmitter<ImageModalEvent>();
Expand Down Expand Up @@ -157,23 +193,37 @@ export class AngularModalGallery implements OnInit, OnDestroy, OnChanges {
currentImage: Image;
currentImageIndex: number = 0;

/**
* Object of type `ButtonsConfig` used to configure buttons visibility. This is a temporary value
* initialized by the real `buttonsConfig`'s input
*/
configButtons: ButtonsConfig;

// enum action used to pass a click action
// when you clicks over the modal image.
// Declared here to use it in the template.
/**
* Enum of type `Action` used to pass a click action when you click over the modal image.
* Declared here to be used inside the template.
*/
clickAction: Action = Action.CLICK;

/**
* Private SWIPE_ACTION to define all swipe actions used by hammerjs.
*/
private SWIPE_ACTION = {
LEFT: 'swipeleft',
RIGHT: 'swiperight',
UP: 'swipeup',
DOWN: 'swipedown'
};

/**
* Private Subscription used to subscribe to input's `modalImages` is passed as Observable.
*/
private subscription: Subscription;


/**
* Constructor with the injection of ´KeyboardService´ that initialize some description fields based on default values.
*/
constructor(private keyboardService: KeyboardService) {
// if description isn't provided initialize it with a default object
if (!this.description) {
Expand Down

0 comments on commit 9fba849

Please sign in to comment.