/* * compact-boardlist.js * https://github.com/vichan-devel/Tinyboard/blob/master/js/compact-boardlist.js * * Released under the MIT license * Copyright (c) 2014 Marcin Ɓabanowski * * Usage: * $config['boards'] = array( * "icon_vichan" => array('*'), # would refer to /static/icons/vichan.png * "Regular" => array('b', 'cp', 'r+oc', 'id', 'waifu'), * "Topical" => array('sci', "Offsite board name" => '//int.vichan.net/s/'), * "fa_search" => array("search" => "/search.php") # would refer to a search * # font-awesome icon * ) * * $config['additional_javascript'][] = 'js/jquery.min.js'; * $config['additional_javascript'][] = 'js/mobile-style.js'; * $config['additional_javascript'][] = 'js/compact-boardlist.js'; * //$config['additional_javascript'][] = 'js/watch.js'; * */ if (device_type == 'desktop') { compact_boardlist = true; do_boardlist = function() { var categories = []; var topbl = $('.boardlist:first'); topbl.find('>.sub').each(function() { var cat = {name: $(this).data('description'), boards: []}; $(this).find('a').each(function() { var board = {name: $(this).prop('title'), uri: $(this).html(), href: $(this).prop('href') } cat.boards.push(board); }); categories.push(cat); }); topbl.addClass("compact-boardlist") .html(""); for (var i in categories) { var item = categories[i]; if (item.name.match(/^icon_/)) { var icon = item.name.replace(/^icon_/, '') $("") .appendTo(topbl) } else if (item.name.match(/^fa_/)) { var icon = item.name.replace(/^fa_/, '') $('') .appendTo(topbl) } else { $(""+item.name+"") .appendTo(topbl) .mouseenter(function() { var list = $("
") .css("top", $(this).position().top + 13 + $(this).height()) .css("left", $(this).position().left) .css("right", "auto") .appendTo(this); for (var j in this.item.boards) { var board = this.item.boards[j]; var tag; if (board.name) { tag = $(""+board.name+"/"+board.uri+"/") } else { tag = $(""+board.uri+"") } tag .addClass("cb-menuitem") .appendTo(list) } }) .mouseleave(function() { topbl.find(".cb-menu").remove(); })[0].item = item; } } do_boardlist = undefined; }; }