Commit Graph

42 Commits

Author SHA1 Message Date
Anders Kaseorg 9dbb43eb71 realm_logo: Add fallback for MediaQueryList.addEventListener.
MediaQueryList.addEventListener is missing in Safari < 14:
https://caniuse.com/mdn-api_mediaquerylist_eventtarget_inheritance

Fixes #23915.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-12-27 10:28:20 -08:00
Anders Kaseorg 21f8d26040 dark_theme: Move color scheme classes from body to root element.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-27 13:18:52 -08:00
Rohitt Vashishtha 7e883add5b dark_theme: Re-render realm-logo on prefers-color-scheme changes.
We already re-rendered the realm-logo when the user selects either
the light or dark color scheme, but on `color-scheme-automatic`,
we didn't have any event handlers to trigger a render. This commit
adds a handler to listen for changes to `prefers-color-scheme` property.

Fixes #23548.
2022-11-15 10:35:31 -08:00
Anders Kaseorg f84a2c08d5 js: Prefix jQuery object variable names with $.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-03-16 12:52:07 -07:00
Sahil Batra dcd6da0351 misc: Replace "night" and "day" with "dark" and "light".
This commit replaces "night" and "day" used in the context
of themes with "dark" and "light".
2021-11-26 22:03:29 -08:00
Sahil Batra f49346892f misc: Replace "day mode" with "light theme" in comments. 2021-11-26 22:03:29 -08:00
Sahil Batra 88e21d0387 misc: Replace "night mode" with "dark theme" in comments. 2021-11-26 22:03:29 -08:00
sahil839 0594207180 realm_logo: Rename realm_logo.rerender to realm_logo.render.
As realm_logo.rerender is now used for initial rendering of
logo as well in c8849f8, so we rename this function from
rerender to render.
2021-07-19 09:45:29 -07:00
sahil839 a3f7639af3 settings: Extract code for checking night-mode setting.
We extract the code for checking night mode setting on
the basis of color_scheme value and using matchMedia when
color_scheme is set to automatic. This is currently used
in rendering the correct logo only.

