Commit Graph

35 Commits

Author SHA1 Message Date
Anders Kaseorg d17b577d0c js: Purge useless IIFEs.
With webpack, variables declared in each file are already file-local
(Global variables need to be explicitly exported), so these IIFEs are
no longer needed.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2019-10-25 13:51:21 -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 3c3471b720 templates: Rename *.handlebars ↦ *.hbs and - ↦ _.
Tweaked by tabbott to avoid accidentally disabling the linter for
handlebars templates.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-07-12 21:11:03 -07:00
Thomas Ip f6aaf43029 refactor: Use explicit path when referencing handlebars templates. 2019-07-02 16:23:30 -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
Vishnu Ks a288cfc43a uploads: Show used upload space in attachments UI. 2019-03-07 20:18:00 -08:00
Vishnu Ks 6af885bd5c attachments: Export bytes_to_size function. 2019-03-04 18:46:13 -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
Cynthia Lin b27201056c attachments ui: Initialize table sorted by Date uploaded column.
Previously we only added the active class to the Date uploaded
column, thinking it was already sorted by upload date by default.
However, it wasn't, so now we explicitly make a call to sort it by upload
date to fix an issue with broken sorting.

Fixes #10518.
2018-10-02 11:32:45 -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 eaeaf2d851 list_render: Remove rows sort click handler from the body.
This removes the click handler previously attached to the body, now
we just need to pass `parent_container` which at least contains the
table heads.
2018-06-22 09:21:47 -04:00
Shubham Dhama 2aba7c239f list_render: Make list creation logic as an export in list_render module.
This changes how we create lists i.e.
    from `list_render($container, list, opts)`
        to `list_render.create($container, list, opts)`
2018-06-22 09:21:47 -04:00
Shubham Dhama 80a2d5bc59 eslint: Enable `conditionalAssign` config of no-trailing-spaces rule. 2018-06-11 07:51:24 -04:00
Tim Abbott 43fa0aacbf attachments: Implement frontend for real-time sync.
We now do real-time sync to update the attachments UI when new
attachments are uploaded/deleted.

While we're at it, we fix the UI for the delete option to not do a
weird local echo thing.

This completes the work of a couple issues.  There's still useful
performance work to do here (see the TODO), but it's a minor issue in
a rarely-used screen.

Fixes #6731.
Fixes #3710.
2018-05-04 16:22:27 -07:00
Tim Abbott 19737aab3e attachments: Store the attachments state in a global. 2018-05-04 16:22:27 -07:00
Tim Abbott 802636fbde attachments: Extract format_attachments_data. 2018-05-04 16:22:27 -07:00
Tim Abbott 62a92764f1 attachments: Move one-time-rendering logic out of set_up_attachments. 2018-05-04 16:22:27 -07:00
Tim Abbott 02ad498aa2 attachments: Use data-attachment-id to refer to attachments.
This may fix an issue with the delete button not actually sending the
right data to the server; I'm not sure.  Extracted from a patch by
Aastha Gupta.
2018-05-04 16:22:27 -07:00
Tim Abbott 69c4645bd2 attachments: Stop fetching attachments in / endpoint.
We only use this data in a rarely-used settings screen, and it can be
large after years of posting screenshots.

So optimize the performance of / by just loading these data when we
actually visit the page.

This saves about 300ms of runtime for loading the home view for my
user account on chat.zulip.org.
2018-05-04 16:22:26 -07:00
sreenivas alapati a2fa087235 attachments_ui: Remove unnecessary export of bytes_to_size. 2018-03-15 18:06:04 -07:00
Utkarsh Patil c2441e4455 user settings: Clean settings.css and fix bug
Clean up settings.css and fix js bug in attachments_ui.js
2017-12-18 10:12:33 -05:00
Utkarsh Patil c9596e12be user settings: fix uploaded files UI
Fix UI and date uploaded
2017-12-18 10:12:33 -05:00
Utkarsh Patil b3d7a87552 user settings: Change file size display format
Display 1MB for 1000KB and display atleast 2 sig digits from 'KB' onwards
2017-12-18 10:12:33 -05:00
Utkarsh Patil 25f742839d user settings: change 'Date uploaded' display format
Display 'Today' or 'Yesterday' and the date for days beyond those
2017-12-18 10:12:33 -05:00
Brock Whittaker 8e2d9d64b2 settings: Enable sorting on uploads table.
This allows for sorting in the uploads table by all of the attributes
in ascending order by clicking on the headers.

Fixes #6747.
2017-09-28 16:16:16 -07:00
Brock Whittaker 24b5030776 settings: Add perfectScrollbar to uploads table.
This adds the perfectScrollbar to the uploads table so that it will
function properly in the settings container since the parent node has a
perfectScrollbar.
2017-09-28 14:13:33 -07:00
Brock Whittaker 7b8fd1aafb settings: Add file search to the uploads table.
This uses the searching capabilities of the list_render class to search
for files by name; normalized by lowercase locale.
2017-09-28 14:13:33 -07:00
Brock Whittaker 7882039a11 settings: Add `list_render` basics to the uploads table.
This implements the basic form of list_render to the uploads table so
it will now load progressively.

Fixes: #6746.
2017-09-28 14:13:33 -07:00
Vishnu Ks 17cc32f168 settings: Show error or success message when deleting uploaded files.
Fixes #6519
2017-09-27 17:50:22 -07:00
Vishnu Ks 865bc06945 settings: Show attachment size and upload date in uploaded files page. 2017-09-27 17:50:22 -07:00
Rafid Aslam 1143a2d8c4 attachment: Add file icon to the green box when file has no extension.
Fixes #3848.
2017-03-09 00:56:37 -08:00
Tim Abbott a8d8855624 attachment: Avoid inserting into the DOM in a loop.
This has a huge impact on the performance of loading the settings page
if you have a decent number of past uploaded files.
2017-03-08 16:20:50 -08:00
Brock Whittaker c35d821786 Restyle uploaded files table.
This restyles the uploaded files table to be lighter, more minimal, and
easier to parse than the previous table.
2017-02-24 15:05:06 -08:00
Brock Whittaker e504eaaa68 Change time render to be client-side and formatted.
This changes the time render to be done on the client-side and
therefore take advantage of knowing the client’s timezone, along with
being formatted in a more human-parseable way.
2017-02-24 15:05:06 -08:00
paxapy 9a5179c460 Add support for managing and deleting attachments.
Modified substantially by tabbott to fix tons of issues.

Fixes #454.
2017-02-16 23:44:44 -08:00