checkbox for tree view

Conflicts:
	js/post-hover.js
This commit is contained in:
topkek 2014-11-28 01:15:10 +00:00 committed by czaks
parent 1888e174b3
commit 8de9b68f5f
2 changed files with 9 additions and 13 deletions

View File

@ -54,7 +54,6 @@ if (active_page == 'thread' || active_page == 'index') {
$(document).ready(function(){ $(document).ready(function(){
var favorites = JSON.parse(localStorage.favorites); var favorites = JSON.parse(localStorage.favorites);
var is_board_favorite = ~$.inArray(board_name, favorites); var is_board_favorite = ~$.inArray(board_name, favorites);
console.log(is_board_favorite);
$('header>h1').append('<a id="favorite-star" href="#" data-active="'+(is_board_favorite ? 'true' : 'false')+'" style="color: '+(is_board_favorite ? 'yellow' : 'grey')+'; text-decoration:none">\u2605</span>'); $('header>h1').append('<a id="favorite-star" href="#" data-active="'+(is_board_favorite ? 'true' : 'false')+'" style="color: '+(is_board_favorite ? 'yellow' : 'grey')+'; text-decoration:none">\u2605</span>');
add_favorites(); add_favorites();

View File

@ -31,10 +31,8 @@ $(function() {
if (active_page == 'thread') if (active_page == 'thread')
$(function() { $(function() {
var treeview_on = false; var treeview = function(enable) {
var treeview = function() { if (enable === true) {
if (!treeview_on) {
treeview_on = true;
$('.post.reply').each(function(){ $('.post.reply').each(function(){
var references = []; var references = [];
$(this).find('.body a').each(function(){ $(this).find('.body a').each(function(){
@ -56,23 +54,22 @@ $(function() {
br.detach().insertAfter(post); br.detach().insertAfter(post);
}); });
} else { } else {
treeview_on = false;
$('.post.reply').sort(function(a,b) { $('.post.reply').sort(function(a,b) {
return parseInt(a.id.replace('reply_', '')) - parseInt(b.id.replace('reply_', '')); return parseInt(a.id.replace('reply_', '')) - parseInt(b.id.replace('reply_', ''));
}).each(function () { }).each(function () {
var post = $(this); var post = $(this);
var br = post.next(); var br = post.next();
post.detach().css('margin-left', '0').appendTo('.thread'); post.detach().css('margin-left', '').appendTo('.thread');
br.detach().insertAfter(post); br.detach().insertAfter(post);
}); });
} }
} }
if (localStorage.treeview === 'true') {
treeview();
}
$('hr:first').before('<div id="treeview" style="text-align:right"><a class="unimportant" href="javascript:void(0)"></a></div>'); $('hr:first').before('<div class="unimportant" style="text-align:right"><label for="treeview"><input type="checkbox" id="treeview"> '+_('Tree view')+'</label></div>');
$('div#treeview a') $('input#treeview').on('change', function(e) { treeview($(this).is(':checked')); });
.text(_('Tree view'))
.click(function(e) { treeview(); e.preventDefault(); }); if (localStorage.treeview === 'true') {
treeview(true);
$('input#treeview').attr('checked', true);
}
}); });