Despite the length of this commit, it is a very straightforward
moving of code from narrow.js -> narrow_state.js, and then
everything else is just s/narrow.foo()/narrow_state.foo()/
(with a few tiny cleanups to remove some code duplication
in certain callers).
The only new functions are simple setter/getters that
encapsulate the current_filter variable:
narrow_state.reset_current_filter()
narrow_state.set_current_filter()
narrow_state.get_current_filter()
We removed narrow.predicate() as part of this, since it was dead
code.
Also, we removed the shim for narrow_state.set_compose_defaults(),
and since that was the last shim, we removed shim.js from the app.
This fixes an issue with the menu going below the bottom of screen
with non-tiny windows, and it was rare that anyone benefitted from the
extra suggestions.
Fixes: #4133.
A clear-search option to clear the user-list searchbox has been added.
This feature was present in the main searchbar but absent elsewhere.
Fix a part of #3716.
The one call we were making to it was actually unnecessary since highlighting is
no longer done client-side.
(imported from commit 7644a5961ca48cd57f4b65c6f698083677e0a130)
Narrow.activate was called without an options object in one
obscure location. I'm not sure how it's actually triggered,
since all searches seem to go through the typeahead path with
the "Search for x" option, but someone managed to do it.
(imported from commit 5e0e1bbe7570e5f6a654949547dc164e01125efa)
I'm trying to move well-isolated methods out of narrow.js, so that
narrow.js is more strongly focused on UI/ajax interactions and
big, heavy lifting stuff. The logical home for parse/unparse
seemed to be Filter, and they brought along two private methods
with them. The big code moves involved trivial follow ups
like s/exports/Filter/.
(imported from commit ace0fe5aa1c7abce0334d079ba9eb8d9a57bd10f)
Trac #1479
All our typeaheads use this, but I made it an option that must be enabled
explicitly since it is not default bootstrap behavior.
(imported from commit 97852dc407d1f6dbe46b5fdd2c56d3ed8c6718d2)
Moved 400+ lines out of search.js into search_suggestion.js. This
leaves search.js primarily responsible for lots of little DOM
interactions, whereas search_suggestion is more about data.
(imported from commit 53d08b29367c0172e483064f213538d45098279e)
1. Change code comment in search.get_suggestion.
2. Remove side effects from search.get_suggestions.
The function get_suggestions() was updating a module-scoped variable
called search_object, but now it returns a dictionary to its caller.
3. Greatly reduce the scope of the search_object var in search.js.
I also clarified the comment around it a bit. We could squeeze
the scope of search_object even further by using a function wrapper, but
this is a big enough win for now.
(imported from commit 4b633dd30ab45d24b85ea1d10df27df5aaa0c959)
For legacy reasons this function used to have convert item to
search_string via the search_object hash, because we used to
have an overly convoluted data model. The mid-July-2013
refactoring on search.js made the data model simple, and this
little bit of cleanup follows up on that.
(imported from commit aeea629862e4307897f24eaa5fc364f2b12a7c52)
In a few cases the $.each was doing something imperatively that was
terser and easier to understand by using a different Underscore method,
so a few of these I rewrote.
Some code was using the fact that jQuery sets `this` in the callback to
be the item; I rewrote those to use an explicit parameter.
Some code was using $(some selector).each(callback). I converted these
to _.each($(some selector), callback).
One function, ui.process_condensing, was written to be a jQuery $.each
callback despite being in a totally different module from code using it.
I noticed this and updated the function's args.
(imported from commit bf5922a35f257c168cc09ec1d077415d6ef19a03)
The option caused some race conditions on Firefox, and it is
really made moot by the naturalSearch option anyway.
(imported from commit dc7080c905ced9b2f4ad4275d82549acf09a59f7)