Commit Graph

23 Commits

Author SHA1 Message Date
Sampriti Panda b2a1754f8a drafts: Re-narrow on restoring draft.
Fixes #4587
2017-06-25 12:26:42 -04:00
Joshua Pan bbc0103183 drafts.js: Create initialize() function. 2017-06-07 00:01:55 -07:00
Rohitt Vashishtha 2d73e03e37 ui-refactor: Rename modals.js to overlays.js.
Fixed #4702.
2017-05-29 11:24:46 -07:00
Rohitt Vashishtha 442537ebb8 overlays: Rename hashchange.exit_modal() to exit_overlay. 2017-05-28 18:40:54 -07:00
Steve Howell 0a0f567aeb Split out markdown.js from echo.js.
The new module handles markdown rendering.

The code left behind in echo.js does local-echo kind of things
like reifying message ids.
2017-05-09 11:06:10 -07:00
Steve Howell 6d1a6934b8 Use modal.open_overlay() in drafts.js. 2017-05-08 22:04:56 -07:00
Mahim Goyal 6464514ca9 Break compose.js and drafts.js dependency. 2017-05-08 14:43:49 -07:00
wangjames 744f4aa663 Fix modals dependency cycle.
This commit forces the files that create modals to create their own
modal closing function instead of creating all of them in the modals
file. These functions are then passed to the modals.close object. This
is intended to remove modals.js's dependencies on these other files.
2017-04-24 14:30:02 -07:00
Steve Howell c999bdf823 compose: Distinguish get_message_type() from composing().
We now only call compose_state.composing() in a boolean context,
where we simply care whether or not the compose box is open.  The
function now also returns true/false.

Callers who need to know the actual message type (e.g. "stream" or
"private") now call compose_state.get_message_type().
2017-04-24 12:42:06 -07:00
Steve Howell 70b7d4c00b Extract compose_state.js.
This is mostly just moving methods out of compose.js.

The variable `is_composing_message`, which isn't a boolean, has
been renamed to `message_type`, and there are new functions
set_message_type() and get_message_type() that wrap it.

This commit removes some shims related to the global variable
`compose_state`; now, `compose_state` is a typical global
variable with a 1:1 relationship with the module by the same
name.

The new module has 100% line coverage, most of it coming
via the tests on compose_actions.js.  (The methods here are
super simple, so it's a good thing that the tests are somewhat
integrated with a higher layer.)
2017-04-18 12:26:58 -07:00
Joshua Pan 6fe567846c Extract drafts_scroll() function.
Fixes #4334.
2017-04-18 12:14:41 -07:00
Joshua Pan 0377b5aba6 Extract drafts_initialize_focus().
This function takes care of focusing a draft if a draft
is not already focused in draft modal.
2017-04-18 12:14:41 -07:00
Joshua Pan 6fe26b6c04 Extract drafts process enter key to drafts.js.
Extracted draft code from hotkey.process_enter_key to drafts.js.
2017-04-18 12:14:41 -07:00
Brock Whittaker e3d510154d drafts: Move the draft empty placeholder logic to template render path.
This moves the logic to embed the translated string “(no topic)” to
only render in the handlebars template rather than saving in
localStorage and therefore being added to the message topic and
eventually put in the database if not changed.

Fixes: #4378.
2017-04-12 14:15:31 -07:00
Steve Howell 4a3211d6af hotkeys: Clean up dispatching of drafts hotkeys.
We now explicitly return true from process_hotkey() when we
handle up/down/backspace for the drafts modal.  Also, we no longer
call preventDefault() from drafts.draft_handle_events(), since the
caller does that, and we no longer return `true`, since we were
never inspecting the return value anyway.
2017-04-05 11:53:52 -07:00
Sampriti Panda 32e76c2c60 drafts: Move snapshot_message from compose to drafts
Previously drafts called compose.snapshot_message which would then
get the message object from compose.create_message_object. This method often
checked for the validity of stream/user recipients which would often cause tracebacks.

The new method in drafts.snapshot message just gets the data from the fields and
stores them in the draft model without any additional checking.
2017-03-30 10:20:37 -07:00
JPJPJPOPOP f7d2889c1d drafts.js: Prevent delete from triggering in the back of draft overlay.
Fixes #4340.
2017-03-27 18:13:57 -07:00
Jonathan Pan 5556d2341c hotkey.js: Add hotkey for drafts.
* 'd' in message view opens drafts.

This also adds hotkeys within the drafts UI:
* Up/down arrow keys navigate the drafts.
* Pressing enter edits the selected draft.
* Pressing backspace deletes the selected draft.

Some variable names tweaked by tabbott.
2017-03-27 14:05:00 -07:00
Steve Howell faa9446e64 Add compose_actions.start() shim. 2017-03-18 15:52:50 -07:00
Brock Whittaker b0e5aeb313 Consolidate JavaScript modal closing in modals.js.
This consolidates all actions to close modals into modals.js and
triggers the correct cleaning/collapsing function dependent on what the
data-overlay attribute is labeled as.

It also ensures these all have an e.stopPropagation().

Fixes #4029.
2017-03-15 12:27:44 -07:00
Brock Whittaker 2e30cef8e9 Change "hashchange.exit_settings" to "hashchange.exit_modal".
Change the name of the hashignore and replace mechanism from
exit_settings to exit_modals since it is now used for more than just
the settings.
2017-03-15 12:17:27 -07:00
Aman Khantaal f0a9b7e4a1 Drafts: Click on a message will open it for edit. 2017-02-28 10:10:12 -08:00
Sampriti Panda 1929cc5190 Implement persistent drafts functionality
* Created a drafts modal to display/restore/delete drafts
* Created a Draft model to support storing draft data in localstorage
* Removed existing restore-draft functionality
* Added casper and node tests for drafts functionality

Fixes #1717.
2017-02-23 02:58:23 -08:00