Commit Graph

79 Commits

Author SHA1 Message Date
vinitS101 fe2ec995b6 message_view: Add js tooltip hovers for emoji reactions.
This removes HTML title hovers for emoji reaction buttons below messages
and replaces them with js tooltips.

Fixes #8679.
2019-07-19 12:45:44 -07:00
vinitS101 278ccc559b message_view: Add a js tooltip hover for reaction button.
This change removes the html title for the reaction button
and replaces it with a JS Tooltip with the same title text.
2019-07-19 12:45:44 -07:00
Anders Kaseorg db0b33842c templates: Replace templates.render with require calls.
This removes an unnecessary layer of indirection and allows webpack to
catch filename mistakes.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-07-12 21:11:14 -07:00
Anders Kaseorg 01613e71fb ui: Replace set_up_scrollbar with data-simplebar attribute.
With perfectScrollbar, we needed to call a function from JavaScript to
enable a scrollbar on a new element, but simplebar has a much simpler
default API one can do by using data-simplebar attributes in the HTML.

So we can delete all the scrollbar creation/deletion code.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-05-19 18:06:38 -07:00
Anders Kaseorg 141088586b Completely replace perfect-scrollbar with SimpleBar.
perfect-scrollbar replaces both the appearance and the behavior of the
scrollbar, and its emulated behavior will never feel native on most
platforms.  SimpleBar customizes the appearance while preserving the
native behavior.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2019-05-17 12:06:51 -07:00
Steve Howell b1f58fb1ff emoji picker: Prevent cropping.
We now use `fix_positions` to avoid cropping the emoji
picker.  You can see cropping pretty easily on a short
screen if you click the smiley icon for reactions on a
message.  It's a bit tricky to repro, since some
of the current top/bottom placements are correct, but
it's definitely reproducible.

I think there are opportunities to both simplify
and optimize `popovers.compute_placement`, so that it
plays nicer with `fix_positions`.  For example, I would
bias it even more strongly toward favoring right/left
placement.  But there are complicating factors--it is
also used by the hotspot code.

And I wanted to especially preserve the current
behavior when you launch the picker from the compose
box.  That's one place where it looks pretty bad if
you select "right" instead of "bottom".
2019-02-15 10:40:53 -08:00
Steve Howell a537f4a075 refactor: Clean up viewport_center hack. 2019-02-15 10:40:53 -08:00
Harshit Bansal d386706382 emoji: Fix traceback on opening emoji popover in quick succession.
Since the bootstrap popovers are destroyed asynchronously so opening a
emoji popover in quick succession like by clicking the reaction button
on another message was causing a race condition which was causing some
operations to be applied on a destroyed emoji popover.  This commit
fixes it by making sure to apply any operations only to the currently
active popover.

Fixes: #9851.
2019-02-14 11:29:25 -08:00
Abhinav Singh e6493ef0c8 emoji: Add support for using emoji picker in message edit.
This code will correctly render emoji to the message textarea based on
whether emoji was selected from message composition form or message
edit form.

Fixes part of #11188.
2019-01-15 12:00:02 -08:00
Steve Howell 82e453d9fe ui: Fix scrollbar regressions.
In between releases, the following commit introduced
a bug where we agressively scroll to the top every
place we call `ui.update_scrollbar`:

    092b73d0b7

The main symptoms were that the left and right sidebars
would go to the top for things like selecting a topic,
getting activity updates from the server, and resizing
the window.  It was very jarring.

The recent commit looked innocuous--the root of the problem
was the original API expressed an intent to scroll to the
top, but didn't actually do it, so it was a bug in hiding.

There are **some** occasions where it's actually appropriate
to scroll to the top, mostly around search filtering, and
in those places we now call the new `ui.reset_scrollbar`
function.

This is a bit of an emergency fix, so particularly with
the settings stuff, we may get more reports of glitches here.

The important thing here is that you almost never want to
reset the scrollTop for sidebars.
2019-01-09 09:15:45 -08:00
Tim Abbott bdb3da4504 eslint: Add key-spacing linter rule.
Apparently, we didn't have one of these, and thus had a moderate
number of generally very old violations in the codebase.  Fix this and
clear the ones that exist..
2018-12-18 10:41:06 -08:00
Aditya Bansal 7eeed1413c icons: Remove base class from comments and test templates. 2018-10-15 19:55:18 +05:30
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
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 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
Armaan Ahluwalia 6d255efe4c app: Prepare JS files for consumption by webpack.
This commit prepares the frontend code to be consumed by webpack.

