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) * [`getScrollPosition`](#getscrollposition)
* [`getURLParameters`](#geturlparameters) * [`getURLParameters`](#geturlparameters)
* [`hasClass`](#hasclass) * [`hasClass`](#hasclass)
* [`hide`](#hide)
* [`httpsRedirect`](#httpsredirect) * [`httpsRedirect`](#httpsredirect)
* [`redirect`](#redirect) * [`redirect`](#redirect)
* [`scrollToTop`](#scrolltotop) * [`scrollToTop`](#scrolltotop)
* [`show`](#show)
* [`toggleClass`](#toggleclass) * [`toggleClass`](#toggleclass)
</details> </details>
@ -1787,6 +1789,29 @@ hasClass(document.querySelector('p.special'), 'special'); // true
[⬆ Back to top](#table-of-contents) [⬆ 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 ### 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. 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) [⬆ 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 ### toggleClass
Toggle a class for an element. Toggle a class for an element.

View File

@ -161,9 +161,11 @@
<a class="sublink-1" href="#getscrollposition">getScrollPosition</a> <a class="sublink-1" href="#getscrollposition">getScrollPosition</a>
<a class="sublink-1" href="#geturlparameters">getURLParameters</a> <a class="sublink-1" href="#geturlparameters">getURLParameters</a>
<a class="sublink-1" href="#hasclass">hasClass</a> <a class="sublink-1" href="#hasclass">hasClass</a>
<a class="sublink-1" href="#hide">hide</a>
<a class="sublink-1" href="#httpsredirect">httpsRedirect</a> <a class="sublink-1" href="#httpsredirect">httpsRedirect</a>
<a class="sublink-1" href="#redirect">redirect</a> <a class="sublink-1" href="#redirect">redirect</a>
<a class="sublink-1" href="#scrolltotop">scrollToTop</a> <a class="sublink-1" href="#scrolltotop">scrollToTop</a>
<a class="sublink-1" href="#show">show</a>
<a class="sublink-1" href="#toggleclass">toggleClass</a> <a class="sublink-1" href="#toggleclass">toggleClass</a>
<h3>Date <h3>Date
@ -868,6 +870,13 @@ Pass <code>location.search</code> as the argument to apply to the current <code>
</code></pre> </code></pre>
<pre><code class="language-js">hasClass(document.querySelector('p.special'), 'special'); // true <pre><code class="language-js">hasClass(document.querySelector('p.special'), 'special'); // true
</code></pre> </code></pre>
</div></div><br/><div class="card fluid"><div class="section double-padded"><h3 id="hide">hide</h3></div><div class="section double-padded">
<p>Hides all the elements specified.</p>
<p>Use the spread operator (<code>...</code>) and <code>Array.forEach()</code> to apply <code>display: none</code> to each element specified.</p>
<pre><code class="language-js">const hide = (...el) =&gt; [...el].forEach(e =&gt; (e.style.display = 'none'));
</code></pre>
<pre><code class="language-js">hide(document.querySelectorAll('img')); // Hides all &lt;img&gt; elements on the page
</code></pre>
</div></div><br/><div class="card fluid"><div class="section double-padded"><h3 id="httpsredirect">httpsRedirect</h3></div><div class="section double-padded"> </div></div><br/><div class="card fluid"><div class="section double-padded"><h3 id="httpsredirect">httpsRedirect</h3></div><div class="section double-padded">
<p>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.</p> <p>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.</p>
<p>Use <code>location.protocol</code> to get the protocol currently being used. If it's not HTTPS, use <code>location.replace()</code> to replace the existing page with the HTTPS version of the page. Use <code>location.href</code> to get the full address, split it with <code>String.split()</code> and remove the protocol part of the URL.</p> <p>Use <code>location.protocol</code> to get the protocol currently being used. If it's not HTTPS, use <code>location.replace()</code> to replace the existing page with the HTTPS version of the page. Use <code>location.href</code> to get the full address, split it with <code>String.split()</code> and remove the protocol part of the URL.</p>
@ -898,6 +907,13 @@ Scroll by a fraction of the distance from the top. Use <code>window.requestAnima
</code></pre> </code></pre>
<pre><code class="language-js">scrollToTop(); <pre><code class="language-js">scrollToTop();
</code></pre> </code></pre>
</div></div><br/><div class="card fluid"><div class="section double-padded"><h3 id="show">show</h3></div><div class="section double-padded">
<p>Shows all the elements specified.</p>
<p>Use the spread operator (<code>...</code>) and <code>Array.forEach()</code> to clear the <code>display</code> property for each element specified.</p>
<pre><code class="language-js">const show = (...el) =&gt; [...el].forEach(e =&gt; (e.style.display = ''));
</code></pre>
<pre><code class="language-js">show(document.querySelectorAll('img')); // Shows all &lt;img&gt; elements on the page
</code></pre>
</div></div><br/><div class="card fluid"><div class="section double-padded"><h3 id="toggleclass">toggleClass</h3></div><div class="section double-padded"> </div></div><br/><div class="card fluid"><div class="section double-padded"><h3 id="toggleclass">toggleClass</h3></div><div class="section double-padded">
<p>Toggle a class for an element.</p> <p>Toggle a class for an element.</p>
<p>Use <code>element.classList.toggle()</code> to toggle the specified class for the element.</p> <p>Use <code>element.classList.toggle()</code> to toggle the specified class for the element.</p>

13
snippets/hide.md Normal file
View File

@ -0,0 +1,13 @@
### 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'));
```
```js
hide(document.querySelectorAll('img')); // Hides all <img> elements on the page
```

13
snippets/show.md Normal file
View File

@ -0,0 +1,13 @@
### 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 = ''));
```
```js
show(document.querySelectorAll('img')); // Shows all <img> elements on the page
```

View File

@ -57,6 +57,7 @@ hammingDistance:math
hasClass:browser hasClass:browser
head:array head:array
hexToRGB:utility hexToRGB:utility
hide:browser
httpsRedirect:browser httpsRedirect:browser
initial:array initial:array
initialize2DArray:array initialize2DArray:array
@ -112,6 +113,7 @@ scrollToTop:browser
sdbm:utility sdbm:utility
select:object select:object
shallowClone:object shallowClone:object
show:browser
shuffle:array shuffle:array
similarity:array similarity:array
sleep:function sleep:function