| 
									
										
										
										
											2017-07-15 17:19:12 +02:00
										 |  |  | /* | 
					
						
							|  |  |  |  * index.js | 
					
						
							|  |  |  |  * Copyright (c) 2017 thegrumpydictator@gmail.com | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2017-10-21 08:40:00 +02:00
										 |  |  |  * This file is part of Firefly III. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Firefly III is free software: you can redistribute it and/or modify | 
					
						
							|  |  |  |  * it under the terms of the GNU General Public License as published by | 
					
						
							|  |  |  |  * the Free Software Foundation, either version 3 of the License, or | 
					
						
							|  |  |  |  * (at your option) any later version. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Firefly III is distributed in the hope that it will be useful, | 
					
						
							|  |  |  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
					
						
							|  |  |  |  * GNU General Public License for more details. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * You should have received a copy of the GNU General Public License | 
					
						
							| 
									
										
										
										
											2017-12-17 14:43:13 +01:00
										 |  |  |  * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
 | 
					
						
							| 
									
										
										
										
											2017-07-15 17:19:12 +02:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-29 09:05:35 +01:00
										 |  |  | /** global: searchQuery,searchUri,token */ | 
					
						
							| 
									
										
										
										
											2017-07-15 17:19:12 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | $(function () { | 
					
						
							|  |  |  |     "use strict"; | 
					
						
							|  |  |  |     startSearch(searchQuery); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function startSearch(query) { | 
					
						
							| 
									
										
										
										
											2017-12-20 20:07:57 +01:00
										 |  |  |     $.post(searchUri, {query: query, _token: token}).done(presentSearchResults).fail(searchFailure); | 
					
						
							| 
									
										
										
										
											2017-07-15 17:19:12 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function searchFailure() { | 
					
						
							|  |  |  |     $('.result_row').hide(); | 
					
						
							|  |  |  |     $('.error_row').show(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function presentSearchResults(data) { | 
					
						
							|  |  |  |     $('.search_ongoing').hide(); | 
					
						
							|  |  |  |     $('p.search_count').show(); | 
					
						
							|  |  |  |     $('span.search_count').text(data.count); | 
					
						
							|  |  |  |     $('.search_box').find('.overlay').remove(); | 
					
						
							|  |  |  |     $('.search_results').html(data.html).show(); | 
					
						
							| 
									
										
										
										
											2017-10-26 19:57:41 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     $('.select_all_single').unbind('change').change(function () { | 
					
						
							|  |  |  |         countChecked(); | 
					
						
							|  |  |  |     }); | 
					
						
							| 
									
										
										
										
											2018-12-30 15:44:33 +01:00
										 |  |  |     // make sure select button works:
 | 
					
						
							|  |  |  |     $('input[name="select_all"]').change(function () { | 
					
						
							|  |  |  |         if (this.checked) { | 
					
						
							|  |  |  |             checkAll(); | 
					
						
							|  |  |  |             countChecked(); | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             uncheckAll(); | 
					
						
							|  |  |  |             countChecked(); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     }); | 
					
						
							| 
									
										
										
										
											2017-07-15 17:19:12 +02:00
										 |  |  | } |