Commit Graph

6782 Commits

Author SHA1 Message Date
Yashashvi Dave ee8948c3e1 default stream: Limit private streams in default stream suggestions.
Admin users can't add private unsubscribed streams to the default
streams list.  Therefore, we shouldn't include private streams the
user is not subscribed to in the default stream suggestions.
2018-08-07 13:29:17 -07:00
Rohitt Vashishtha c41c82aae0 settings_emoji: Use display_name in handlebars.
This commit fixes two issues with the previous implementation:

1. JavaScript's replace replaces only the first instance,
   thus we need to use a regex.
2. Handlebars was setting the id of the HTML elements with
   spaces in between which broke the delete button; now a
   new variable display_name is passed to the template.

This also makes changes to the casper tests to have an emoji
name with multiple spaces in it to ensure this bug doesn't
appear again.
2018-08-07 10:22:08 -07:00
Marco Burstein 9c1dd5cda5 compose: Deactivate the reply button when there are no messages.
When visiting a narrow like
https://chat.zulip.org/#narrow/stream/doesnotexist, grey-out the reply
button and add the title `There are no messages to reply to.`

Also, add to the tests for `narrow.js` with
`#left_bar_compose_reply_button_big`.

Fix #8547.
2018-08-07 10:19:45 -07:00
Marco Burstein 5a160c66b7 night-mode: Add styles for disabled buttons.
Also create the similar styles for the hovered state.
2018-08-07 10:19:44 -07:00
Yashashvi Dave 6a382f332e create stream: Fix announce_stream isn't disabled in create-private-stream.
Currently in create new stream form, announce_stream option isn't get
disabled for private stream with public history.
This commit fixes the above issue.
2018-08-07 10:15:22 -07:00
Priyank Patel 97d93ec8cb group pms: Fix unread count not on the same line of text.
Fixes #10199.
The issue was observed on Chrome v68 while it was not reproduced
on Chrome v64.
2018-08-05 16:04:07 -07:00
Joshua Pan 3a74df17de hash_util: Remove unnecessary parameter is_absolute_url.
is_absolute_url was always true. Removed the conditional also.
2018-08-04 17:56:02 -07:00
Steve Howell ecb3879d0c refactor: Break subs dependency in stream_data.
We move remove_deactivated_user_from_all_streams
into stream_events.js.  There were some minor changes
to rename variables and also to not rely on using
`stream_info`.
2018-08-04 14:06:19 -07:00
Abhilash Verma 1d2f8bed92 emoji: Show emoji names with spaces on front-end.
This commit also supports entering emoji names with spaces
replacing them with underscores before saving.

Fixes #10177.
2018-08-04 09:40:52 -07:00
Abhilash Verma 8826ea1eaf settings_emoji: Reduce size to 20px in custom emoji list. 2018-08-04 09:40:52 -07:00
Abhilash Verma fd9652a9d7 settings_emoji: Make strings more user-friendly. 2018-08-04 09:37:48 -07:00
Steve Howell c8898e1dc8 refactor: Move by_conversation_and_time_uri to hash_util.
This removes the 100% coverage on hash_util, but we are
pretty careful about not messing with this code.
2018-08-04 09:32:27 -07:00
Steve Howell ffca07ffdd refactor: Move by_sender_uri to hash_util. 2018-08-04 09:32:27 -07:00
Steve Howell a866f3ec17 refactor: Move huddle_with_uri to hash_util. 2018-08-04 09:32:27 -07:00
Steve Howell fc62e554ce refactor: Move pm_with_uri to hash_util. 2018-08-04 09:32:27 -07:00
Steve Howell 9accc2a3b6 refactor: Move operators_to_hash to hash_utils.
This breaks some unnecessary dependencies on
hashchange.js, in favor of hash_util, which
has fewer dependencies.
2018-08-04 09:32:27 -07:00
Steve Howell ab26e27fef Move stream-related uri helpers to hash_util.
This allows several modules to no longer need
to import `narrow` (or, in our current pre-import
world, to not have to use that global).

The broken dependencies are reflected in the node
tests, which should now run slightly faster.
2018-08-04 09:32:27 -07:00
Steve Howell a4c2971b1e Remove unused uri helpers. 2018-08-04 09:32:27 -07:00
Shubham Dhama db4ee05653 stream_data: Add helper function to get default streams. 2018-08-04 09:27:16 -07:00
Shubham Dhama 14855097c6 input_pill: Add documentation link. 2018-08-04 09:27:16 -07:00
Steve Howell ab22b4411f refactor: Move list of frequent emojis to emoji.js.
All of our data related to emojis is in emoji.js.
Now typeahead_helper no longer depends on emoji_picker.

Generally we want typeahead_helper to only depend
on data modules to avoid complicated circular
dependencies (or at least mitigate them).
2018-08-04 07:59:42 -07:00
Steve Howell f4a8ff415c minor: Fix comments for frequently used emojis.
I think it's a known problem that we don't match
on common aliases for our top N emojis, but I don't
attempt to address that here.  I just made the
comments reflect the names we use in our
current data structures.
2018-08-04 07:59:42 -07:00
Steve Howell 95490e98c9 Break emoji_picker dependency inside util.js.
We don't need util.js to be depending on emoji_picker.js.

