3 $.fn.toggle_slide = function(p) {
5 short_el = p['short_el'] || $(':first-child', this);
6 long_el = p['long_el'] || short_el.next();
8 short_text = p['short_text'],
9 long_text = p['long_text'];
11 var toggle_fun = function(cont, short_el, long_el, button, short_text, long_text) {
12 var toggle = function() {
13 if (cont.hasClass('short')) {
14 cont.animate({"height": long_el.attr("cont_h")+'px'}, {duration: "fast" }).removeClass('short');
17 if (button && long_text) button.html(long_text);
19 cont.animate({"height": short_el.attr("cont_h")+'px'}, {duration: "fast" }).addClass('short');
22 if (button && short_text) button.html(short_text);
28 if (long_el.html().length <= short_el.html().length)
31 // ensure long element shown first
32 long_el.show();short_el.hide();
33 long_el.attr("cont_h", $(this).height()).hide();
34 short_el.show().attr("cont_h", $(this).height());
35 $(this).addClass('short');
37 if (button && short_text) button.html(short_text);
38 if (button) button.click(toggle_fun(cont, short_el, long_el, button, short_text, long_text));
43 $('.fragment-with-short').each(function() {
44 $(this).toggle_slide({
45 short_el: $('.fragment-short-text', this),
46 long_el: $('.fragment-long-text', this),
47 button: $('.toggle', this)
50 $('#description').each(function() {
51 $(this).toggle_slide({
52 short_el: $('#description-short', this),
53 long_el: $('#description-long', this),
62 var menu_loaded = false;
63 $('.hidden-box-wrapper').each(function() {
64 var $hidden = $('.hidden-box', this);
65 $('.hidden-box-trigger', this).click(function(event) {
66 event.preventDefault();
67 if ($current == $hidden) {
71 $current && $current.hide('fast');
74 if ($(this).hasClass('load-menu') && !menu_loaded) {
78 }).done(function(data) {
79 $.each(data, function(index, value) {
80 $('#menu-' + index).html(value);
88 /* this kinda breaks the whole page. */
89 $('body').click(function(e) {
90 if ($current == null) return;
95 if (p.hasClass('hidden-box-trigger')
96 || p.hasClass('simple-toggler'))
100 $current.hide('fast');
106 $('#show-menu').click(function(event) {
107 event.preventDefault();
108 $('#menu').toggle('slow');
110 $('#book-list-nav h2').click(function(event) {
111 event.preventDefault();
112 $('#book-list-nav-index').toggle();
116 $('#themes-list-toggle').click(function(event) {
117 event.preventDefault();
118 $('#themes-list').toggle('slow');
122 $('.book-list-index').click(function(){
123 $('.book-list-show-index').hide('slow');
124 if($(this).parent().next('ul:not(:hidden)').length == 0){
125 $(this).parent().next('ul').toggle('slow');
130 $('.hoverclick').click(function() {$(this).closest('.hoverget').toggleClass('hover');});
133 $("#search").search();});
135 $('body').on('click', '.simple-toggler' , function(ev) {
137 var scope = $(this).closest('.simple-toggler-scope');
138 scope.find('.simple-hidden-box').each(function(){
140 if ($this.is(':hidden')) {