script.php
56 lines
| 1 | <?php |
| 2 | /** |
| 3 | * @package VikAppointments - Libraries |
| 4 | * @subpackage html.form |
| 5 | * @author E4J s.r.l. |
| 6 | * @copyright Copyright (C) 2021 E4J s.r.l. All Rights Reserved. |
| 7 | * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL |
| 8 | * @link https://vikwp.com |
| 9 | */ |
| 10 | |
| 11 | // No direct access |
| 12 | defined('ABSPATH') or die('No script kiddies please!'); |
| 13 | |
| 14 | ?> |
| 15 | |
| 16 | <script> |
| 17 | |
| 18 | (function($) { |
| 19 | 'use script'; |
| 20 | |
| 21 | $(function() { |
| 22 | // iterate all postbox containers generated by VikAppointments |
| 23 | $('.postbox-container.vap').each(function() { |
| 24 | // find postbox wrapper |
| 25 | const postbox = $(this).find('.postbox'); |
| 26 | |
| 27 | // find toggle button inside postbox and register click action |
| 28 | $(this).find('button.toggler').off('click').on('click', function() { |
| 29 | let status; |
| 30 | |
| 31 | if (postbox.hasClass('closed')) { |
| 32 | postbox.removeClass('closed'); |
| 33 | $(this).find('i').removeClass('fa-caret-down').addClass('fa-caret-up'); |
| 34 | status = 1; |
| 35 | } else { |
| 36 | postbox.addClass('closed'); |
| 37 | $(this).find('i').removeClass('fa-caret-up').addClass('fa-caret-down'); |
| 38 | status = 0; |
| 39 | } |
| 40 | |
| 41 | const tag = postbox.data('tag'); |
| 42 | |
| 43 | if (tag) { |
| 44 | const date = new Date(); |
| 45 | date.setYear(date.getFullYear() + 1); |
| 46 | |
| 47 | // keep status in a cookie for a year |
| 48 | document.cookie = tag + '=' + status + '; expires=' + date.toUTCString() + '; path=/'; |
| 49 | } |
| 50 | }); |
| 51 | }); |
| 52 | }); |
| 53 | })(jQuery); |
| 54 | |
| 55 | </script> |
| 56 |