Commit Graph

26 Commits

Author SHA1 Message Date
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
Anders Kaseorg 4ad00c1aea lightbox_canvas: Remove old-style window.onload handler.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-07-24 16:32:53 -07:00
Anders Kaseorg fc21417d67 lightbox_canvas: Convert LightboxCanvas to an ES6 class.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-07-24 16:32:53 -07:00
Anders Kaseorg d5a0ee612f lightbox_canvas: Make parameter type error fatal.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-07-24 16:32:53 -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 a79322bc94 eslint: Enable prefer-arrow-callback.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-07-03 16:55:50 -07:00
Anders Kaseorg 0ad8fff35d lightbox_canvas: Clear canvas with less obfuscation.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-05-26 23:33:40 -07:00
Hashir Sarwar 2a80f4109a lightbox_canvas: Return from sizeCanvas() if parentNode is null.
The value of `canvas.parentNode` in `sizeCanvas()`
appears to be `null` sometimes and it throwed an
exception specially when you switch images from
the images-list quickly.
2020-04-05 13:06:03 -07:00
Stefan Weil d2fa058cc1
text: Fix some typos (most of them found and fixed by codespell).
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2020-03-27 17:25:56 -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 02004c9b0f js: Convert self-referential vars to const.
ESLint won’t convert these automatically because it can’t rule out a
behavior difference arising from an access to a self-referential var
before it’s initialized:

> var x = (f => f())(() => x);
undefined
> let y = (f => f())(() => y);
Thrown:
ReferenceError: Cannot access 'y' before initialization
    at repl:1:26
    at repl:1:15

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-10-28 15:02:43 -07: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
Marco Burstein 3ae5e40f8f lightbox: Make `v` close the lightbox during Pan & Zoom.
When Pan & Zoom (canvas) is enabled, the `v` hotkey does not work due to
`LightboxCanvas` overriding the `keydown` event. Add `v` as an option in
the new listener.

Fix #9777.
2018-07-23 10:36:48 -07:00
Armaan Ahluwalia ba6543b850 webpack: Fix missing exposed modules left out of transition.
This commit fixes some modules that were erroneously left out while
transitioning app.js to webpack. This commit exposes them using
expose-loader or setting them directly to window.
2018-07-07 08:00:34 +02: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 80a2d5bc59 eslint: Enable `conditionalAssign` config of no-trailing-spaces rule. 2018-06-11 07:51:24 -04:00
Shubham Dhama dcb6254a4e eslint: Enable `no-extra-parens` rule.
Following sub-configuration is disabled:
                "nestedBinaryExpressions": false,
2018-06-11 07:51:24 -04:00
Tim Abbott 7ab8a8e820 js: Fix a bunch of indentation issues found by eslint.
This is preparation for enabling an eslint indentation configuration.
90% of these changes are just fixes for indentation errors that have
snuck into the codebase over the years; the others are more
significant reformatting to make eslint happy (that are not otherwise
actually improvements).

The one area that we do not attempt to work on here is the
"switch/case" indentation.
2018-05-06 16:25:02 -07:00
Abhigyan Khaund 6f15e635d2 hotkeys: Add shortcuts for pan and zoom in lightbox view
This commit adds support for '+' and 'Z' for "zoom in" and '-' and 'z'
for "zoom out" shortcut keys in the lightbox image viewer for Pan and
Zoom.

Fixes: #8689.
2018-04-03 09:20:55 -07:00
Tim Abbott c657db77e8 lightbox_canvas: Fix use of unsupported const. 2017-08-05 16:47:11 -07:00
Brock Whittaker e22920bef6 Fix lightbox zoom issues.
This fixes the lightbox zoom issues that occurred on some browsers
due to the units of `deltaY` being in lines rathern than pixels,
making it incredibly slow to zoom.
2017-08-05 15:47:34 -07:00
Brock Whittaker 7eb41c5f7e Make lightbox canvas feature cross-browser compatible.
This makes the canvas zoom and pan feature cross-browser compatible in
a few ways:

1. Replace deprecated `mousewheel` event in favor of the similar and
cross-browser event `wheel`.

2. Create approximate substitute for `e.movementX` and `e.movementY`
values that are missing in Safari.
2017-07-31 17:03:31 -07:00
Brock Whittaker 8445f886d7 Add ability to pan and zoom lightbox images.
This adds the ability to pan and zoom lightbox images because they
are now converted to <canvas> elements.
2017-07-31 17:03:31 -07:00