Commit Graph

270 Commits

Author SHA1 Message Date
Steve Howell bdca28a14b Avoid opening compose box for topic sidebar clicks.
We don't want to auto-open the compose box for topic
sidebar clicks, because we want to convenience folks
reading messages, not writing messages, since on
stream narrows, people tend to do much more reading
than writing.  (Also, opening the compose box explicitly
is super easy.)

The part of this change that affects behavior is that
we remove the call to compose_actions.start('stream').

Then the simplification is that we replace the checks
to narrowed_by_reply() and !narrowed_to_topic() with
a single call to narrowed_by_pm_reply().

Fixes #3886.
2017-04-17 22:54:36 -07:00
Steve Howell af887822b5 Add narrowed_by_pm_reply() helper. 2017-04-17 22:54:36 -07:00
Steve Howell 33eb5ad237 Add narrow.is_for_stream_id() helper. 2017-04-13 07:49:55 -07:00
Steve Howell fd856d728c Extract message_util.js 2017-03-19 21:03:45 -07:00
Steve Howell 1114c8bf62 Extract message_fetch.js. 2017-03-19 21:03:45 -07:00
Steve Howell d026344b37 Extract js/ui_util.js. 2017-03-19 11:05:45 -07:00
Steve Howell 5b2407bb22 Add ui_state.home_tab_obscured() shim. 2017-03-19 10:56:09 -07:00
Rishi Gupta 19d8d16126 js dependencies: Split hash_util.js from hashchange.js. 2017-03-18 20:40:34 -07:00
Steve Howell 27f37e6378 Add hash_util.encodeHashComponent() shim. 2017-03-18 15:52:50 -07:00
Steve Howell d75efa19db Add compose_state.has_message_content() shim. 2017-03-18 15:52:50 -07:00
Steve Howell 59fd9e4d48 Add compose_actions.cancel() shim. 2017-03-18 15:52:50 -07:00
Steve Howell faa9446e64 Add compose_actions.start() shim. 2017-03-18 15:52:50 -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
Steve Howell 0bd3af2bc8 Create narrow.update_email(). 2017-02-14 23:25:22 -08:00
Elliott Jin 4092aab620 unread: Refactor to move DOM element updates into UI layer. 2017-02-11 08:36:39 -08:00
sinwar 21083278b5 Fix banners for unknown streams.
Fixes #3443
2017-01-28 13:11:31 -08:00
Steve Howell cd6115c24d Make nicer slugs for "sender" narrows.
Slugs are now like our "pm-with" slugs:

    narrow/sender/3-cordelia
2017-01-19 14:54:50 -08:00
Steve Howell c94b8c39d0 Add narrow.huddle_with_uri() convenience method.
This will be used in a subsequent commit.
2017-01-17 15:13:49 -08:00
Steve Howell d757f840dd Make nicer slugs for "pm-with" narrows.
The slugs for PM-with narrows now have user ids in them, so they
are more resilient to email changes, and they have less escaping
characters and are generally prettier.

Examples:

    narrow/pm-with/3-cordelia
    narrow/pm-with/3,5-group

The part of the URL that is actionable is the comma-delimited
list of one or more userids.

When we decode the slugs, we only use the part before the dash; the
stuff after the dash is just for humans.  If we don't see a number
before the dash, we fall back to the old decoding (which should only
matter during a transition period where folks may have old links).

For group PMS, we always say "group" after the dash. For single PMs,
we use the person's email userid, since it's usually fairly concise
and not noisy for a URL.  We may tinker with this later.

Basically, the heart of this change is these two new methods:

    people.emails_to_slug
    people.slug_to_emails

And then we unify the encode codepath as follows:

    narrow.pm_with_uri ->
    hashchange.operators_to_hash ->
    hashchange.encode_operand ->
    people.emails_to_slug

The decode path didn't really require much modication in this commit,
other than to have hashchange.decode_operand call people.slug_to_emails
for the pm-with case.
2017-01-17 15:13:49 -08:00
Tim Abbott 998dff9e50 lint: Add dangling commas in JavaScript objects. 2017-01-11 15:23:42 -08:00
Tim Abbott f0f4be4af7 lint: Fix remaining no-unused-vars eslint rule violations. 2016-12-14 22:36:47 -08:00
AZtheAsian 5e9918135b eslint: change quote-props from off to error and fix violations. 2016-12-02 18:35:53 -08:00
AZtheAsian 9c0ebc7359 eslint: change no-else-return to error and fix violations 2016-12-02 14:43:09 -08:00
Tommy Ip b3f4feb996 eslint: change max-len from warning to error and fix violations. 2016-12-02 14:16:33 +00:00
Steve Howell 853126344e Add narrow.topic() helper method.
This has similar semantics to narrow.stream().
2016-11-10 15:55:31 -08:00
Steve Howell eb64b32bc8 Fix "subjects" in JS comments. Say "topics" instead. 2016-10-28 13:52:25 -07:00
Tim Abbott 2867c019cb Don't show special empty narrow messages for complex narrows.
Previously we showed an empty narrow error message determined entirely
by the first operator, even though there could have been multiple
operators.
2016-07-31 19:38:19 -07:00
Kartik Maji cea079279e Improve error message when narrowed to nonexistant or silent users.
Fixes #1418.
2016-07-31 19:38:17 -07:00
krtkmj 734ab8d5e3 Correctly narrow to stream using search box from subscription page.
Fixes #1012.
2016-06-23 15:20:57 -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 e329c9e0f5 Move maybe_scroll_to_selected to navigate.js. 2016-05-27 01:03:21 -07:00
Vishnu Ks fe4a03fd01 Move narrowed_msg_list to message_list.js. 2016-04-26 10:25:11 -07:00
Vishnu Ks ae49ad383d Rename all function on MessageList to all_messages. 2016-04-25 13:45:18 -07:00
Vishnu Ks 35b0af2852 Move all_msg_list to message_list.js. 2016-04-21 17:46:21 -07:00
Vishnu Ks ee39f5009f Make message_list.js work like the other modules. 2016-04-20 15:29:30 -07:00
Aristeidis Fkiaras 0058ccbdb0 Move global unread_messages_read_in_narrow to unread.js. 2016-04-08 12:11:47 -07:00
Liz Sander 860cf68716 Show current narrow in page title.
Fixes issue #157.
2015-12-14 21:21:30 -08:00
Steve Howell f8b71fa497 Created condense.js (with code taken from ui.js).
(imported from commit 72b27b48614a7c396170d46936646e52757e2743)
2014-03-14 20:48:58 -04:00
Leo Franchi 748e5b6da6 Remove disabled summarization code
This experiment has been disabled for everyone for a while: if we
bring something like this back, it is not likely to be exactly the same,
and will be different enough to require a different implementation.

As it is, the summarization code was making a few code paths (rendering
especially) more complex, and is worth removing for simplicity's sake.

(imported from commit 6ac8cdc9f7077a5a1da01ab4268aba3db0bc43f8)
2014-02-27 20:25:23 -05:00
Leo Franchi acec697fe7 Report unnarrow times as well as narrow times
(imported from commit b3a889aa11dc112508c5a1d213f68e5223a879fc)
2014-02-13 14:45:22 -05:00
Tim Abbott fcb8c106b1 Fix saving of pointer on server-initiated reload when narrowed.
Previously, we saved the current_msg_list selected id and then
restored it as the home_msg_list selected id, which could result in
the home view loading to the wrong place.

This takes some already bad code and makes it even more in need of
refactoring, but it does fix a pressing bug.  We should definitely
refactor both:

* the top of narrow.js
* the save/restore code in reload.js

after this, though.

(imported from commit bb2040219e4f545ba90bb04a696996cec2831484)
2014-02-12 14:40:38 -05:00
Steve Howell 10b24f77b6 Fix misc. uses of search tuples.
(imported from commit c7dc47c1396eb0d9f6821cafcb3dc90d283b4764)
2014-02-10 15:11:43 -05:00
Steve Howell 8d81ea33da Have pick_empty_narrow_banner() use operator/operand.
This is part of phasing out the internal tuple representation.

(imported from commit aa8788efbdc0f8d08d99bae154f68a3b60272c65)
2014-02-10 13:23:26 -05:00
Tim Abbott 02d69f18ac Clean up codepath for selecting a message on unnarrowing.
This does have a small functional change of using use_closest even for
the current_msg_list.last().id case, but that's harmless; and it does
reduce a lot of code duplication and confusing logic here.

(imported from commit 7c4ecaa197120cc6d5c05ce4887f33c7d94a9c59)
2014-02-06 10:25:35 -05:00
Jason Michalski 0dd61e9222 Blueslip has a warn not warning function
(imported from commit 1f18331cac451c62a089f042b316278030c41965)
2014-02-04 23:08:19 -05:00
Tim Abbott 0b12681558 Export message_store.get() for getting message objects.
(imported from commit d7d20bf3aab62a1b407709b1c0bf947b3ad8bee8)
2014-02-03 13:32:02 -05:00
Tim Abbott f26af47fb6 Center on-page-load narrows on first unread message.
This implementation is somewhat hackish in large part because I think
we're going to be wanting to redo the get_old_messages API somewhat
soon, and this may naturally become a lot cleaner as a result, but
this isn't a lot of code and fixes #2235 part (A) and substantially
mitigates #1510.

(imported from commit 47a2160a44befa9d83190c5cc95b90e92cc5b4cc)
2014-02-03 13:32:02 -05:00
Tim Abbott 88fbd5d16a Split out new module message_store.js.
(imported from commit 57cf3f2b8e74d7c56e3baf75859d5b3646282225)
2014-01-31 15:57:28 -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
Leo Franchi 01e948ac97 Allow unnarrowing to an empty message list in unread-messages-read case
(imported from commit f377dbce61fe2fc2051bc286f7215e8112f92736)
2014-01-30 18:08:48 -05:00
Steve Howell 15b0f9dcc7 Use operator/operand in narrow.collect_single().
(This is part of converting away from tuples.)

(imported from commit ba3083f8b3242fee1d532d7666aee68af89d8ddc)
2014-01-30 16:15:16 -05:00
Steve Howell 796ebfd007 Do not return raw operators from narrow.operators().
Even in the case where we are running embedded narrows,
we want narrow.operators() to return new-style operators
that you get with Filter objects, so that callees do
not need to support the legacy tuple format.

(imported from commit a6649881a926a2304e9f7cc8ca53b406e2c8828e)
2014-01-30 16:15:14 -05:00
Steve Howell b3a551f402 Stop using raw operators in narrow.activate().
Have narrow.activate() user filter.operators() to produce
operators that have operand/operator fields, so that its callees
don't need to be backward compatible with the tuple format.

(imported from commit e408e33074d1be2d112bb3cdc081ec3616c908ee)
2014-01-30 15:57:28 -05:00
Jason Michalski 21c2aea755 Fix scroll position on narrow and unnarrow
Change the offset to hold of the selected message as an offset from the
top of the screen. Then use the current offset and scrollTop to compute
the new scrollTop.

(imported from commit 718e95d3435c0f84cbb7663a9bb2bc2789314203)
2014-01-30 01:48:15 -05:00
Leo Franchi dd7d31c7a6 Allow an empty home view when unnarrowing
(imported from commit 69f1a84b23ae8942db58851a1a1c6723c26df560)
2014-01-28 15:35:31 -05:00
Leo Franchi 1fdb586c13 Make sure then_select_id is a number to call .toFixed()
(imported from commit 58635110c737ccb38e74cce8b4feb5d93dfbf5cc)
2014-01-27 12:30:42 -05:00
Leo Franchi 00f64113e9 Support locally echoing messages when sending
(imported from commit 00b5c5f9b933d119553c32cadff0f17b9f7c2879)
2014-01-23 16:28:55 -05:00
Leo Franchi 49c4ad61a1 Delay render on narrowing to end, to ensure only one render happens
(imported from commit c38574417e339275a90b235ecabc96e0deab95f8)
2014-01-23 13:29:18 -05:00
Leo Franchi 9160fb3ed5 Remove debug that slipped in to previous commit
(imported from commit 1aeb04b0e8fc0b37da4a8aa123b567d2f96cc32a)
2014-01-22 14:04:25 -05:00
Leo Franchi c0fdbf81cf Use the feedback connection for getting APNS feedback
(imported from commit d371188e0437606b3ff435ee9c005cee2849f6ae)
2014-01-22 13:50:15 -05:00
Tim Abbott 6443aead67 Fix scrolling when unnarrowing after reading new messages.
Our logic for unnarrowing when messages were read during the narrow
did not properly use the then_scroll option and thus actually set the
scroll position when they selected a new message.  This was
accidentally prevented from being a big problem by the incorrect
scrolling logic that was fixed by:

    Only preserve_pre_narrowing_screen_position when preserving pointer.

which caused the browser to scroll _back_ to close to the correct
scroll position (but not the intended scroll position -- it would
usually be a little bit off).

(imported from commit d779de8f89590d242f62d32b22a297bdc096c594)
2014-01-15 16:07:20 -05:00
Tim Abbott 86f9ea0cd2 Move save_narrow earlier in narrow.deactivate.
I think that this will fix the issues we've been having with
hashchange.save_narrow() screwing up the scroll position in the page.

(imported from commit 25af9b7dda2d107220e11dd12b9dc344bc63addc)
2014-01-15 16:07:17 -05:00
Tim Abbott 2632b130a5 Only preserve_pre_narrowing_screen_position when preserving pointer.
(imported from commit a0e323796f62b2bacd205a441ef68ac160918cdd)
2014-01-10 21:39:01 -05:00
Tim Abbott 795930c803 Add channel module wrapping our various JSON requests to the server.
(imported from commit 6489938678551ad8594822363ae6d1c9ae295496)
2013-12-19 16:52:47 -05:00
Tim Abbott 2276c6e524 Add support for loading a narrows-only embedded Zulip window.
Features:
* Only shows messages in the narrow
* New messages in the narrow will arrive as they are sent
* Works even for streams you're not subscribed to
* Automatically subscribes you to a stream on send
* Doesn't update your pointer
* All searches etc. automatically have the narrow added

(imported from commit 2e12b76849f6ca0f53dda5985dad477a04f7bbac)
2013-12-16 17:46:02 -05:00
Steve Howell e1727844d7 Only condense/collapse when messages are visible.
Trying to condense messages when they are not yet visible just
leads to wasted effort and wrong results.

This commit makes it so that current_msg_list always points to a
visible list, so the code related to message rendering knows when
to call ui.condense_and_collapse().  For activating narrows, we
now let rendering handle the condense/collapse case.

The home view situation is a little trickier, because we render
new messages in the home view even when we're inside inside of a narrow,
presumably to make it fast to switch into the home view.  When
we actually go back to the home view, we need to sweep for messages
that might need to be condensed, since they have been originally
rendered while the home view was not visible.

(imported from commit 4da2d278a4353e9e0c2b98cbf8c9dd03b06cd59b)
2013-12-12 15:38:38 -05:00
Jessica McKellar 81b493ba0b Change pointer semantic to better support side bar users.
There are now 2 cases for narrowing:

1. We narrowed, but only backwards in time (ie no unread were
read). In this case, try to go back to exactly where we were before
narrowing. This behavior is unchanged.

2. We read some unread messages in a narrow. Instead of going back to
where we were before the narrow, go to our first unread message (or
the bottom of the feed, if there are no unread messages). This is new.

This means that after catching up through the sidebar, on returning
home you'll be at the bottom of your feed.

Searching for the first unread message in a message list with 40,000
messages only takes 17ms according to:

function timeit() {
    var t0 = new Date().getTime();
    _.find(current_msg_list.all(), unread.message_unread);
    var t1 = new Date().getTime();
    console.log('Find first unread: ' + (t1 - t0) + ' ms');
}

(imported from commit 87c467578a2cced0aa976d8ae2924371b85d2445)
2013-12-09 10:41:26 -05:00
Jessica McKellar d4fae47430 Don't nudge pointer after unnarrowing.
This is in preparation for changing the pointer semantics later in the
branch.

(imported from commit 705ac2a48d7f36531d7683c5cf585cc89188a210)
2013-12-09 10:41:26 -05:00
Tim Abbott 458c066925 Add reporting for how long narrowing takes in the wild.
I'd also like to add a database table to actually store the values
that we get out of this and our send message requests for future
inspection, but for now, grepping logs+statsd is good enough.

(imported from commit 99ef179651850217fe6e82c5e928d122ca91101e)
2013-12-06 10:28:01 -05:00
Steve Howell f923c15ba8 Change signature of ui.process_condensing().
I renamed ui.process_condensing() to ui.condense_and_collapse(),
and, more importantly, it now takes a list of elements, not a single
element, which allows us to do some computations outside the loop.

(imported from commit d5984088030c2a0d4ec8b258c7fcec3e84caf2b1)
2013-12-05 16:42:07 -05:00
Jeff Arnold ec56e946a7 Only manually update fading if the compose box is staying open
(compose.start() and compose.cancel() both update the fading themselves)

(imported from commit 63ce2f54106c8cce2306b0c1f3ce56e06f24235f)
2013-12-03 16:58:50 -05:00
Tim Abbott ef906c3cd3 Fix traceback when unnarrowing before home message list has loaded.
If we load a browser window in a narrowed view and then un-narrow
before the home message list has loaded, we end up attempting to
select message ID -1 from home_msg_list even though it is empty,
triggering a traceback.

(imported from commit eb8b686f6e9c1fa518028e5755ac6196781e92d7)
2013-12-02 16:03:21 -05:00
Jeff Arnold 3a41184533 Revert "Make c/C compose to a new destination instead of being identical to r/R"
This reverts commit 755c92aed79ab79089b2e35d2c100582f012736a.

(imported from commit b7790fc63a2cea0a8e294c3f0a881ed6f06ed061)
2013-11-27 10:43:10 -05:00
Jeff Arnold c0a8fc459a Make c/C compose to a new destination instead of being identical to r/R
R means "I want to send a PM, you can guess the destination"
r means "I want send a stream message, you can guess the destination"
C means "I want to send a PM and specify the destination"
c means "I want to send a stream message and specify the destination"

(imported from commit 755c92aed79ab79089b2e35d2c100582f012736a)
2013-11-27 10:35:37 -05:00
Tim Abbott 8952d8d428 Add 'narrow to this conversation and time' narrowing.
(imported from commit 3bc5ea09d333c2caa37557419d54d48bbbb5a639)
2013-11-25 14:00:28 -05:00
Tim Abbott be2d546ffe Fix narrowing links in message popovers.
This should make it possible to either open these using middle-click
or copy the links for e.g. putting in a bug tracker ticket.

(imported from commit 0c531453cdd7197f932079c245700948b416a3d5)
2013-11-25 14:00:28 -05:00
Kevin Mehall e82f11ed46 Fix a JS error introduced by the debug logging.
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)
2013-11-05 15:07:24 -05:00
acrefoot 9af244a6bc fix narrowing bug introduced by composebox notifications
I switched narrow.by_subject and narrow.by_recipient to use the all_msg_list
instead of current_msg_list, since we wanted to be able to narrow to messages
specifically not in the current_msg_list. However, in searches which revealed
old messages outside the range of all_msg_list (which only has a single contiguous range),
this broke narrowing.

Let's use msg_metadata_cache instead.

(imported from commit 427f717484b4ae83d9bb4cc6e51ce17177d037fe)
2013-11-01 18:33:10 -04:00
acrefoot 434b7ac120 Give Feedback in non-obvious cases for sent messages
Displays a notification above the composebox in cases where the message
is not visible (further down), or where it's outside the current narrow or search.

It also offers a link to the appropriate narrow when it makes sense, and offers
timetravel when appropriate. There is currently a bug with timetravel (and you can
see this when using the popover menu) that makes "narrow to messages around this time"
not work for muted messages.

This resolves Trac #1518.

(imported from commit 391ca0b9c07d91496f6585a4fd8e15723d1170e2)
2013-11-01 12:34:39 -04:00
Kevin Mehall 58f7138e07 Collect additional debug information for JS errors
(imported from commit 7c94ad118c2cd33e5b6eec4e27fd22dfa2d56909)
2013-10-31 13:18:43 -04:00
Zev Benjamin eb7fd1ba51 Add some front-end debugging changes
(imported from commit 21684b09100bc0a24372948a9417c973709c1be2)
2013-10-30 15:52:35 -04:00
Kevin Mehall 463b10cf0e Enable summarization only for the right narrows.
* Disable for search-like narrows (whitelist stream and home instead of
    blacklisting topics and PMs)
  * Use home view summarization flag for All Messages

(imported from commit 48bd10ae5da7c7564c2efe86a40078f1a7e96e20)
2013-10-21 11:48:56 -04:00
Steve Howell 0ad4554723 Allow customer12.invalid users to narrow to a single message.
Add the option "Narrow to just this message" to the chevron
menu.  This has two use cases:

    * It's an easy way to get a sharable URL for the message.
    * It reduces distractions.

For now it is feature flagged to just customer12.invalid and staging.
See #1880.

(imported from commit 897d247176f9024ff825ccd3b338236569eed5ab)
2013-10-11 15:52:10 -04:00
Steve Howell 89cbda5001 Keep in-progress compose open on narrows.
If the user has text in the compose box, don't close or
change the compose box when they narrow.

(imported from commit f9b400f6bac37cb313f1fd87aadb3ba1d3a035ef)
2013-10-10 11:20:49 -04:00
Steve Howell 8017fc9a15 Move compose.start() calls out of click handlers.
For the two cases where narrowing should open the compose box,
we now put that logic inside of narrow.js.

(imported from commit 570e22e90c2f6d422ba71cce400c075f0b8adf51)
2013-10-10 11:20:49 -04:00
Steve Howell 7007cf203d Move compose.cancel() calls out of click handlers.
Handle closing the compose box inside of narrow.js, to
ensure consistent behavior for all the narrowing UI options.

(imported from commit f17a687491eb2361c73032cd974cedb2a0a2dd85)
2013-10-10 11:20:49 -04:00
Steve Howell a78a1ec36c Use <a> tags for links in the recipient/summary bars.
The main user-facing feature here is that users can open narrows
in new tabs or windows. Internally, it makes the HTML more semantic.

One consequence of making these elements into actual anchor tags
is that clicking on them no longer triggers this logic to
close the compose box when you click outside of it:

        // Unfocus our compose area if we click out of it. Don't let exits out
        // of modals or selecting text (for copy+paste) trigger cancelling.
        if (compose.composing() && !$(e.target).is("a") &&
            ($(e.target).closest(".modal").length === 0) &&
            window.getSelection().toString() === "") {
            compose.cancel();
        }

Instead of patching the above code, I elected to just call
compose.cancel() explicitly in the click handlers for the links
themselves.

We are gonna try to clean up the compose-box behavior globally soon.

(imported from commit c9a01916f1714fe3dd495d25c78cd5e5532105ef)
2013-10-09 17:09:10 -04:00
Steve Howell 6c6816491d Add muting_enabled option to MessageList.
(imported from commit c86772b7dea864c49091c988772e17aae5efa5bc)
2013-09-23 10:53:06 -04:00
Steve Howell 022ef6e9b9 Add narrow.muting_enabled()
(imported from commit 8972d1e3ca347397664094a7f150ec86fd2f8f8e)
2013-09-23 10:53:06 -04:00
Steve Howell e79e74ade4 Add narrowed_to_topic() helper function.
(imported from commit 9190caa9b183893fb7ae883686b9bdbd661d5895)
2013-09-19 15:41:00 -04:00
Steve Howell c4d598b36e Move parse/unparse from narrow to Filter.
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)
2013-08-22 14:53:00 -04:00
Steve Howell edda967100 Leave casing alone in search suggestions.
The function narrow.unparse() is used in a bunch of places in
the search suggestion code, and now it no longer lower cases
operands.  This change contributes to fixing trac #1659.

(imported from commit 6b44b8a818482b5c8b4f9a45bc7d3a9d21e04eba)
2013-08-20 14:27:44 -04:00
Steve Howell d5f997eb58 Use the correct stream name in compose defaults.
If we have a stream named "Denmark" and we're narrowed to it,
then use "Denmark" as the default stream name in the compose box
even if the narrow operators are lowercase.

(imported from commit e9f06b7307c73231aa887dc95849e0307984e6f0)
2013-08-20 14:27:42 -04:00
Steve Howell 29c012dc74 Create stream_data.js module.
This pulls a lot of data-centric functions out of subs.js.

(imported from commit 0deed7d4bf5697e893af9bc9d888c2d5da8d9fa2)
2013-08-19 12:17:55 -04:00
Steve Howell 75ffd4d637 Exempt last 5 messages in view from summarization.
Once you enter a view, the last n messages will be exempt from
summarization, to give the users a little more context.  Any
subsequently arriving messages will also be exempt.

We will try n=5 at first.

(imported from commit 3e6fe58109e692389bf02dde2230d788b5818d52)
2013-08-15 08:20:29 -04:00
Kevin Mehall 0f6c7ca7be Use msg_list.get_row(id) instead of rows.get(id, msg_list.table_name)
(imported from commit 953cd24e605269d2bbdc42b878506f0ab01501e8)
2013-08-14 17:08:32 -04:00
Steve Howell 878ee2b3fd Move Filter class to filter.js from narrow.js.
1) The class Filter now lives in its own module.
2) The function canonicalized_operators() is now a class method on Filter.
3) The function message_in_home moved to filter.js and became private.
4) Various calling code had to change, of course.
5) Splitting out Filter helped simplify a few tests.

(imported from commit e41d792b46d3d6a30d3bd03db0419f129d0a2a7b)
2013-08-12 13:58:32 -04:00
Steve Howell c4e168254c Fix too-much-fading regression and remove spurious classes.
To get to the bottom of the too-much-fading regression,
it was necessary to clean up the code, which was overly
complicated by multi-purposed functions.

The API for compose_fade now has these functions:

    set_focused_recipient
    start_compose
    clear_compose
    update_message_list
    update_faded_messages

Internally there is now a notion of "normal display",
so e.g. when you want a normal display, we call
_diplay_messages_normally() internally, which removes the
faded/unfaded classes from all messages.

(imported from commit 7eb2b0a163f29d9ebae26661f432fecc7c331e4c)
2013-08-12 11:54:27 -04:00
Steve Howell 37f8cc9294 Extracted code into compose_fade.js.
The compose_fade has three public exports:

    set_focused_recipient
    unfade_messages
    update_faded_messages

All code was pulled directly from compose.js, except for the
one-line setter of set_focused_recipient.  The focused_recipients
variable that used to be in compose.js was moved to compose_fade.js,
hence the need for the setter.

(imported from commit 462ca5d0d0bd58612d0197f3734a8c78de8c6d30)
2013-08-11 17:05:13 -04:00
Zev Benjamin 222f6194e2 Fix key lookup when canonicalizing operators
(imported from commit 59d460bfaa50c0872918d1e5a22efb98d15ce669)
2013-08-09 17:35:58 -04:00
Zev Benjamin ec9322fc87 Use Dict everywhere we have keys based on potentially dangerous, user-supplied data
There are also one or two places we don't need to use it for security
purposes, but we do so for consistencey.

(imported from commit aa111f5a22a0e8597ec3cf8504adae66d5fb6768)
2013-08-09 17:35:14 -04:00
Steve Howell cc73619a9d Add unit tests to narrow.js.
This includes slightly invasive, but harmless, changes to
production code.

(imported from commit 847557c11088b75c836cc399d0af75353a8faa3a)
2013-08-09 11:59:32 -04:00
Kevin Mehall 2664002dec Make summary rows selectable.
We represent summary rows by the ID of their first message for
for selection purposes.

(imported from commit 9f3c4d23f6b1295b117d5197e214de983bb2cc20)
2013-08-08 13:04:01 -04:00
Kevin Mehall eac6463031 Implement message summarization experiment.
When you read messages in a narrow and then un-narrow, collapse
adjacent messages read in the narrow into a summary row that can
be clicked to expand those messages.

Scoped to staging with feature flags.

The implementation of this within our current MessageList is rather ugly.

(imported from commit bcb3a39d8c0c334136fe86318f18ead03f0f50bf)
2013-08-07 10:24:03 -04:00
Steve Howell 01b40f3c98 Fix compose/topic regression (trac #1648).
When you are narrowed and hit "New stream message", the topic
will autofill.  This broke during the subject-to-topic
transition.

(imported from commit a9b471884c5cdae449e02ce7aa782add4a178077)
2013-08-05 17:58:45 -04:00
Tim Abbott 5a320db3c1 Add curly braces for all javascript if statements lacking them.
(imported from commit 32c7643d1a6ecdfaf634424d217938c8a368dade)
2013-08-01 11:47:54 -04:00
Scott Feeney 1e642ae158 Use _.any instead of _.some
They are synonyms, and Zukeeper consensus is that _.any makes it clearer
what the function does.

(imported from commit 847383e27ccefeaff1ecff15f4cb4177c9e40c25)
2013-08-01 10:16:32 -04:00
Zev Benjamin 905354f7a1 For mit.edu, include .d instances in narrowed views
(imported from commit 502b36d1a62f3f8f7b956c701fd10f580e1927d7)
2013-07-31 18:30:28 -04:00
Zev Benjamin bae5924b53 Fix whitespace
(imported from commit 96937f8225bc7039f2a98163deb9b5b142c71c7f)
2013-07-31 18:30:28 -04:00
Zev Benjamin a637fadd18 Fix regexes for MIT narrows that include un- and -.d streams
The previous regex didn't escape the period in '.d' and was doing a
case-sensitive match to find the base stream name.

(imported from commit 43ef13733987e50dcead06b7bd3e768cb4395998)
2013-07-31 18:30:28 -04:00
Tim Abbott d6acd8fce9 Add support for narrowing to a single message ID.
This is mostly useful for sending someone a link to a single Humbug
message.

(imported from commit b0994a2bf503c84690b13ce89bbcf5bab829bf0c)
2013-07-31 14:59:05 -04:00
Tim Abbott ed6f5ac470 Fix time travel by adding new near: operator.
(imported from commit 727a68016090164b586cbe59e692676a00e8cd3a)
2013-07-31 14:59:01 -04:00
Scott Feeney 473a96fd1f Fix #1629 (wrong scroll pos on narrow)
(imported from commit ac78077f104b079406e745c3eb9ff11b759d033e)
2013-07-31 14:35:48 -04:00
Scott Feeney a35fff90cc Replace $.extend
(imported from commit 2c1ee3c2714d388f2a71398fe81c049cc54ff94d)
2013-07-30 12:12:59 -04:00
Scott Feeney 8703134a23 Replace $.each with _.each
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)
2013-07-30 12:12:58 -04:00
Scott Feeney 375b1f9eb3 Replace $.map with _.map
(imported from commit 97c7a6612d8d56d19f8650db0ea8906afc0f20ef)
2013-07-30 12:09:18 -04:00
Steve Howell 6cf5b64b3c Update module.exports for various modules.
(This makes them play nice with node-style unit tests.)

(imported from commit 44fa97c9d38d0b7e82366b49db1425508b6aed67)
2013-07-30 08:54:23 -04:00
Tim Abbott bc4d7c687d Rename our custom JS events to use Zulip, not Zephyr.
(imported from commit 61ac456d394a6dbc14f3e9183a53313990db5059)
2013-07-29 12:11:26 -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