src/main/webapp/js/singlepage-interface.js
/**
	 * The core search trigger, named a little awkwardly because it autotriggers when a tab is made active/opens.
	 * We emulate the tab reopening to update the displayed search results when new search parameters are set/selected.
	 */
The core search trigger, named a little awkwardly because it autotriggers when a tab is made active/opens.
We emulate the tab reopening to update the displayed search results when new search parameters are set/selected.
The core search trigger named a little awkwardly because it autotriggers when a tab is made active / opens . We emulate the tab reopening to update the displayed search results when new search parameters are set / selected .
function onTabOpen() {
		var $tab = $(this);
		var searchSettings = $.extend({}, $tab.data('defaultParameters'), $tab.data('parameters'), $tab.data('constParameters'));
		$('#results').show();
		var querySummary = SINGLEPAGE.BLS.getQuerySummary(searchSettings.pattern, searchSettings.within, searchSettings.filters);
		$('#searchFormDivHeader').show()
		.find('#querySummary').text(querySummary).attr('title', querySummary.substr(0, 1000));
		if ($tab.data('results')) {
			SINGLEPAGE.CORE.onSearchUpdated(searchSettings);
			return;
		}
		if (searchSettings.operation === 'hits' && (searchSettings.pattern == null || searchSettings.pattern.length === 0)) {
			replaceTableContent($tab.find('.resultcontainer table'),
				['<thead>',
					'<tr><th><a>No hits to display</a></th></tr>',
				'</thead>',
				'<tbody>',
					'<tr>',
						'<td class="no-results-found">No hits to display... (one or more of Lemma/PoS/Word is required).</td>',
					'</tr>',
				'</tbody>'
				].join('')
			);
			$tab.find('.resultcontainer').show();
			$tab.find('.resultcontrols').hide();
			$tab.data('results', {}); 
			return;
		}
		showSearchIndicator($tab);
		SINGLEPAGE.CORE.onSearchUpdated(searchSettings);
		SINGLEPAGE.BLS.search(searchSettings,
			function onSuccess() {
				hideBlsError();
				$tab.data('fnSetResults').apply(undefined, Array.prototype.slice.call(arguments)); 
			},
			function onError() {
				hideSearchIndicator($tab);
				showBlsError.apply(undefined, Array.prototype.slice.call(arguments)); 
			}
		);
	}
function onTabOpen ( ) { var $tab = $ ( this ) ; var searchSettings = $ . extend ( { } , $tab . data ( 'defaultParameters' ) , $tab . data ( 'parameters' ) , $tab . data ( 'constParameters' ) ) ; $ ( '#results' ) . show ( ) ; var querySummary = SINGLEPAGE . BLS . getQuerySummary ( searchSettings . pattern , searchSettings . within , searchSettings . filters ) ; $ ( '#searchFormDivHeader' ) . show ( ) . find ( '#querySummary' ) . text ( querySummary ) . attr ( 'title' , querySummary . substr ( 0 , 1000 ) ) ; if ( $tab . data ( 'results' ) ) { SINGLEPAGE . CORE . onSearchUpdated ( searchSettings ) ; return ; } if ( searchSettings . operation === 'hits' && ( searchSettings . pattern == null || searchSettings . pattern . length === 0 ) ) { replaceTableContent ( $tab . find ( '.resultcontainer table' ) , [ '<thead>' , '<tr><th><a>No hits to display</a></th></tr>' , '</thead>' , '<tbody>' , '<tr>' , '<td class="no-results-found">No hits to display... (one or more of Lemma/PoS/Word is required).</td>' , '</tr>' , '</tbody>' ] . join ( '' ) ) ; $tab . find ( '.resultcontainer' ) . show ( ) ; $tab . find ( '.resultcontrols' ) . hide ( ) ; $tab . data ( 'results' , { } ) ; return ; } showSearchIndicator ( $tab ) ; SINGLEPAGE . CORE . onSearchUpdated ( searchSettings ) ; SINGLEPAGE . BLS . search ( searchSettings , function onSuccess ( ) { hideBlsError ( ) ; $tab . data ( 'fnSetResults' ) . apply ( undefined , Array . prototype . slice . call ( arguments ) ) ; } , function onError ( ) { hideSearchIndicator ( $tab ) ; showBlsError . apply ( undefined , Array . prototype . slice . call ( arguments ) ) ; } ) ; }
The core search trigger, named a little awkwardly because it autotriggers when a tab is made active/opens.
The core search trigger named a little awkwardly because it autotriggers when a tab is made active / opens .
/*event, data*/ // CORE does as little UI manipulation as possible, just shows a tab when required // so we're responsible for showing the entire results area. // Nothing to do, tab is already displaying data (this happens when you go back and forth between tabs without changing your query in between) // Still notify core so that when the url is copied out the current tab can be restored. // Not all configurations of search parameters will result in a valid search // Verify that we're not trying to view hits without a pattern to generate said hits // and warn the user if we are // Prevent refreshing search on next tab open // All is well, search! // call with original args // call with original args