File

src/app/cursos/curso-info/curso-info.component.ts

Implements

OnInit OnChanges

Metadata

selector app-curso-info
styleUrls curso-info.component.scss
templateUrl ./curso-info.component.html

Inputs

curso

Type: Curso

type

Type: string

Constructor

constructor(sanitizer: DomSanitizer)

Methods

ngOnInit
ngOnInit()
Returns : void
ngOnChanges
ngOnChanges()
Returns : void
play
play(url: any, i: any)
Returns : void
Protected _sanitizerURL
_sanitizerURL(url: string)

'Sanea' la url, es imprescindible hacerlo para el src dinámico del frameset de youtube


Parameters :
  • url
Returns : SafeResourceUrl
close
close()
Returns : void
Static getClass
getClass()

Obtiene la clase correspondiente en función del tipo de listado


Returns : string
show
show()
Returns : void

Properties

Protected _display
_display: any
Protected _playing
_playing: any
Static CURSOS_TYPE
CURSOS_TYPE: any
Static display
display: string
Static indexSelected
indexSelected: any
Static playing
playing: any
import { CURSOS_TYPE, Curso } from './../../util/cursos';
import { Component, OnInit, Input, OnChanges } from '@angular/core';
import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser';

@Component({
  selector: 'app-curso-info',
  templateUrl: './curso-info.component.html',
  styleUrls: ['./curso-info.component.scss']
})
export class CursoInfoComponent implements OnInit, OnChanges {

 @Input() curso: Curso;
 @Input() type: string;

private _playing;
private _display;
public CURSOS_TYPE;
public indexSelected;

  constructor(private sanitizer: DomSanitizer) { }

  ngOnInit() {
    this.CURSOS_TYPE = CURSOS_TYPE;
   }

  ngOnChanges() {
   this.playing = false;
  }

  play(url, i) {
    this.playing = this._sanitizerURL(url);
    this.indexSelected = i;
    console.log(this.indexSelected);
  }

 /**
  * 'Sanea' la url, es imprescindible hacerlo para el src dinámico del frameset de youtube
  * @private
  * @param {string} url
  * @returns {SafeResourceUrl}
  * @memberOf CursoInfoComponent
  */
  private _sanitizerURL( url: string ): SafeResourceUrl {
    return this.sanitizer.bypassSecurityTrustResourceUrl(url);
  }

  close () {
    this.playing = null;
  }

/**
 * Obtiene la clase correspondiente en función del tipo de listado
 * @returns
 * @memberOf CursoInfoComponent
 */
  public getClass (): string {
    let clase = '';
    switch (this.type) {
      case CURSOS_TYPE.DISPONIBLES:
          clase = 'curso-card-disponibles';
          break;
      case CURSOS_TYPE.PUBLICADOS:
          clase = 'curso-card-publicados';
          break;
      case CURSOS_TYPE.SUSCRITOS:
          clase = 'curso-card-suscritos';
          break;
     }
     return clase;
  }

 show () {
   this._display = true;
 }

  public get display (): string{
   return this._display ;
 }

  public set display (value: string){
   this._display = value ;
 }


  public get playing(){
   return this._playing;
 }

 public set playing (value){
   this._playing = value;
 }

}
<div [ngClass]="getClass()" (click)="show()">
    <div class="curso-header">
        <i class="curso-icon fa {{curso.icon}} fa-2x "></i>
        <div class="curso-title">{{curso.nombre}}</div>
    </div>

    <div [ngSwitch]="type">
        <i class="curso-arrow fa fa-2x fa-arrows" *ngSwitchCase="CURSOS_TYPE.DISPONIBLES"></i>
        <i class="curso-play fa fa-2x fa-list-ol" *ngSwitchCase="CURSOS_TYPE.PUBLICADOS"></i>
        <i class="curso-play fa fa-2x fa-play-circle-o" *ngSwitchCase="CURSOS_TYPE.SUSCRITOS"></i>

    </div>
</div>

<p-dialog [(visible)]="display" modal="modal" [responsive]="true" #op>
    <p-header>
        <i class="curso-icon fa {{curso.icon}} fa-2x "></i>
        <span class="curso-title">{{curso.nombre}}</span>
    </p-header>
    <div class="curso-player">
        <div class="curso-video" *ngIf='type===CURSOS_TYPE.SUSCRITOS'>
            <div class="curso-video-iframe">
                <iframe *ngIf="playing" width="520" height="300" [src]="playing" frameborder="0" allowfullscreen></iframe>
            </div>
        </div>
        <div class="curso-temario">
            <ul>
                <li *ngFor="let video of curso.temario; let i =index">
                    <div [ngClass]="{'video-item':true, 'selected': i==indexSelected} " (click)="play(video.url,i)">
                        <img class="video-thumbnail" [src]="video.thumbnail" />
                        <p class="video-title">{{video.titulo}}</p>
                    </div>
                </li>
            </ul>
        </div>
    </div>

</p-dialog>
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""