The function emoji_prefix_sort is only used
in typeahead_helper, so I just moved the implemenation
to there.
2018-08-04 07:59:42 -07:00
Steve Howell c7ab3884c6 refactor: Extract reload_state module.
This is part of work to break some of our
nastier circular dependencies in preparation
for our es6 migration.

This commit should facilitate loading leaf-like
modules such as people.js before all of the things
that reload.js depends on.
2018-08-04 13:55:02 +00:00
Steve Howell a7d7f6cada settings: Make unsubscribed streams less sticky.
When you unsubscribe a stream by clicking on the
checkmark, we don't want it to disappear right
away, but we also don't need it to stay around
once you start searching for new streams.

Note from Tim: This commit removes some complex code that was just a
workaround for the fact that this widget used to automatically
re-filter immediately after clicking to unsubscribe a user.

Since we've since fixed that original issue, we don't need this.
2018-08-03 16:01:02 -07:00
Steve Howell 04ac832183 Change ui check to ui_report in blueslip.
This was an oversight from an old refactoring.
2018-08-03 15:59:10 -07:00
Akash Nimare edf23cd743 desktop: Update desktop app to v2.3.5. 2018-08-03 10:19:33 -07:00
Tim Abbott b658462a43 locale: Update translations data from transifex.
This includes adding several new languages that now have significant
translations.

Fixes #10165.
2018-08-03 09:49:01 -07:00
Yashashvi Dave aa14d24618 settings: Fix color of icons in custom profile settings. 2018-08-02 17:27:28 -07:00
Tim Abbott 97711ce083 settings: Remove useless duplicated margin-top.
We only needed this margin for the "filter settings" CSS, and it
doesn't take effect anyway due to CSS precedence.
2018-08-02 17:26:56 -07:00
Tim Abbott 0984d876ed settings: Fix styling for admin_filters_table.
Apparently, the 20px top margin was being overriden because it wasn't
deeply layered enough.
2018-08-02 17:24:38 -07:00
Steve Howell 1c2ddb00d1 buddy list: Add padding to progressive scrollings.
We add a padded div to our container for the buddy
list to give scrolling the illusion that we've
rendered every list item, while still letting
the browser do the heavy lifting instead of trying
to fake it out too much.
2018-08-02 16:59:27 -07:00
Tim Abbott 786501f707 buddy list: Shrink #user_presences to 95% width.
This fixes annoying problems where the scrollbar at the right of the
buddy list looks bad where it overlaps the buddy list.
2018-08-02 16:57:25 -07:00
Steve Howell 94884a4418 buddy list: Introduce buddy_list_wrapper div.
This new div allows us to split out two concerns:

    semantic list of items - remains in #user_presences
    widget real estate - controlled by new #buddy_list_wrapper

We will use this for progressive rendering.  We want to add
padding to the buddy list without messing with the integrity
of the actual HTML '<ul>' list.  (One ugly alternative would
have been to add a dummy list item, which be a pitfall for
any code traversing the list.)

Basically, all the code relating to click handlers and similar
things was left alone.  We only change js/css related to
scrolling, resizing, and overflow.
2018-08-02 16:56:50 -07:00
Steve Howell 1a84af1e79 buddy list: Add v1 progresive scrolling.
This version of progressive scrolling lazily
renders buddy list items, but it doesn't
provide the browser with any notion of upcoming
list items, so as you scroll down and the size
of the rendered list grows, the scrollbar shows
you being too close to the bottom.

This maintains 100% coverage on buddy_list.js.
2018-08-02 16:56:50 -07:00
Steve Howell 407b13af25 list_cursor: Replace container with scroll_container_sel.
Our lists tend to have both containers and scroll_containers,
and we care more about the latter to the extent they're
different.
2018-08-02 16:56:50 -07:00
Shubham Dhama 4a53560106 settings_users: Change users "Make admin" button to dropdown.
This is done taking "Guest user" into account as we're soon
gonna support that.
2018-08-02 15:55:50 -07:00
Shubham Dhama 338acb1008 settings_users: Change class name for "Save changes" button. 2018-08-02 15:55:50 -07:00
Shubham Dhama 7776fa0d05 settings_user: Move "Make admin" button to user-info-form modal. 2018-08-02 15:55:50 -07:00
Shubham Dhama 4206314184 settings_users: Update admin_icon with admin change event. 2018-08-02 15:55:50 -07:00
Shubham Dhama 6d699ff59c settings_user: Add icon for admin users. 2018-08-02 15:55:50 -07:00
Sampriti Panda bcab6748ff subs: Remove default selected tab in subscriptions modal.
Earlier, on opening the subs modal, the "Subscribed" tab would be selected
by default when the components.toggle was created for tab switching.
This would change the hash to `#streams/subscribed`, and then extra work had
to be done to change it back to `#streams/all` leading to a longer open times.

With this change, `#streams` and `#streams/subscribed` both take you to
the "Subscribed Tab", and `#streams/all` takes you directly to
the "All Streams" tab.
2018-08-02 10:20:01 -07:00
Cynthia Lin 0f34e2fe3c subs: Fix broken streams list header/search container in Safari.
Fixes #10064.
2018-08-02 09:55:32 -07:00
Tim Abbott 9779117e3c message_flags: Add a comment to explain the update_starred flag. 2018-08-01 11:11:32 -07:00
Tim Abbott 4b4d420a5f message_flags: Clarify name for toggle_starred_and_update_server.
This makes it clear that the function sends the update to the server,
not just toggling the UI or local data structures.
2018-08-01 11:09:12 -07:00
Joshua Pan 2fcc54ac14 ui: Rename update_starred to update_starred_view. 2018-08-01 11:07:44 -07:00
Roman Godov 5e70577f84 models: Rename Realm.show_digest_email field.
This renames Realm.show_digest_email field to
digest_emails_enabled, for greater clarity as to what it does
just from seeing the setting name, without having to look it up.

Fixes part of #10042.
2018-08-01 11:05:58 -07:00
Shubham Dhama 5fafddaef5 settings_user: Use `person` as an argument in open_user_info_form_modal. 2018-08-01 10:39:03 -07:00
Sampriti Panda d917901ca3 subs: Fix bug with narrow_to_row callback in subs modal.
We set the keep=false for the narrow_to_row callack so that it is deleted
once the subs modal is opened. Previously, this callback would cause issues
when you then tried to open the All Streams Settings as it would narrow to
the stream row.
2018-08-01 10:14:09 -07:00
Cynthia Lin 9efe907ef1 night_mode: Use nested selectors to change night mode element styling.
This is a SASS-exclusive feature that simplifies a majority of the night
mode selectors.
2018-07-31 17:41:27 -07:00
Cynthia Lin 0314d63e7a night_mode: Improve legacy searchbox styling to fit night mode. 2018-07-31 17:41:27 -07:00
Cynthia Lin ae48010158 night_mode: Improve pill searchbox styling to fit night mode. 2018-07-31 17:41:27 -07:00
Tim Abbott 0044866682 events: Fix starring logic correctly.
In 47aaa73f96, we fixed one issue, which
is that server_events_dispatch.js was calling `update_starred` with
the wrong arguments, but created a new one (toggle_starred wasn't
updated) and missed another (which is that we weren't ever updating
message.starred, and thus if you toggle a message's star-state in one
browser, and then tried to toggle it back in a second, it would feel
like the click didn't work, because it was trying to toggle
e.g. off->on a second time).
2018-07-31 17:38:24 -07:00
Cynthia Lin cdbb38096a night_mode: Fix broken background color for user profile. 2018-07-31 17:06:11 -07:00
Joshua Pan 47aaa73f96 events: Fix buggy update starred event.
Fixes #10111.
2018-07-31 14:47:36 -07:00
Akash Nimare cc6af84a08 portico: Redesign download button on apps page.
This PR updates the styling of download button so
that it matches with the other buttons on portico pages.

Partially fixes #10104.
2018-07-31 14:18:28 -07:00
Shubham Padia 3e6eb360c4 stream edit: Remove bottom margin from `sub_settings_title`. 2018-07-31 11:12:09 -07:00
Shubham Padia 7d6ee2e10a stream_edit: Display server error message when subscribing other users. 2018-07-31 11:12:09 -07:00
Tim Abbott d377ac5768 people: Fix blueslip errors for late-added users.
This was supposed to be suppressed when a reload is in progress,
however, the logic was accidentally checking that
reload.is_in_progress was a defined function, not whether a reload was
actually in progress.
2018-07-31 10:41:33 -07:00
Tim Abbott f71316edd0 presence: Suppress some unnecessary blueslip errors for presence.
There was previously a race condition where reload.is_in_progress was
set after `activity.js` sent the presence request to the server, but
before we process the response; in that race condition, we still
shouldn't send blueslip errors to the server.
2018-07-31 10:40:34 -07:00
Akash Nimare 57ed871800 pill: Fix broken width of input-pill.
This PR fixes a UI bug which was caused by removing
the width of pill-container.

This issue was only visible in night mode.
2018-07-31 09:45:12 -07:00
Roman Godov c0806917ec models: Rename Realm.restricted_to_domain field.
This renames Realm.restricted_to_domain field to
emails_restricted_to_domains, for greater clarity as to what it does
just from seeing the setting name, without having to look it up.

Fixes part of #10042.
2018-07-31 09:28:33 -07:00
Cynthia Lin 29442ffb93 zcommand: Add light/dark mode command aliases for day/night mode.
Fixes #10095.
2018-07-31 07:12:31 -04:00
Shubham Padia 28589c5563 search pills: Backspace should remove a search pill with typeahead open.
Fixes part of #10026.

Typeaheads stopped propogation of keydown and keyup events for any
key except tab and enter. If stopAdvance was true even tab and enter
were not allowed.

advanceKeyCodes option was added to typeahead which allowed to specify
key codes for which propogation of keydown and keyup events should not
stop. advanceKeyCodes does not respect the stopAdvance option.
As the backspace key code is added to advanceKeyCodes in search.js,
the backspace key deletes pill on pressing backspace if input is empty
or only consists of spaces.
2018-07-30 14:33:06 -07:00
Shubham Dhama 4186ebe56a settings_user: Don't render bot_owner_select for user list.
This optimize the case when the user-info-form modal is opened
in user-list by not rendering bot_owner_select handlebar.
This bug is before changing form to modal.
2018-07-30 13:48:36 -07:00
Shubham Dhama 8f115c8291 settings_user: Refactor `open-user-form` click handler. 2018-07-30 13:48:36 -07:00
Shubham Dhama 5506f74084 settings_user: Remove redundant verbose check of owner value. 2018-07-30 13:48:36 -07:00
Shubham Dhama e08daf9a00 settings_user: Add modal for user info and roles form.
Advantages of changing it to modal is that now it doesn't render
form for every row i.e. form is rendered only for row edit button
is clicked.
2018-07-30 13:48:36 -07:00
Shubham Dhama 2b738d02c3 org settings: Refactor modal "partials" to a seperate file. 2018-07-30 13:48:36 -07:00
Shubham Dhama 2bcd21aeca org settings: Use people.get_active_human_persons to get active humans. 2018-07-30 13:48:36 -07:00
Shubham Dhama 16357fc84a people: Add common function for getting active human users. 2018-07-30 13:48:36 -07:00
Aditya Bansal 5b5d8bb310 thumbnails: Rename data-original to data-src-fullsize. 2018-07-30 13:00:23 -07:00
Harshit Bansal 8aabce5a5f hotkeys: Use canonical name for reacting with `+` hotkey.
This is sort of a temporary fix to bring the state back to how it
was in commit: ef4337edcb. However,
long-term we will need to fix our local echo feature to do merging
of names just like we do on backend.
2018-07-30 12:18:33 -07:00
Steve Howell 6a4bacbd18 stream settings: Avoid redundant sorting step.
We don't need to get our original items in sorted
order, especially since we re-sort them using
a different comparison function.
2018-07-30 11:25:32 -07:00
Steve Howell 51edcb02c8 Streamline typeahead for stream links.
We don't need to get sorted streams in the "source"
function for typeahead, since we sort them later,
and we don't need to recalculate values.

This preserves the behavior that we include
unsubscribed streams in the typeahead, which is
probably intentional.
2018-07-30 11:25:32 -07:00
Steve Howell 5c4d44bf3d refactor: Extract subs.get_stream_id_buckets().
This pulls the essential bucketing/sorting logic out
of filter_table().

The diff isn't quite as clean as I'd like, but some
of the code that got added back to filter_table() can be
eliminated in the future.  Basically, all the stuff
related to hidden ids can just be zapped if we go
to an approach of just re-building the DOM cleanly
whenever our filters change.
2018-07-30 11:25:32 -07:00
Steve Howell 68dba4515d refactor: Use triage_stream() to filter streams.
We replace two calls to stream_matches_query() with
a single call to triage_stream(), which prevents us
from doing the same is-subscribed checks twice.
2018-07-30 11:25:32 -07:00
Steve Howell 95edf68fd0 Refactor stream_matches_query to early-exit.
For the non-subscribed case, checking flags is a quick
way to reject streams vs. the more expensive indexOf
checks.
2018-07-30 11:25:32 -07:00
Steve Howell 95d136ca5e Extract search_util.js module.
We probably should have done this a while ago, even
though these functions are pretty tiny.  The goal here
is to make it easier to have more consistent search
semantics.

Our first use case is subs.js.  In this case we
are able to decouple a bit of generic string
matching from the subs-specific code.
2018-07-30 11:25:32 -07:00
Steve Howell 064d0f3c89 Extract stream_data.sort_for_stream_settings().
We move some data code from subs.js to stream_data.js.

It's not clear we have been using the optimal sort for
dealing with locales, but this change preserves the
current behavior.  The only subtle change here is that
we look up subs using a Dict now instead of a plain
JS object.
2018-07-30 11:25:32 -07:00
Steve Howell 5641c77c94 refactor: Introduce other_stream_ids in filter_table().
We now build up three buckets of stream ids for slightly
more consistent code that will help in future refactorings.
2018-07-30 11:25:32 -07:00
Lyla Fischer ba791b7071 user docs: Remove add-a-link-preview since it is a server admin doc. 2018-07-29 20:32:46 -04:00
Lyla Fischer 9f80322a35 user docs: Update custom-linkification doc. 2018-07-29 20:32:46 -04:00
Lyla Fischer c6938a42d6 user docs: Update add-custom-emoji. 2018-07-29 20:32:46 -04:00
Tim Abbott aa8533a5f7 locale: Update transation data from transifex and repo. 2018-07-27 12:26:10 -07:00
Steve Howell 441a21fac8 Use jQuery objects in MessageListView._rows.
The values of this dictionary used to be raw DOM elements,
but get_row() wraps them again, so there's not a huge
reason to store them as raw DOM elements internally.  It
is slightly easier to reason about the code if everything
stays at the jQuery level.

To preserve the old behavior here, we have to do something
that is kind of ugly, but at least it's explicit now.  In
the old code, our cache was DOM elements, and if an id
wasn't in the cache, we would sneakily return $(undefined)
with this code in get_row():

    return $(this._rows[id]);

And it turns out that $(undefined) is basically just a
zero-element jQuery object.  A lot of our code depends
on this behavior and just works around the zero-element
objects as needed with checks like this:

    if (this.selected_row()).length === 0) {
        // don't try to get offset
    }

For now we just preserve this behavior.  We could eventually
be more strict here, or at least have aggressive warnings
on cache misses, but we'd need to retrofit code to be
able to call something like `has_rendered_selection()`
and/or deal with `undefined` as the return value for the case
where the selection hasn't been rendered.

Here is some example code that would cause tracebacks if
we just returned `undefined` for cache misses:

    rerender_preserving_scrolltop: function () {
        // old_offset is the number of pixels between the top of the
        // viewable window and the selected message
        var old_offset;
        var selected_row = this.selected_row();
        var selected_in_view = selected_row.length > 0;
        if (selected_in_view) {
            old_offset = selected_row.offset().top;
        }
        return this.rerender_with_target_scrolltop(selected_row,
            old_offset);
    },
