* Added Copy Permalink Functionality to Comment Dropdown
Copy functionality is similar to the way 'copy article link' is implemented. It checks for the android bridge first, then the navigator, then fallsback to the default document copy command
Since the codes were really similar, I moved the copy functionality to a function of its own with callbacks and fallbacks as lambdas, and triggered it with the copyArticleLink and the copyPermalink
* Replaced Copy Permalink Callbacks with Promises
* Keep anchor tags instead of buttons (#1)
* copy permalink using anchor tag
* Missing closing button tag
* Adds 'Copied to Clipboard' Snackbar Message
* Patches bug introduced in #10323
Patch suggested in following comment: https://github.com/forem/forem/pull/8311\#pullrequestreview-492011202
* Removes import statement for addSnackbarItem and Suppresses ESLint Error
Initializer runs in global scope
* Unhandles exception when copying permalink so Honeybadger can handle it
* Replaces ButtonListener suffix for copyPermalink method with Listener
Co-authored-by: Fernando Valverde <fernando@visualcosita.com>
What was wrong?
`initializeCommentDropdown` is called when a new comment is added.
`initializeCommentDropdown` calls `addDropdownListener(dropdown)` on all
`.dropbtn` elements. Elements with the `.dropbtn` class already exist on
the page so an extra listener is added to it whenever a comment is
added.
How was it fixed?
Whenever a dropdown listener is added to an element with the
`.dropbtn` class, an attribute is set on that element so we know it
already has a dropdown listener. When we add listeners to elements with
the `.dropbtn` class in the future, we don't add them to elements with
the attribute.
* Adds Clipboard Async API & makes use of Android Native Bridge interface for write post image copy to clipboard
* Checks for clipboard api support before trying to use it
* Adds support for comment dropdown copy link
* Adds AndroidBridge to globals definition
* Fix JavaScript Console errors in /Comments sub-page of any article
- Make use of `document.body.contains()` to check if the element is present before trying to Add or Remove Event listeners or assign attribute values to the same.
* Implement recommendations for changes
- Switch String.match() to Regex.test() in order to have consistent Boolean return.
- Switch if(document.body.contains(element)) to if(element) as no need to check if the element is in visible context, only whether present or not.
* Implement recommendations for changes
- Switch String.match() to Regex.test() in order to have consistent Boolean return for isIOSDevice().
- Switch if(document.body.contains(element)) to if(element) as no need to check if the element is in visible context, only whether present or not.
* Simplify article show page reactions
* Clean up styling and adjust zen mode logic
* Remove unused variables
* Update app/views/articles/_actions.html.erb
Co-Authored-By: Nick Taylor <nick@iamdeveloper.com>
* Small style mods
* Slight padding change
* Finalize new show page button design
* Remove uncompileable JS and small css changes
* Simplify article show page reactions
* Clean up styling and adjust zen mode logic
* Remove unused variables
* Update app/views/articles/_actions.html.erb
Co-Authored-By: Nick Taylor <nick@iamdeveloper.com>
* Small style mods
* Slight padding change
* Finalize new show page button design