PluginProbe
Float menu – awesome floating side menu / 5.0.3
Float menu – awesome floating side menu v5.0.3
7.2.5 trunk 2.1 2.2 3.0.1 3.1 3.2.2 3.3.1 3.5 3.5.1 3.5.2 3.5.3. 3.5.4 4.0 4.1 4.1.1 4.2 4.3 4.3.1 4.3.2 5.0 5.0.1 5.0.2 5.0.3 5.1 All 57 releases
float-menu / admin / assets / js / script.js

script.js in Float menu – awesome floating side menu 5.0.3, at admin/assets/js/script.js

465 lines 11.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 'use strict';
2
3 (function($) {
4
5 // Submit Form for save
6 $('#wow-plugin').on('submit', function(event) {
7 event.preventDefault();
8 get_tinymce_content();
9 const dataform = $(this).serialize();
10 let prefix = $('#prefix').val();
11 let data = 'action=' + prefix + '_item_save&' + dataform;
12 $('.wow-plugin .saving').animate({opacity: '0.75'});
13 $.post(ajaxurl, data, function(response) {
14 if (response.status == 'OK') {
15 $('#wow-message').addClass('notice notice-success is-dismissible');
16 $('#wow-message').html('<p>' + response.message + '</p>');
17 $('#add_action').val(2);
18 let tool_id = $('#tool_id').val();
19 $('.nav-tab.nav-tab-active').text('Update #' + tool_id);
20 }
21 $('.wow-plugin .saving').animate({opacity: '0'});
22 });
23 });
24
25 // Get Tinymce contetn
26 function get_tinymce_content() {
27 if ($('#wp-popupcontent-wrap').hasClass('tmce-active')) {
28 let content = tinyMCE.activeEditor.getContent();
29 $('#popupcontent').val(content);
30 }
31 }
32
33 // Tabs
34 $('#tab li').on('click', function() {
35 const selected = $(this).data('tab');
36 $('#tab li').removeClass('is-active');
37 $(this).addClass('is-active');
38 $('.tab-content').addClass('is-hidden');
39 $('[data-content="' + selected + '"]').removeClass('is-hidden');
40 });
41
42 // Tooltip
43 wow_attach_tooltips($('.wow-help'));
44
45 function wow_attach_tooltips(selector) {
46 selector.tooltip({
47 content: function() {
48 return $(this).prop('title');
49 },
50 tooltipClass: 'wow-ui-tooltip',
51 position: {
52 my: 'center top',
53 at: 'center bottom+10',
54 collision: 'flipfit',
55 },
56 hide: {
57 duration: 200,
58 },
59 show: {
60 duration: 200,
61 },
62 });
63 }
64
65 // CheckLabel
66
67 $('.checkLabel').each(function() {
68 checkLabel(this);
69 }).on('click', function() {
70 checkLabel(this);
71 });
72
73 function checkLabel(el) {
74 const check = $(el).find('input');
75 if (check.prop('checked')) {
76 $(el).parent().find('.field').removeClass('is-hidden');
77 } else {
78 $(el).parent().find('.field').addClass('is-hidden');
79 }
80 }
81
82 // CheckBLock
83 $('.checkBlock').each(function() {
84 checkBlock(this);
85 }).on('click', function() {
86 checkBlock(this);
87 });
88
89 function checkBlock(el) {
90 const check = $(el).find('input');
91 if (check.prop('checked')) {
92 $(el).closest('.columns').children('.blockHidden').removeClass('is-hidden');
93 } else {
94 $(el).closest('.columns').children('.blockHidden').addClass('is-hidden');
95 }
96 }
97
98 // Publish
99 publish();
100 $('#show').on('change', publish);
101
102 function publish() {
103 const type = $('#show').val();
104 switch (type) {
105 case 'shortecode':
106 $('#shortcode').fadeIn();
107 break;
108 case 'taxonomy':
109 $('#taxonomy, #id-post').fadeIn();
110 break;
111 case 'posts':
112 case 'pages':
113 case 'expost':
114 case 'expage':
115 case 'postsincat':
116 $('#id-post').fadeIn();
117 break;
118 default:
119 $('#taxonomy, #id-post, #shortcode').hide();
120 break;
121 }
122 }
123
124 // Set value in input hidden for checkbox
125 $('.wow-plugin input:checkbox:checked').each(function() {
126 $(this).siblings('input[type="hidden"]').val('1');
127 });
128
129 $('body').on('click', '.wow-plugin input:checkbox', function() {
130 checkboxchecked(this);
131 });
132
133 function checkboxchecked(el) {
134 if ($(el).prop('checked')) {
135 $(el).siblings('input[type="hidden"]').val('1');
136 } else {
137 $(el).siblings('input[type="hidden"]').val('0');
138 }
139 }
140
141 // Change user role
142 usersroles();
143 $('#item_user').on('change', function() {
144 usersroles();
145 });
146
147 function usersroles() {
148 const type = $('#item_user').val();
149 $('.item-user').fadeOut('200');
150 if (type == '2') {
151 $('.item-user').fadeIn('200');
152 }
153 }
154
155 // Select Item type
156 $('select.item-type').each(function() {
157 itemtype(this);
158 });
159
160 $('body').on('change', '.item-type', function() {
161 itemtype(this);
162 });
163
164 function itemtype(el) {
165 const type = $(el).val();
166 const typeText = $(el).find('option:selected').text();
167 const parent = $(el).parents('.tabs-content');
168 const itemLink = $(parent).find('.item-link');
169 const itemShare = $(parent).find('.item-share');
170 const itemTranslate = $(parent).find('.item-translate');
171 const itemLinkBlank = $(parent).find('.item-link-blank');
172 const itemModal = $(parent).find('.item-modal');
173 const itemText = $(parent).find('.item-link-text');
174 $(el).parents('.panel').find('.element-type').text(typeText);
175 $(itemLink).hide();
176 $(itemShare).hide();
177 $(itemTranslate).hide();
178 $(itemLinkBlank).hide();
179 $(itemModal).hide();
180 switch (type) {
181 case 'link':
182 case 'smoothscroll':
183 case 'email':
184 case 'telephone':
185 case 'login':
186 case 'logout':
187 case 'lostpassword':
188 $(itemLink).show();
189 break;
190 case 'share':
191 $(itemShare).show();
192 break;
193 case 'id':
194 case 'class':
195 case 'modal':
196 $(itemModal).show();
197 break;
198 case 'translate':
199 $(itemTranslate).show();
200 break;
201 }
202
203 switch (type) {
204 case 'link':
205 case 'smoothscroll':
206 case 'login':
207 case 'logout':
208 case 'lostpassword':
209 $(itemText).text('Link');
210 break;
211 case 'email':
212 $(itemText).text('Email');
213 break;
214 case 'telephone':
215 $(itemText).text('Telephone');
216 break;
217 }
218
219 if (type === 'link' || type === 'dynamic') {
220 $(itemLinkBlank).show();
221 }
222
223
224
225 }
226
227 // Color Picker
228 $('.wp-color-picker-field').wpColorPicker({
229 change: function(event, ui){ panelHeadingIconColor(this); },
230 });
231
232
233 // Label keydown
234 $('body').on('keyup', '.item-tooltip', function() {
235 const val = $(this).val();
236 const parent = $(this).parents('.panel');
237 $(parent).find('.item-label-text').html(val);
238 if (val == '') {
239 $(parent).find('.item-label-text').html('(no label)');
240 }
241 });
242
243 // Toogle menu item
244
245 $('body').on('click', '.toogle-element .dashicons-arrow-down', function() {
246 const parent = $(this).parents('.panel');
247 $(parent).find('.toogle-content').removeClass('is-hidden');
248 $(this).addClass('is-hidden');
249 $(parent).find('.dashicons-arrow-up').removeClass('is-hidden');
250 });
251
252 $('body').on('click', '.toogle-element .dashicons-arrow-up', function() {
253 const parent = $(this).parents('.panel');
254 $(parent).find('.toogle-content').addClass('is-hidden');
255 $(this).addClass('is-hidden');
256 $(parent).find('.dashicons-arrow-down').removeClass('is-hidden');
257 });
258
259 // Check sub-item
260 $('input.sub-item:checkbox').each(function() {
261 subitem(this);
262 });
263 $('body').on('change', 'input.sub-item', function() {
264 subitem(this);
265 });
266
267 function subitem(el) {
268 const parent = $(el).parents('.panel');
269 if ($(el).prop('checked')) {
270 $(parent).find('.is-submenu').removeClass('is-hidden');
271 } else {
272 $(parent).find('.is-submenu').addClass('is-hidden');
273 }
274 }
275
276 // Check custom icon
277 $('.icons').fontIconPicker({
278 theme: 'fip-darkgrey',
279 emptyIcon: false,
280 allCategoryText: 'Show all',
281 });
282
283
284 $('input.custom-icon:checkbox').each(function() {
285 customicon(this);
286 });
287 $('body').on('click', '.custom-icon', function() {
288 customicon(this);
289 });
290
291 function customicon(el) {
292 const parent = $(el).parents('.tabs-content');
293 const iconDefault = $(parent).find('.icon-default');
294 const iconCustom = $(parent).find('.icon-custom');
295 const iconText = $(parent).find('.icon-text');
296 const iconTextField = $(parent).find('.icon-text-field');
297 const checkText = $(parent).find('.custom-icon-text');
298 if ($(el).prop('checked')) {
299 $(iconDefault).hide();
300 $(iconCustom).show();
301 $(iconText).hide();
302 $(checkText).prop('checked', false);
303 $(iconTextField).addClass('is-hidden');
304 } else {
305 $(iconDefault).show();
306 $(iconCustom).hide();
307 $(iconText).show();
308 }
309
310 }
311
312 $('input.custom-icon-text:checkbox').each(function() {
313 customIconText(this);
314 });
315 $('body').on('click', '.custom-icon-text', function() {
316 customIconText(this);
317 });
318
319 function customIconText(el) {
320 const parent = $(el).parents('.tabs-content');
321 const iconDefault = $(parent).find('.icon-default');
322 const iconCustom = $(parent).find('.icon-custom');
323 const iconText = $(parent).find('.icon-text-field');
324 const checkCustomIcon = $(parent).find('.custom-icon');
325 if ($(el).prop('checked')) {
326 $(iconDefault).hide();
327 $(iconCustom).hide();
328 $(iconText).removeClass('is-hidden');
329 $(checkCustomIcon).prop('checked', false);
330 } else {
331 $(iconText).addClass('is-hidden');
332 $(iconDefault).show();
333 }
334 }
335
336 // Hide plugin message
337
338 $(document).on('click', '.wow-plugin-message .notice-dismiss', function() {
339 $.ajax({
340 url: ajaxurl, data: {
341 action: 'float_menu_message',
342 },
343 });
344 });
345
346 // Add new Menu item
347 $('.add-item').on('click', function() {
348 const element = document.getElementById('clone').innerHTML;
349 document.querySelector('.menu-items').insertAdjacentHTML('beforeend', element);
350 refreashel();
351 });
352
353 // Refreash the functions
354 function refreashel() {
355 $('select.item-type').each(function() {
356 itemtype(this);
357 });
358 $('input.custom-icon:checkbox').each(function() {
359 customicon(this);
360 });
361 $('.wp-color-picker-field').wpColorPicker({
362 change: function(event, ui){ panelHeadingIconColor(this); },
363 });
364
365 wow_attach_tooltips($('.wow-help'));
366 $('.icons').fontIconPicker({
367 theme: 'fip-darkgrey',
368 emptyIcon: false,
369 allCategoryText: 'Show all',
370 });
371
372 $('.icons-selector').on('click', function() {
373 const parent = $(this).parents('.panel');
374 selectIcon(parent);
375 });
376
377 $('body').on('click keyup', '[data-tab-content="2"]', function() {
378 const parent = $(this).parents('.panel');
379 selectIcon(parent);
380 });
381
382 }
383
384 // Remove Items
385 $('body').on('click', '.item-delete', function() {
386 const parent = $(this).parents('.panel');
387 $(parent).remove();
388 });
389
390 // Panel tabs
391 $('body').on('click', '.panel-tabs a', function() {
392 panelTab(this);
393 });
394
395 function panelTab(el) {
396 const selected = $(el).data('tab');
397 const parent = $(el).parents('.panel');
398 $(parent).find('.panel-tabs a').removeClass('is-active');
399 $(el).addClass('is-active');
400 $(parent).find('.tabs-content').addClass('is-hidden');
401 $(parent).find('[data-tab-content="' + selected + '"]').removeClass('is-hidden');
402 }
403
404
405
406 $('.wp-color-picker-field').each(function() {
407 panelHeadingIconColor(this);
408 });
409 $('body').on('change', '.wp-color-picker-field', function() {
410 panelHeadingIconColor(this);
411 });
412
413 function panelHeadingIconColor(el) {
414 const attr = $(el).attr('name');
415 const color = $(el).val();
416 const parent = $(el).parents('.panel');
417 if (attr.includes('[color]')) {
418 $(parent).find('.icon-select').css('color', color);
419 } else if (attr.includes('[bcolor]')) {
420 $(parent).find('.icon-select').css('background-color', color);
421 }
422 }
423
424
425 $('.icons-selector').on('click', function() {
426 const parent = $(this).parents('.panel');
427 selectIcon(parent);
428 });
429
430
431 $('body').on('click keyup', '[data-tab-content="2"]', function() {
432 const parent = $(this).parents('.panel');
433 selectIcon(parent);
434 });
435
436 $('.panel').each(function() {
437 selectIcon(this);
438 });
439
440 function selectIcon(el) {
441 let icon;
442 const iconCustom = $(el).find('.custom-icon');
443 const iconText = $(el).find('.custom-icon-text');
444 const iconDefault = $(el).find('.icons').val();
445 if ($(iconCustom).prop('checked')) {
446 const img = $(el).find('.custom-icon-url').val();
447 icon = '<img src="'+img+'">';
448 } else if ($(iconText).prop('checked')) {
449 const text = $(el).find('.icon-custom-text').val();
450 icon = text;
451 } else {
452 icon = '<i class="'+iconDefault+'"></i>';
453 }
454 $(el).find('.icon-select').html(icon);
455
456 }
457
458 $('.menu-items').sortable();
459
460
461
462
463
464 })(jQuery);
465