Merge remote-tracking branch 'origin/master'

This commit is contained in:
Angelos Chalaris
2017-12-29 00:18:58 +02:00
5 changed files with 92 additions and 0 deletions

View File

@ -92,9 +92,11 @@
* [`getScrollPosition`](#getscrollposition)
* [`getURLParameters`](#geturlparameters)
* [`hasClass`](#hasclass)
* [`hide`](#hide)
* [`httpsRedirect`](#httpsredirect)
* [`redirect`](#redirect)
* [`scrollToTop`](#scrolltotop)
* [`show`](#show)
* [`toggleClass`](#toggleclass)
</details>
@ -1787,6 +1789,29 @@ hasClass(document.querySelector('p.special'), 'special'); // true
[⬆ Back to top](#table-of-contents)
### hide
Hides all the elements specified.
Use the spread operator (`...`) and `Array.forEach()` to apply `display: none` to each element specified.
```js
const hide = (...el) => [...el].forEach(e => (e.style.display = 'none'));
```
<details>
<summary>Examples</summary>
```js
hide(document.querySelectorAll('img')); // Hides all <img> elements on the page
```
</details>
[⬆ Back to top](#table-of-contents)
### httpsRedirect
Redirects the page to HTTPS if its currently in HTTP. Also, pressing the back button doesn't take it back to the HTTP page as its replaced in the history.
@ -1863,6 +1888,29 @@ scrollToTop();
[⬆ Back to top](#table-of-contents)
### show
Shows all the elements specified.
Use the spread operator (`...`) and `Array.forEach()` to clear the `display` property for each element specified.
```js
const show = (...el) => [...el].forEach(e => (e.style.display = ''));
```
<details>
<summary>Examples</summary>
```js
show(document.querySelectorAll('img')); // Shows all <img> elements on the page
```
</details>
[⬆ Back to top](#table-of-contents)
### toggleClass
Toggle a class for an element.