PluginProbe ʕ •ᴥ•ʔ
VikAppointments Services Booking Calendar / 1.2.21
VikAppointments Services Booking Calendar v1.2.21
1.2.21 1.2.20 trunk 1.2.17 1.2.18 1.2.19
vikappointments / site / layouts / form / fields / tel.php
vikappointments / site / layouts / form / fields Last commit date
checkbox.php 2 days ago color.php 2 days ago date.php 2 days ago editor.php 2 days ago file.php 2 days ago hidden.php 2 days ago html.php 2 days ago index.html 2 days ago number.php 2 days ago select.php 2 days ago separator.php 2 days ago tel.php 2 days ago text.php 2 days ago textarea.php 2 days ago
tel.php
75 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 $name = !empty($displayData['name']) ? $displayData['name'] : 'name';
15 $id = !empty($displayData['id']) ? $displayData['id'] : $name;
16 $value = isset($displayData['value']) ? $displayData['value'] : '';
17 $class = isset($displayData['class']) ? $displayData['class'] : '';
18
19 $config = array(
20 // custom data to be passed when initializing
21 // international tel input
22 'data' => array(
23 // display flags dropdown according to the
24 // global configuration (Show Prefix Selection)
25 'allowDropdown' => VAPFactory::getConfig()->getBool('showphprefix'),
26 ),
27 );
28
29 // render input using intltel
30 JHtml::fetch('vaphtml.assets.intltel', '#' . $id, $config);
31
32 ?>
33
34 <input
35 type="tel"
36 name="<?php echo $this->escape($name); ?>"
37 id="<?php echo $this->escape($id); ?>"
38 value="<?php echo $this->escape($value); ?>"
39 size="40"
40 class="<?php echo $this->escape($class); ?>"
41 aria-labelledby="<?php echo $id; ?>-label"
42 />
43
44 <input type="hidden" name="<?php echo $this->escape($id); ?>_dialcode" value="" />
45 <input type="hidden" name="<?php echo $this->escape($id); ?>_country" value="" />
46
47 <script>
48
49 jQuery(function($) {
50 // save "country code" and "dial code" every time the phone number changes
51 $('#<?php echo $id; ?>').on('change countrychange', function() {
52 var country = $(this).intlTelInput('getSelectedCountryData');
53
54 if (!country) {
55 return false;
56 }
57
58 if (country.iso2) {
59 $('input[name="<?php echo $id; ?>_country"]').val(country.iso2.toUpperCase());
60 }
61
62 if (country.dialCode) {
63 var dial = '+' + country.dialCode.toString().replace(/^\+/);
64
65 if (country.areaCodes) {
66 dial += ' ' + country.areaCodes[0];
67 }
68
69 $('input[name="<?php echo $id; ?>_dialcode"]').val(dial);
70 }
71 }).trigger('change');
72 });
73
74 </script>
75