|
|
@ -1,26 +1,20 @@ |
|
|
|
import { SliderTab } from "../../slider"; |
|
|
|
import { SliderSuperTab } from "../../slider"; |
|
|
|
import InputSearch from "../../inputSearch"; |
|
|
|
import InputSearch from "../../inputSearch"; |
|
|
|
import Scrollable from "../../scrollable"; |
|
|
|
|
|
|
|
import animationIntersector from "../../animationIntersector"; |
|
|
|
import animationIntersector from "../../animationIntersector"; |
|
|
|
import appSidebarRight, { AppSidebarRight } from ".."; |
|
|
|
import appSidebarRight from ".."; |
|
|
|
import appUsersManager from "../../../lib/appManagers/appUsersManager"; |
|
|
|
import appUsersManager from "../../../lib/appManagers/appUsersManager"; |
|
|
|
import appInlineBotsManager, { AppInlineBotsManager } from "../../../lib/appManagers/appInlineBotsManager"; |
|
|
|
import appInlineBotsManager, { AppInlineBotsManager } from "../../../lib/appManagers/appInlineBotsManager"; |
|
|
|
import GifsMasonry from "../../gifsMasonry"; |
|
|
|
import GifsMasonry from "../../gifsMasonry"; |
|
|
|
import { findUpClassName } from "../../../helpers/dom"; |
|
|
|
import { findUpClassName, attachClickEvent } from "../../../helpers/dom"; |
|
|
|
import appImManager from "../../../lib/appManagers/appImManager"; |
|
|
|
import appImManager from "../../../lib/appManagers/appImManager"; |
|
|
|
import type { MyDocument } from "../../../lib/appManagers/appDocsManager"; |
|
|
|
import type { MyDocument } from "../../../lib/appManagers/appDocsManager"; |
|
|
|
import mediaSizes from "../../../helpers/mediaSizes"; |
|
|
|
import mediaSizes from "../../../helpers/mediaSizes"; |
|
|
|
|
|
|
|
|
|
|
|
const ANIMATIONGROUP = 'GIFS-SEARCH'; |
|
|
|
const ANIMATIONGROUP = 'GIFS-SEARCH'; |
|
|
|
|
|
|
|
|
|
|
|
export default class AppGifsTab implements SliderTab { |
|
|
|
export default class AppGifsTab extends SliderSuperTab { |
|
|
|
private container = document.getElementById('search-gifs-container') as HTMLDivElement; |
|
|
|
|
|
|
|
private contentDiv = this.container.querySelector('.sidebar-content') as HTMLDivElement; |
|
|
|
|
|
|
|
private backBtn = this.container.querySelector('.sidebar-close-button') as HTMLButtonElement; |
|
|
|
|
|
|
|
//private input = this.container.querySelector('#stickers-search') as HTMLInputElement;
|
|
|
|
|
|
|
|
private inputSearch: InputSearch; |
|
|
|
private inputSearch: InputSearch; |
|
|
|
private gifsDiv = this.contentDiv.firstElementChild as HTMLDivElement; |
|
|
|
private gifsDiv: HTMLDivElement; |
|
|
|
private scrollable: Scrollable; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private nextOffset = ''; |
|
|
|
private nextOffset = ''; |
|
|
|
private loadedAll = false; |
|
|
|
private loadedAll = false; |
|
|
@ -30,22 +24,27 @@ export default class AppGifsTab implements SliderTab { |
|
|
|
|
|
|
|
|
|
|
|
private searchPromise: ReturnType<AppInlineBotsManager['getInlineResults']>; |
|
|
|
private searchPromise: ReturnType<AppInlineBotsManager['getInlineResults']>; |
|
|
|
|
|
|
|
|
|
|
|
constructor() { |
|
|
|
protected init() { |
|
|
|
this.scrollable = new Scrollable(this.contentDiv, ANIMATIONGROUP); |
|
|
|
this.container.id = 'search-gifs-container'; |
|
|
|
|
|
|
|
|
|
|
|
this.masonry = new GifsMasonry(this.gifsDiv, ANIMATIONGROUP, this.scrollable); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.inputSearch = new InputSearch('Search GIFs', (value) => { |
|
|
|
this.inputSearch = new InputSearch('Search GIFs', (value) => { |
|
|
|
this.reset(); |
|
|
|
this.reset(); |
|
|
|
this.search(value); |
|
|
|
this.search(value); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
this.gifsDiv.addEventListener('click', this.onGifsClick); |
|
|
|
this.title.replaceWith(this.inputSearch.container); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.gifsDiv = document.createElement('div'); |
|
|
|
|
|
|
|
this.gifsDiv.classList.add('gifs-masonry'); |
|
|
|
|
|
|
|
attachClickEvent(this.gifsDiv, this.onGifsClick, {listenerSetter: this.listenerSetter}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.scrollable.append(this.gifsDiv); |
|
|
|
|
|
|
|
|
|
|
|
this.backBtn.parentElement.append(this.inputSearch.container); |
|
|
|
this.masonry = new GifsMasonry(this.gifsDiv, ANIMATIONGROUP, this.scrollable); |
|
|
|
|
|
|
|
//this.backBtn.parentElement.append(this.inputSearch.container);
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
onGifsClick = (e: MouseEvent) => { |
|
|
|
private onGifsClick = (e: MouseEvent | TouchEvent) => { |
|
|
|
const target = findUpClassName(e.target, 'gif'); |
|
|
|
const target = findUpClassName(e.target, 'gif'); |
|
|
|
if(!target) return; |
|
|
|
if(!target) return; |
|
|
|
|
|
|
|
|
|
|
@ -66,8 +65,9 @@ export default class AppGifsTab implements SliderTab { |
|
|
|
public onCloseAfterTimeout() { |
|
|
|
public onCloseAfterTimeout() { |
|
|
|
this.reset(); |
|
|
|
this.reset(); |
|
|
|
this.gifsDiv.innerHTML = ''; |
|
|
|
this.gifsDiv.innerHTML = ''; |
|
|
|
this.inputSearch.value = ''; |
|
|
|
|
|
|
|
animationIntersector.checkAnimations(undefined, ANIMATIONGROUP); |
|
|
|
animationIntersector.checkAnimations(undefined, ANIMATIONGROUP); |
|
|
|
|
|
|
|
this.inputSearch.remove(); |
|
|
|
|
|
|
|
return super.onCloseAfterTimeout(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private reset() { |
|
|
|
private reset() { |
|
|
@ -77,13 +77,9 @@ export default class AppGifsTab implements SliderTab { |
|
|
|
this.masonry.lazyLoadQueue.clear(); |
|
|
|
this.masonry.lazyLoadQueue.clear(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public init() { |
|
|
|
protected onOpen() { |
|
|
|
appSidebarRight.selectTab(AppSidebarRight.SLIDERITEMSIDS.gifs); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
appSidebarRight.toggleSidebar(true).then(() => { |
|
|
|
appSidebarRight.toggleSidebar(true).then(() => { |
|
|
|
//this.renderFeatured();
|
|
|
|
|
|
|
|
this.search('', true); |
|
|
|
this.search('', true); |
|
|
|
this.reset(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.scrollable.onScrolledBottom = () => { |
|
|
|
this.scrollable.onScrolledBottom = () => { |
|
|
|
this.search(this.inputSearch.value, false); |
|
|
|
this.search(this.inputSearch.value, false); |
|
|
@ -125,7 +121,8 @@ export default class AppGifsTab implements SliderTab { |
|
|
|
this.scrollable.onScroll(); |
|
|
|
this.scrollable.onScroll(); |
|
|
|
} catch(err) { |
|
|
|
} catch(err) { |
|
|
|
this.searchPromise = null; |
|
|
|
this.searchPromise = null; |
|
|
|
throw new Error(JSON.stringify(err)); |
|
|
|
console.error('gifs loading error:', err); |
|
|
|
|
|
|
|
throw err; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |