Commit Graph

28 Commits

Author SHA1 Message Date
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
Steve Howell 0bc272fc86 hotkeys: Fix very recent regression with down key.
In 1f72647a5a I accidentally
flipped a condition that made the down key "recenter" on
the "normal" case, not in the "is-at-end" case.

This commit undoes that regression, which probably only
affected czo for a weekend, and makes the logic a bit
more clear.
2018-05-28 16:49:57 -07:00
Steve Howell 1f72647a5a navigate: Use msg_list.prev/next for up/down methods.
We've had rare and hard-to-track-down glitches with our
old implementation for going up and down in the message
list, which was using jQuery selectors.

We now just use MessageListData under the hood to find
our next id.
2018-05-27 22:41:19 -07:00
Steve Howell 860f62c792 Have home key go to actual first message in the list.
Before this, the home key would go to the first message in our
render window.  Now we go to the first message in our local
list of messages.  (Note that there may still be older
messages, so it will still often take multiple uses of the
home key to truly get to the top of your feed.)
2017-10-03 11:28:28 -07:00
Steve Howell 29c05c82f0 Fix A/D hotkeys for cycling through stream narrows.
We now use similar code for A/D hotkeys as we do for the "n"
key.

The old code was using jQuery operations that got tripped up
by our splitters between active and inactive streams.

Fixes #4569
2017-08-16 15:45:47 -07:00
Brock Whittaker d01549e8e3 Fix outerHeight to OR with 0 to not produce NaN.
This is an issue where in jQuery v3 the result of outerHeight on a node
that doesn’t exist is now “undefined” rather than “null”, which means
it will no longer cast to a Number but rather NaN. For this, we create
the safeOuterHeight and safeOuterWidth functions to safely return a
result (or 0).

This is a better solution than manually going to each instance and
ORing it with 0 for type safety.

https://stackoverflow.com/questions/41454285/jquery-outerheight-returns-
undefined-instead-of-null
2017-07-27 14:16:57 -07:00
Steve Howell 79acbcd1bf Refine error handling for stream_list.get_stream_li calls.
We avoid false warnings in get_stream_li and for updating
unread counts.  We also early-exit for A/D keys if there is
no current stream.
2017-06-03 06:16:45 -06:00
Tim Abbott f4a049110f navigate: Fix incorrect reference to narrow.stream().
This was renamed to narrow_state.stream() recently.
2017-05-15 21:07:00 -07:00
Steve Howell d3a7aa3a37 Have get_stream_li() take a stream_id.
Rather than having get_stream_li() look up stream id using
stream name, we force the callers to pass in the stream id.

This adds an extra line to most of the callers for now, but
this will eventually change as we fix some of the callers to
have their callers pass in stream_id.

In places where we now call stream_data.get_stream_id() to
get the stream id, we will be more resilient toward stream
renamings, at least until the next reload, since
stream_data.get_stream_id() can resolve old names that
are stored when we process stream-rename events.
2017-05-15 14:47:41 -07:00
Steve Howell 8eb86335b9 Extract narrow_state.js.
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.
2017-04-25 09:57:32 -07:00
Steve Howell eda046409c Move paging methods into navigate.js. 2017-03-19 11:05:46 -07:00
Steve Howell a51caceea5 refactor: Extract unread_ops.js
This module mostly contains the mark_* functions that
update the server with info about unread counts.
2017-03-18 10:35:52 -07:00
Tim Abbott 5e39ccd642 js: Rename viewport.js to message_viewport.js.
This fixes the mobile web experience for Chrome on iOS.

Apparently, Chrome-on-iOS silently has a `viewport` module that
overrides and user-defined module by that name, causing all of our
code that accesses the viewport module to not work on that platform.
We fix this by renaming it.
2017-03-10 14:59:59 -08:00
Elliott Jin 4092aab620 unread: Refactor to move DOM element updates into UI layer. 2017-02-11 08:36:39 -08:00
Rafid Aslam 7856217a63 Migrate JS modules to CommonJS style.
Closes #1488.
2016-12-07 16:11:52 -08:00
AZtheAsian ed0bc831be eslint: change one-var from warning to error and fix violations 2016-12-02 11:25:16 -07:00
Tim Abbott c35781d505 lint: Require folding of } on same line as else statements. 2016-06-09 14:02:49 -07:00
Vishnu Ks 89d743787e Move recenter_view to viewport.js. 2016-05-27 01:03:21 -07:00
Vishnu Ks 4be20c4b4a Move scroll_to_selected to navigate.js. 2016-05-27 01:03:21 -07:00
Vishnu Ks e329c9e0f5 Move maybe_scroll_to_selected to navigate.js. 2016-05-27 01:03:21 -07:00
Vishnu Ks dc577343fe Move last_viewport_movement_direction to viewport. 2016-05-27 01:03:21 -07:00
Leo Franchi de9d26126a Only cycle through stream elements when cycling through streams
(imported from commit 244d72e88e18cc49f32ecfada791f032140390f2)
2014-02-28 16:48:45 -05:00
Luke Faraone 8075c6e5a8 Allow cycling between streams with shift+{A,D}
Closes trac #2273.

(imported from commit 858ffd47aa6dbb372d426fe94b860dfe1c1cce34)
2014-02-20 13:27:43 -05:00
Tim Abbott 004fd0eab8 Move unread-related functions from zulip.js to unread.js.
(imported from commit efc0dd84c2cd30b0203b906af6991475d8a63985)
2014-01-31 14:59:03 -05:00
Steve Howell b3f60faf3f Restore centering when using the down arrow (or "j").
This restores the feature that hitting down when you are at the
last message automatically centers the last message.  This is not
a pure revert, because some additional code now goes through
navigate.down.

(imported from commit 2db1f247692ba068613a2d6c93f18ca7c13a16b8)
2013-08-05 16:10:01 -04:00
Steve Howell 4ad78ade68 Don't widen bottom whitespace on down-arrow.
We had a feature that if you hit the down arrow key when you
were at the last message, it would recenter you.  Waseem has bought
into temporarily removing this feature.  Justifications:

  1) We can always put it back.
  2) Autoscrolling makes it less relevant.
  3) The feature complicated the code a bit.
  4) The feature worked different for End than down arrow, due to
     a FIXME.
  5) It might have been a misfeature for users that want more
     control over their own scrolling.
  6) You can achieve the same essential effect by using PgDn
     or space.

(imported from commit fa6874bb5d29d7057bb1601f0b6d577bac1272c7)
2013-08-02 18:18:04 -04:00
Tim Abbott 3bba0cc927 Move zephyr/static to just static.
It's not really a part of the server (aka the rest of zephyr/).

(imported from commit 27f6b6b064938ad927075a68d873e4b68710d279)
2013-07-29 12:11:26 -04:00