2018-07-27 11:14:53 -07:00
Steve Howell 69b42a7440 refactor: Extract MessageListView._fix_single_row().
This function is more cohesive and always takes in
a jQuery object containing exactly one DOM element,
and it does all stuff at the jQuery level of
abstraction (no raw DOM).

It's a pretty simple extraction--removing the level
of indentation makes the diff a bit noisy.
2018-07-27 11:14:27 -07:00
Steve Howell 6b2c291b4e refactor: Extract MessageListView._put_row().
Saving row data in `_rows` is a very data-specific task,
unlike the rest of `_post_process`, plus extracting it
will help with unit testing.
2018-07-27 11:10:50 -07:00
Steve Howell 3d853f9bf4 refactor: Pass in jQuery objects to _post_process.
We shorten the name of the function and avoid having
all the callers call `.get()`.  Now we mostly stay
in jQuery "space", which avoids some confusion about
when we're dealing with raw DOM elements and which
will facilitate unit testing.
2018-07-27 11:10:49 -07:00
Shubham Padia 5bf6e55778 search pills: Fix visual bugs due to CSS refactoring of input pills.
Changed search pill padding, `.navbar-search` flex-wrap to match with
the CSS refactoring in 66df4e3e84.
The `height: 100%` changes to `.navbar-search` and `.input-append`
make up for the issue in which the pills overflowed in the mobile
view due to `.navbar-search` height being declared 40px explicitly
while the actual heiight in mobile view was shorter.
2018-07-27 10:54:09 -07:00
Yashashvi Dave 00f9772ccc stream list: Scroll to opened stream on zoom out from stream-more-topics.
Currently on zoom out from stream topics, scrollbar didn't scroll back
to opened stream. Because call to scroll-to-stream func isn't called
after all streams view is displayed. So wrong stream element is
passed to func.

Fix this by calling scroll-to-stream func after all-stream-list view
is displayed.
2018-07-27 09:09:53 -07:00
Cynthia Lin e9cf545ada scroll_util: Account for element padding in height calculations. 2018-07-27 09:09:52 -07:00
Cynthia Lin ee82f14d04 subs: Use scroll_util to move selected stream rows into view.
This eliminates a bunch of complex logic we previously used when
trying to make keyboard stream row navigation smoother.
2018-07-27 09:08:49 -07:00
Aditya Bansal 5190f4c51a stylesheets: Fix coding style to comply with stylistic rules. 2018-07-27 00:15:58 -07:00
Aditya Bansal 5bca93d147 hotspots.scss: Fix styling to conform to stylistic rules. 2018-07-27 00:15:58 -07:00
Aditya Bansal 4cbe827581 portico.scss: Fix styling to conform to stylistic rules. 2018-07-27 00:15:58 -07:00
Aditya Bansal 92e29db3f5 landing-page.scss: Fix styling to conform to stylistic rules. 2018-07-27 00:15:58 -07:00
Cynthia Lin 2fe4056b3c composebox_typeahead: Add user groups to PM recipient typeahead.
When a user group is selected, we add PM pills for each user in the
group instead of creating a PM pill for the user group.

Fixes #9971.
2018-07-26 11:21:11 -07:00
Cynthia Lin 0198e2b2b1 typeahead: Add new functions for differentiating user groups and people.
We use these new functions in the message compose typeahead so that they
can also be used in a PM recipients typeahead with both people and user
groups.
2018-07-26 11:21:11 -07:00
Steve Howell 8aa3eebe70 refactor: Render Stream Settings in two steps.
We now render the "skin" part of "Stream Settings" before
adding in the actual streams.  The new function
populate_stream_settings_left_panel() takes care of adding
the streams.  It uses a new template called
`subscriptions.handlebars`.

Splitting out this function will give us more flexibility
for various improvements.

First, we can decide to render the list after we open the
overlay, just to avoid the problem that users don't know why
the modal's opening.  (And we could add a loader spinner as
needed.)

Second, we can improve our filter features so that we do
filtering in the data instead of moving DOM rows around,
which is expensive.

Third, we can eventually introduce progressive rendering.

Finally, having the function broken out will make profiling
more precise about where bottlenecks exist.
2018-07-26 11:20:46 -07:00
Shubham Padia 6162ea1075 pills: Add `flex-wrap: wrap` to pill container for all pills.
Fixes #10059.
In 66df4e3e84,
`display: inline-flex` was added to `.pill-container` but
`flex-wrap: wrap` was missing which forced overflow pills to be on
one line and made the pill text overflow vertically. This was not
observed in composebox pills as `.pm_recipient .pill-container`
already had a `flex-wrap: wrap` rule which has been removed in this
commit to avoid duplication.
2018-07-25 16:35:00 -07:00
Steve Howell 5cdce82f7c refactor: Add compare_function to buddy_list.
We were passing this in before, but having it as
a data member reinforces the idea that we'll want
this to be a first-class concept in the list, since
we depend on ordering for various things.
2018-07-25 15:53:27 -07:00
Steve Howell 45ab5a2f61 refactor: Simplify navigation code for buddy list.
We can now take advantage of self.keys to return
first_key, prev_key, and next_key.
2018-07-25 15:53:27 -07:00
Steve Howell d69b3a3c71 refactor: Track user_ids in buddy_list.js.
We now keep track of keys in buddy_list.js, so that
when we insert/remove items, we no longer need to
traverse all the DOM.  Instead, we just find out
which position in the list we need to insert the
key in (where "key" is "user_id") and then find
the relevant DOM node directly and insert the new
HTML before that node.  (And of course we still
account for the "append" case.)

