Changeset View
Changeset View
Standalone View
Standalone View
webroot/rsrc/js/phuix/PHUIXAutocomplete.js
Show First 20 Lines • Show All 549 Lines • ▼ Show 20 Lines | _update: function(e) { | ||||
// If this rule has a prefix pattern, like the "[[ document ]]" rule, | // If this rule has a prefix pattern, like the "[[ document ]]" rule, | ||||
// require it match and throw it away before we begin suggesting | // require it match and throw it away before we begin suggesting | ||||
// results. The autocomplete remains active, it's just dormant until | // results. The autocomplete remains active, it's just dormant until | ||||
// the user gives us more to work with. | // the user gives us more to work with. | ||||
var prefix = this._map[this._active].prefix; | var prefix = this._map[this._active].prefix; | ||||
if (prefix) { | if (prefix) { | ||||
var pattern = new RegExp(prefix); | var pattern = new RegExp(prefix); | ||||
if (!trim.match(pattern)) { | if (!trim.match(pattern)) { | ||||
// If the prefix pattern can not match the text, deactivate. (This | |||||
// check might need to be more careful if we have a more varied | |||||
// set of prefixes in the future, but for now they're all a single | |||||
// prefix character.) | |||||
if (trim.length) { | |||||
this._deactivate(); | |||||
} | |||||
return; | return; | ||||
} | } | ||||
trim = trim.replace(pattern, ''); | trim = trim.replace(pattern, ''); | ||||
trim = trim.trim(); | trim = trim.trim(); | ||||
} | } | ||||
// Store the current value now that we've finished mutating the text. | // Store the current value now that we've finished mutating the text. | ||||
// This needs to match what we pass to the typeahead datasource. | // This needs to match what we pass to the typeahead datasource. | ||||
▲ Show 20 Lines • Show All 210 Lines • Show Last 20 Lines |