2017-01-23 14:05:59 -05:00
|
|
|
/// <reference path="../../../typings/browser/ambient/jquery/index.d.ts" />
|
|
|
|
import { HostListener, EventEmitter, Component, Input, Output, AfterViewChecked } from "@angular/core";
|
2017-01-18 17:51:06 -05:00
|
|
|
import { Reference } from '../../libs/Reference';
|
|
|
|
import { OpenData, CardItem } from "../../pages/search/search";
|
2016-12-27 21:10:00 -05:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: "words",
|
|
|
|
templateUrl: "words.html"
|
|
|
|
})
|
2017-01-23 14:05:59 -05:00
|
|
|
export class Words implements AfterViewChecked
|
2017-01-18 17:51:06 -05:00
|
|
|
{
|
2016-12-27 21:10:00 -05:00
|
|
|
@Output()
|
|
|
|
onClose = new EventEmitter<CardItem>();
|
|
|
|
|
|
|
|
@Output()
|
2017-01-20 18:57:02 -05:00
|
|
|
onItemClicked = new EventEmitter<OpenData>();
|
2017-01-23 14:05:59 -05:00
|
|
|
|
2016-12-27 21:10:00 -05:00
|
|
|
@Input()
|
|
|
|
cardItem: CardItem;
|
|
|
|
|
2017-01-23 14:05:59 -05:00
|
|
|
$: any;
|
|
|
|
|
2017-01-18 17:51:06 -05:00
|
|
|
constructor()
|
|
|
|
{
|
2016-12-27 21:10:00 -05:00
|
|
|
}
|
|
|
|
|
2017-01-23 14:05:59 -05:00
|
|
|
@HostListener('window:resize', ['$event'])
|
|
|
|
onResize(evt)
|
|
|
|
{
|
|
|
|
$("words ion-scroll").each((i, el) =>
|
|
|
|
{
|
|
|
|
let wr = $(el).find(".scroll-content .scroll-zoom-wrapper")[0];
|
|
|
|
let len = $(el).find(".scroll-zoom-wrapper a").length;
|
|
|
|
|
|
|
|
if (wr.scrollWidth < 500) // 1 col
|
|
|
|
{
|
|
|
|
if (len < 6) // 5 rows
|
|
|
|
$(el).css("height", len * 44.4 + 25);
|
|
|
|
else
|
|
|
|
$(el).css("height", 250);
|
|
|
|
}
|
|
|
|
else if (wr.scrollWidth < 699) // 2 col
|
|
|
|
{
|
|
|
|
if (len < 13) // 6 rows
|
|
|
|
$(el).css("height", Math.ceil(len / 2) * 44.4 + 25);
|
|
|
|
else
|
|
|
|
$(el).css("height", 300);
|
|
|
|
}
|
|
|
|
else if (wr.scrollWidth < 799) // 3 col
|
|
|
|
{
|
|
|
|
if (len < 22) // 7 rows
|
|
|
|
$(el).css("height", Math.ceil(len / 3) * 44.4 + 25);
|
|
|
|
else
|
|
|
|
$(el).css("height", 350);
|
|
|
|
}
|
|
|
|
else if (wr.scrollWidth < 899) // 4 col
|
|
|
|
{
|
|
|
|
if (len < 29) // 7 rows
|
|
|
|
$(el).css("height", Math.ceil(len / 4) * 44.4 + 25);
|
|
|
|
else
|
|
|
|
$(el).css("height", 350);
|
|
|
|
}
|
|
|
|
else if (wr.scrollWidth < 1199) // 5 col
|
|
|
|
{
|
|
|
|
if (len < 41) // 8 rows
|
|
|
|
$(el).css("height", Math.ceil(len / 5) * 44.4 + 25);
|
|
|
|
else
|
|
|
|
$(el).css("height", 400);
|
|
|
|
}
|
|
|
|
else // 6 col
|
|
|
|
{
|
|
|
|
if (len < 49) // 8 rows
|
|
|
|
$(el).css("height", Math.ceil(len / 6) * 44.4 + 25);
|
|
|
|
else
|
|
|
|
$(el).css("height", 400);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
public ngAfterViewChecked(): void
|
|
|
|
{
|
|
|
|
this.onResize(null);
|
|
|
|
}
|
|
|
|
|
2017-01-18 17:51:06 -05:00
|
|
|
close()
|
|
|
|
{
|
2016-12-27 21:10:00 -05:00
|
|
|
this.onClose.emit(this.cardItem);
|
|
|
|
}
|
|
|
|
|
2017-01-16 21:36:22 -05:00
|
|
|
makePassage(p: string)
|
2016-12-27 21:10:00 -05:00
|
|
|
{
|
|
|
|
return Reference.bookName(parseInt(p.split(":")[0])) + ' ' + p.split(":")[1] + ":" + p.split(":")[2];
|
|
|
|
}
|
2017-01-20 18:57:02 -05:00
|
|
|
|
2017-01-16 21:36:22 -05:00
|
|
|
openPassage(p: string)
|
2016-12-27 21:10:00 -05:00
|
|
|
{
|
|
|
|
let ref = this.makePassage(p);
|
2017-01-20 18:57:02 -05:00
|
|
|
this.onItemClicked.emit({ card: this.cardItem, qry: ref });
|
2016-12-27 21:10:00 -05:00
|
|
|
}
|
2017-01-18 17:51:06 -05:00
|
|
|
}
|