There's a little more bookkeeping to make this
happen, but it should help reduce some code in
upcoming commits and pave the way toward
progressive rendering optimizations.

This commit should produce a minor speedup
for activity-related events that go through
buddy_list.insert_or_move(), since we are
not traversing the DOM to find insertion points
any more.
2018-07-25 15:53:27 -07:00
Steve Howell 18c3cb8f7e refactor: Extract buddy_data.get_items_for_users().
This will be useful for lazy rendering, where our
buddy_list widget already knows the keys (aka "userids")
it wants to render as you start scrolling them into
view.
2018-07-25 15:53:27 -07:00
Aditya Bansal fa3a337f37 stylelint: Fix css stylistic violations in various scss stylesheets. 2018-07-25 14:58:25 -07:00
Aditya Bansal be77e600ee stylelint: Fix landing-page.scss to comply with stylelist rules. 2018-07-25 14:58:25 -07:00
Shubham Padia 56644d149a typeahead: Replace `no-break space (U+00A0)` in query with `space (U+0020)`.
Typing "tim " did not did not produce any match when suggesting person
in composebox typeahead or user group typeahead as the space at the
end of the "tim " string passed by the browser was a
`no break-space (U+00A0)`  instead of `space (U+0020)`.

Although there are unicode characters other than `no break-space` which
represent spaces, only U+00A0 is replaced as it was the only space
character encountered when testing this issue manually.

Fixes #10039.
2018-07-25 14:55:11 -07:00
Rishi Gupta 1bbe87cf82 portico: Add links to import from slack and gitter to /new. 2018-07-25 08:49:27 -07:00
Shubham Padia 22c5a73ccb search: Add #searchbox_legacy selector to #searchbox rules in media.scss.
This is a fixup for e1291cf839.
While copying the the rules of `#searchbox` to `#searchbox_legacy`
in the search pills feature, the existing `#searchbox` rules were
missed in the conversion.
`#searchbox_legacy` has been added beside `#searchbox` in `media.scss`
instead of replacing that as both of them need those rules for the
mobile view.
2018-07-25 08:47:58 -07:00
Lyla Fischer d50faa4d81 user docs: Add reference to support email in docs footer. 2018-07-24 11:10:23 -07:00
Cynthia Lin 9593a8a7f5 help: Exclude anchor link hash to highlight main article in sidebar.
Currently, if you access an article link with an anchor link that isn't
featured in the sidebar, the main article won't be highlighted. Thus, we
exclude the anchor link hash from the article-searching selector if
the full article pathname wasn't found.
2018-07-24 09:01:42 -07:00
Vishnu Ks 82fc82b7e2 billing: Sign and verify the seat count during upgrade. 2018-07-24 08:04:00 -07:00
Cynthia Lin eaeec30590 help: Fix broken anchor link handling in documentation.
Fixes #10022.
2018-07-23 23:18:33 -07:00
Marco Burstein 7daf7c1498 portico: Slightly shrink the Core Team profiles' width.
Shrinking the widths enables all five core team profiles to be aligned
on the same line, instead of having four on the first line and one
profile on its own line.

Fix #10008.
2018-07-23 22:43:07 -07:00
Marco Burstein bb09bea0b6 ui: Simplify hotkey deprecation notices.
To reduce code duplication when creating hotkey deprecation notices,
create the `get_hotkey_deprecation_notice` function. Also, create a
`ui` testing file with a test for the new function.

Fix #10004.
2018-07-23 22:41:59 -07:00
Steve Howell 520e85b866 Use topic_data.js for topic typeaheads.
This replaces some old code with calls to topic_data.js.

Now our topic typeahead uses the same data as our
sidebar, stream suggestions, and the "n" key, so any
future improvements to that data will benefit all
features the same.

