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),
60 $('.more').each(function () {
72 var menu_loaded = false;
73 $('.hidden-box-wrapper').each(function() {
74 var $hidden = $('.hidden-box', this);
75 $('.hidden-box-trigger', this).click(function(event) {
76 event.preventDefault();
77 if ($current == $hidden) {
81 $current && $current.hide('fast');
84 if ($(this).hasClass('load-menu') && !menu_loaded) {
86 url: '/katalog/' + LANGUAGE_CODE + '.json',
88 }).done(function(data) {
89 $.each(data, function(index, value) {
90 var $menuitem = $('#menu-' + index);
91 $menuitem.html(value);
92 var $minisearch = $("<input class='mini-search' style='margin-bottom: 1em' />");
93 $minisearch.keyup(function() {
94 var s = $(this).val().toLowerCase();
96 $("li", $menuitem).each(function() {
97 if ($("a", this).text().toLowerCase().indexOf(s) != -1)
104 $("li", $menuitem).css("display", "");
107 $menuitem.prepend($minisearch);
115 /* this kinda breaks the whole page. */
116 $('body').click(function(e) {
117 if ($current == null) return;
122 if (p.hasClass('hidden-box-trigger')
123 || p.hasClass('simple-toggler')
124 || p.hasClass('mini-search'))
128 $current.hide('fast');
134 $('#show-menu').click(function(event) {
135 event.preventDefault();
136 //$('#menu').toggle('fast');
137 $('body').toggleClass('menu-on');
141 $('#book-list-nav').find('h2').click(function(event) {
142 event.preventDefault();
143 $('#book-list-nav-index').toggle();
147 $('#themes-list-toggle').click(function(event) {
148 event.preventDefault();
149 $('#themes-list').toggle('fast');
153 $('.book-list-index').click(function(){
154 $('.book-list-show-index').hide('fast');
155 var books_ul = $(this).parent().next().children().first();
156 if(books_ul.first().is(':hidden')){
157 books_ul.toggle('fast');
162 $('.hoverclick').click(function() {$(this).closest('.hoverget').toggleClass('hover');});
165 $("#search").search();
168 $('body').on('click', '.simple-toggler' , function(ev) {
170 var scope = $(this).closest('.simple-toggler-scope');
171 scope.find('.simple-hidden-box').each(function() {
173 if ($this.is(':hidden')) {
182 $('.tabbed-filter').each(function() {
184 $('.tab').click(function() {
185 if ($(this).hasClass('active')) {
186 $(this).removeClass('active');
187 $('#' + $(this).attr('data-id')).hide();
190 var $active = $('.active', tf);
191 $active.removeClass('active');
192 $('#' + $active.attr('data-id')).hide();
193 $(this).addClass('active');
194 $('#' + $(this).attr('data-id')).show();
200 $('.plain-list-paged').each(function() {
201 // should change on resize?
203 var $pl = $('.plain-list', this);
205 var $items = $('p', $pl);
207 if ($items.length > 40) {
211 $('.pager', $plc).paging($items.length, {
212 format: '[< ncnnn >]', // define how the navigation should look like and in which order onFormat() get's called
214 lapping: 0, // don't overlap pages for the moment
215 page: 1, // start at page, can also be "null" or negative
216 onSelect: function (page) {
217 var data = this.slice;
218 $items.slice(prev[0], prev[1]).hide();
219 $items.slice(data[0], data[1]).show();
222 onFormat: function (type) {
224 case 'block': // n and c
225 return ' <li><a href="#"' + (this.value == this.page ? ' class="current"' : '') + '>' +
226 this.value + '</a></li>';
228 return '<li><a href="#">›</a></li>';
230 return '<li><a href="#">‹</a></li>';
232 return '<li><a href="#">«</a></li>';
234 return '<li><a href="#">»</a></li>';
242 tlite(function (el) {
243 return $(el).hasClass('tlite-tooltip');
246 /* more/less switch from https://codepen.io/JoshBlackwood/pen/pEwHe */
247 // Hide the extra content initially, using JS so that if JS is disabled, no problemo:
248 $('.read-more-content').addClass('hide');
249 $('.read-more-show, .read-more-hide').removeClass('hide');
251 // Set up the toggle effect:
252 $('.read-more-show').on('click', function(e) {
253 $(this).next('.read-more-content').removeClass('hide');
254 $(this).addClass('hide');
258 // Changes contributed by @diego-rzg
259 $('.read-more-hide').on('click', function(e) {
260 var p = $(this).parent('.read-more-content');
262 p.prev('.read-more-show').removeClass('hide'); // Hide only the preceding "Read More"