It is a hack: In theory, modules should be declaring and importing the
modules they depend on and the globals they expose directly.

However, that requires significant per-module work, which we don't
really want to block moving our toolchain to webpack on.

So we expose the modules by setting window.varName = varName; as
needed in the js files.
2018-07-05 10:53:36 +02:00
Shubham Dhama 80a2d5bc59 eslint: Enable `conditionalAssign` config of no-trailing-spaces rule. 2018-06-11 07:51:24 -04:00
Shubham Dhama dcb6254a4e eslint: Enable `no-extra-parens` rule.
Following sub-configuration is disabled:
                "nestedBinaryExpressions": false,
2018-06-11 07:51:24 -04:00
Shubham Dhama cc03f9fb8f eslint: Enable space-infix-ops rule.
More about rule at  https://eslint.org/docs/rules/space-infix-ops
2018-06-05 00:47:35 +05:30
Tim Abbott 063d11b139 js: Standardize indentation of switch/case statements.
This gets my current draft eslint indentation configuration passing
cleaning on static/js.
2018-05-06 19:35:18 -07:00
Tim Abbott 7ab8a8e820 js: Fix a bunch of indentation issues found by eslint.
This is preparation for enabling an eslint indentation configuration.
90% of these changes are just fixes for indentation errors that have
snuck into the codebase over the years; the others are more
significant reformatting to make eslint happy (that are not otherwise
actually improvements).

The one area that we do not attempt to work on here is the
"switch/case" indentation.
2018-05-06 16:25:02 -07:00
Utkarsh Patil 59f5af6b62 emoji: Export popular emojis list.
Provisions to export popular emojis list.
2018-04-21 22:24:07 -07:00
Tim Abbott ab8fb23164 emoji: Clean up variable names for rendered template content. 2018-04-12 09:48:02 -07:00
gooca ba05ac5c77 Refactor perfect-scrollbar: Call ui methods in emoji_picker.js. 2018-03-16 12:47:44 -07:00
Harshit Bansal 31baf25783 emoji picker: Change the delimiter used in `emoji_id`.
We were using underscore as a delimiter in `emoji_id` in emoji picker
but since `emoji_type` also contains underscores, it seems wrong to
use underscore as a delimiter. This commit switches `emoji_id` to use
comma as a delimiter instead of underscore.
2018-02-21 12:48:27 -08:00
Steve Howell 12dc567a89 Move insert_syntax_and_focus() to compose_ui.js.
This change also removes a couple lines of test code that
weren't really testing anything.
2017-11-09 09:49:20 -08:00
Tim Abbott bb80c0cc24 compose_state: Extract insert_syntax_and_focus.
This moves the existing emoji picker code to a new library.
2017-10-30 17:12:56 -07:00
Brock Whittaker a6f5d3d93a emoji-picker: Do not change scroll on emoji hover.
Currently when hovering on an emoji it will focus it, which makes
the browser by default scroll down or up to include the entirity
of the focused element. This corects the scrollTop to what it was
before the focus event adjusted the scroll position.

This is a follow-up to #6869.
2017-10-05 15:51:06 -07:00
Tim Abbott bcbe41177a emoji_picker: Fix hover behavior to key off entire emoji.
Previously, you had to hover over the smaller area where the emoji
image was to select it, whereas the user expectation is that hovering
the emoji's padding should select it as well.
2017-10-05 09:11:03 -07:00
Harshit Bansal b8c58cc830 emoji_picker: Make the mouse hover and key navigation share same state.
This commit makes the arrow key navigation and mouse hover affect the
same state such that for example if one moves the mouse over some emoji
and then hits down-arrow the cursor will move down by one from where he
left the mouse at rather than beginning from the top-left corner.

