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'));
77 $(".carousel").each(function() {
79 if ($('html').hasClass('media-eink')) {
88 var menu_loaded = false;
89 $('.hidden-box-wrapper').each(function() {
90 var $hidden = $('.hidden-box', this);
91 $('.hidden-box-trigger', this).click(function(event) {
92 event.preventDefault();
93 if ($current == $hidden) {
97 $current && $current.hide('fast');
100 if ($(this).hasClass('load-menu') && !menu_loaded) {
102 url: '/katalog/' + LANGUAGE_CODE + '.json',
104 }).done(function(data) {
105 $.each(data, function(index, value) {
106 var $menuitem = $('#menu-' + index);
107 $menuitem.html(value);
108 var $minisearch = $("<input class='mini-search' style='margin-bottom: 1em' />");
109 $minisearch.keyup(function() {
110 var s = $(this).val().toLowerCase();
112 $("li", $menuitem).each(function() {
113 if ($("a", this).text().toLowerCase().indexOf(s) != -1)
120 $("li", $menuitem).css("display", "");
123 $menuitem.prepend($minisearch);
131 /* this kinda breaks the whole page. */
132 $('body').click(function(e) {
133 if ($current == null) return;
138 if (p.hasClass('hidden-box-trigger')
139 || p.hasClass('simple-toggler')
140 || p.hasClass('mini-search'))
144 $current.hide('fast');
150 $('#show-menu').click(function(event) {
151 event.preventDefault();
152 //$('#menu').toggle('fast');
153 $('body').toggleClass('menu-on');
157 $('#book-list-nav').find('h2').click(function(event) {
158 event.preventDefault();
159 $('#book-list-nav-index').toggle();
163 $('#themes-list-toggle').click(function(event) {
164 event.preventDefault();
165 $('#themes-list').toggle('fast');
169 $('.book-list-index').click(function(){
170 $('.book-list-show-index').hide('fast');
171 var books_ul = $(this).parent().next().children().first();
172 if(books_ul.first().is(':hidden')){
173 books_ul.toggle('fast');
178 $('.hoverclick').click(function() {$(this).closest('.hoverget').toggleClass('hover');});
181 $("#search").search();
184 $('body').on('click', '.simple-toggler' , function(ev) {
186 var scope = $(this).closest('.simple-toggler-scope');
187 scope.find('.simple-hidden-box').each(function() {
189 if ($this.is(':hidden')) {
198 $('.tabbed-filter').each(function() {
200 $('.tab').click(function() {
201 if ($(this).hasClass('active')) {
202 $(this).removeClass('active');
203 $('#' + $(this).attr('data-id')).hide();
206 var $active = $('.active', tf);
207 $active.removeClass('active');
208 $('#' + $active.attr('data-id')).hide();
209 $(this).addClass('active');
210 $('#' + $(this).attr('data-id')).show();
216 $('.plain-list-paged').each(function() {
217 // should change on resize?
219 var $pl = $('.plain-list', this);
221 var $items = $('p', $pl);
223 if ($items.length > 40) {
227 $('.pager', $plc).paging($items.length, {
228 format: '[< ncnnn >]', // define how the navigation should look like and in which order onFormat() get's called
230 lapping: 0, // don't overlap pages for the moment
231 page: 1, // start at page, can also be "null" or negative
232 onSelect: function (page) {
233 var data = this.slice;
234 $items.slice(prev[0], prev[1]).hide();
235 $items.slice(data[0], data[1]).show();
238 onFormat: function (type) {
240 case 'block': // n and c
241 return ' <li><a href="#"' + (this.value == this.page ? ' class="current"' : '') + '>' +
242 this.value + '</a></li>';
244 return '<li><a href="#">›</a></li>';
246 return '<li><a href="#">‹</a></li>';
248 return '<li><a href="#">«</a></li>';
250 return '<li><a href="#">»</a></li>';
258 tlite(function (el) {
259 return $(el).hasClass('tlite-tooltip');
262 /* more/less switch from https://codepen.io/JoshBlackwood/pen/pEwHe */
263 // Hide the extra content initially, using JS so that if JS is disabled, no problemo:
264 $('.read-more-content').addClass('hide');
265 $('.read-more-show, .read-more-hide').removeClass('hide');
267 // Set up the toggle effect:
268 $('.read-more-show').on('click', function(e) {
269 $(this).next('.read-more-content').removeClass('hide');
270 $(this).addClass('hide');
274 // Changes contributed by @diego-rzg
275 $('.read-more-hide').on('click', function(e) {
276 var p = $(this).parent('.read-more-content');
278 p.prev('.read-more-show').removeClass('hide'); // Hide only the preceding "Read More"
283 function update_info() {
284 var amount = parseInt($("#id_amount").val());
285 var monthly = $("#id_monthly").val() == 'True';
286 if (monthly) slug = "monthly";
287 else if (amount >= parseInt($("#plan-single").attr('data-min-for-year'))) slug = 'single-year';
288 else slug = 'single';
290 var chunk = $('.club-form-info .chunk-' + slug);
291 if (chunk.css('display') == 'none') {
292 $('.chunk-alt').css('height', $('.chunk-alt').height());
293 $('.chunk-alt .chunk').css('position', 'absolute');
295 $('.club-form-info .chunk').fadeOut();
296 $('.club-form-info .chunk.chunk-' + slug).fadeIn(function() {
297 $('.chunk-alt .chunk').css('position', 'static');
298 $('.chunk-alt').css('height', 'auto');
300 $('.chunk-alt').animate({height: chunk.height()}, 100);
304 $("#id_amount").val($("#plan-monthly").attr('data-amount'));
306 $(".button.kwota").click(function() {
307 var plan = $(this).closest('.plan');
308 $('.kwota', plan).removeClass('active')
309 $('.inna', plan).removeClass('active')
310 $(this).addClass('active');
312 var amount = $(this).text();
313 plan.attr("data-amount", amount);
314 $("#id_amount").val(amount);
320 $(".plan-toggle").click(function() {
321 $(".plan-toggle").removeClass('active');
322 $(this).addClass('active')
324 var plan = $("#" + $(this).attr('data-plan'));
326 $("#id_amount").val(plan.attr('data-amount'));
327 $("#id_monthly").val(plan.attr('data-monthly'));
333 $(".inna .button").click(function() {
334 var plan = $(this).closest('.plan');
335 $('.kwota', plan).removeClass('active');
336 $(this).parent().addClass('active');
337 $('input', plan).focus();
339 var amount = $('input', $(this).parent()).val();
340 plan.attr("data-amount", amount);
341 $("#id_amount").val(amount);
347 $(".inna input").on('input', function() {
348 var plan = $(this).closest('.plan');
349 $('.kwota', plan).removeClass('active');
350 var amount = $(this).val();
351 plan.attr("data-amount", amount);
352 $("#id_amount").val(amount);
358 $("#id_method").val('payu-re');
359 $(".methods .button").click(function() {
360 $("#id_method").val($(this).attr('data-method'));
361 $(".methods .button").removeClass('active');
362 $(this).addClass("active");