From cf3f8a09a85437c36f6c3c48492d4ee772a53295 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Wed, 27 Jan 2016 15:59:56 +0100 Subject: [PATCH] implement foldable fieldset as in w.c.s. (fixes #9788) --- gadjo/static/css/gadjo.css | 25 +++++++++++++++++++++++++ gadjo/static/js/gadjo.js | 18 ++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/gadjo/static/css/gadjo.css b/gadjo/static/css/gadjo.css index 8f5eade..54ff09d 100644 --- a/gadjo/static/css/gadjo.css +++ b/gadjo/static/css/gadjo.css @@ -784,6 +784,31 @@ div.old-ie-warning p { margin: 0; line-height: 150%; } +/* fieldsets */ +fieldset.gadjo-foldable legend.gadjo-foldable-widget { + border-bottom: 1px solid #aaa; + cursor: pointer; + display: block; + font-weight: bold; + padding: 1ex 0 0; + width: 100%; +} +fieldset.gadjo-foldable legend.gadjo-foldable-widget:after { + font-family: FontAwesome; + content: "\f106"; /* angle-up */ + position: absolute; + right: 1em; +} +fieldset.gadjo-foldable.gadjo-folded legend.gadjo-foldable-widget:after { + content: "\f107"; /* angle-down */ +} +fieldset.gadjo-foldable { + padding: 1ex 0 0 0; + border: 0; +} +.gadjo-foldable.gadjo-folded > .gadjo-folding { + display: none; +} ul#sidepage-menu li a.icon-add { background-image: url(icons/add.small.png); } ul#sidepage-menu li a.icon-calendar { background-image: url(icons/calendar.small.png); } diff --git a/gadjo/static/js/gadjo.js b/gadjo/static/js/gadjo.js index f68c974..6859aa5 100644 --- a/gadjo/static/js/gadjo.js +++ b/gadjo/static/js/gadjo.js @@ -233,4 +233,22 @@ } } }); + $(function () { + function gadjo_unfold_saved() { + $('.gadjo-folded').each(function (idx, elem) { + if (elem.id && sessionStorage['gadjo-foldable-id-' + elem.id + '-' + window.location.pathname] == "true") { + $(elem).removeClass('gadjo-folded'); + } + }); + } + gadjo_unfold_saved() + $(document).on('gadjo:content-update', gadjo_unfold_saved); + $('body').on('click', '.gadjo-foldable-widget', function (event) { + var $parent = $(event.target).closest('.gadjo-foldable'); + $parent.toggleClass('gadjo-folded'); + if ($parent[0].id) { + sessionStorage['gadjo-foldable-id-' + $parent[0].id + '-' + window.location.pathname] = ! $parent.is('.gadjo-folded'); + } + }); + }); })(); -- 2.1.4