PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 3.9.9
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v3.9.9
4.0.3 4.0.2 4.0.1 4.0.0 3.16.6 3.16.5 3.16.4 3.16.3 3.16.2 3.16.1 3.16.0 3.15.9 3.9.9 3.9.5 3.9.6 3.9.7 3.9.8 1.1.7 1.1.8 1.1.9 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 All 341 releases
profile-builder / assets / js / jquery-pb-sitewide.js

jquery-pb-sitewide.js in User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor 3.9.9, at assets/js/jquery-pb-sitewide.js

481 lines 24.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * Add a negative letter spacing to Profile Builder email customizer menus.
3 */
4
5 jQuery( document ).ready(function(){
6 jQuery('li a[href$="admin-email-customizer"]').css("letter-spacing", "-0.7px");
7 jQuery('li a[href$="user-email-customizer"]').css("letter-spacing", "-0.7px");
8 });
9
10 /*
11 * Set the width of the shortcode input based on an element that
12 * has the width of its contents
13 */
14 function setShortcodeInputWidth( $inputField ) {
15 var tempSpan = document.createElement('span');
16 tempSpan.className = "wppb-shortcode-temp";
17 tempSpan.innerHTML = $inputField.val();
18 document.body.appendChild(tempSpan);
19
20 var tempWidth = jQuery(tempSpan).outerWidth();
21
22 document.body.removeChild(tempSpan);
23
24 $inputField.outerWidth( tempWidth + 18 );
25 }
26
27 jQuery( document ).ready( function() {
28
29 jQuery('.wppb-shortcode.input').each( function() {
30 setShortcodeInputWidth( jQuery(this) );
31 });
32
33 jQuery('.wppb-shortcode.textarea').each( function() {
34 jQuery(this).outerHeight( jQuery(this)[0].scrollHeight + parseInt( jQuery(this).css('border-top-width') ) * 2 );
35 });
36
37 jQuery('.wppb-shortcode').on('click', function() {
38 this.select();
39 });
40 });
41
42
43 /* make sure that we don;t leave the page without having a title in the Post Title field, otherwise we loose data */
44 jQuery( function(){
45 if( jQuery( 'body').hasClass('post-new-php') ){
46
47 if( jQuery( 'body').hasClass('post-type-wppb-rf-cpt') || jQuery( 'body').hasClass('post-type-wppb-epf-cpt') || jQuery( 'body').hasClass('post-type-wppb-ul-cpt') ){
48
49 if( jQuery('#title').val() == '' ){
50 jQuery(window).on('beforeunload',function() {
51 return "This page is asking you to confirm that you want to leave - data you have entered may not be saved";
52 });
53 }
54
55 /* remove beforeunload event when entering a title or pressing the puclish button */
56 jQuery( '#title').on( 'keypress', function() {
57 jQuery(window).off('beforeunload');
58 });
59 jQuery( '#publish').on('click', function() {
60 jQuery(window).off('beforeunload');
61 });
62 }
63 }
64 });
65
66
67 /* show hide fields based on selected options */
68 jQuery( function(){
69 jQuery( '#wppb-rf-settings-args').on('change', '#redirect', function(){
70 if( jQuery(this).val() == 'Yes' ){
71 jQuery( '.row-url, .row-display-messages', jQuery(this).parent().parent().parent()).css('display', 'flex');
72 }
73 else{
74 jQuery( '.row-url, .row-display-messages', jQuery(this).parent().parent().parent()).hide();
75 }
76 });
77
78 jQuery( '#wppb-epf-settings-args').on('change', '#redirect', function(){
79 if( jQuery(this).val() == 'Yes' ){
80 jQuery( '.row-url, .row-display-messages', jQuery(this).parent().parent().parent()).css('display', 'flex');
81 }
82 else{
83 jQuery( '.row-url, .row-display-messages', jQuery(this).parent().parent().parent()).hide();
84 }
85 });
86
87
88 jQuery( '#wppb-ul-settings-args').on('click', '#visible-only-to-logged-in-users_yes', function(){
89
90 if (jQuery(this).is(':checked')) {
91 jQuery( '.row-visible-to-following-roles').css('display', 'flex');
92 }
93 else jQuery( '.row-visible-to-following-roles').css('display', 'none');
94 });
95
96 jQuery( '#wppb-ul-faceted-args').on('change', '#facet-type', function(){
97 if( jQuery(this).val() == 'checkboxes' ){
98 jQuery( '.row-facet-behaviour, .row-facet-limit', jQuery(this).parent().parent().parent()).show();
99 }else if( jQuery(this).val() == 'select_multiple' ){
100 jQuery( '.row-facet-behaviour, .row-facet-limit', jQuery(this).parent().parent().parent()).hide();
101 jQuery( '.row-facet-behaviour #facet-behaviour', jQuery(this).parent().parent().parent()).val('expand');
102 }
103 else{
104 jQuery( '.row-facet-behaviour, .row-facet-limit', jQuery(this).parent().parent().parent()).hide();
105 jQuery( '.row-facet-behaviour #facet-behaviour', jQuery(this).parent().parent().parent()).val('narrow');
106 }
107 if( jQuery(this).val() == 'search' ){
108 jQuery( '#wppb-ul-faceted-args .row-facet-meta #facet-meta option[value="billing_country"] ').hide();
109 jQuery( '#wppb-ul-faceted-args .row-facet-meta #facet-meta option[value="shipping_country"] ').hide();
110 jQuery( '#wppb-ul-faceted-args .row-facet-meta #facet-meta option[value="billing_state"] ').hide();
111 jQuery( '#wppb-ul-faceted-args .row-facet-meta #facet-meta option[value="shipping_state"] ').hide();
112 }
113 else {
114 jQuery( '#wppb-ul-faceted-args .row-facet-meta #facet-meta option[value="billing_country"] ').show();
115 jQuery( '#wppb-ul-faceted-args .row-facet-meta #facet-meta option[value="shipping_country"] ').show();
116 jQuery( '#wppb-ul-faceted-args .row-facet-meta #facet-meta option[value="billing_state"] ').show();
117 jQuery( '#wppb-ul-faceted-args .row-facet-meta #facet-meta option[value="shipping_state"] ').show()
118 }
119
120 });
121
122 });
123
124 /*
125 * Dialog boxes throughout Profile Builder
126 */
127 jQuery( function() {
128 if ( jQuery.fn.dialog ) {
129 jQuery('.wppb-modal-box').dialog({
130 autoOpen: false,
131 modal: true,
132 draggable: false,
133 minWidth: 450,
134 minHeight: 450
135 });
136
137 jQuery('.wppb-open-modal-box').on('click', function (e) {
138 e.preventDefault();
139 jQuery('#' + jQuery(this).attr('href')).dialog('open');
140 });
141 }
142 });
143
144 /*
145 * Private Website Settings page
146 */
147
148 jQuery( function() {
149 if( jQuery( '.wppb-private-website' ).length != 0 ) {
150
151 wppbSelect2.call( jQuery('#private-website-redirect-to-login') );
152 wppbSelect2.call( jQuery('#private-website-allowed-pages') );
153
154 wppbDisablePrivatePageOptions(jQuery('#private-website-enable').val());
155
156 jQuery('#private-website-enable').on('change', function () {
157 wppbDisablePrivatePageOptions(jQuery(this).val());
158 });
159
160
161 function wppbDisablePrivatePageOptions(value) {
162 if (value == 'no') {
163 jQuery('#private-website-redirect-to-login').closest('tr').addClass("wppb-disabled");
164 jQuery('#private-website-allowed-pages').closest('tr').addClass("wppb-disabled");
165 jQuery('#private-website-menu-hide').addClass("wppb-disabled");
166 jQuery('#private-website-disable-rest-api').addClass("wppb-disabled");
167 jQuery('#private-website-allowed-paths').addClass("wppb-disabled");
168 }
169 else if (value == 'yes') {
170 jQuery('#private-website-redirect-to-login').closest('tr').removeClass("wppb-disabled");
171 jQuery('#private-website-allowed-pages').closest('tr').removeClass("wppb-disabled");
172 jQuery('#private-website-menu-hide').removeClass("wppb-disabled");
173 jQuery('#private-website-disable-rest-api').removeClass("wppb-disabled");
174 jQuery('#private-website-allowed-paths').removeClass("wppb-disabled");
175 }
176 }
177 }
178 });
179
180 /*
181 * Login Widget trigger html validation
182 */
183 jQuery( function() {
184 if( jQuery( ".widgets-php" ).length != 0 ){//should be in the admin widgets page
185 jQuery("#wpbody").on("click", ".widget-control-save", function () {
186 if (jQuery('.wppb-widget-url-field', jQuery(this).closest('form')).length != 0) {//we are in the PB widget
187 jQuery('.wppb-widget-url-field', jQuery(this).closest('form')).each(function () {
188 jQuery(this)[0].reportValidity();//reportValidity is the function that triggers the default html validation
189 });
190 }
191 });
192 }
193 });
194
195
196 /*
197 * Advanced Settings page (Toolbox)
198 */
199
200 jQuery( function() {
201 if( jQuery('body.profile-builder_page_profile-builder-toolbox-settings').length != 0 ) {
202
203 wppbSelect2.call( jQuery('#toolbox-bypass-ec') );
204
205 wppbSelect2.call( jQuery('#toolbox-restricted-emails'), {
206 tags: true,
207 });
208
209 jQuery('.wppb-toolbox-switch').on('click', function () {
210 if (jQuery(this).prop('checked'))
211 jQuery('.wppb-toolbox-accordion').css('display','flex');
212 else
213 jQuery('.wppb-toolbox-accordion').hide();
214 });
215
216 jQuery('#toolbox-send-credentials-hide').on('click', function () {
217 if (jQuery(this).prop('checked'))
218 jQuery('#wppb-toolbox-send-credentials-text').hide();
219 else
220 jQuery('#wppb-toolbox-send-credentials-text').css('display','flex');
221 });
222
223 jQuery('#toolbox-redirect-if-empty-required').on('click', function () {
224 if (jQuery(this).prop('checked'))
225 jQuery('#wppb-toolbox-redirect-if-empty-required-url').css('display','flex');
226 else
227 jQuery('#wppb-toolbox-redirect-if-empty-required-url').hide();
228 });
229
230
231 if (jQuery('.wppb-toolbox-switch').prop('checked'))
232 jQuery('.wppb-toolbox-accordion').css('display','flex');
233
234 if (jQuery('#toolbox-send-credentials-hide').prop('checked'))
235 jQuery('#wppb-toolbox-send-credentials-text').hide();
236
237 if (jQuery('#toolbox-redirect-if-empty-required').prop('checked'))
238 jQuery('#wppb-toolbox-redirect-if-empty-required-url').css('display','flex');
239 }
240 });
241
242 // Fix for Select2 search not focusing
243 jQuery(document).on('select2:open', function() {
244 let allSelect2Found = document.querySelectorAll('.select2-container--open .select2-search__field');
245 allSelect2Found[allSelect2Found.length - 1].focus();
246 });
247
248 /**
249 * Add Link to PB Docs next to page/setting titles
250 * */
251 jQuery(document).ready( function () {
252 // email customizer
253 jQuery('.wp-admin.profile-builder_page_user-email-customizer .wrap h2.cozmoslabs-page-title').append('<a href="https://www.cozmoslabs.com/docs/profile-builder/modules/user-email-customizer/?utm_source=wpbackend&utm_medium=pb-documentation&utm_campaign=PBDocs" target="_blank" data-code="f223" class="wppb-docs-link dashicons dashicons-editor-help" style="margin-left: 5px"></a>');
254 jQuery('.wp-admin.profile-builder_page_admin-email-customizer .wrap h2.cozmoslabs-page-title').append('<a href="https://www.cozmoslabs.com/docs/profile-builder/modules/admin-email-customizer/?utm_source=wpbackend&utm_medium=pb-documentation&utm_campaign=PBDocs" target="_blank" data-code="f223" class="wppb-docs-link dashicons dashicons-editor-help" style="margin-left: 5px"></a>');
255
256 // roles editor
257 jQuery('.wp-admin.post-type-wppb-roles-editor .wrap h1.wp-heading-inline').append('<a href="https://www.cozmoslabs.com/docs/profile-builder/general-settings/roles-editor/?utm_source=wpbackend&utm_medium=pb-documentation&utm_campaign=PBDocs" target="_blank" data-code="f223" class="wppb-docs-link dashicons dashicons-editor-help" style="margin-left: 5px"></a>');
258
259 // manage form fields
260 jQuery('.wp-admin.profile-builder_page_manage-fields .wrap > h2').append('<a href="https://www.cozmoslabs.com/docs/profile-builder/manage-user-fields/?utm_source=wpbackend&utm_medium=pb-documentation&utm_campaign=PBDocs" target="_blank" data-code="f223" class="wppb-docs-link dashicons dashicons-editor-help" style="margin-left: 5px"></a>');
261 jQuery('html').on('wpbFormMetaLoaded', function() {
262 // conditional logic
263 jQuery('.wp-admin.profile-builder_page_manage-fields .update_container_wppb_manage_fields ul.mb-list-entry-fields li.row-conditional-logic-enabled .mb-right-column label').append('<a href="https://www.cozmoslabs.com/docs/profile-builder/manage-user-fields/?utm_source=wpbackend&utm_medium=pb-documentation&utm_campaign=PBDocs#Conditional_Logic" target="_blank" data-code="f223" class="wppb-docs-link dashicons dashicons-editor-help" style="margin-left: 10px"></a>');
264 // visibility
265 jQuery('.wp-admin.profile-builder_page_manage-fields .update_container_wppb_manage_fields ul.mb-list-entry-fields li.row-visibility .mb-right-column').append('<a href="https://www.cozmoslabs.com/docs/profile-builder/add-ons/field-visibility/?utm_source=wpbackend&utm_medium=pb-documentation&utm_campaign=PBDocs#Visibility" target="_blank" data-code="f223" class="wppb-docs-link dashicons dashicons-editor-help" style="margin-left: 10px"></a>');
266 // user role visibility
267 jQuery('.wp-admin.profile-builder_page_manage-fields .update_container_wppb_manage_fields ul.mb-list-entry-fields li.row-user-role-visibility .mb-right-column .wck-checkboxes').append('<a href="https://www.cozmoslabs.com/docs/profile-builder/add-ons/field-visibility/?utm_source=wpbackend&utm_medium=pb-documentation&utm_campaign=PBDocs#User_Role_Visibility" target="_blank" data-code="f223" class="wppb-docs-link dashicons dashicons-editor-help"></a>');
268 // location visibility
269 jQuery('.wp-admin.profile-builder_page_manage-fields .update_container_wppb_manage_fields ul.mb-list-entry-fields li.row-location-visibility .mb-right-column .wck-checkboxes').append('<a href="https://www.cozmoslabs.com/docs/profile-builder/add-ons/field-visibility/?utm_source=wpbackend&utm_medium=pb-documentation&utm_campaign=PBDocs#Location_Visibility" target="_blank" data-code="f223" class="wppb-docs-link dashicons dashicons-editor-help"></a>');
270 // admin approval
271 jQuery('.wp-admin.profile-builder_page_manage-fields .update_container_wppb_manage_fields ul.mb-list-entry-fields li.row-edit-profile-approved-by-admin .mb-right-column .wck-checkboxes label').append('<a href="https://www.cozmoslabs.com/docs/profile-builder/add-ons/edit-profile-approved-by-admin/?utm_source=wpbackend&utm_medium=pb-documentation&utm_campaign=PBDocs" target="_blank" data-code="f223" class="wppb-docs-link dashicons dashicons-editor-help" style="margin-left: 10px"></a>');
272 });
273
274 // register forms
275 jQuery('.wp-admin.post-type-wppb-rf-cpt .wrap h1.wp-heading-inline').append('<a href="https://www.cozmoslabs.com/docs/profile-builder/modules/multiple-registration-forms/?utm_source=wpbackend&utm_medium=pb-documentation&utm_campaign=PBDocs" target="_blank" data-code="f223" class="wppb-docs-link dashicons dashicons-editor-help" style="margin-left: 5px"></a>');
276
277 // edit profile forms
278 jQuery('.wp-admin.post-type-wppb-epf-cpt .wrap h1.wp-heading-inline').append('<a href="https://www.cozmoslabs.com/docs/profile-builder/modules/multiple-edit-profile-forms/?utm_source=wpbackend&utm_medium=pb-documentation&utm_campaign=PBDocs" target="_blank" data-code="f223" class="wppb-docs-link dashicons dashicons-editor-help" style="margin-left: 5px"></a>');
279
280 // user-listing
281 jQuery('.wp-admin.post-type-wppb-ul-cpt .wrap h1.wp-heading-inline').append('<a href="https://www.cozmoslabs.com/docs/profile-builder/modules/user-listing/?utm_source=wpbackend&utm_medium=pb-documentation&utm_campaign=PBDocs" target="_blank" data-code="f223" class="wppb-docs-link dashicons dashicons-editor-help" style="margin-left: 5px"></a>');
282 // ul settings
283 jQuery('.wp-admin.post-type-wppb-ul-cpt #wppb_ul_page_settings').prepend('<a href="https://www.cozmoslabs.com/docs/profile-builder/modules/user-listing/?utm_source=wpbackend&utm_medium=pb-documentation&utm_campaign=PBDocs#User_Listing_Settings" target="_blank" data-code="f223" class="wppb-docs-link dashicons dashicons-editor-help"></a>');
284 // ul faceted menus
285 jQuery('.wp-admin.post-type-wppb-ul-cpt #wppb_ul_faceted_settings').prepend('<a href="https://www.cozmoslabs.com/docs/profile-builder/modules/user-listing/?utm_source=wpbackend&utm_medium=pb-documentation&utm_campaign=PBDocs#Faceted_Menus" target="_blank" data-code="f223" class="wppb-docs-link dashicons dashicons-editor-help"></a>');
286 // ul search settings
287 jQuery('.wp-admin.post-type-wppb-ul-cpt #wppb_ul_search_settings').prepend('<a href="https://www.cozmoslabs.com/docs/profile-builder/modules/user-listing/?utm_source=wpbackend&utm_medium=pb-documentation&utm_campaign=PBDocs#Search_Settings" target="_blank" data-code="f223" class="wppb-docs-link dashicons dashicons-editor-help"></a>');
288 // ul themes
289 jQuery('.wp-admin.post-type-wppb-ul-cpt #wppb-ul-themes-settings .inside').prepend('<a href="https://www.cozmoslabs.com/docs/profile-builder/modules/user-listing/?utm_source=wpbackend&utm_medium=pb-documentation&utm_campaign=PBDocs#Themes" target="_blank" data-code="f223" class="wppb-docs-link dashicons dashicons-editor-help"></a>');
290 // ul all users template
291 jQuery('.wp-admin.post-type-wppb-ul-cpt #wppb-ul-templates .inside').prepend('<a href="https://www.cozmoslabs.com/docs/profile-builder/modules/user-listing/?utm_source=wpbackend&utm_medium=pb-documentation&utm_campaign=PBDocs#The_All-Userlisting_Template" target="_blank" data-code="f223" class="wppb-docs-link dashicons dashicons-editor-help"></a>');
292 // ul single user template
293 jQuery('.wp-admin.post-type-wppb-ul-cpt #wppb-single-ul-templates .inside').prepend('<a href="https://www.cozmoslabs.com/docs/profile-builder/modules/user-listing/?utm_source=wpbackend&utm_medium=pb-documentation&utm_campaign=PBDocs#The_Single-Userlisting_Template" target="_blank" data-code="f223" class="wppb-docs-link dashicons dashicons-editor-help"></a>');
294
295 // custom redirects
296 jQuery('.wp-admin.profile-builder_page_custom-redirects .wrap h2.cozmoslabs-page-title').append('<a href="https://www.cozmoslabs.com/docs/profile-builder/modules/custom-redirects/?utm_source=wpbackend&utm_medium=pb-documentation&utm_campaign=PBDocs" target="_blank" data-code="f223" class="wppb-docs-link dashicons dashicons-editor-help" style="margin-left: 5px"></a>');
297 // cr individual user
298 jQuery('.wp-admin.profile-builder_page_custom-redirects #wppb_custom_redirects_user .inside').prepend('<a href="https://www.cozmoslabs.com/docs/profile-builder/modules/custom-redirects/?utm_source=wpbackend&utm_medium=pb-documentation&utm_campaign=PBDocs#Individual_User_Redirects" target="_blank" data-code="f223" class="wppb-docs-link dashicons dashicons-editor-help"></a>');
299 // cr user role based
300 jQuery('.wp-admin.profile-builder_page_custom-redirects #wppb_custom_redirects_role .inside').prepend('<a href="https://www.cozmoslabs.com/docs/profile-builder/modules/custom-redirects/?utm_source=wpbackend&utm_medium=pb-documentation&utm_campaign=PBDocs#User_Role_based_Redirects" target="_blank" data-code="f223" class="wppb-docs-link dashicons dashicons-editor-help"></a>');
301 // cr global
302 jQuery('.wp-admin.profile-builder_page_custom-redirects #wppb_custom_redirects_global .inside').prepend('<a href="https://www.cozmoslabs.com/docs/profile-builder/modules/custom-redirects/?utm_source=wpbackend&utm_medium=pb-documentation&utm_campaign=PBDocs#Global_Redirects" target="_blank" data-code="f223" class="wppb-docs-link dashicons dashicons-editor-help"></a>');
303 // cr default wp pages
304 jQuery('.wp-admin.profile-builder_page_custom-redirects #wppb_custom_redirects_default_wp_pages .inside').prepend('<a href="https://www.cozmoslabs.com/docs/profile-builder/modules/custom-redirects/?utm_source=wpbackend&utm_medium=pb-documentation&utm_campaign=PBDocs#Redirect_Default_WordPress_Forms_and_Pages" target="_blank" data-code="f223" class="wppb-docs-link dashicons dashicons-editor-help"></a>');
305
306 // social connect
307 jQuery('.wp-admin.profile-builder_page_wppb-social-connect .wrap h2.cozmoslabs-page-title').append('<a href="https://www.cozmoslabs.com/docs/profile-builder/add-ons/social-connect/?utm_source=wpbackend&utm_medium=pb-documentation&utm_campaign=PBDocs" target="_blank" data-code="f223" class="wppb-docs-link dashicons dashicons-editor-help" style="margin-left: 5px"></a>');
308
309 // multi-step forms
310 jQuery('.wp-admin.profile-builder_page_manage-fields #wppb-msf-side .inside').prepend('<a href="https://www.cozmoslabs.com/docs/profile-builder/add-ons/multi-step-forms/?utm_source=wpbackend&utm_medium=pb-documentation&utm_campaign=PBDocs" target="_blank" data-code="f223" class="wppb-docs-link dashicons dashicons-editor-help"></a>');
311
312 // labels edit
313 jQuery('.wp-admin.profile-builder_page_pb-labels-edit .wrap h2.cozmoslabs-page-title').append('<a href="https://www.cozmoslabs.com/docs/profile-builder/add-ons/labels-edit/?utm_source=wpbackend&utm_medium=pb-documentation&utm_campaign=PBDocs" target="_blank" data-code="f223" class="wppb-docs-link dashicons dashicons-editor-help" style="margin-left: 5px"></a>');
314 });
315
316
317 /**
318 * Initialize Select2
319 *
320 * */
321 jQuery(document).ready(function() {
322
323 if (typeof jQuery.fn.select2 === 'function')
324 jQuery('.wppb-select2').select2();
325
326 });
327
328
329 /**
330 * Form Designs Feature --> Admin UI
331 *
332 * - Activate new Design
333 * - Preview Modal
334 * - Modal Image Slider controls
335 *
336 * */
337
338 jQuery( document ).ready(function(){
339
340 jQuery('.wppb-forms-design-preview').click(function (e) {
341 let themeID = e.target.id.replace('-info', '');
342 displayDesignPreviewModal(themeID);
343 });
344
345 jQuery('.wppb-slideshow-button').click(function (e) {
346 let themeID = jQuery(e.target).data('theme-id'),
347 direction = jQuery(e.target).data('slideshow-direction'),
348 currentSlide = jQuery('#modal-' + themeID + ' .wppb-forms-design-preview-image.active'),
349 changeSlideshowImage = window[direction+'SlideshowImage'];
350
351 changeSlideshowImage(currentSlide,themeID);
352 });
353
354 });
355
356 function displayDesignPreviewModal( themeID ) {
357 jQuery('#modal-' + themeID).dialog({
358 resizable: false,
359 height: 'auto',
360 width: 1200,
361 modal: true,
362 closeOnEscape: true,
363 open: function () {
364 jQuery('.ui-widget-overlay').bind('click',function () {
365 jQuery('#modal-' + themeID).dialog('close');
366 })
367 },
368 close: function () {
369 let allImages = jQuery('.wppb-forms-design-preview-image');
370
371 allImages.each( function() {
372 if ( jQuery(this).is(':first-child') && !jQuery(this).hasClass('active') ) {
373 jQuery(this).addClass('active');
374 }
375 else if ( !jQuery(this).is(':first-child') ) {
376 jQuery(this).removeClass('active');
377 }
378 });
379
380 jQuery('.wppb-forms-design-sildeshow-previous').addClass('disabled');
381 jQuery('.wppb-forms-design-sildeshow-next').removeClass('disabled');
382 }
383 });
384 return false;
385 }
386
387 function nextSlideshowImage( currentSlide, themeID ){
388 if ( currentSlide.next().length > 0 ) {
389 currentSlide.removeClass('active');
390 currentSlide.next().addClass('active');
391
392 jQuery('#modal-' + themeID + ' .wppb-forms-design-sildeshow-previous').removeClass('disabled');
393
394 if ( currentSlide.next().next().length <= 0 )
395 jQuery('#modal-' + themeID + ' .wppb-forms-design-sildeshow-next').addClass('disabled');
396
397 }
398 }
399
400 function previousSlideshowImage( currentSlide, themeID ){
401 if ( currentSlide.prev().length > 0 ) {
402 currentSlide.removeClass('active');
403 currentSlide.prev().addClass('active');
404
405 jQuery('#modal-' + themeID + ' .wppb-forms-design-sildeshow-next').removeClass('disabled');
406
407 if ( currentSlide.prev().prev().length <= 0 )
408 jQuery('#modal-' + themeID + ' .wppb-forms-design-sildeshow-previous').addClass('disabled');
409
410 }
411 }
412
413
414 /**
415 * Hide/Show Roles Selector
416 *
417 * */
418 jQuery(document).ready(function() {
419 let input = jQuery('input#wppb-auth-enable'),
420 rolesSelector = jQuery('#wppb-auth-roles-selector');
421
422 input.click(function (e) {
423 rolesSelector.toggle();
424 });
425
426 });
427
428
429 /**
430 * Set Edit View wrap width for: Register Form, Edit Profile Form & User-Listing
431 *
432 * */
433 jQuery(document).ready(function() {
434 if (jQuery('#wppb-rf-settings-args').length > 0) {
435 jQuery('body.post-type-wppb-rf-cpt #wpbody-content > .wrap').css({
436 "max-width" : "1200px",
437 "margin" : "0 auto",
438 });
439 }
440
441 if (jQuery('#wppb-epf-settings-args').length > 0) {
442 jQuery('body.post-type-wppb-epf-cpt #wpbody-content > .wrap').css({
443 "max-width" : "1200px",
444 "margin" : "0 auto",
445 });
446 }
447
448 if (jQuery('#wppb-ul-settings-args').length > 0) {
449 jQuery('body.post-type-wppb-ul-cpt #wpbody-content > .wrap').css({
450 "max-width" : "1200px",
451 "margin" : "0 auto",
452 });
453 }
454 });
455
456
457
458 /**
459 * Reposition the Update/Publish button/section on scroll in Admin Dashboard --> PB CPTs
460 */
461 jQuery( function() {
462 if(jQuery('body').is('[class*="post-type-wppb"]') && jQuery('#side-sortables #submitdiv').length > 0 )
463 wppbRepositionUpdateButton();
464 });
465
466 function wppbRepositionUpdateButton() {
467 let elementOffset = jQuery('#side-sortables').offset().top,
468 mobileScreen = window.matchMedia("(max-width: 850px)"),
469 breakPoint = 0;
470
471 if (mobileScreen.matches)
472 breakPoint = elementOffset + 115; // 115px buttons container height
473 else breakPoint = elementOffset - 32; // 32px admin bar height
474
475 jQuery(window).on('scroll', function() {
476 if ( jQuery(window).scrollTop() >= (breakPoint) )
477 jQuery('#side-sortables').addClass('cozmoslabs-publish-metabox-fixed');
478 else jQuery('#side-sortables').removeClass('cozmoslabs-publish-metabox-fixed');
479 });
480 }
481