Merge pull request #2835 from BernieHuang2008/auto-copy
[feature] added a "copy" button in `search url` sidebar.
This commit is contained in:
		
						commit
						7b1951aa97
					
				
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
										
											Binary file not shown.
										
									
								
							| Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 5.0 KiB | 
										
											Binary file not shown.
										
									
								
							| Before Width: | Height: | Size: 8.5 KiB After Width: | Height: | Size: 8.7 KiB | 
							
								
								
									
										2
									
								
								searx/static/themes/simple/js/searxng.min.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								searx/static/themes/simple/js/searxng.min.js
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							| @ -16,6 +16,8 @@ | |||||||
|           } |           } | ||||||
|         )); |         )); | ||||||
| 
 | 
 | ||||||
|  |     d.querySelector('#search_url button#copy_url').style.display = "block"; | ||||||
|  | 
 | ||||||
|     searxng.on('.btn-collapse', 'click', function () { |     searxng.on('.btn-collapse', 'click', function () { | ||||||
|       var btnLabelCollapsed = this.getAttribute('data-btn-text-collapsed'); |       var btnLabelCollapsed = this.getAttribute('data-btn-text-collapsed'); | ||||||
|       var btnLabelNotCollapsed = this.getAttribute('data-btn-text-not-collapsed'); |       var btnLabelNotCollapsed = this.getAttribute('data-btn-text-not-collapsed'); | ||||||
| @ -41,6 +43,12 @@ | |||||||
|       } |       } | ||||||
|     }); |     }); | ||||||
| 
 | 
 | ||||||
|  |     searxng.on('#copy_url', 'click', function () { | ||||||
|  |       var target = this.parentElement.querySelector('pre'); | ||||||
|  |       navigator.clipboard.writeText(target.innerText); | ||||||
|  |       this.innerText = this.dataset.copiedText; | ||||||
|  |     }); | ||||||
|  | 
 | ||||||
|     searxng.selectImage = function (resultElement) { |     searxng.selectImage = function (resultElement) { | ||||||
|       /* eslint no-unused-vars: 0 */ |       /* eslint no-unused-vars: 0 */ | ||||||
|       if (resultElement) { |       if (resultElement) { | ||||||
|  | |||||||
| @ -729,9 +729,18 @@ summary.title { | |||||||
| #search_url { | #search_url { | ||||||
|   div.selectable_url { |   div.selectable_url { | ||||||
|     pre { |     pre { | ||||||
|  |       float: left; | ||||||
|       width: 200em; |       width: 200em; | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  | 
 | ||||||
|  |   button#copy_url { | ||||||
|  |     float: right; | ||||||
|  |     padding: 0.4rem; | ||||||
|  |     margin-left: 0.5rem; | ||||||
|  |     border-radius: 0.3rem; | ||||||
|  |     display: none;    // will be shown by JS. | ||||||
|  |   } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| #links_on_top { | #links_on_top { | ||||||
|  | |||||||
| @ -1,6 +1,7 @@ | |||||||
| <div id="search_url" role="complementary" aria-labelledby="search_url-title"> | <div id="search_url" role="complementary" aria-labelledby="search_url-title"> | ||||||
|   <details class="sidebar-collapsable"> |   <details class="sidebar-collapsable"> | ||||||
|     <summary class="title" id="search_url-title">{{ _('Search URL') }}</summary> |     <summary class="title" id="search_url-title">{{ _('Search URL') }}</summary> | ||||||
|  |     <button id="copy_url" type="submit" data-copied-text="{{ _('Copied') }}">{{ _('Copy') }}</button> | ||||||
|     <div class="selectable_url"> |     <div class="selectable_url"> | ||||||
|       <pre>{{ url_for('search', _external=True) }}?q={{ q|urlencode }}&language={{ current_language }}&time_range={{ time_range }}&safesearch={{ safesearch }} |       <pre>{{ url_for('search', _external=True) }}?q={{ q|urlencode }}&language={{ current_language }}&time_range={{ time_range }}&safesearch={{ safesearch }} | ||||||
|         {%- if pageno > 1 -%} |         {%- if pageno > 1 -%} | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Paul Braeuning
						Paul Braeuning