Changes for page Academy

Last modified by Erik Bakker on 2024/09/24 16:12

From version 40.1
edited by Erik Bakker
on 2022/04/21 15:58
Change comment: There is no comment for this version
To version 38.1
edited by Erik Bakker
on 2022/04/21 15:54
Change comment: There is no comment for this version

Summary

Details

XWiki.GadgetClass[1]
content
... ... @@ -11,10 +11,16 @@
11 11  /* Create two equal columns that floats next to each other */
12 12  .column {
13 13   float: left;
14 - width: "50%";
14 + width: 50%;
15 15   padding: 10px;
16 16  }
17 17  
18 +/* Clear floats after the columns */
19 +.row:after {
20 + content: "";
21 + display: table;
22 + clear: both;
23 +}
18 18  /* Style the buttons */
19 19  .btn {
20 20   border: none;
... ... @@ -36,8 +36,16 @@
36 36  </head>
37 37  <body>
38 38  
45 +<h2>List View or Grid View</h2>
39 39  
47 +<p>Click on a button to choose list view or grid view.</p>
40 40  
49 +<div id="btnContainer">
50 + <button class="btn" onclick="listView()"><i class="fa fa-bars"></i> List</button>
51 + <button class="btn active" onclick="gridView()"><i class="fa fa-th-large"></i> Grid</button>
52 +</div>
53 +<br>
54 +
41 41  <div class="row">
42 42   <div class="column" style="background-color:#aaa;">
43 43   <h2>Column 1</h2>
... ... @@ -60,8 +60,39 @@
60 60   </div>
61 61  </div>
62 62  
77 +<script>
78 +// Get the elements with class="column"
79 +var elements = document.getElementsByClassName("column");
63 63  
81 +// Declare a loop variable
82 +var i;
64 64  
84 +// List View
85 +function listView() {
86 + for (i = 0; i < elements.length; i++) {
87 + elements[i].style.width = "100%";
88 + }
89 +}
90 +
91 +// Grid View
92 +function gridView() {
93 + for (i = 0; i < elements.length; i++) {
94 + elements[i].style.width = "50%";
95 + }
96 +}
97 +
98 +/* Optional: Add active class to the current button (highlight it) */
99 +var container = document.getElementById("btnContainer");
100 +var btns = container.getElementsByClassName("btn");
101 +for (var i = 0; i < btns.length; i++) {
102 + btns[i].addEventListener("click", function() {
103 + var current = document.getElementsByClassName("active");
104 + current[0].className = current[0].className.replace(" active", "");
105 + this.className += " active";
106 + });
107 +}
108 +</script>
109 +
65 65  </body>
66 66  </html>
67 67