| 1 |
/* ========= INFORMATION ============================ |
| 2 |
- author: Dmytro Lobov |
| 3 |
- url: https://wow-estore.com |
| 4 |
- email: givememoney1982@gmail.com |
| 5 |
==================================================== */ |
| 6 |
|
| 7 |
'use strict'; |
| 8 |
|
| 9 |
(function ($) { |
| 10 |
|
| 11 |
$('#wow-plugin').on('submit', function (event) { |
| 12 |
event.preventDefault() |
| 13 |
var dataform = $(this).serialize() |
| 14 |
var data = 'action=wow_item_save&' + dataform |
| 15 |
$('.wow-plugin .saving').animate({ opacity: '0.75' }) |
| 16 |
|
| 17 |
$.post(ajaxurl, data, function (response) { |
| 18 |
if (response.status == 'OK') { |
| 19 |
$('#wow-message').addClass('notice notice-success is-dismissible') |
| 20 |
$('#wow-message').html('<p>' + response.message + '</p>') |
| 21 |
$('#add_action').val(2) |
| 22 |
let tool_id = $('#tool_id').val(); |
| 23 |
$('.nav-tab.nav-tab-active').text('Update #' + tool_id); |
| 24 |
} |
| 25 |
$('.wow-plugin .saving').animate({ opacity: '0' }) |
| 26 |
}) |
| 27 |
}); |
| 28 |
|
| 29 |
$('.wow-plugin .tab-nav li:first').addClass('select'); |
| 30 |
$('.wow-plugin .tab-panels>div').hide().filter(':first').show(); |
| 31 |
$('.wow-plugin .tab-nav a').on('click',function () { |
| 32 |
$('.wow-plugin .tab-panels>div').hide().filter(this.hash).show(); |
| 33 |
$('.wow-plugin .tab-nav li').removeClass('select'); |
| 34 |
$(this).parent().addClass('select'); |
| 35 |
return false; |
| 36 |
}); |
| 37 |
|
| 38 |
$('body').on('hover', '.wow-help', function() { |
| 39 |
if ( $(this).hasClass( "dashicons-lock" ) ) { |
| 40 |
$(this).removeClass('dashicons-lock'); |
| 41 |
$(this).addClass('dashicons-unlock'); |
| 42 |
} |
| 43 |
else if ( $(this).hasClass( "dashicons-unlock" ) ){ |
| 44 |
$(this).removeClass('dashicons-unlock'); |
| 45 |
$(this).addClass('dashicons-lock'); |
| 46 |
} |
| 47 |
}) |
| 48 |
|
| 49 |
$('.wow-plugin input:checkbox:checked').each(function () { |
| 50 |
$(this).siblings('input[type="hidden"]').val('1'); |
| 51 |
}); |
| 52 |
|
| 53 |
$('.wow-plugin input:checkbox').on('click',function () { |
| 54 |
checkboxchecked(this); |
| 55 |
} |
| 56 |
); |
| 57 |
|
| 58 |
$('.wp-color-picker-field').not('#clone .wp-color-picker-field').wpColorPicker(); |
| 59 |
|
| 60 |
$('.adding-menu-1').sortable(); |
| 61 |
|
| 62 |
$('body').on('click', '.item-del', function() { |
| 63 |
$(this).closest('.itembox').remove(); |
| 64 |
}); |
| 65 |
|
| 66 |
$('body').on('click', '.toogle', function() { |
| 67 |
var perent = $(this).closest('.itembox'); |
| 68 |
$(perent).children(".menu_block").toggle(); |
| 69 |
$(this).siblings('.toogle').toggle(); |
| 70 |
$(this).toggle(); |
| 71 |
}); |
| 72 |
|
| 73 |
$('.icons').not('#clone .icons').fontIconPicker({ |
| 74 |
theme: 'fip-darkgrey', |
| 75 |
emptyIcon: false, |
| 76 |
allCategoryText: 'Show all' |
| 77 |
}); |
| 78 |
|
| 79 |
wow_attach_tooltips($(".wow-help")); |
| 80 |
|
| 81 |
$('input.tooltip-include:checkbox').each(function () { |
| 82 |
itemtooltip(this); |
| 83 |
}); |
| 84 |
|
| 85 |
$('select.item-type').each(function () { |
| 86 |
itemtype(this); |
| 87 |
}); |
| 88 |
|
| 89 |
$('input#depending_language:checkbox').each(function () { |
| 90 |
languages(this); |
| 91 |
}); |
| 92 |
|
| 93 |
$('select#show').each(function () { |
| 94 |
showchange(this); |
| 95 |
}); |
| 96 |
|
| 97 |
$('input.item_user:radio:checked').each(function () { |
| 98 |
usersroles(this); |
| 99 |
}); |
| 100 |
|
| 101 |
$('input#include_mobile:checkbox').each(function () { |
| 102 |
screen_less(this); |
| 103 |
}); |
| 104 |
|
| 105 |
$('input#include_more_screen:checkbox').each(function () { |
| 106 |
screen_more(this); |
| 107 |
}); |
| 108 |
|
| 109 |
$('.icons').css('display', 'none'); |
| 110 |
$('input.custom-icon:checkbox').each(function () { |
| 111 |
customicon(this); |
| 112 |
}); |
| 113 |
})(jQuery) |
| 114 |
|
| 115 |
function wow_attach_tooltips(selector) { |
| 116 |
selector.tooltip({ |
| 117 |
content: function () { |
| 118 |
return jQuery(this).prop("title") |
| 119 |
}, |
| 120 |
tooltipClass: "wow-ui-tooltip", |
| 121 |
position: { |
| 122 |
my: "center top", |
| 123 |
at: "center bottom+10", |
| 124 |
collision: "flipfit" |
| 125 |
}, |
| 126 |
hide: { |
| 127 |
duration: 200 |
| 128 |
}, |
| 129 |
show: { |
| 130 |
duration: 200 |
| 131 |
} |
| 132 |
}) |
| 133 |
} |
| 134 |
|
| 135 |
function itemadd(menu) { |
| 136 |
var menu = 'adding-menu-' + menu; |
| 137 |
var nextelement = jQuery('.' + menu + ' fieldset').length * 1 + 1; |
| 138 |
jQuery('#' + menu + ' .item').text(nextelement); |
| 139 |
jQuery('#' + menu).clone().removeAttr('id').appendTo('.' + menu); |
| 140 |
refreashel(); |
| 141 |
} |
| 142 |
|
| 143 |
function refreashel() { |
| 144 |
jQuery('.icons').css('display', 'none'); |
| 145 |
jQuery('.wp-color-picker-field').not('#clone .wp-color-picker-field').wpColorPicker(); |
| 146 |
|
| 147 |
jQuery('.icons').not('#clone .icons').fontIconPicker({ |
| 148 |
theme: 'fip-darkgrey', |
| 149 |
emptyIcon: false, |
| 150 |
allCategoryText: 'Show all' |
| 151 |
}); |
| 152 |
} |
| 153 |
|
| 154 |
function itemremove(menu) { |
| 155 |
var menu = 'adding-menu-' + menu; |
| 156 |
jQuery('.' + menu + ' fieldset').last().remove(); |
| 157 |
} |
| 158 |
|
| 159 |
function checkboxchecked(that) { |
| 160 |
if (jQuery(that).prop('checked')) { |
| 161 |
jQuery(that).siblings('input[type="hidden"]').val('1'); |
| 162 |
} |
| 163 |
else { |
| 164 |
jQuery(that).siblings('input[type="hidden"]').val('0'); |
| 165 |
} |
| 166 |
}0 |
| 167 |
|
| 168 |
//* Change item type |
| 169 |
function itemtype(that) { |
| 170 |
var type = jQuery(that).val(); |
| 171 |
var parent = jQuery(that).parents('.container'); |
| 172 |
jQuery(parent).find('.type-link-blank').css('visibility', 'hidden '); |
| 173 |
jQuery(that).parents('.menu_block').find('.button_id').css('visibility', 'visible'); |
| 174 |
jQuery(that).parents('.menu_block').find('.button_class').css('visibility', 'visible'); |
| 175 |
if (type === 'link' || type === 'smoothscroll' || type === 'email' || type === 'telephone' ) { |
| 176 |
jQuery(parent).find('.type-link').css('display', 'block'); |
| 177 |
jQuery(parent).find('.type-share').css('display', 'none'); |
| 178 |
jQuery(parent).find('.type-modal').css('display', 'none'); |
| 179 |
jQuery(parent).find('.type-link-text').text('Link'); |
| 180 |
if ( type === 'link' ) { |
| 181 |
jQuery(parent).find('.type-link-blank').css('visibility', 'visible'); |
| 182 |
} |
| 183 |
else if ( type === 'email' ) { |
| 184 |
jQuery(parent).find('.type-link-text').text('Email'); |
| 185 |
} |
| 186 |
else if ( type === 'telephone' ) { |
| 187 |
jQuery(parent).find('.type-link-text').text('Telephone'); |
| 188 |
} |
| 189 |
|
| 190 |
} |
| 191 |
else if (type === 'share') { |
| 192 |
jQuery(parent).find('.type-link').css('display', 'none'); |
| 193 |
jQuery(parent).find('.type-share').css('display', 'block'); |
| 194 |
jQuery(parent).find('.type-modal').css('display', 'none'); |
| 195 |
} |
| 196 |
else if (type === 'login' || type === 'logout' || type === 'lostpassword') { |
| 197 |
jQuery(parent).find('.type-link').css('display', 'block'); |
| 198 |
jQuery(parent).find('.type-share').css('display', 'none'); |
| 199 |
jQuery(parent).find('.type-link-text').text('Redirect URL'); |
| 200 |
jQuery(parent).find('.type-modal').css('display', 'none'); |
| 201 |
|
| 202 |
} |
| 203 |
else if (type == 'id' || type == 'class' || type == 'modal'){ |
| 204 |
jQuery(parent).find('.type-link').css('display', 'none'); |
| 205 |
jQuery(parent).find('.type-share').css('display', 'none'); |
| 206 |
jQuery(parent).find('.type-modal').css('display', 'block'); |
| 207 |
jQuery(that).parents('.menu_block').find('.button_id').css('visibility', 'hidden'); |
| 208 |
jQuery(that).parents('.menu_block').find('.button_class').css('visibility', 'hidden'); |
| 209 |
} |
| 210 |
else { |
| 211 |
jQuery(parent).find('.type-link').css('display', 'none'); |
| 212 |
jQuery(parent).find('.type-share').css('display', 'none'); |
| 213 |
jQuery(parent).find('.type-modal').css('display', 'none'); |
| 214 |
} |
| 215 |
} |
| 216 |
|
| 217 |
function itemtooltip(that) { |
| 218 |
let parent = jQuery(that).parents('.container'); |
| 219 |
jQuery(parent).find('.show-tooltip').css('visibility', 'hidden '); |
| 220 |
if (jQuery(that).is(':checked')) { |
| 221 |
jQuery(that).siblings('.item-tooltip').css('display', 'block'); |
| 222 |
jQuery(parent).find('.show-tooltip').css('visibility', 'visible'); |
| 223 |
} |
| 224 |
else { |
| 225 |
jQuery(that).siblings('.item-tooltip').css('display', 'none'); |
| 226 |
} |
| 227 |
} |
| 228 |
|
| 229 |
function customicon(that) { |
| 230 |
jQuery('.icons').css('display', 'none'); |
| 231 |
if (jQuery(that).is(':checked')) { |
| 232 |
jQuery(that).siblings('.custom-icon-url').css('display', 'block'); |
| 233 |
jQuery(that).siblings('.icons-selector').css('display', 'none'); |
| 234 |
} |
| 235 |
else { |
| 236 |
jQuery(that).siblings('.custom-icon-url').css('display', 'none'); |
| 237 |
jQuery(that).siblings('.icons-selector').css('display', 'block'); |
| 238 |
} |
| 239 |
} |
| 240 |
|
| 241 |
//* Show language |
| 242 |
function languages(that) { |
| 243 |
if (jQuery(that).is(':checked')) { |
| 244 |
jQuery('#language').css('display', ''); |
| 245 |
} |
| 246 |
else { |
| 247 |
jQuery('#language').css('display', 'none'); |
| 248 |
} |
| 249 |
} |
| 250 |
|
| 251 |
//* When show |
| 252 |
function showchange(that) { |
| 253 |
var show = jQuery(that).val(); |
| 254 |
if (show === 'posts' || show === 'pages' || show === 'expost' || show === 'expage' || show === 'taxonomy') { |
| 255 |
jQuery('#id_post').css('display', ''); |
| 256 |
jQuery('#shortcode').css('display', 'none'); |
| 257 |
} |
| 258 |
else if (show === 'shortecode') { |
| 259 |
jQuery('#shortcode').css('display', ''); |
| 260 |
jQuery('#id_post').css('display', 'none'); |
| 261 |
} |
| 262 |
else { |
| 263 |
jQuery('#shortcode').css('display', 'none'); |
| 264 |
jQuery('#id_post').css('display', 'none'); |
| 265 |
} |
| 266 |
if (show === 'taxonomy') { |
| 267 |
jQuery('#taxonomy').css('display', ''); |
| 268 |
} |
| 269 |
else { |
| 270 |
jQuery('#taxonomy').css('display', 'none'); |
| 271 |
} |
| 272 |
} |
| 273 |
|
| 274 |
//* Show screen |
| 275 |
function screen_less(that) { |
| 276 |
if (jQuery(that).is(':checked')) { |
| 277 |
jQuery('#screen').css('display', ''); |
| 278 |
} |
| 279 |
else { |
| 280 |
jQuery('#screen').css('display', 'none'); |
| 281 |
} |
| 282 |
} |
| 283 |
|
| 284 |
function screen_more(that) { |
| 285 |
if (jQuery(that).is(':checked')) { |
| 286 |
jQuery('#screenmore').css('display', ''); |
| 287 |
} |
| 288 |
else { |
| 289 |
jQuery('#screenmore').css('display', 'none'); |
| 290 |
} |
| 291 |
} |
| 292 |
|
| 293 |
function usersroles(that) { |
| 294 |
var users = jQuery(that).val(); |
| 295 |
if (users == 2) { |
| 296 |
jQuery('#users_roles').css('display', ''); |
| 297 |
} |
| 298 |
else { |
| 299 |
jQuery('#users_roles').css('display', 'none'); |
| 300 |
} |
| 301 |
} |
| 302 |
|
| 303 |
function menuicon(){ |
| 304 |
var icon = jQuery('#select_icon').val(); |
| 305 |
var position = jQuery('#icon_position').val(); |
| 306 |
jQuery('#icon_class').text(icon+position); |
| 307 |
} |