forked from GithubBackups/vichan
Merge pull request #285 from topkek/treeview
Add tree view to options dialog & close ctrlcctrlv/8chan#280
This commit is contained in:
commit
d53ce19076
@ -56,7 +56,6 @@ if (active_page == 'thread' || active_page == 'index' || active_page == 'catalog
|
||||
$(document).ready(function(){
|
||||
var favorites = JSON.parse(localStorage.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>');
|
||||
add_favorites();
|
||||
|
@ -73,6 +73,7 @@ onready(function(){
|
||||
.css('font-style', 'normal')
|
||||
.css('z-index', '100')
|
||||
.css('left', '0')
|
||||
.css('margin-left', '')
|
||||
.addClass('reply').addClass('post')
|
||||
.appendTo(link.closest('div.post'))
|
||||
|
||||
|
@ -11,14 +11,28 @@
|
||||
*
|
||||
*/
|
||||
|
||||
if (active_page == 'thread' || active_page == 'ukko' || active_page == 'index')
|
||||
$(function() {
|
||||
if (window.Options && Options.get_tab('general')) {
|
||||
var selector = '#treeview-global>input';
|
||||
Options.extend_tab("general", "<label id='treeview-global'><input type='checkbox' /> "+_('Use tree view by default')+"</label>");
|
||||
$(selector).on('change', function() {
|
||||
if (localStorage.treeview === 'true') {
|
||||
localStorage.treeview = 'false';
|
||||
} else {
|
||||
localStorage.treeview = 'true';
|
||||
}
|
||||
});
|
||||
if (localStorage.treeview === 'true') {
|
||||
$(selector).attr('checked', 'checked');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (active_page == 'thread')
|
||||
$(function() {
|
||||
$('hr:first').before('<div id="treeview" style="text-align:right"><a class="unimportant" href="javascript:void(0)"></a></div>');
|
||||
$('div#treeview a')
|
||||
.text(_('Tree view'))
|
||||
.click(function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var treeview = function(enable) {
|
||||
if (enable === true) {
|
||||
$('.post.reply').each(function(){
|
||||
var references = [];
|
||||
$(this).find('.body a').each(function(){
|
||||
@ -26,7 +40,6 @@ $(function() {
|
||||
references.push(parseInt($(this).html().replace('>>', '')));
|
||||
}
|
||||
});
|
||||
|
||||
var maxref = references.reduce(function(a,b) { return a > b ? a : b; }, 0);
|
||||
|
||||
var parent_post = $("#reply_"+maxref);
|
||||
@ -39,7 +52,24 @@ $(function() {
|
||||
|
||||
post.detach().css("margin-left", margin).insertAfter(parent_post.next());
|
||||
br.detach().insertAfter(post);
|
||||
});
|
||||
} else {
|
||||
$('.post.reply').sort(function(a,b) {
|
||||
return parseInt(a.id.replace('reply_', '')) - parseInt(b.id.replace('reply_', ''));
|
||||
}).each(function () {
|
||||
var post = $(this);
|
||||
var br = post.next();
|
||||
post.detach().css('margin-left', '').appendTo('.thread');
|
||||
br.detach().insertAfter(post);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
$('hr:first').before('<div class="unimportant" style="text-align:right"><label for="treeview"><input type="checkbox" id="treeview"> '+_('Tree view')+'</label></div>');
|
||||
$('input#treeview').on('change', function(e) { treeview($(this).is(':checked')); });
|
||||
|
||||
if (localStorage.treeview === 'true') {
|
||||
treeview(true);
|
||||
$('input#treeview').attr('checked', true);
|
||||
}
|
||||
});
|
||||
|
@ -925,6 +925,7 @@ pre {
|
||||
right: 0px;
|
||||
text-align: left;
|
||||
font-size: 12px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.options_tab h2 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user