3 $.fn.toggle_slide = function(p) {
5 var short_el = p['short_el'] || $(':first-child', this);
6 var long_el = p['long_el'] || short_el.next();
7 var button = p['button'];
8 var short_text = p['short_text'];
9 var long_text = p['long_text'];
11 var toggle_fun = function(cont, short_el, long_el, button, short_text, long_text) {
13 if (cont.hasClass('short')) {
14 cont.animate({"height": long_el.attr("cont_h") + 'px'}, {duration: "fast"})
15 .removeClass('short');
18 if (button && long_text) button.html(long_text);
20 cont.animate({"height": short_el.attr("cont_h") + 'px'}, {duration: "fast"}).addClass('short');
23 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)
38 button.html(short_text);
40 button.click(toggle_fun(cont, short_el, long_el, button, short_text, long_text));
45 $('.fragment-with-short').each(function() {
46 $(this).toggle_slide({
47 short_el: $('.fragment-short-text', this),
48 long_el: $('.fragment-long-text', this),
49 button: $('.toggle', this)
52 $('#description').each(function() {
53 $(this).toggle_slide({
54 short_el: $('#description-short', this),
55 long_el: $('#description-long', this),
64 var menu_loaded = false;
65 $('.hidden-box-wrapper').each(function() {
66 var $hidden = $('.hidden-box', this);
67 $('.hidden-box-trigger', this).click(function(event) {
68 event.preventDefault();
69 if ($current == $hidden) {
73 $current && $current.hide('fast');
76 if ($(this).hasClass('load-menu') && !menu_loaded) {
78 url: '/katalog/' + LANGUAGE_CODE + '.json',
80 }).done(function(data) {
81 $.each(data, function(index, value) {
82 var $menuitem = $('#menu-' + index);
83 $menuitem.html(value);
84 var $minisearch = $("<input class='mini-search' style='margin-bottom: 1em' />");
85 $minisearch.keyup(function() {
86 var s = $(this).val().toLowerCase();
88 $("li", $menuitem).each(function() {
89 if ($("a", this).text().toLowerCase().indexOf(s) != -1)
96 $("li", $menuitem).css("display", "");
99 $menuitem.prepend($minisearch);
107 /* this kinda breaks the whole page. */
108 $('body').click(function(e) {
109 if ($current == null) return;
114 if (p.hasClass('hidden-box-trigger')
115 || p.hasClass('simple-toggler')
116 || p.hasClass('mini-search'))
120 $current.hide('fast');
126 $('#show-menu').click(function(event) {
127 event.preventDefault();
128 //$('#menu').toggle('fast');
129 $('body').toggleClass('menu-on');
133 $('#book-list-nav').find('h2').click(function(event) {
134 event.preventDefault();
135 $('#book-list-nav-index').toggle();
139 $('#themes-list-toggle').click(function(event) {
140 event.preventDefault();
141 $('#themes-list').toggle('fast');
145 $('.book-list-index').click(function(){
146 $('.book-list-show-index').hide('fast');
147 var books_ul = $(this).parent().next().children().first();
148 if(books_ul.first().is(':hidden')){
149 books_ul.toggle('fast');
154 $('.hoverclick').click(function() {$(this).closest('.hoverget').toggleClass('hover');});
157 $("#search").search();
160 $('body').on('click', '.simple-toggler' , function(ev) {
162 var scope = $(this).closest('.simple-toggler-scope');
163 scope.find('.simple-hidden-box').each(function() {
165 if ($this.is(':hidden')) {
174 $('.tabbed-filter').each(function() {
176 $('.tab').click(function() {
177 if ($(this).hasClass('active')) {
178 $(this).removeClass('active');
179 $('#' + $(this).attr('data-id')).hide();
182 var $active = $('.active', tf);
183 $active.removeClass('active');
184 $('#' + $active.attr('data-id')).hide();
185 $(this).addClass('active');
186 $('#' + $(this).attr('data-id')).show();
192 $('.plain-list-paged').each(function() {
193 // should change on resize?
195 var $pl = $('.plain-list', this);
197 var $items = $('p', $pl);
199 if ($items.length > 40) {
203 $('.pager', $plc).paging($items.length, {
204 format: '[< ncnnn >]', // define how the navigation should look like and in which order onFormat() get's called
206 lapping: 0, // don't overlap pages for the moment
207 page: 1, // start at page, can also be "null" or negative
208 onSelect: function (page) {
209 var data = this.slice;
210 $items.slice(prev[0], prev[1]).hide();
211 $items.slice(data[0], data[1]).show();
214 onFormat: function (type) {
216 case 'block': // n and c
217 return ' <li><a href="#"' + (this.value == this.page ? ' class="current"' : '') + '>' +
218 this.value + '</a></li>';
220 return '<li><a href="#">›</a></li>';
222 return '<li><a href="#">‹</a></li>';
224 return '<li><a href="#">«</a></li>';
226 return '<li><a href="#">»</a></li>';