This is an important piece of #9857.
2018-07-23 16:08:24 -07:00
Joshua Pan 6890b98dec settings: Use delivery_email for user settings. 2018-07-23 15:38:41 -07:00
Harshit Bansal fbdc21a161 typeahead: Extract `query_matches_string()`. 2018-07-23 12:35:08 -07:00
Harshit Bansal a906d564a3 emoji: Rename `css_class` to `emoji_code` in emoji.js.
Now that `emoji_collection` and `emojis_by_name` are global
datasources in the webapp we need to rename things carefully
to reflect their actual meaning. The fact that emoji code is
used as a css class for unicode emoji is one thing but it is
not its sole use so renaming it seems a good idea.
2018-07-23 12:35:08 -07:00
Harshit Bansal 88bc78645d emoji: Move `emoji_collection` from emoji picker to emoji.js.
This commit moves the `emoji_collection` datasource in the emoji
picker to emoji.js and renames it to `emojis_by_name`. It is a
mapping from emoji name to object where each object describes an
emoji. This is an effort in the direction of de-duplicating and
unifying the datasets being used by various our widgets(like
emoji picker and composebox typeahead) in the webapp. Migrating
all the widgets to a single datasource will help us in removing
the whole class of annoying bugs which causes some emojis to be
missing from some widgets.
2018-07-23 12:35:08 -07:00
Harshit Bansal c0b0fb7cce emoji: Move `EMOTICON_CONVERSIONS` mapping to build_emoji infra.
This commit closes a long pending issue which involved moving the
`EMOTICON_CONVERSION` mapping to build_emoji infrastructure so
that there is only one source of truth. This was pending from the
time when this feature was implemented.
2018-07-23 12:35:08 -07:00
Shubham Padia ef2f6b7e47 hotkey: Blur search pill or searchbox contenteditable div on `Esc` key.
Pressing `Esc` did not blur a contenteditable div by default, while
an input field was blurred by default. Due to this when a user tried
to unnarrow using `Esc` key when the searchbox had focus, the focus
remained stuck in the div itself and no further action was taken.
2018-07-23 11:37:10 -07:00
Shubham Padia 9b1dc48ebd keyboard-shortcuts: Focus instead of select on `/` if search pills enabled.
If search pills are not enabled, the text present in the search bar
will be selected on pressing '/' and writing someting without deselecting
the text will clear the search text. Since selecting the pills would
not make sense in this context, the search box is focused instead.
2018-07-23 11:29:10 -07:00
Shubham Padia 22b2393cae pills: Use `widget` instead of `my_pill` throughout the app.
`compose_pm_pill.my_pill`, `search_pill_widget.my_pill` and any of
its occurrences throughout the app have been replaced to use `widget`
instead.
2018-07-23 11:29:10 -07:00
Shubham Padia 1f553a41d0 search: Higlight `#searchbox` on focus.
Adds box-shadow to `#searchbox` when either `#search_query` or any
of the pills have focus. Uses jquery instead of pure css as the
`:focus` event occurs on `#search_query`, while we want to add
box-shadow to `#searchbox`. This could have been done with
`:focus-within` CSS selector, but it is not supported in IE or Opera.

`#search_query` already had an onfocus/focusout listener, adding
listeners to `#searchbox.pills` for those events wouldn't have worked
as you don't want the focusout event to fire when the focus shifts
from input to pill.

Also adds `focusin`, `focusout` and `css()` to zjquery. `css` is
same as `val`, except it returns an empty object in case of no value
instead of an empty string. I don't think `css()` is valid syntax
in actual jquery.
2018-07-23 11:29:10 -07:00
Shubham Padia 73e4f3b3fa search: Do not display `All messages` suggestion if bar not empty.
Previously `All messages` was displayed irrespective of the existing
pills. Now the suggestion is displayed only if no pills are present
2018-07-23 11:29:10 -07:00
Shubham Padia 8b153f6452 search: Validate suggestion against existing operators.
After adding search pills, suggestions were based only on the
current input and no validation against the existing pills was done.
operator_subset_suggestions have been removed. Default suggestions
for base_operators have also been removed.
Handle multiple operators:
if `is:starred stream:Ver` was typed without selecting the typeahead
or pressing enter in between i.e search pill for is:starred has not yet
been added, then the description of `is:starred` will act as a prefix
in every suggestion.
Also makes changes re-enabling person suggestions for names with spaces.
2018-07-23 11:29:10 -07:00
Tim Abbott db4f6e278f search: Duplicate get_default_suggestion.
This lets us modify the implementation of this function for the search
pills implementation only.
2018-07-23 11:29:10 -07:00
Tim Abbott 5b0e9b7fe6 search: Duplicate search_suggestions.get_suggestions.
This large function will need to be modified significantly as part of
the pills effort, and copying it lets us preserve behavior in
production until we're ready to cut things over.
2018-07-23 11:29:10 -07:00
Shubham Padia 069a4f1626 search: Disable tab_bar due to addition of search pills.
tab_bar.js becomes redundant after implementation of search pills.
This commit adds a comment to tab_bar.initiliaze, so the event
listeners related to it do not get initiated. This does not remove
any code related to tab_bar.js.
Also adds left and right border around the search icon.
2018-07-23 11:29:10 -07:00
Shubham Padia 36707a33ca search: Add a basic implementation of search pills.
Following points have been implemented in this commit:
1.) Add search pill on selecting typeahead.
2.) Re-narrow after removing a search pill.
3.) Add quiet optional parameter to removeLastPill.
4.) Pre populate search pills in narrow.activate.
5.) Clear existing search pills on narrow.deactivate.

Description of above points:
1.) I tried out using the description from suggestions.lookup_table
to append a pill using appendValidatedData so that the description
had not to be calculated again. But the description in the suggestions
lookup contains html due to highlighting. This html is escaped when
inputed in a pill. An attempt was also made to remove the higlighting
by replacing the tags. But other espaced characters like &lt; also
popped up, so it was better to use append_search_string.
3.) If one wants to refresh the pill using pill.clear and wants to
repopulate them, evaluating the event_handler associated with the
action of removing the pill may not be desired.
4.) Pill population code is added to narrow.activate. Pills are not
populated if the narrow was triggered by search as search handles the
addition and removal of pill by itself. The reason for not handling
search too in narrow.activate is to avoid clearing the pills and
repopulating them. Example of some of the triggers for narrow.activate
include `restore draft`, `topic change`,`sidebar`.

