From c8913f41a7a7a8be76a458b001c3f2b2e1ca0dea Mon Sep 17 00:00:00 2001 From: czaks Date: Sat, 28 Dec 2013 00:53:42 +0100 Subject: compact-boardlist.js: initial commit --- js/compact-boardlist.js | 105 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 js/compact-boardlist.js (limited to 'js') diff --git a/js/compact-boardlist.js b/js/compact-boardlist.js new file mode 100644 index 00000000..9baefa11 --- /dev/null +++ b/js/compact-boardlist.js @@ -0,0 +1,105 @@ +if (device_type == 'desktop') { + compact_boardlist = true; + + var do_css = function() { + $('#compact-boardlist-css').remove(); + + $('').appendTo($("head")); + }; + + do_boardlist = function() { + do_css(); + + 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; + }; +} -- cgit v1.3