Browse Source

add global option for tree view

pull/40/head
topkek 10 years ago
committed by czaks
parent
commit
2256604dad
  1. 67
      js/treeview.js
  2. 3
      stylesheets/style.css

67
js/treeview.js

@ -11,35 +11,54 @@
* *
*/ */
if (active_page == 'thread') if (active_page == 'thread' || active_page == 'ukko' || active_page == 'index')
$(function() { $(function() {
$('hr:first').before('<div id="treeview" style="text-align:right"><a class="unimportant" href="javascript:void(0)"></a></div>'); if (window.Options && Options.get_tab('general')) {
$('div#treeview a') var selector = '#treeview-global>input';
.text(_('Tree view')) Options.extend_tab("general", "<label id='treeview-global'><input type='checkbox' /> "+_('Use tree view by default')+"</label>");
.click(function(e) { }
e.preventDefault(); $(selector).on('change', function () {
if (localStorage.treeview === 'true') {
$('.post.reply').each(function(){ localStorage.treeview = 'false';
var references = []; } else {
$(this).find('.body a').each(function(){ localStorage.treeview = 'true';
if ($(this).html().match('^&gt;&gt;[0-9]+$')) { }
references.push(parseInt($(this).html().replace('&gt;&gt;', ''))); });
} if (localStorage.treeview === 'true') {
}); $(selector).attr('checked', 'checked');
}
var maxref = references.reduce(function(a,b) { return a > b ? a : b; }, 0); });
var parent_post = $("#reply_"+maxref); if (active_page == 'thread')
if (parent_post.length == 0) return; $(function() {
var treeview = function() {
$('.post.reply').each(function(){
var references = [];
$(this).find('.body a').each(function(){
if ($(this).html().match('^&gt;&gt;[0-9]+$')) {
references.push(parseInt($(this).html().replace('&gt;&gt;', '')));
}
});
var maxref = references.reduce(function(a,b) { return a > b ? a : b; }, 0);
var margin = parseInt(parent_post.css("margin-left"))+32; var parent_post = $("#reply_"+maxref);
if (parent_post.length == 0) return;
var post = $(this); var margin = parseInt(parent_post.css("margin-left"))+32;
var br = post.next();
post.detach().css("margin-left", margin).insertAfter(parent_post.next()); var post = $(this);
br.detach().insertAfter(post); var br = post.next();
}); post.detach().css("margin-left", margin).insertAfter(parent_post.next());
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>');
$('div#treeview a')
.text(_('Tree view'))
.click(function(e) { treeview(); e.preventDefault(); });
}); });

3
stylesheets/style.css

@ -825,7 +825,7 @@ div.thread:hover {
#options_div { #options_div {
width: 600px; width: 600px;
height: 300px; height: 320px;
} }
#alert_div { #alert_div {
@ -892,6 +892,7 @@ div.thread:hover {
right: 0px; right: 0px;
text-align: left; text-align: left;
font-size: 12px; font-size: 12px;
overflow-y: auto;
} }
.options_tab h2 { .options_tab h2 {

Loading…
Cancel
Save