Fixes: #6827.
2017-10-05 09:02:49 -07:00
Harshit Bansal 7546e3325f emoji_picker: Add `get_emoji_coordinates()` function.
Given the `emoji-id` of an emoji in emoji picker this function
returns its coordinates, i.e, section number and index.
2017-10-05 09:02:49 -07:00
Harshit Bansal da86cbdaf5 emoji_picker: Extract `get_emoji_id()`. 2017-10-05 09:02:49 -07:00
Harshit Bansal 48ac282667 hotkeys: Remap ':' to close the reactions popover in case of empty search.
Fixes: #6806.
2017-10-05 19:05:27 +05:30
Harshit Bansal bb38f98975 emoji_picker: Update emoji showcase on mouse hover. 2017-09-29 21:10:03 +00:00
Harshit Bansal 2873b886fb emoji_picker: Add emoji showcase.
Emoji showcase refers to the space at the bottom of the emoji
picker we use for showing name as well as aliases of the currently
focused emoji.

Fixes: #6110.
2017-09-29 21:09:00 +00:00
Harshit Bansal 4973d992d1 emoji_picker: Move the category tabs to just below the emoji filter.
Also removes the now unused `get_rendered_emoji_categories()` function.
2017-09-29 20:22:09 +00:00
Brock Whittaker be64c43cc5 emoji-popover: Add centered layout for mobile/responsive.
This adds a centered layout for mobile and responsive screens where the
emoji picker is guaranteed to be in the center of the screen, and the
rest of the screen darkens behind it.

Fixes: #6291.
2017-09-26 14:18:20 -07:00
Harshit Bansal 5662726a22 emoji_picker: Add ability to search by emoji aliases.
Fixes: #6250.
2017-09-16 08:24:05 -07:00
Harshit Bansal 6f7bf32e15 emoji_picker: Extract `toggle_reaction()` function. 2017-09-16 08:24:05 -07:00
Harshit Bansal 60b0e0f801 emoji_picker: Add `get_alias_to_be_used()` function.
Given a `message_id` and `emoji_name` this function returns the
alias of the emoji user used for reacting to this message, otherwise,
if he has not reacted returns the passed `emoji_name` as it is.
2017-09-16 08:24:05 -07:00
Harshit Bansal dae51b821d message_controls: Don't auto-hide message control if a popover is open.
If a reactions picker is open then don't auto-hide the element over
which it is based off. Earlier we were inconsistently auto-hiding
some elements while keeping others visible.
2017-09-16 08:17:41 -07:00
Harshit Bansal afba03f84e emoji_picker: Change reaction popover's base element.
Change the reaction popover to be based off the container elements
for the various message control icons. This will enable us to easily
control the visibility of the base element when the popover is opened
or closed. Also removes redundant `reactions_hover` class.
2017-09-16 08:17:41 -07:00
Harshit Bansal 16885ef0a7 emoji_picker: Correctly restore the title attribute of base element.
Bootstrap's `fixTitle()` function removes the base element's original
title attribute. This commit fixes some weird behaviors by restoring
the original title of the element on which the popover is based off.
2017-09-16 08:17:41 -07:00
Harshit Bansal 918e2519b0 emoji_picker: Bring focus back to filter on typing while navigating.
Fixes: #6112.
2017-09-16 08:14:47 -07:00
Harshit Bansal c864816f64 emoji_picker: Extract `register_popover_events()` function. 2017-08-29 14:09:35 -07:00
Harshit Bansal aebb49b18c emoji_picker: Move some functions to avoid lint errors.
Move `render_emoji_popover()` and `toggle_emoji_popover()` to bottom
to avoid lint errors.
2017-08-29 14:09:35 -07:00
Harshit Bansal 90d8b0f520 emoji_picker: Fix the two different titles appearing for each emoji.
Fixes: #6286.
2017-08-27 17:22:44 -07:00
Harshit Bansal cd2f41dbb1 popovers: Extend the `compute_placement()` function.
This commit extends the `compute_placement()` function in
`popovers.js` to take into account height/width of popover as well as
positioning preference. If vertical positioning is desired and the
popover fits in either 'top/bottom' positions then we don't check for
`left/right' positions. Earlier the behavior was to prefer
'left/right'positions over 'top/bottom' positions, which resulted in
the emoji picker popping incorrectly to the left.
2017-08-27 12:27:53 -07:00
Harshit Bansal f24582576a emoji_picker: Further improve emoji picker navigation.
This further improves the emoji picker by introducing two new behaviors:

1: If the cursor is at the end of the input box then pressing `right_arrow`
moves the focus down into `emoji_catalog.

2: If the currently focused emoji is the first emoji in the `emoji_catalog`
then pressing `left_arrow` moves focus back to search filter.
2017-08-27 12:04:10 -07:00