Also modifies tests for search.js
2018-07-23 11:29:10 -07:00
Shubham Padia 6ff13d0d01 pills: Allow removing pill without calling the remove event handler.
Adds an optional parameter `quiet` to removeLastPill and removeAllPills.
If `quiet` is a truthy value, the event handler associated with the
pill will not be evaluated. This is useful when using clear to reset
the pills.
2018-07-23 11:29:10 -07:00
Shubham Padia 5212026620 search: Change letter-spacing to normal for search box.
The letter-spacing was changed last in commit
fc4d80d941 which is about a 5 year old
commit at the point of writing. The change is removed as I did not
notice any visual change on removing it. Changing the letter spacing to
normal lets the text in the pills be seen legibly, otherwise the characters
were overlapping.
2018-07-23 11:29:10 -07:00
Shubham Padia 4c575985c1 search: Initialize search pill widget in ui_init.js.
Adds the initialize function to search_pill_widget.js for initializing
a pill object on search query box.
2018-07-23 11:29:10 -07:00
Shubham Padia e228687094 search: Make search query a contenteditable div for search pill.
Input pills require a contenteditable div with a class named input
to fall inside the pill container. On converting the input tag into
a div, the size of the input decreases which is compensated by a
line-height of 40px. Comment above letter-spacing:normal was removed
as chrome and firefox do not change the letter-spacing to normal
for a div via the default browser stylesheet.

NOTE: Currently writing something into the div will call the action
corresponding to that key in the keyboard shortcuts. The input will
work fine once the pills have been initiated.

For the casper tests, for now, we just use the legacy search code.
When we change that, $.val() cannot be used on contenteditable div, so
$.html() will need to be used instead in select_item_via_typeahead.
2018-07-23 11:29:10 -07:00
Tim Abbott e1291cf839 search: Copy CSS to a separate #searchbox_legacy block.
This way, we can edit the CSS for the searchbox without having to
worry about changing the legacy behavior.
2018-07-23 11:29:10 -07:00
Tim Abbott 87427fb923 css: Put searchbox CSS into a single CSS block. 2018-07-23 11:29:10 -07:00
Tim Abbott 26cd7f931c css: Move message edit history CSS from middle of search CSS. 2018-07-23 11:29:10 -07:00
Shubham Padia 5e93922a7d search: Add search_pill_widget.js.
Also adds the file to the static asset pipeline.
search_pill_widget.js will be used to access the pills object for
the search query box. It will act in a similar way to
compose_pm_pill.js. Why is this needed: Consider you've initiated
a pills object in search.js for the search query box. Now you want to
also access that pills object to pre-populate pills after a reload in
hashchange.js. search_pill_widget.js makes this easy without the use
of events.
2018-07-23 11:29:10 -07:00
Sampriti Panda ffb29ddaf1 subs: Replace tr block with t in subs handlebars template.
The `tr` block does clones the `options` array (which contains the
entire subscriptions data set) very inefficiently, which leads to the
rendering being very slow.

We don't need a `tr` block here, as there is no dynamic content that
needs to be replaced.
2018-07-23 10:55:16 -07:00
Yashashvi Dave bbe326dd29 message edit: Add markdown shortcuts to message edit UI.
This makes the ctrl+B, ctrl+I, ctrl+shift+L shortcuts available when
doing message editing.

Fixes #9917.
2018-07-23 10:41:46 -07:00
Yashashvi Dave 987c4f7df3 static/js/compose.js: Clean `add_markdown` function.
Rename `add_markdown` function to `wrap_text_with_markdown` and
use closure variables in function `wrap_text_with_markdown`.
2018-07-23 10:38:18 -07:00
Marco Burstein 3ae5e40f8f lightbox: Make `v` close the lightbox during Pan & Zoom.
When Pan & Zoom (canvas) is enabled, the `v` hotkey does not work due to
`LightboxCanvas` overriding the `keydown` event. Add `v` as an option in
the new listener.

Fix #9777.
2018-07-23 10:36:48 -07:00
Cynthia Lin c3b1381c2a left sidebar: Make sure the selected stream is visible in left sidebar.
This triggers a scroll in the left sidebar after an initial narrow if
the target stream isn't visible.

Fixes #9043.
2018-07-23 10:32:10 -07:00
Cynthia Lin 66df4e3e84 input-pill: Refactor pills to eliminate fixed positioning of elements. 2018-07-23 10:21:13 -07:00
Cynthia Lin f081ee7120 help: Limit width of documentation content. 2018-07-23 10:10:02 -07:00
Cynthia Lin 55d5089156 help: Use simplebar instead of container to calculate hash scrolling. 2018-07-23 10:10:02 -07:00
Steve Howell 9608b82a36 refactor: Make vars local inside subs.filter_table().
There was no reason for these to be module variables.
2018-07-23 10:01:38 -07:00
Harshit Bansal bf70955c0c emoji: Update `emoji-datasource` packages.
This commit updates the `emoji-datasource` packages to version 4.0.4.
This update brings following changes to emoji infra:

1: Fix for the bleeding sprite sheets.

2: The category of some emojis has been changed. Categorywise breakup of
   net gain or loss is as follows:
    Travel & Places: 58 (gain)
    Symbols: 47 (loss)
    Smileys & People: 52 (gain)
    Objects: 11 (loss)
    Food & Drink: 3 (gain)
    Animals and Nature: 46 (gain)
    Activities: 9 (loss)

3: There were some changes in the image farm of the package which were
   breaking our old emoji farm. I fixed them by modifying the remapped
   emoji map.

Fixes: #8235.
2018-07-23 08:04:58 -07:00