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-expand').each(function () {
69 $('.carousel').on('cycle-before', function(event, optionHash, outgoingSlideEl, incomingSlideEl, forwardFlag) {
70 $("iframe", outgoingSlideEl).attr("src", '');
71 $("iframe", incomingSlideEl).attr("src", $("iframe", incomingSlideEl).attr('data-src'));
73 $('.carousel section').first().each(function() {
74 $("iframe", this).attr("src", $("iframe", this).attr('data-src'));
80 var menu_loaded = false;
81 $('.hidden-box-wrapper').each(function() {
82 var $hidden = $('.hidden-box', this);
83 $('.hidden-box-trigger', this).click(function(event) {
84 event.preventDefault();
85 if ($current == $hidden) {
89 $current && $current.hide('fast');
92 if ($(this).hasClass('load-menu') && !menu_loaded) {
94 url: '/katalog/' + LANGUAGE_CODE + '.json',
96 }).done(function(data) {
97 $.each(data, function(index, value) {
98 var $menuitem = $('#menu-' + index);
99 $menuitem.html(value);
100 var $minisearch = $("<input class='mini-search' style='margin-bottom: 1em' />");
101 $minisearch.keyup(function() {
102 var s = $(this).val().toLowerCase();
104 $("li", $menuitem).each(function() {
105 if ($("a", this).text().toLowerCase().indexOf(s) != -1)
112 $("li", $menuitem).css("display", "");
115 $menuitem.prepend($minisearch);
123 /* this kinda breaks the whole page. */
124 $('body').click(function(e) {
125 if ($current == null) return;
130 if (p.hasClass('hidden-box-trigger')
131 || p.hasClass('simple-toggler')
132 || p.hasClass('mini-search'))
136 $current.hide('fast');
142 $('#show-menu').click(function(event) {
143 event.preventDefault();
144 //$('#menu').toggle('fast');
145 $('body').toggleClass('menu-on');
149 $('#book-list-nav').find('h2').click(function(event) {
150 event.preventDefault();
151 $('#book-list-nav-index').toggle();
155 $('#themes-list-toggle').click(function(event) {
156 event.preventDefault();
157 $('#themes-list').toggle('fast');
161 $('.book-list-index').click(function(){
162 $('.book-list-show-index').hide('fast');
163 var books_ul = $(this).parent().next().children().first();
164 if(books_ul.first().is(':hidden')){
165 books_ul.toggle('fast');
170 $('.hoverclick').click(function() {$(this).closest('.hoverget').toggleClass('hover');});
173 $("#search").search();
176 $('body').on('click', '.simple-toggler' , function(ev) {
178 var scope = $(this).closest('.simple-toggler-scope');
179 scope.find('.simple-hidden-box').each(function() {
181 if ($this.is(':hidden')) {
190 $('.tabbed-filter').each(function() {
192 $('.tab').click(function() {
193 if ($(this).hasClass('active')) {
194 $(this).removeClass('active');
195 $('#' + $(this).attr('data-id')).hide();
198 var $active = $('.active', tf);
199 $active.removeClass('active');
200 $('#' + $active.attr('data-id')).hide();
201 $(this).addClass('active');
202 $('#' + $(this).attr('data-id')).show();
208 $('.plain-list-paged').each(function() {
209 // should change on resize?
211 var $pl = $('.plain-list', this);
213 var $items = $('p', $pl);
215 if ($items.length > 40) {
219 $('.pager', $plc).paging($items.length, {
220 format: '[< ncnnn >]', // define how the navigation should look like and in which order onFormat() get's called
222 lapping: 0, // don't overlap pages for the moment
223 page: 1, // start at page, can also be "null" or negative
224 onSelect: function (page) {
225 var data = this.slice;
226 $items.slice(prev[0], prev[1]).hide();
227 $items.slice(data[0], data[1]).show();
230 onFormat: function (type) {
232 case 'block': // n and c
233 return ' <li><a href="#"' + (this.value == this.page ? ' class="current"' : '') + '>' +
234 this.value + '</a></li>';
236 return '<li><a href="#">›</a></li>';
238 return '<li><a href="#">‹</a></li>';
240 return '<li><a href="#">«</a></li>';
242 return '<li><a href="#">»</a></li>';
250 tlite(function (el) {
251 return $(el).hasClass('tlite-tooltip');
254 /* more/less switch from https://codepen.io/JoshBlackwood/pen/pEwHe */
255 // Hide the extra content initially, using JS so that if JS is disabled, no problemo:
256 $('.read-more-content').addClass('hide');
257 $('.read-more-show, .read-more-hide').removeClass('hide');
259 // Set up the toggle effect:
260 $('.read-more-show').on('click', function(e) {
261 $(this).next('.read-more-content').removeClass('hide');
262 $(this).addClass('hide');
266 // Changes contributed by @diego-rzg
267 $('.read-more-hide').on('click', function(e) {
268 var p = $(this).parent('.read-more-content');
270 p.prev('.read-more-show').removeClass('hide'); // Hide only the preceding "Read More"