1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-27 07:50:57 +01:00
phorge-phorge/webroot/rsrc/js/application/diffusion/behavior-locate-file.js
epriestley 436f0563e8 Add a SublimeText-style repository typeahead
Summary:
Allows you to quickly search for files within a repository. Roughly:

  - We build a big tree of everything and ship it to the client.
  - The client implements a bunch of Sublime-ish magic to find paths.

Test Plan: {F154007}

Reviewers: chad, btrahan

Reviewed By: btrahan

Subscribers: epriestley, zeeg

Differential Revision: https://secure.phabricator.com/D9087
2014-05-13 14:08:21 -07:00

31 lines
767 B
JavaScript

/**
* @provides javelin-behavior-diffusion-locate-file
* @requires javelin-behavior
* javelin-diffusion-locate-file-source
* javelin-dom
* javelin-typeahead
* javelin-uri
*/
JX.behavior('diffusion-locate-file', function(config) {
var control = JX.$(config.controlID);
var input = JX.$(config.inputID);
var datasource = new JX.DiffusionLocateFileSource(config.uri);
var typeahead = new JX.Typeahead(control, input);
typeahead.setDatasource(datasource);
typeahead.listen('choose', function(r) {
JX.$U(config.browseBaseURI + r.ref).go();
});
var started = false;
JX.DOM.listen(input, 'click', null, function() {
if (!started) {
started = true;
typeahead.start();
}
});
});