aboutsummaryrefslogtreecommitdiffhomepage
path: root/tpl/js/poche.js
blob: 97d9911dccbe3fff59ddccf8aed2a8dfb125c815 (plain) (blame)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
function toggle_favorite(element, id) {
    $(element).toggleClass('fav-off');
    $.ajax ({
        url: "index.php?action=toggle_fav",
        data:{id:id}
    });
}

function toggle_archive(element, id, view_article) {
    $(element).toggleClass('archive-off');
    $.ajax ({
        url: "index.php?action=toggle_archive",
        data:{id:id}
    });
    var obj = $('#entry-'+id);

    // on vient de la vue de l'article, donc pas de gestion de grille
    if (view_article != 1) {
        $('#content').masonry('remove',obj);
        $('#content').masonry('reloadItems');
        $('#content').masonry('reload');
    }
}

function sort_links(view, sort) {
    $.get('index.php', { view: view, sort: sort, full_head: 'no' }, function(data) {
      $('#content').html(data);
    });
}


// ---------- Swith light or dark view
function setActiveStyleSheet(title) {
	var i, a, main;
	for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
		if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
			a.disabled = true;
			if(a.getAttribute("title") == title) a.disabled = false;
		}
	}
}
$('#themeswitch').click(function() {
	// we want the dark
	if ($('body').hasClass('light-style')) {
		setActiveStyleSheet('dark-style');
		$('body').addClass('dark-style');
		$('body').removeClass('light-style');
		$('#themeswitch').text('light');
	// we want the light
	} else if ($('body').hasClass('dark-style')) {
		setActiveStyleSheet('light-style');
		$('body').addClass('light-style');
		$('body').removeClass('dark-style');
		$('#themeswitch').text('dark');
	}
	return false;
});