# HG changeset patch # User veltr # Date 1349346312 -7200 # Node ID 91bc8521e3cbd41e878be449858acf3303411556 # Parent 3a34fc74e0d28afdfe13bbe43f6259bfe798c5e1 Ajout de la navigation par thesaurus diff -r 3a34fc74e0d2 -r 91bc8521e3cb web/hdalab/static/hdalab/css/cattree.css --- a/web/hdalab/static/hdalab/css/cattree.css Sun Sep 09 21:56:43 2012 +0200 +++ b/web/hdalab/static/hdalab/css/cattree.css Thu Oct 04 12:25:12 2012 +0200 @@ -31,19 +31,19 @@ color: #000060; } -ul.disciplist { +ul.disciplist, ul.theslist { list-style: none; margin: 10px 5px; } -.disciplist li { +.disciplist li, .theslist li { font-size: 12px; font-weight: bold; } -.disciplist a { +.disciplist a, .theslist a { color: #000066; } -.disciplist .selected a { +.disciplist .selected a, .theslist .selected a { color: #0000ff; } diff -r 3a34fc74e0d2 -r 91bc8521e3cb web/hdalab/static/hdalab/js/cattree.js --- a/web/hdalab/static/hdalab/js/cattree.js Sun Sep 09 21:56:43 2012 +0200 +++ b/web/hdalab/static/hdalab/js/cattree.js Thu Oct 04 12:25:12 2012 +0200 @@ -1,3 +1,163 @@ +var trees = [ + { + title: "Thésaurus de l'Architecture et de l'Urbanisme : Secteur urbain", + tree: { + label: "secteur urbain", + contents: [ + { + label: "banlieue", + contents: [ + { + label: "faubourg" + } + ] + }, + { + label: "îlot" + }, + { + label: "quartier", + contents: [ + { + label: "centre-ville" + } + ] + }, + { + label: "secteur urbain concerté", + contents: [ + { + label: "grand ensemble" + }, + { + label: "lotissement", + contents: [ + { + label: "lotissement concerté", + contents: [ + { + label: "cité-jardin" + }, + { + label: "cité ouvrière" + }, + { + label: "courée" + }, + ] + } + ] + } + ] + }, + ] + } + }, + { + title: "Thésaurus Garnier : Architecture d'habitation", + tree: { + label: "architecture d'habitation", + contents: [ + { + label: "cité-jardin" + }, + { + label: "édifice d'habitation", + contents: [ + { + label: "demeure", + contents: [ + { + label: "chalet" + }, + { + label: "château" + }, + { + label: "château-fort", + contents: [ + { + label: "chemin de ronde" + }, + { + label: "donjon" + } + ] + }, + { + label: "hôtel particulier" + }, + { + label: "maison" + }, + { + label: "manoir" + }, + { + label: "palais" + } + ] + }, + { + label: "abri", + contents: [ + { + label: "buron" + }, + { + label: "cabane" + }, + { + label: "campement", + contents: [ + { + label: "tente" + }, + { + label: "tipi" + }, + { + label: "igloo" + } + ] + } + ] + } + ] + } + ] + } + }, + { + title: "Thésaurus Garnier : Sciences occultes", + tree: { + label: "sciences occultes", + contents: [ + { + label: "alchimie" + }, + { + label: "astrologie" + }, + { + label: "divination" + }, + { + label: "magie", + contents: [ + { + label: "sorcellerie" + }, + { + label: "sorcière" + } + ] + } + ] + } + } +] + function render(_data, _level) { _data.theme_count = (typeof _data.sub_categories == "object" && typeof _data.sub_categories.slice == "function" ? _data.sub_categories.length : 0) @@ -34,56 +194,60 @@ return _html; } +function showData(_label, _data) { + $(".disciplist li, .theslist li").each(function() { + if ($(this).text().trim().toLowerCase() === _label.toLowerCase()) { + $(this).addClass("selected"); + } + }) + $(".label-name").html(_label); + if (_data) { + $("#tree").html(render(_data, 0)); + $(".cattree p.theme").click(function() { + $(this).parent().toggleClass("folded") + return false; + }); + $("li.content").mouseenter(function() { + $(this).find(".foldedcontent") + .dequeue() + .animate({ + height: 5 + $(this).find("p.description").outerHeight() + }, + 500); + }).mouseleave(function() { + $(this).find(".foldedcontent") + .dequeue() + .animate({ + height: "0" + }, + 500); + }); + $(".show_more").click(function() { + $(this).siblings(".hidden:lt(5)").removeClass("hidden"); + var _l = $(this).siblings(".hidden").length; + $(this).find(".show_more_count").html(_l); + if (!_l) { + $(this).detach(); + } + }) + $(".results").show(); + $(".content-count").html($(".cattree a.content").length); + $(".category-count").html(Math.max(0, $("p.category").length - 1)); + $(".tag-count").html($("p.tag").length); + } else { + $("#tree").html(""); + $(".results").hide(); + } +} + function gettree(_label) { - $(".disciplist li").removeClass("selected"); + $(".disciplist li, .theslist li").removeClass("selected"); $("#tree").html('
'); $.getJSON( endpoints.cat_tree, { label: _label }, function(_data) { - $(".disciplist li").each(function() { - if ($(this).text().trim().toLowerCase() === _label.toLowerCase()) { - $(this).addClass("selected"); - } - }) - $(".label-name").html(_label); - if (_data) { - $("#tree").html(render(_data, 0)); - $(".cattree p.theme").click(function() { - $(this).parent().toggleClass("folded") - return false; - }); - $("li.content").mouseenter(function() { - $(this).find(".foldedcontent") - .dequeue() - .animate({ - height: 5 + $(this).find("p.description").outerHeight() - }, - 500); - }).mouseleave(function() { - $(this).find(".foldedcontent") - .dequeue() - .animate({ - height: "0" - }, - 500); - }); - $(".show_more").click(function() { - $(this).siblings(".hidden:lt(5)").removeClass("hidden"); - var _l = $(this).siblings(".hidden").length; - $(this).find(".show_more_count").html(_l); - if (!_l) { - $(this).detach(); - } - }) - $(".results").show(); - $(".content-count").html($(".cattree a.content").length); - $(".category-count").html(Math.max(0, $("p.category").length - 1)); - $(".tag-count").html($("p.tag").length); - } else { - $("#tree").html(""); - $(".results").hide(); - } + showData(_label, _data); } ); } @@ -115,5 +279,22 @@ gettree("peinture"); $(".disciplist li").click(function() { gettree($(this).text().trim()); - }) + }); + _(trees).each(function(_tree) { + $("") + .html($('').text(_tree.title)) + .appendTo(".theslist") + .click(function() { + $(".disciplist li, .theslist li").removeClass("selected"); + $("#tree").html(''); + $.getJSON( + endpoints.fill_tree, + { tree: JSON.stringify(_tree.tree) }, + function(_data) { + showData(_tree.title, _data); + } + ); + return false; + }); + }); }); \ No newline at end of file diff -r 3a34fc74e0d2 -r 91bc8521e3cb web/hdalab/templates/categories.html --- a/web/hdalab/templates/categories.html Sun Sep 09 21:56:43 2012 +0200 +++ b/web/hdalab/templates/categories.html Thu Oct 04 12:25:12 2012 +0200 @@ -1,6 +1,6 @@ {% extends "base.html" %} -{% block title %}{{block.super}} > Arbre des catégories Wikipedia{% endblock %} +{% block title %}{{block.super}} > Recherche par arbre{% endblock %} {% block css_import %} {{block.super}} @@ -16,7 +16,8 @@ @@ -43,10 +44,12 @@+