forked from vert3x/OL_videoserver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gridlistview.js
44 lines (36 loc) · 1.12 KB
/
gridlistview.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
// Get the elements with class="column"
var elements = document.getElementsByClassName("column");
// Declare a loop variable
var i;
// List View
function listView()
{
for (i = 0; i < elements.length; i++)
{
elements[i].style.width = "100%";
}
}
// Grid View
function gridView()
{
for (i = 0; i < elements.length; i++)
{
elements[i].style.width = "25%";
}
}
/* Optional: Add active class to the current button (highlight it)
var container = document.getElementById("btnContainer");
var btns = container.getElementsByClassName("btn");
for (var i = 0; i < btns.length; i++) {
btns[i].addEventListener("click", function() {
var current = document.getElementsByClassName("active");
current[0].className = current[0].className.replace(" active", "wwww");
this.className += " active";
});
}
*/
$(document).ready(function() {
$('#list').click(function(event){event.preventDefault();$('#products .item').addClass('list-group-item');});
$('#grid').click(function(event){event.preventDefault();$('#products .item').removeClass('list-group-item');$('#products .item').addClass('grid-group-item');});
});