PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 2.4.8
Booking for Appointments and Events Calendar – Amelia v2.4.8
2.4.8 2.4.7 2.4.6 2.4.5 2.4.4 2.4.3 2.4.2 2.4.1 2.4 trunk 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.2 1.2.20 1.2.21 1.2.22 1.2.23 1.2.24 1.2.25 1.2.26 1.2.27 1.2.28 1.2.29 1.2.3 1.2.30 1.2.31 1.2.32 1.2.33 1.2.34 1.2.35 1.2.36 1.2.37 1.2.38 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.3
ameliabooking / public / js / gutenberg / amelia-block-icon.js
ameliabooking / public / js / gutenberg Last commit date
amelia-booking 2 days ago amelia-catalog 2 days ago amelia-catalog-booking 2 days ago amelia-events 2 days ago amelia-events-calendar-booking 2 days ago amelia-events-list-booking 2 days ago amelia-events-list-booking-button 2 days ago amelia-step-booking 2 days ago amelia-step-booking-button 2 days ago amelia-block-icon.js 2 days ago amelia-gutenberg-placeholder.css 2 days ago
amelia-block-icon.js
255 lines
1 /* eslint-disable quotes */
2 (function (wp) {
3 var el = wp.element.createElement
4 var useNeutralShortcodes = Boolean(window.wpAmeliaUseNeutralShortcodes)
5 var shortcodeAliases = window.wpAmeliaShortcodeAliases || {}
6
7 window.ameliaShortcodeTag = function (view, legacyTag) {
8 return useNeutralShortcodes && shortcodeAliases[view] ? shortcodeAliases[view] : legacyTag
9 }
10
11 window.ameliaResolvePluginName = function () {
12 var customName = window.wpAmeliaPluginName && String(window.wpAmeliaPluginName).trim()
13
14 if (customName) {
15 return customName
16 }
17
18 if (useNeutralShortcodes && window.wpAmeliaBuilderBrandName) {
19 return String(window.wpAmeliaBuilderBrandName).trim() || 'Amelia'
20 }
21
22 return 'Amelia'
23 }
24
25 window.ameliaGutenbergLabel = function (label) {
26 // Keep custom name, or default "Amelia" when white-label has no plugin name.
27 label = String(label || '').replace(/\{pluginName\}/g, window.ameliaResolvePluginName())
28
29 if (!useNeutralShortcodes) {
30 return label
31 }
32
33 return label.replace(/\s\(Legacy\)$/, '')
34 }
35
36 function sanitizeLabels(labels) {
37 Object.keys(labels || {}).forEach(function (key) {
38 if (typeof labels[key] === 'string') {
39 labels[key] = window.ameliaGutenbergLabel(labels[key])
40 return
41 }
42
43 if (labels[key] && typeof labels[key] === 'object') {
44 sanitizeLabels(labels[key])
45 }
46 })
47 }
48
49 // Always resolve {pluginName}; also strip brand when neutral shortcodes are active.
50 sanitizeLabels(window.wpAmeliaLabels)
51
52 window.ameliaGutenbergHelpLink = function (href, style) {
53 if (useNeutralShortcodes) {
54 return null
55 }
56
57 return el(
58 "a",
59 {href: href, target: "_blank", rel: "noopener noreferrer", style: style},
60 "Start working with Amelia WordPress Appointment Booking plugin"
61 )
62 }
63
64 // Shared Amelia block icon.
65 // White-label + custom image: uploaded brand logo.
66 // White-label without image / no white-label: Amelia logo.
67 function createAmeliaSvgIcon() {
68 return el(
69 "svg",
70 {
71 width: "20",
72 height: "20",
73 viewBox: "0 0 20 20",
74 fill: "none",
75 xmlns: "http://www.w3.org/2000/svg"
76 },
77 el("path", {
78 d: "M11.0084 1.32972V7.10632C11.0084 7.58281 11.2628 8.02212 11.675 8.25862L16.6701 11.1222C17.5529 11.6284 18.6513 10.9892 18.6513 9.96993V4.22064C18.6513 3.74647 18.3991 3.30833 17.9893 3.07124L12.9942 0.179748C12.1114 -0.331029 11.0078 0.307587 11.0078 1.32914L11.0084 1.32972Z",
79 fill: "#4A3BD6"
80 }),
81 el("path", {
82 d: "M9.64395 1.32972V7.10632C9.64395 7.58281 9.3895 8.02212 8.97739 8.25862L3.98222 11.1222C3.09946 11.6284 2.00108 10.9892 2.00108 9.96993V4.22064C2.00108 3.74647 2.25321 3.30833 2.663 3.07124L7.65817 0.179748C8.54093 -0.331029 9.64453 0.307587 9.64453 1.32914L9.64395 1.32972Z",
83 fill: "#7165DF"
84 }),
85 el("path", {
86 d: "M9.5927 9.40127L4.56913 12.2811C3.68231 12.7896 3.67941 14.0709 4.56449 14.5828L9.58806 17.4906C9.99785 17.7277 10.5027 17.7277 10.9119 17.4906L15.9355 14.5828C16.8206 14.0709 16.8177 12.7896 15.9308 12.2811L10.9073 9.40127C10.4998 9.16767 10.0002 9.16767 9.5927 9.40127Z",
87 fill: "#9E94F8"
88 })
89 )
90 }
91
92 function createBlockIcon() {
93 var imageUrl = useNeutralShortcodes && window.wpAmeliaPluginImage
94 ? String(window.wpAmeliaPluginImage).trim()
95 : ''
96
97 if (imageUrl) {
98 return el("img", {
99 src: imageUrl,
100 alt: "",
101 width: 20,
102 height: 20,
103 style: {
104 objectFit: "contain",
105 display: "block"
106 }
107 })
108 }
109
110 return createAmeliaSvgIcon()
111 }
112
113 window.ameliaBlockIcon = createBlockIcon()
114
115 // Shared Gutenberg helpers (icon script loads first for all Amelia blocks).
116 window.ameliaGutenbergShared = window.ameliaGutenbergShared || {}
117
118 // Enables the hover preview card in the block inserter.
119 // Gutenberg shows "No preview available." when `example` is missing.
120 window.ameliaGutenbergShared.getBlockExample = function () {
121 return {
122 attributes: {
123 ameliaInserterPreview: true
124 }
125 }
126 }
127
128 window.ameliaGutenbergShared.isInserterPreview = function (attributes) {
129 return !!(attributes && attributes.ameliaInserterPreview)
130 }
131
132 window.ameliaGutenbergShared.getBlockPreview = function (preview) {
133 preview = preview || {}
134
135 return el('picture', {},
136 el('source', {
137 media: '(max-width: 479px)',
138 srcSet: preview.mobile || ''
139 }),
140 el('img', {
141 src: preview.desktop || '',
142 alt: '',
143 style: {
144 maxWidth: '100%',
145 height: 'auto',
146 display: 'block',
147 margin: '0 auto'
148 }
149 })
150 )
151 }
152
153 window.ameliaGutenbergShared.getSharedShortcodeDepricatedAttributes = function () {
154 return {
155 ivy: {type: 'string', default: ''},
156 trigger: {type: 'string', default: ''},
157 trigger_type: {type: 'string', default: 'id'},
158 in_dialog: {type: 'boolean', default: false},
159 }
160 }
161
162 window.ameliaGutenbergShared.getSharedShortcodeAttributes = function () {
163 return {
164 ivy: {
165 type: 'string',
166 default: ''
167 },
168 trigger: {
169 type: 'string',
170 default: ''
171 },
172 trigger_type: {
173 type: 'string',
174 default: 'id'
175 },
176 in_dialog: {
177 type: 'boolean',
178 default: false
179 },
180 }
181 }
182
183 window.ameliaGutenbergShared.setSharedShortcodeElements = function (inspectorElements, components, attributes, props, options, data) {
184 inspectorElements.push(el(components.TextControl, {
185 id: 'amelia-js-trigger',
186 label: wpAmeliaLabels.manually_loading,
187 value: attributes.trigger,
188 help: wpAmeliaLabels.manually_loading_description,
189 onChange: function (TextControl) {
190 return props.setAttributes({trigger: TextControl})
191 }
192 }))
193
194 if (attributes.trigger) {
195 inspectorElements.push(el(components.SelectControl, {
196 id: 'amelia-js-trigger_type',
197 label: wpAmeliaLabels.trigger_type,
198 value: attributes.trigger_type,
199 options: options.trigger_type,
200 help: wpAmeliaLabels.trigger_type_tooltip,
201 onChange: function (selectControl) {
202 return props.setAttributes({trigger_type: selectControl})
203 }
204 }))
205
206 inspectorElements.push(el(components.PanelRow,
207 {},
208 el('label', {htmlFor: 'amelia-js-in-dialog'}, wpAmeliaLabels.in_dialog),
209 el(components.FormToggle, {
210 id: 'amelia-js-in-dialog',
211 checked: attributes.in_dialog,
212 onChange: function () {
213 return props.setAttributes({in_dialog: !props.attributes.in_dialog})
214 }
215 })
216 ))
217 }
218
219 if (!attributes.trigger && data.ivy && data.ivy.length) {
220 inspectorElements.push(el(components.SelectControl, {
221 id: "amelia-js-select-ivy",
222 label: wpAmeliaLabels.ivy,
223 help: wpAmeliaLabels.ivy_tooltip,
224 value: String(attributes.ivy),
225 options: data.ivy,
226 onChange: function (selectControl) {
227 return props.setAttributes({ivy: selectControl})
228 }
229 }))
230 }
231 }
232
233 window.ameliaGutenbergShared.getSharedShortcodeString = function (attributes) {
234 let shortCode = ''
235
236 if (attributes.trigger) {
237 shortCode += ' trigger=' + attributes.trigger + ''
238 }
239
240 if (attributes.trigger && attributes.trigger_type) {
241 shortCode += ' trigger_type=' + attributes.trigger_type + ''
242 }
243
244 if (attributes.trigger && attributes.in_dialog) {
245 shortCode += ' in_dialog=1'
246 }
247
248 if (attributes.trigger === '' && attributes.ivy) {
249 shortCode += ' ivy=' + attributes.ivy + ''
250 }
251
252 return shortCode
253 }
254 })(window.wp)
255