default.php
3 days ago
default_position_modal.php
3 days ago
default_widget_modal.php
3 days ago
index.html
3 days ago
default_position_modal.php
99 lines
| 1 | <?php |
| 2 | /** |
| 3 | * @package VikAppointments |
| 4 | * @subpackage core |
| 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 | $vik = VAPApplication::getInstance(); |
| 15 | |
| 16 | ?> |
| 17 | |
| 18 | <div class="inspector-form" id="inspector-position-form"> |
| 19 | |
| 20 | <div class="inspector-fieldset"> |
| 21 | |
| 22 | <?php |
| 23 | $help = $vik->createPopover(array( |
| 24 | 'title' => JText::translate('VAP_WIDGET_POSITION'), |
| 25 | 'content' => JText::translate('VAP_WIDGET_POSITION_ADD_HELP'), |
| 26 | )); |
| 27 | |
| 28 | echo $vik->openControl(JText::translate('VAP_WIDGET_POSITION') . $help); ?> |
| 29 | <input type="text" name="position_name" value="" class="field required" /> |
| 30 | <?php echo $vik->closeControl(); ?> |
| 31 | |
| 32 | </div> |
| 33 | |
| 34 | </div> |
| 35 | |
| 36 | <?php |
| 37 | JText::script('VAP_WIDGET_POSITION_EXISTS_ERR'); |
| 38 | ?> |
| 39 | |
| 40 | <script> |
| 41 | |
| 42 | var positionValidator; |
| 43 | |
| 44 | (function($) { |
| 45 | 'use strict'; |
| 46 | |
| 47 | $(function() { |
| 48 | positionValidator = new VikFormValidator('#inspector-position-form'); |
| 49 | |
| 50 | positionValidator.addCallback(function() { |
| 51 | // get position input |
| 52 | var input = $('#inspector-position-form input[name="position_name"]'); |
| 53 | |
| 54 | // get position value |
| 55 | var data = getPositionData(); |
| 56 | |
| 57 | // make sure the position is not empty |
| 58 | if (!data.position) { |
| 59 | positionValidator.setInvalid(input); |
| 60 | |
| 61 | return false; |
| 62 | } |
| 63 | // make sure the position doesn't already exist |
| 64 | else if ($('.widgets-position-row[data-position="' + data.position + '"]').length) { |
| 65 | positionValidator.setInvalid(input); |
| 66 | |
| 67 | // inform the user that the position already exists |
| 68 | alert(Joomla.JText._('VAP_WIDGET_POSITION_EXISTS_ERR')); |
| 69 | |
| 70 | return false; |
| 71 | } |
| 72 | |
| 73 | // position is ok |
| 74 | positionValidator.unsetInvalid(input); |
| 75 | |
| 76 | return true; |
| 77 | }); |
| 78 | |
| 79 | }); |
| 80 | })(jQuery); |
| 81 | |
| 82 | function clearPositionForm() { |
| 83 | jQuery('#inspector-position-form input[name="position_name"]').val(''); |
| 84 | } |
| 85 | |
| 86 | function getPositionData() { |
| 87 | var data = {}; |
| 88 | |
| 89 | // get specified position |
| 90 | data.position = jQuery('#inspector-position-form input[name="position_name"]').val(); |
| 91 | |
| 92 | // strip any non supported character |
| 93 | data.position = data.position.replace(/[^a-zA-Z0-9_-]/g, ''); |
| 94 | |
| 95 | return data; |
| 96 | } |
| 97 | |
| 98 | </script> |
| 99 |