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 / admin / views / manageanalytics / tmpl / default_widget_modal.php
vikappointments / admin / views / manageanalytics / tmpl Last commit date
default.php 2 days ago default_position_modal.php 2 days ago default_widget_modal.php 2 days ago index.html 2 days ago
default_widget_modal.php
244 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-widget-form">
19
20 <div class="inspector-fieldset">
21
22 <!-- WIDGET NAME - Text -->
23
24 <?php
25 $help = $vik->createPopover(array(
26 'title' => JText::translate('VAP_WIDGET_NAME'),
27 'content' => JText::translate('VAP_WIDGET_NAME_DESC'),
28 ));
29
30 echo $vik->openControl(JText::translate('VAP_WIDGET_NAME') . $help); ?>
31 <input type="text" name="widget_name" value="" placeholder="" class="field" />
32 <?php echo $vik->closeControl(); ?>
33
34 <!-- WIDGET CLASS - Select -->
35
36 <?php
37 $options = array(
38 JHtml::fetch('select.option', '', ''),
39 );
40
41 foreach ($this->supported as $widget)
42 {
43 $options[] = JHtml::fetch('select.option', $widget->getName(), $widget->getTitle());
44 }
45
46 $help = $vik->createPopover(array(
47 'title' => JText::translate('VAP_WIDGET_CLASS'),
48 'content' => JText::translate('VAP_WIDGET_CLASS_DESC'),
49 ));
50
51 echo $vik->openControl(JText::translate('VAP_WIDGET_CLASS') . '*' . $help); ?>
52 <select name="widget_class" class="field required">
53 <?php echo JHtml::fetch('select.options', $options); ?>
54 </select>
55 <?php echo $vik->closeControl(); ?>
56
57 <!-- WIDGET POSITION - Select -->
58
59 <?php
60 $options = array(
61 JHtml::fetch('select.option', '', ''),
62 );
63
64 foreach ($this->positions as $position)
65 {
66 $options[] = JHtml::fetch('select.option', $position, $position);
67 }
68
69 $help = $vik->createPopover(array(
70 'title' => JText::translate('VAP_WIDGET_POSITION'),
71 'content' => JText::translate('VAP_WIDGET_POSITION_DESC'),
72 ));
73
74 echo $vik->openControl(JText::translate('VAP_WIDGET_POSITION') . '*' . $help); ?>
75 <select name="widget_position" class="field required">
76 <?php echo JHtml::fetch('select.options', $options); ?>
77 </select>
78 <?php echo $vik->closeControl(); ?>
79
80 <!-- WIDGET SIZE - Select -->
81
82 <?php
83 $options = array(
84 JHtml::fetch('select.option', '', ''),
85 JHtml::fetch('select.option', 'extra-small', JText::translate('VAP_WIDGET_SIZE_OPT_EXTRA_SMALL')),
86 JHtml::fetch('select.option', 'small', JText::translate('VAP_WIDGET_SIZE_OPT_SMALL')),
87 JHtml::fetch('select.option', 'normal', JText::translate('VAP_WIDGET_SIZE_OPT_NORMAL')),
88 JHtml::fetch('select.option', 'large', JText::translate('VAP_WIDGET_SIZE_OPT_LARGE')),
89 JHtml::fetch('select.option', 'extra-large', JText::translate('VAP_WIDGET_SIZE_OPT_EXTRA_LARGE')),
90 );
91
92 $help = $vik->createPopover(array(
93 'title' => JText::translate('VAP_WIDGET_SIZE'),
94 'content' => JText::translate('VAP_WIDGET_SIZE_DESC'),
95 ));
96
97 echo $vik->openControl(JText::translate('VAP_WIDGET_SIZE') . $help); ?>
98 <select name="widget_size" class="field">
99 <?php echo JHtml::fetch('select.options', $options); ?>
100 </select>
101 <?php echo $vik->closeControl(); ?>
102
103 </div>
104
105 <?php
106 foreach ($this->supported as $widget)
107 {
108 ?>
109 <div
110 class="inspector-fieldset widget-desc"
111 data-name="<?php echo $widget->getName(); ?>"
112 data-title="<?php echo $this->escape($widget->getTitle()); ?>"
113 style="display:none;"
114 >
115 <?php
116 // show widget description, if any
117 $desc = $widget->getDescription();
118
119 if ($desc)
120 {
121 echo $vik->alert($desc, 'info');
122 }
123 ?>
124 </div>
125 <?php
126 }
127 ?>
128
129 <input type="hidden" name="widget_id" value="0" />
130
131 </div>
132
133 <?php
134 JText::script('VAP_WIDGET_SELECT_CLASS');
135 JText::script('VAP_WIDGET_SELECT_POSITION');
136 JText::script('VAP_WIDGET_SIZE_OPT_DEFAULT');
137 ?>
138
139 <script>
140
141 var widgetValidator = new VikFormValidator('#inspector-widget-form');
142
143 (function($) {
144 'use strict';
145
146 $(function() {
147 $('#inspector-widget-form select[name="widget_class"]').select2({
148 placeholder: Joomla.JText._('VAP_WIDGET_SELECT_CLASS'),
149 allowClear: false,
150 });
151
152 $('#inspector-widget-form select[name="widget_position"]').select2({
153 placeholder: Joomla.JText._('VAP_WIDGET_SELECT_POSITION'),
154 allowClear: false,
155 });
156
157 $('#inspector-widget-form select[name="widget_size"]').select2({
158 minimumResultsForSearch: -1,
159 placeholder: Joomla.JText._('VAP_WIDGET_SIZE_OPT_DEFAULT'),
160 allowClear: true,
161 });
162
163 $('#inspector-widget-form select[name="widget_class"]').on('change', function() {
164 // hide all descriptions
165 $('#inspector-widget-form .widget-desc').hide();
166
167 // get selected widget
168 var widget = $('#inspector-widget-form .widget-desc[data-name="' + $(this).val() + '"]');
169
170 // get name input
171 var nameInput = $('#inspector-widget-form input[name="widget_name"]');
172
173 // set up placeholder
174 nameInput.attr('placeholder', widget.data('title'));
175
176 if (nameInput.val() == widget.data('title')) {
177 // specified title is equals to the default one, unset it
178 nameInput.val('');
179 }
180
181 // show description of selected widget
182 widget.show();
183 });
184 });
185 })(jQuery);
186
187 function setupWidgetData(data) {
188 // fill ID
189 jQuery('#inspector-widget-form input[name="widget_id"]').val(data.id ? data.id : 0);
190
191 // fill name
192 jQuery('#inspector-widget-form input[name="widget_name"]').val(data.name);
193
194 // fill widget class
195 data.widget = data.widget || data.class;
196
197 jQuery('#inspector-widget-form select[name="widget_class"]').select2('val', data.widget ? data.widget : '').trigger('change');
198
199 // fill widget position
200 jQuery('#inspector-widget-form select[name="widget_position"]').select2('val', data.position ? data.position : '');
201
202 // fill widget size
203 jQuery('#inspector-widget-form select[name="widget_size"]').select2('val', data.size ? data.size : '');
204 }
205
206 function getWidgetData() {
207 var data = {};
208
209 // extract widget data
210 jQuery('#inspector-widget-form')
211 .find('input,select')
212 .filter('[name^="widget_"]')
213 .each(function() {
214 var name = jQuery(this).attr('name').replace(/^widget_/, '');
215 var value = jQuery(this).val();
216
217 data[name] = value;
218 });
219
220 // replicate CLASS in WIDGET property
221 data.widget = data.class;
222
223 return data;
224 }
225
226 function getDefaultWidget(widget) {
227 // get widget
228 var widget = jQuery('#inspector-widget-form .widget-desc[data-name="' + widget + '"]');
229
230 var data = {
231 name: widget.data('name'),
232 title: widget.data('title'),
233 description: widget.html(),
234 };
235
236 return data;
237 }
238
239 function addPositionOption(position) {
240 jQuery('#inspector-widget-form select[name="widget_position"]').append('<option value="' + position + '">' + position + '</option>');
241 }
242
243 </script>
244