This is a prep commit for fixing loading indicator not
visible on message-edit button in night-mode.
2021-07-08 09:43:32 -07:00
Gaurav Pandey 1da818f848 register api: Rename max_logo_file_size.
Renaming `max_logo_file_size` to `max_logo_file_size_mib`
reflecting the file size in mebibyte and update the frontend.
2021-05-26 11:38:24 -07:00
Anders Kaseorg 38ffd47b90 js: Convert static/js/page_params.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-26 10:17:56 -07:00
Anders Kaseorg ea9ca6b7d0 js: Use jQuery as a module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-12 10:08:25 -08:00
Anders Kaseorg 5ebc3f1477 js: Convert static/js/realm_logo.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg e64c7a9efe js: Convert static/js/upload_widget.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 09920af211 js: Convert static/js/channel.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg d72423ef21 eslint: Replace empty-returns with consistent-return.
Instead of prohibiting ‘return undefined’ (#8669), we require that a
function must return an explicit value always or never.  This prevents
you from forgetting to return a value in some cases.  It will also be
important for TypeScript, which distinguishes between undefined and
void.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-09-25 15:17:59 -07:00
Anders Kaseorg 6ec808b8df js: Add "use strict" directive to CommonJS files.
ES and TypeScript modules are strict by default and don’t need this
directive.  ESLint will remind us to add it to new CommonJS files and
remove it from ES and TypeScript modules.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-07-31 22:09:46 -07:00
jagansivam28 90cb72b103 upload widget: Rename image upload widget delete button CSS class.
Previously, image upload widget delete button CSS class name was
`settings-page-delete-button`.
We can change the CSS class name to `image-delete-button`
so that the name can be more generic.
2020-07-21 16:19:20 -07:00
Anders Kaseorg 96dcc0ce6e js: Use ES6 object literal shorthand syntax.
Generated by ESLint.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-07-21 12:42:22 -07:00
Anders Kaseorg b65d2e063d js: Reformat with Prettier.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-07-17 14:31:25 -07:00
Anders Kaseorg f3726db89a js: Normalize strings to double quotes.
Prettier would do this anyway, but it’s separated out for a more
reviewable diff.  Generated by ESLint.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-07-17 14:31:24 -07:00
Anders Kaseorg e014ea966a eslint: Enable comma-dangle for functions.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-07-03 16:55:51 -07:00
Anders Kaseorg a79322bc94 eslint: Enable prefer-arrow-callback.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-07-03 16:55:50 -07:00
MariaGkoulta b10f156250 settings: Add automatic theme detection feature.
With this implementation of the feature of the automatic theme
detection, we make the following changes in the backend, frontend and
documentation.

This replaces the previous night_mode boolean with an enum, with the
default value being to use the prefers-color-scheme feature of the
operating system to determine which theme to use.

Fixes: #14451.

Co-authored-by: @kPerikou <44238834+kPerikou@users.noreply.github.com>
2020-06-21 01:09:01 -07:00
jagansivam28 548107632c settings org: Use `image_upload_widget.hbs` for realm day/night logo.
Now we can use common HTML image upload widget template
`image_upload_widget.hbs` for realm day/night logo and
we should access those day/night logo elements using
e.g., "#realm-day/night-logo-upload-widget .realm-logo-elements".
since we use image_upload_widget.hbs for realm day/night logo upload
widget we need to extract CSS for realm day/night logo and
place them separately under `#realm-day-logo-upload-widget`
and `#realm-day-logo-upload-widget` css id.
2020-06-17 17:47:49 -07:00
sahil839 2491bcdd84 realm_logo: Fix incorrect display of realm logo delete button.
This commit fixes the bug of incorrectly showing/hiding the
realm logo delete button by using realm_night_logo_source for
checking the source of night mode logo instead of previously
used realm_logo_source for both day and night logos.
2020-05-12 11:59:06 -07:00
Pranav d91d32adfc settings ui: Hide buttons to add/delete organization logo for nonadmins.
Users are unable to modify organization's logos, but disabled
buttons for the same are being shown to the user on the organization
settings page. This commit removes those buttons. The file
realm-logo-widget.hbs renders those buttons only if the user is an
admin and realm_logo.js has been updated to allow operations
(like click) on the buttons only to admins.
2020-04-06 15:36:02 -07:00
Anders Kaseorg 28f3dfa284 js: Automatically convert var to let and const in most files.
This commit was originally automatically generated using `tools/lint
--only=eslint --fix`.  It was then modified by tabbott to contain only
changes to a set of files that are unlikely to result in significant
merge conflicts with any open pull request, excluding about 20 files.
His plan is to merge the remaining changes with more precise care,
potentially involving merging parts of conflicting pull requests
before running the `eslint --fix` operation.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-11-03 12:42:39 -08:00
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 5f590d3500 js: Remove /* eslint indent: "off" */ comments.
The time has come to dedent these files.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-10-25 13:21:43 -07:00
Pragati Agrawal 4d0a94a3b1 org settings: Replace usage of ids with classes for delete button. 2019-08-21 15:49:25 -07:00
Pragati Agrawal c29b197ec7 org settings: Replace usage of ids with classes for upload button. 2019-08-21 15:49:25 -07:00
Pragati Agrawal 707e012af0 realm_logo: Refactor `realm_logo.rerender` function to be more clean.
This creates/extract a function `change_logo_delete_button`.
2019-08-21 15:49:25 -07:00
Pragati Agrawal 34d2616158 org settings: Use `.realm-logo-file-input-error` to identify input errors.
This replaces `realm_logo_file_input_error` and
`realm_night_logo_file_input_error` with one class.
2019-08-21 15:49:25 -07:00
Pragati Agrawal c214d184d0 org settings: Replace logo's file input ids with `.realm-logo-file-input`. 2019-08-21 15:49:25 -07:00
Pragati Agrawal a6cd0b8788 org settings: Use `realm-logo-img` class as identifier of realm logo image.
This replaces previously being used ids, `realm-settings-logo` and
`realm-settings-night-logo` with a common class `realm-logo-img`.
2019-08-21 15:49:25 -07:00
Pragati Agrawal 2ccf5655da realm_logo: Refactor `build_realm_logo_widget` function.
As a follow up of commit (bf1c9420df), this
commit removes the `build_realm_day_mode_logo_widget` and
`build_realm_night_mode_logo_widget` function , and changes
`build_realm_logo_widget` to take single argument `is_night` and depending
on this argument, corresponding `day mode` or `night_mode` widget is
handled.
2019-03-14 17:05:22 -07:00
Pragati Agrawal bf1c9420df org_settings: Refactor `build_realm_logo_widget` function.
This commit deduplicates the code for `build_realm_logo_widget` and
`build_realm_night_logo_widget`. It deduplicates the common code for
`build_realm_day_mode_logo_widget` & `build_realm_night_mode_logo_widget`
into tthe function `build_realm_logo_widget`.
2019-03-07 12:12:00 -08:00
Tim Abbott 16123c9a58 realm_logo: Fix synchronization of realm night logo.
The night logo synchronization on the settings page was perfect, but
the actual display logic had a few problems:

* We were including the realm_logo in context_processors, even though
  it is only used in home.py.
* We used different variable names for the templating in navbar.html
  than anywhere else the codebase.

* The behavior that the night logo would default to the day logo if
  only one was uploaded was not correctly implemented for the navbar
  position, either in the synchronization for updates code or the
  logic in the navbar.html templates.
2019-03-02 09:45:50 -08:00
Tim Abbott 4df8a2ac0f settings: Fix handling of day logo without night logo.
In this case, we should just use the day logo for both themes.
2019-02-20 17:55:48 -08:00
sahil839 7157edf4af settings: Add support for uploading logo for night mode.
This adds a new field named realm_night_logo which is used for
displaying the organization logo when the user is in night mode.

Fixes #11176.
2019-02-18 15:15:57 -08:00
Joshua Pan ad1df0ebeb settings: Add support for customizing the top-left logo.
This adds a new realm_logo field, which is a horizontal-format logo to
be displayed in the top-left corner of the webapp, and any other
places where we might want a wide-format branding of the organization.

Tweaked significantly by tabbott to rebase, fix styling, etc.

Fixing the styling of this feature's loading indicator caused me to
notice the loading indicator for the realm_icon feature was also ugly,
so I fixed that too.

Fixes #7995.
2018-12-18 12:44:52 -08:00