1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-18 21:02:41 +01:00
phorge-phorge/webroot/rsrc/js/application/conpherence/behavior-conpherence-search.js
Chad Little ac8e11359d Remove 'full-display' setting from Conpherence, spruce up search results
Summary: This removes 'full-display', 'minimal-display' from Conpherence, which I recall was because we had 2 UIs for column and regular chat. I'm also tossing in slightly nicer search results, with a link to the actual message and the full date shown for context.

Test Plan: Post a message in mobile, tablet, full conpherence, and in durable column. Clean up UI in durable column. Do a search in Full UI, click on result date, get taken to the message... usually. My test data is a little wonky, but I think this works most of the time.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D16710
2016-10-17 15:53:55 -07:00

82 lines
1.8 KiB
JavaScript

/**
* @provides javelin-behavior-conpherence-search
* @requires javelin-behavior
* javelin-dom
* javelin-util
* javelin-workflow
* javelin-stratcom
*/
JX.behavior('conpherence-search', function() {
var shown = true;
var request = null;
function _toggleSearch(e) {
e.kill();
var node = JX.$('conpherence-main-layout');
shown = !shown;
JX.DOM.alterClass(node, 'show-searchbar', !shown);
if (!shown) {
JX.$('conpherence-search-input').focus();
} else {
var form_root = JX.DOM.find(document, 'div', 'conpherence-form');
var textarea = JX.DOM.find(form_root, 'textarea');
textarea.focus();
}
JX.Stratcom.invoke('resize');
}
function _doSearch(e) {
e.kill();
var search_text = JX.$('conpherence-search-input').value;
var search_uri = JX.$('conpherence-search-form').action;
var search_node = JX.$('conpherence-search-results');
if (request || !search_text) {
return;
}
request = new JX.Request(search_uri, function(response) {
JX.DOM.setContent(search_node, JX.$H(response));
request = null;
});
request.setData({fulltext: search_text});
request.send();
}
function _viewResult(e) {
e.kill();
var uri = e.getNode('tag:a');
_toggleSearch(e);
JX.$U(uri).go();
}
JX.Stratcom.listen(
['submit', 'didSyntheticSubmit'],
'conpherence-search-input',
_doSearch);
JX.Stratcom.listen(
'keydown',
'conpherence-search-input',
function(e) {
if (e.getSpecialKey() != 'return') {
return;
}
e.kill();
_doSearch(e);
});
JX.Stratcom.listen(
'click',
'conpherence-search-result-jump',
_viewResult);
JX.Stratcom.listen(
'click',
'conpherence-search-toggle',
_toggleSearch);
});