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"
275 function update_info() {
276 var amount = parseInt($("#id_amount").val());
277 var monthly = $("#id_monthly").val() == 'True';
278 if (monthly) slug = "monthly";
279 else if (amount >= parseInt($("#plan-single").attr('data-min-for-year'))) slug = 'single-year';
280 else slug = 'single';
282 var chunk = $('.club-form-info .chunk-' + slug);
283 if (chunk.css('display') == 'none') {
284 $('.chunk-alt').css('height', $('.chunk-alt').height());
285 $('.chunk-alt .chunk').css('position', 'absolute');
287 $('.club-form-info .chunk').fadeOut();
288 $('.club-form-info .chunk.chunk-' + slug).fadeIn(function() {
289 $('.chunk-alt .chunk').css('position', 'static');
290 $('.chunk-alt').css('height', 'auto');
292 $('.chunk-alt').animate({height: chunk.height()}, 100);
296 $("#id_amount").val($("#plan-monthly").attr('data-amount'));
298 $(".button.kwota").click(function() {
299 var plan = $(this).closest('.plan');
300 $('.kwota', plan).removeClass('active')
301 $('.inna', plan).removeClass('active')
302 $(this).addClass('active');
304 var amount = $(this).text();
305 plan.attr("data-amount", amount);
306 $("#id_amount").val(amount);
312 $(".plan-toggle").click(function() {
313 $(".plan-toggle").removeClass('active');
314 $(this).addClass('active')
316 var plan = $("#" + $(this).attr('data-plan'));
318 $("#id_amount").val(plan.attr('data-amount'));
319 $("#id_monthly").val(plan.attr('data-monthly'));
325 $(".inna .button").click(function() {
326 var plan = $(this).closest('.plan');
327 $('.kwota', plan).removeClass('active');
328 $(this).parent().addClass('active');
329 $('input', plan).focus();
331 var amount = $('input', $(this).parent()).val();
332 plan.attr("data-amount", amount);
333 $("#id_amount").val(amount);
339 $(".inna input").on('input', function() {
340 var plan = $(this).closest('.plan');
341 $('.kwota', plan).removeClass('active');
342 var amount = $(this).val();
343 plan.attr("data-amount", amount);
344 $("#id_amount").val(amount);