@ -56,18 +56,18 @@ export class EmoticonsDropdown {
} ;
} ;
private selectTab : ReturnType < typeof horizontalMenu > ;
private selectTab : ReturnType < typeof horizontalMenu > ;
private forceClose = false ;
private firstTime = true ;
constructor ( ) {
constructor ( ) {
this . element = document . getElementById ( 'emoji-dropdown' ) as HTMLDivElement ;
this . element = document . getElementById ( 'emoji-dropdown' ) as HTMLDivElement ;
}
}
public attachButtonListener ( button : HTMLElement ) {
public attachButtonListener ( button : HTMLElement ) {
let firstTime = true ;
if ( isTouchSupported ) {
if ( isTouchSupported ) {
button . addEventListener ( 'click' , ( ) = > {
button . addEventListener ( 'click' , ( ) = > {
if ( this . firstTime ) {
if ( firstTime ) {
this . firstTime = false ;
firstTime = false ;
this . toggle ( true ) ;
this . toggle ( true ) ;
} else {
} else {
this . toggle ( ) ;
this . toggle ( ) ;
@ -75,29 +75,13 @@ export class EmoticonsDropdown {
} ) ;
} ) ;
} else {
} else {
button . onmouseover = ( e ) = > {
button . onmouseover = ( e ) = > {
//console.log('onmouseover button');
clearTimeout ( this . displayTimeout ) ;
clearTimeout ( this . displayTimeout ) ;
//this.displayTimeout = setTimeout(() => {
//this.displayTimeout = setTimeout(() => {
if ( this . firstTime ) {
if ( firstTime ) {
button . onmouseout = this . element . onmouseout = ( e ) = > {
button . onmouseout = this . onMouseOut ;
if ( test ) return ;
if ( ! this . element . classList . contains ( 'active' ) ) return ;
firstTime = false ;
const toElement = ( e as any ) . toElement as Element ;
if ( toElement && findUpClassName ( toElement , 'emoji-dropdown' ) ) {
return ;
}
clearTimeout ( this . displayTimeout ) ;
this . displayTimeout = window . setTimeout ( ( ) = > {
this . toggle ( false ) ;
} , 200 ) ;
} ;
this . element . onmouseover = ( e ) = > {
clearTimeout ( this . displayTimeout ) ;
} ;
this . firstTime = false ;
}
}
this . toggle ( true ) ;
this . toggle ( true ) ;
@ -106,6 +90,21 @@ export class EmoticonsDropdown {
}
}
}
}
private onMouseOut = ( e : MouseEvent ) = > {
if ( test ) return ;
if ( ! this . element . classList . contains ( 'active' ) ) return ;
const toElement = ( e as any ) . toElement as Element ;
if ( toElement && findUpClassName ( toElement , 'emoji-dropdown' ) ) {
return ;
}
clearTimeout ( this . displayTimeout ) ;
this . displayTimeout = window . setTimeout ( ( ) = > {
this . toggle ( false ) ;
} , 200 ) ;
} ;
private init() {
private init() {
this . emojiTab = new EmojiTab ( ) ;
this . emojiTab = new EmojiTab ( ) ;
this . stickersTab = new StickersTab ( ) ;
this . stickersTab = new StickersTab ( ) ;
@ -161,6 +160,18 @@ export class EmoticonsDropdown {
rootScope . on ( 'peer_changed' , this . checkRights ) ;
rootScope . on ( 'peer_changed' , this . checkRights ) ;
this . checkRights ( ) ;
this . checkRights ( ) ;
if ( ! isTouchSupported ) {
this . element . onmouseout = this . onMouseOut ;
this . element . onmouseover = ( e ) = > {
if ( this . forceClose ) {
return ;
}
//console.log('onmouseover element');
clearTimeout ( this . displayTimeout ) ;
} ;
}
}
}
private onSelectTabClick = ( id : number ) = > {
private onSelectTabClick = ( id : number ) = > {
@ -237,6 +248,9 @@ export class EmoticonsDropdown {
EmoticonsDropdown . lazyLoadQueue . unlock ( ) ;
EmoticonsDropdown . lazyLoadQueue . unlock ( ) ;
EmoticonsDropdown . lazyLoadQueue . refresh ( ) ;
EmoticonsDropdown . lazyLoadQueue . refresh ( ) ;
this . forceClose = false ;
this . container . classList . remove ( 'disable-hover' ) ;
this . events . onOpenAfter . forEach ( cb = > cb ( ) ) ;
this . events . onOpenAfter . forEach ( cb = > cb ( ) ) ;
} , isTouchSupported ? 0 : 200 ) ;
} , isTouchSupported ? 0 : 200 ) ;
@ -264,6 +278,9 @@ export class EmoticonsDropdown {
EmoticonsDropdown . lazyLoadQueue . unlock ( ) ;
EmoticonsDropdown . lazyLoadQueue . unlock ( ) ;
EmoticonsDropdown . lazyLoadQueue . refresh ( ) ;
EmoticonsDropdown . lazyLoadQueue . refresh ( ) ;
this . forceClose = false ;
this . container . classList . remove ( 'disable-hover' ) ;
this . events . onCloseAfter . forEach ( cb = > cb ( ) ) ;
this . events . onCloseAfter . forEach ( cb = > cb ( ) ) ;
} , isTouchSupported ? 0 : 200 ) ;
} , isTouchSupported ? 0 : 200 ) ;
@ -353,6 +370,8 @@ export class EmoticonsDropdown {
if ( appImManager . chat . input . sendMessageWithDocument ( fileId ) ) {
if ( appImManager . chat . input . sendMessageWithDocument ( fileId ) ) {
/ * d r o p d o w n . c l a s s L i s t . r e m o v e ( ' a c t i v e ' ) ;
/ * d r o p d o w n . c l a s s L i s t . r e m o v e ( ' a c t i v e ' ) ;
toggleEl . classList . remove ( 'active' ) ; * /
toggleEl . classList . remove ( 'active' ) ; * /
emoticonsDropdown . forceClose = true ;
emoticonsDropdown . container . classList . add ( 'disable-hover' ) ;
emoticonsDropdown . toggle ( false ) ;
emoticonsDropdown . toggle ( false ) ;
} else {
} else {
console . warn ( 'got no doc by id:' , fileId ) ;
console . warn ( 'got no doc by id:' , fileId ) ;