PluginProbe
Timetics – Appointment Booking Calendar & Scheduling / 1.0.12
Timetics – Appointment Booking Calendar & Scheduling v1.0.12
1.0.64 1.0.62 1.0.63 1.0.61 1.0.60 1.0.59 1.0.58 1.0.57 1.0.56 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.2 1.0.20 1.0.21 All 65 releases
timetics / assets / js / meeting-filter.js

meeting-filter.js in Timetics – Appointment Booking Calendar & Scheduling 1.0.12, at assets/js/meeting-filter.js

128 lines 4.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 jQuery(document).ready(function ($) {
2 const category = $("#timetics-filter-category");
3 const staff = $("#timetics-filter-staff");
4 const url = timetics.site_url + "/wp-json/timetics/v1/appointments/filter";
5 const meetinContainer = $(".tt-meeting-list-wrapper");
6
7 $(category).on("change", function (e) {
8 e.preventDefault();
9
10 $.ajax({
11 url: url,
12 method: "GET",
13 data: {
14 category: $(this).val(),
15 },
16 success: function (res) {
17 if (Array.isArray(res.data.items)) {
18 const meetings_markup = prepare_items(res.data.items);
19 meetinContainer.html(meetings_markup);
20 }
21 },
22 });
23 });
24
25 $(staff).on("change", function (e) {
26 e.preventDefault();
27
28 $.ajax({
29 url: url,
30 method: "GET",
31 data: {
32 staff_id: $(this).val(),
33 },
34 success: function (res) {
35 if (Array.isArray(res.data.items)) {
36 const meetings_markup = prepare_items(res.data.items);
37 meetinContainer.html(meetings_markup);
38 }
39 },
40 });
41 });
42
43 /**
44 * Prepare meeting itesm
45 *
46 * @return string
47 */
48 function prepare_items(items) {
49 if (items.length < 1) {
50 return `<p>No meetings found</p>`;
51 }
52
53 const meetings = items
54 .map((item) => {
55 const staffs = preapare_staff(item.staff);
56 return `
57 <div class="tt-meeting-list-item">
58 <!-- Staff -->
59 ${staffs}
60 <h3 class="tt-title">
61 ${item.name}
62 </h3>
63 <!-- meeting description -->
64 <p>Meeting description</p>
65
66 <!-- meeting info -->
67 <ul class="meeting-info-list">
68 <!-- meeting duration -->
69 <li>
70 <svg fill="#3263F8" width="18" height="18" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
71 <path d="M256 512C114.6 512 0 397.4 0 256S114.6 0 256 0S512 114.6 512 256s-114.6 256-256 256zM232 120V256c0 8 4 15.5 10.7 20l96 64c11 7.4 25.9 4.4 33.3-6.7s4.4-25.9-6.7-33.3L280 243.2V120c0-13.3-10.7-24-24-24s-24 10.7-24 24z" />
72 </svg>
73 ${item.duration}
74 </li>
75 <!-- meeting price -->
76 </ul>
77 <button class="ant-btn ant-btn-primary ant-btn-block" data-id="${item.id}">
78 Book Appointment
79 </button>
80 <div class="timetics-booking-modal"></div>
81 </div>`;
82 })
83 .join("");
84
85 return meetings;
86 }
87
88 function preapare_staff(staffs) {
89 const totalStaff = staffs.length;
90 let markup = "";
91
92 if (totalStaff > 2) {
93 markup = `<ul class="tt-author tt-author-avatar-list">
94 ${staffs
95 .map((staff) => {
96 return `
97 <li class="tt-single-host">
98 ${staff.image
99 ? `<img src="${staff.image}" alt="${staff.full_name}" />`
100 : ""
101 }
102 <div class="tt-tooltip-text">${staff.full_name}</div>
103 </li>
104 `;
105 })
106 .join("")}
107 </ul>`;
108 } else {
109 markup = `<ul class="tt-author">
110 ${staffs
111 .map((staff) => {
112 return `
113 <li>
114 ${staff.image
115 ? `<img src="${staff.image}" alt="${staff.full_name}" />`
116 : ""
117 }
118 <span>${staff.full_name}</span>
119 </li>`;
120 })
121 .join("")}
122 </ul>`;
123 }
124
125 return markup;
126 }
127 });
128