1 | (function (window, document) { |
2 | |
3 | var layout = document.getElementById('layout'), |
4 | menu = document.getElementById('menu'), |
5 | menuLink = document.getElementById('menuLink'), |
6 | content = document.getElementById('main'); |
7 | |
8 | function toggleClass(element, className) { |
9 | var classes = element.className.split(/\s+/), |
10 | length = classes.length, |
11 | i = 0; |
12 | |
13 | for(; i < length; i++) { |
14 | if (classes[i] === className) { |
15 | classes.splice(i, 1); |
16 | break; |
17 | } |
18 | } |
19 | // The className is not found |
20 | if (length === classes.length) { |
21 | classes.push(className); |
22 | } |
23 | |
24 | element.className = classes.join(' '); |
25 | } |
26 | |
27 | function toggleAll(e) { |
28 | var active = 'active'; |
29 | |
30 | e.preventDefault(); |
31 | toggleClass(layout, active); |
32 | toggleClass(menu, active); |
33 | toggleClass(menuLink, active); |
34 | } |
35 | |
36 | menuLink.onclick = function (e) { |
37 | toggleAll(e); |
38 | }; |
39 | |
40 | content.onclick = function(e) { |
41 | if (menu.className.indexOf('active') !== -1) { |
42 | toggleAll(e); |
43 | } |
44 | }; |
45 | |
46 | }(this, this.document)); |
Travelled to 7 computer(s): bhatertpkbcr, gwrvuhgaqvyk, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1020397 |
Snippet name: | ui.js |
Eternal ID of this version: | #1020397/1 |
Text MD5: | b2f4886956867b0573dfbf1c9aaada48 |
Author: | stefan |
Category: | javascript |
Type: | Document |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-12-19 15:06:57 |
Source code size: | 1216 bytes / 46 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 300 / 4667 |
Referenced in: | [show references] |