add window event listeners
This commit is contained in:
		
							parent
							
								
									4c604581bd
								
							
						
					
					
						commit
						f457ac5e23
					
				
					 1 changed files with 13 additions and 0 deletions
				
			
		|  | @ -25,4 +25,17 @@ export default class Window { | |||
|      show() { | ||||
|           this.window = window.open(this.url, this.name, this.options); | ||||
|      }; | ||||
| 
 | ||||
|      /* Create an action listener.  | ||||
| 
 | ||||
|      @param {string} event the event to listen for | ||||
|      @param {function} callback the callback function | ||||
|      */ | ||||
|      static addActionListener(event, callback) { | ||||
|           // Correct possible syntax error on "on" prefix.
 | ||||
|           event = (!event.includes(`on`)) ? `on${event}` : event; | ||||
| 
 | ||||
|           // Add the event. 
 | ||||
|           chrome.windows[event].addListener(callback); | ||||
|      } | ||||
| }; | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue