Separate function to add code copy button
For neatness and also so it can show up separately in the profiler.pull/21833/head
							parent
							
								
									876257f4e2
								
							
						
					
					
						commit
						05a986334d
					
				| 
						 | 
				
			
			@ -114,16 +114,7 @@ module.exports = React.createClass({
 | 
			
		|||
                }, 10);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            // Add 'copy' buttons to pre blocks
 | 
			
		||||
            ReactDOM.findDOMNode(this).querySelectorAll('.mx_EventTile_body pre').forEach((p) => {
 | 
			
		||||
                const button = document.createElement("span");
 | 
			
		||||
                button.className = "mx_EventTile_copyButton";
 | 
			
		||||
                button.onclick = (e) => {
 | 
			
		||||
                    const copyCode = button.parentNode.getElementsByTagName("code")[0];
 | 
			
		||||
                    this.copyToClipboard(copyCode.textContent);
 | 
			
		||||
                };
 | 
			
		||||
                p.appendChild(button);
 | 
			
		||||
            });
 | 
			
		||||
            this._addCodeCopyButton();
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -260,6 +251,19 @@ module.exports = React.createClass({
 | 
			
		|||
        }
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    _addCodeCopyButton() {
 | 
			
		||||
        // Add 'copy' buttons to pre blocks
 | 
			
		||||
        ReactDOM.findDOMNode(this).querySelectorAll('.mx_EventTile_body pre').forEach((p) => {
 | 
			
		||||
            const button = document.createElement("span");
 | 
			
		||||
            button.className = "mx_EventTile_copyButton";
 | 
			
		||||
            button.onclick = (e) => {
 | 
			
		||||
                const copyCode = button.parentNode.getElementsByTagName("code")[0];
 | 
			
		||||
                this.copyToClipboard(copyCode.textContent);
 | 
			
		||||
            };
 | 
			
		||||
            p.appendChild(button);
 | 
			
		||||
        });
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    onCancelClick: function(event) {
 | 
			
		||||
        this.setState({ widgetHidden: true });
 | 
			
		||||
        // FIXME: persist this somewhere smarter than local storage
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue