Add auto_close function to popup
This commit is contained in:
		
							parent
							
								
									6649630754
								
							
						
					
					
						commit
						187f4ea634
					
				@ -150,8 +150,9 @@ will display the specified `entities` card as a popup on the current device.
 | 
			
		||||
 | 
			
		||||

 | 
			
		||||
 | 
			
		||||
The optional parameter `large: true` will make the popup wider.
 | 
			
		||||
The optional parameter `style:` will apply css style options to the popup.
 | 
			
		||||
The optional parameter `large: true` will make the popup wider.  
 | 
			
		||||
The optional parameter `style:` will apply css style options to the popup.  
 | 
			
		||||
The optional parameter `auto_close: true` will make the popup close automatically when the mouse is moved or a key is pressed on the keyboard. This also removes the header bar.  
 | 
			
		||||
 | 
			
		||||
Ex:
 | 
			
		||||
```yaml
 | 
			
		||||
 | 
			
		||||
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										11
									
								
								js/main.js
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								js/main.js
									
									
									
									
									
								
							@ -39,6 +39,8 @@ class BrowserMod {
 | 
			
		||||
    this.player = new Audio();
 | 
			
		||||
    this.playedOnce = false;
 | 
			
		||||
 | 
			
		||||
    this.autoclose_popup_active = false;
 | 
			
		||||
 | 
			
		||||
    const updater = this.update.bind(this);
 | 
			
		||||
    this.player.addEventListener("ended", updater);
 | 
			
		||||
    this.player.addEventListener("play", updater);
 | 
			
		||||
@ -167,11 +169,14 @@ class BrowserMod {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  popup(msg){
 | 
			
		||||
    if(!msg.title) return;
 | 
			
		||||
    if(!msg.title && !msg.auto_close) return;
 | 
			
		||||
    if(!msg.card) return;
 | 
			
		||||
    popUp(msg.title, msg.card, msg.large, msg.style);
 | 
			
		||||
    popUp(msg.title, msg.card, msg.large, msg.style, msg.auto_close);
 | 
			
		||||
    if(msg.auto_close)
 | 
			
		||||
      this.autoclose_popup_active = true;
 | 
			
		||||
  }
 | 
			
		||||
  close_popup(msg){
 | 
			
		||||
    this.autoclose_popup_active = false;
 | 
			
		||||
    closePopUp();
 | 
			
		||||
  }
 | 
			
		||||
  navigate(msg){
 | 
			
		||||
@ -199,6 +204,8 @@ class BrowserMod {
 | 
			
		||||
    this.update();
 | 
			
		||||
  }
 | 
			
		||||
  no_blackout(msg){
 | 
			
		||||
    if(this.autoclose_popup_active)
 | 
			
		||||
      return this.close_popup();
 | 
			
		||||
    this._blackout.style.visibility = "hidden";
 | 
			
		||||
    this.update();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user