diff --git a/includes/admin/assets/js/um-admin-ajax.js b/includes/admin/assets/js/um-admin-ajax.js index b7f92ea7..ebca1cb3 100644 --- a/includes/admin/assets/js/um-admin-ajax.js +++ b/includes/admin/assets/js/um-admin-ajax.js @@ -1,32 +1,33 @@ jQuery(document).ready(function() { - jQuery(document).ajaxStart(function(){ + jQuery(document).ajaxStart( function() { jQuery('.tipsy').hide(); }); - - jQuery(document).on('click', 'a[data-silent_action^="um_"]',function(){ - - if ( typeof jQuery(this).attr('disabled') !== 'undefined' ) + + jQuery( document.body ).on('click', 'a[data-silent_action^="um_"]', function() { + if ( typeof jQuery(this).attr('disabled') !== 'undefined' ) { return false; - - in_row = ''; - in_sub_row = ''; - in_column = ''; - in_group = ''; - - if ( jQuery('.um-col-demon-settings').data('in_column') ) { - in_row = jQuery('.um-col-demon-settings').data('in_row'); - in_sub_row = jQuery('.um-col-demon-settings').data('in_sub_row'); - in_column = jQuery('.um-col-demon-settings').data('in_column'); - in_group = jQuery('.um-col-demon-settings').data('in_group'); } - - act_id = jQuery(this).data('silent_action'); - arg1 = jQuery(this).data('arg1'); - arg2 = jQuery(this).data('arg2'); - + + var in_row = ''; + var in_sub_row = ''; + var in_column = ''; + var in_group = ''; + + var demon_settings = jQuery('.um-col-demon-settings'); + if ( demon_settings.data('in_column') ) { + in_row = demon_settings.data('in_row'); + in_sub_row = demon_settings.data('in_sub_row'); + in_column = demon_settings.data('in_column'); + in_group = demon_settings.data('in_group'); + } + + var act_id = jQuery(this).data('silent_action'); + var arg1 = jQuery(this).data('arg1'); + var arg2 = jQuery(this).data('arg2'); + jQuery('.tipsy').hide(); - + um_admin_remove_modal(); jQuery.ajax({ url: wp.ajax.settings.url, @@ -42,24 +43,16 @@ jQuery(document).ready(function() { in_group: in_group, nonce: um_admin_scripts.nonce }, - success: function(data){ - - jQuery('.um-col-demon-settings').data('in_row', ''); - jQuery('.um-col-demon-settings').data('in_sub_row', ''); - jQuery('.um-col-demon-settings').data('in_column', ''); - jQuery('.um-col-demon-settings').data('in_group', ''); - + success: function( data ) { + demon_settings.data('in_row', '').data('in_sub_row', '').data('in_column', '').data('in_group', ''); um_admin_modal_responsive(); um_admin_update_builder(); - }, - error: function(data){ + error: function( data ) { } }); - - return false; - - }); -}); + return false; + }); +}); \ No newline at end of file diff --git a/includes/admin/assets/js/um-admin-builder.js b/includes/admin/assets/js/um-admin-builder.js index 9839c66b..9c797323 100644 --- a/includes/admin/assets/js/um-admin-builder.js +++ b/includes/admin/assets/js/um-admin-builder.js @@ -1,12 +1,11 @@ /** - This function updates the - builder area with fields -**/ - + * This function updates the builder area with fields + * + * @returns {boolean} + */ function um_admin_update_builder() { + var form_id = jQuery('.um-admin-builder').data('form_id'); - form_id = jQuery('.um-admin-builder').data('form_id'); - jQuery('.tipsy').hide(); jQuery.ajax({ @@ -17,31 +16,30 @@ function um_admin_update_builder() { form_id: form_id, nonce: um_admin_scripts.nonce }, - success: function(data){ - - jQuery('.um-admin-drag-ajax').html(data); - + success: function( data ) { + jQuery('.um-admin-drag-ajax').html( data ); jQuery('.tipsy').hide(); /* trigger columns at start */ allow_update_via_col_click = false; - jQuery('.um-admin-drag-ctrls.columns a.active').each(function(){ + jQuery('.um-admin-drag-ctrls.columns a.active').each( function() { jQuery(this).trigger('click'); - }).promise().done( function(){ allow_update_via_col_click = true; } ); - - UM_Rows_Refresh(); + }).promise().done( function(){ + allow_update_via_col_click = true; + }); + UM_Rows_Refresh(); }, - error: function(data){ + error: function( data ) { } }); - - return false; + return false; } -jQuery(document).ready(function() { - if ( um_admin_builder_data.hide_footer ) +jQuery( document ).ready( function() { + if ( um_admin_builder_data.hide_footer ) { jQuery('#wpfooter').hide(); + } }); \ No newline at end of file diff --git a/includes/admin/assets/js/um-admin-dashboard.js b/includes/admin/assets/js/um-admin-dashboard.js deleted file mode 100644 index 8f3f03bd..00000000 --- a/includes/admin/assets/js/um-admin-dashboard.js +++ /dev/null @@ -1,3 +0,0 @@ -jQuery(document).ready(function() { - -}); \ No newline at end of file diff --git a/includes/admin/assets/js/um-admin-dragdrop.js b/includes/admin/assets/js/um-admin-dragdrop.js index 43f687d4..1f22eb30 100644 --- a/includes/admin/assets/js/um-admin-dragdrop.js +++ b/includes/admin/assets/js/um-admin-dragdrop.js @@ -1,5 +1,4 @@ -function UM_Drag_and_Drop(){ - +function UM_Drag_and_Drop() { jQuery('.um-admin-drag-col,.um-admin-drag-group').sortable({ items: '.um-admin-drag-fld', connectWith: '.um-admin-drag-col,.um-admin-drag-group', @@ -89,10 +88,9 @@ function UM_Drag_and_Drop(){ } }).disableSelection(); - } -function UM_update_rows(){ +function UM_update_rows() { var c = 0; jQuery('a[data-remove_element="um-admin-drag-row"]').remove(); jQuery('.um-admin-drag-row').each(function(){ @@ -279,13 +277,14 @@ function UM_Add_Icon(){ } jQuery(document).ready(function() { - - if ( !jQuery('.um-admin-drag').length ) return false; + if ( !jQuery('.um-admin-drag').length ) { + return false; + } UM_Drag_and_Drop(); /* add field to respected area */ - jQuery(document).on('click', 'a.um-admin-drag-add-field', function(){ + jQuery( document.body ).on('click', 'a.um-admin-drag-add-field', function() { in_row = jQuery(this).parents('.um-admin-drag-row').index(); in_sub_row = jQuery(this).parents('.um-admin-drag-rowsub').index(); if ( jQuery(this).parents('.um-admin-drag-rowsub').find('.um-admin-drag-col').length == 1 ) { @@ -317,7 +316,7 @@ jQuery(document).ready(function() { }); /* add row */ - jQuery(document).on('click', '*[data-row_action="add_row"]', function(){ + jQuery(document.body).on('click', '*[data-row_action="add_row"]', function(){ var dragg = jQuery('.um-admin-drag-ajax'); dragg.append( '
' + jQuery('.um-col-demon-row').html() + '
' ); dragg.find('.um-admin-drag-row:last').find('.um-admin-drag-row-icons').find('a.um-admin-drag-row-edit').attr('data-arg3', '_um_row_' + ( dragg.find('.um-admin-drag-row').length ) ); @@ -328,7 +327,7 @@ jQuery(document).ready(function() { }); /* add sub row */ - jQuery(document).on('click', '*[data-row_action="add_subrow"]', function(){ + jQuery(document.body).on('click', '*[data-row_action="add_subrow"]', function(){ var dragg = jQuery(this).parents('.um-admin-drag-row').find('.um-admin-drag-rowsubs'); dragg.append( '
' + jQuery('.um-col-demon-subrow').html() + '
' ); UM_update_subrows(); @@ -336,7 +335,7 @@ jQuery(document).ready(function() { }); /* remove element */ - jQuery(document).on('click', 'a[data-remove_element^="um-"]',function(){ + jQuery(document.body).on('click', 'a[data-remove_element^="um-"]',function(){ element = jQuery(this).data('remove_element'); jQuery(this).parents('.' +element).find('.um-admin-drag-fld').each(function(){ @@ -349,7 +348,7 @@ jQuery(document).ready(function() { }); /* dynamically change columns */ - jQuery(document).on('click', '.um-admin-drag-ctrls.columns a', function(){ + jQuery(document.body).on('click', '.um-admin-drag-ctrls.columns a', function(){ var row = jQuery(this).parents('.um-admin-drag-rowsub'); var tab = jQuery(this); @@ -406,5 +405,4 @@ jQuery(document).ready(function() { }).promise().done( function(){ allow_update_via_col_click = true; } ); UM_Rows_Refresh(); - }); \ No newline at end of file diff --git a/includes/admin/assets/js/um-admin-field.js b/includes/admin/assets/js/um-admin-field.js index 4795ff8a..43cac49d 100644 --- a/includes/admin/assets/js/um-admin-field.js +++ b/includes/admin/assets/js/um-admin-field.js @@ -1,7 +1,7 @@ jQuery(document).ready(function() { /* Remove field permanently */ - jQuery(document).on('click', '.um-admin-btns a span.remove', function(e){ + jQuery(document.body).on('click', '.um-admin-btns a span.remove', function(e){ e.preventDefault(); if ( confirm( 'This will permanently delete this custom field from database' ) ) { @@ -34,7 +34,7 @@ jQuery(document).ready(function() { /* Add a Field */ - jQuery(document).on('submit', 'form.um_add_field', function(e){ + jQuery(document.body).on('submit', 'form.um_add_field', function(e){ e.preventDefault(); var conditions = jQuery('.um-admin-cur-condition'); diff --git a/includes/admin/assets/js/um-admin-form.js b/includes/admin/assets/js/um-admin-form.js index c5425d50..8c75995b 100644 --- a/includes/admin/assets/js/um-admin-form.js +++ b/includes/admin/assets/js/um-admin-form.js @@ -1,38 +1,32 @@ +function um_form_select_tab( tab, set_val ) { + var mode_block = jQuery('input#form__um_mode'); + tab.parents('.um-admin-boxed-links').find('a').removeClass('um-admin-activebg'); + tab.addClass('um-admin-activebg'); + + jQuery('.um-admin div#side-sortables').show(); + jQuery('div[id^="um-admin-form"]').hide(); + jQuery('#submitdiv').show(); + jQuery('div#um-admin-form-mode,div#um-admin-form-title,div#um-admin-form-builder,div#um-admin-form-shortcode').show(); + jQuery('div[id^="um-admin-form-' + tab.data('role') + '"]').show(); + + if ( set_val ) { + mode_block.val( tab.data('role') ); + } + + jQuery('.empty-container').css({'border' : 'none'}); + jQuery('.um-admin-builder').removeClass().addClass( 'um-admin-builder ' + mode_block.val() ); +} + jQuery(document).ready(function() { - /* Default form tab */ if ( jQuery('.um-admin-boxed-links').length > 0 ) { - var tab = jQuery('.um-admin-boxed-links a[data-role="'+jQuery('input#form__um_mode').val()+'"]'); - - tab.parents('.um-admin-boxed-links').find('a').removeClass('um-admin-activebg'); - tab.addClass('um-admin-activebg'); - jQuery('.um-admin div#side-sortables').show(); - jQuery('div[id^="um-admin-form"]').hide(); - jQuery('#submitdiv').show(); - jQuery('div#um-admin-form-mode,div#um-admin-form-title,div#um-admin-form-builder,div#um-admin-form-shortcode').show(); - jQuery('div[id^="um-admin-form-'+tab.data('role')+'"]').show(); - jQuery('.empty-container').css({'border' : 'none'}); - jQuery('.um-admin-builder').removeClass().addClass( 'um-admin-builder ' + jQuery('input#form__um_mode').val() ); - + um_form_select_tab( tab, false ); } - + + /* Creating new form button */ - jQuery('.um-admin-boxed-links:not(.is-core-form) a').click(function(){ - - var tab = jQuery(this); - - tab.parents('.um-admin-boxed-links').find('a').removeClass('um-admin-activebg'); - tab.addClass('um-admin-activebg'); - jQuery('.um-admin div#side-sortables').show(); - jQuery('div[id^="um-admin-form"]').hide(); - jQuery('#submitdiv').show(); - jQuery('div#um-admin-form-mode,div#um-admin-form-title,div#um-admin-form-builder,div#um-admin-form-shortcode').show(); - jQuery('div[id^="um-admin-form-'+tab.data('role')+'"]').show(); - jQuery('input#form__um_mode').val( tab.data('role') ); - jQuery('.empty-container').css({'border' : 'none'}); - jQuery('.um-admin-builder').removeClass().addClass( 'um-admin-builder ' + jQuery('input#form__um_mode').val() ); - + jQuery('.um-admin-boxed-links:not(.is-core-form) a').click( function() { + um_form_select_tab( jQuery(this), true ); }); - }); \ No newline at end of file diff --git a/includes/admin/assets/js/um-admin-forms.js b/includes/admin/assets/js/um-admin-forms.js index dd16ba99..3d645653 100644 --- a/includes/admin/assets/js/um-admin-forms.js +++ b/includes/admin/assets/js/um-admin-forms.js @@ -1,248 +1,248 @@ jQuery(document).ready( function() { - - /** - * Multi-selects field - */ - jQuery( 'body' ).on( 'click', '.um-select-delete', function() { - jQuery( this ).parents( 'li.um-multi-selects-option-line' ).remove(); - }); + /** + * Multi-selects field + */ + jQuery( document.body ).on( 'click', '.um-select-delete', function() { + jQuery( this ).parents( 'li.um-multi-selects-option-line' ).remove(); + }); - jQuery( '.um-multi-selects-add-option' ).click( function() { - var list = jQuery(this).siblings('ul.um-multi-selects-list'); + jQuery( '.um-multi-selects-add-option' ).click( function() { + var list = jQuery(this).siblings('ul.um-multi-selects-list'); - var field_id = list.data('field_id'); - var k = 0; - if ( list.find( 'li:last select.um-forms-field' ).length > 0 ) { - k = list.find( 'li:last select.um-forms-field' ).attr('id').split("-"); - k = k[1]*1 + 1; - } + var field_id = list.data('field_id'); + var k = 0; + if ( list.find( 'li:last select.um-forms-field' ).length > 0 ) { + k = list.find( 'li:last select.um-forms-field' ).attr('id').split("-"); + k = k[1]*1 + 1; + } - var selector_html = jQuery( '
' ).append( list.siblings('.um-hidden-multi-selects').clone() ).html(); + var selector_html = jQuery( '
' ).append( list.siblings('.um-hidden-multi-selects').clone() ).html(); - var classes = list.find('li:last').attr('class'); + var classes = list.find('li:last').attr('class'); - list.append( - '
  • ' + selector_html + - '' + php_data.texts.remove + '
  • ' - ); + list.append( + '
  • ' + selector_html + + '' + php_data.texts.remove + '
  • ' + ); - list.find('li:last .um-hidden-multi-selects').attr('name', jQuery(this).data('name') ). - addClass('um-forms-field um-long-field').removeClass('um-hidden-multi-selects').attr('id', list.data('id_attr') + '-' + k); + list.find('li:last .um-hidden-multi-selects').attr('name', jQuery(this).data('name') ). + addClass('um-forms-field um-long-field').removeClass('um-hidden-multi-selects').attr('id', list.data('id_attr') + '-' + k); - }); + }); - /** - * Multi-text field - */ - jQuery( 'body' ).on( 'click', '.um-text-delete', function() { - jQuery(this).parents('li.um-multi-text-option-line').remove(); - }); + /** + * Multi-text field + */ + jQuery( document.body ).on( 'click', '.um-text-delete', function() { + jQuery(this).parents('li.um-multi-text-option-line').remove(); + }); - jQuery( '.um-multi-text-add-option' ).click( function() { - var list = jQuery(this).siblings( 'ul.um-multi-text-list' ); + jQuery( '.um-multi-text-add-option' ).click( function() { + var list = jQuery(this).siblings( 'ul.um-multi-text-list' ); - var field_id = list.data( 'field_id' ); - var k = 0; - if ( list.find( 'li:last input.um-forms-field' ).length > 0 ) { - k = list.find( 'li:last input.um-forms-field' ).attr('id').split("-"); - k = k[1]*1 + 1; - } + var field_id = list.data( 'field_id' ); + var k = 0; + if ( list.find( 'li:last input.um-forms-field' ).length > 0 ) { + k = list.find( 'li:last input.um-forms-field' ).attr('id').split("-"); + k = k[1]*1 + 1; + } - var text_html = jQuery( '
    ' ).append( list.siblings('.um-hidden-multi-text').clone() ).html(); + var text_html = jQuery( '
    ' ).append( list.siblings('.um-hidden-multi-text').clone() ).html(); - var classes = list.find('li:last').attr('class'); + var classes = list.find('li:last').attr('class'); - list.append( - '
  • ' + text_html + - '' + php_data.texts.remove + '
  • ' - ); + list.append( + '
  • ' + text_html + + '' + php_data.texts.remove + '
  • ' + ); - list.find('li:last .um-hidden-multi-text').attr('name', jQuery(this).data('name') ). - addClass('um-forms-field um-long-field').removeClass('um-hidden-multi-text').attr('id', list.data('id_attr') + '-' + k); - }); + list.find('li:last .um-hidden-multi-text').attr('name', jQuery(this).data('name') ). + addClass('um-forms-field um-long-field').removeClass('um-hidden-multi-text').attr('id', list.data('id_attr') + '-' + k); + }); - /** - * Media uploader - */ - jQuery( '.um-media-upload' ).each( function() { - var field = jQuery(this).find( '.um-forms-field' ); - var default_value = field.data('default'); + /** + * Media uploader + */ + jQuery( '.um-media-upload' ).each( function() { + var field = jQuery(this).find( '.um-forms-field' ); + var default_value = field.data('default'); - if ( field.val() != '' && field.val() != default_value ) { - field.siblings('.um-set-image').hide(); - field.siblings('.um-clear-image').show(); - field.siblings('.icon_preview').show(); - } else { - if ( field.val() == default_value ) { - field.siblings('.icon_preview').show(); - } - field.siblings('.um-set-image').show(); - field.siblings('.um-clear-image').hide(); - } - }); + if ( field.val() != '' && field.val() != default_value ) { + field.siblings('.um-set-image').hide(); + field.siblings('.um-clear-image').show(); + field.siblings('.icon_preview').show(); + } else { + if ( field.val() == default_value ) { + field.siblings('.icon_preview').show(); + } + field.siblings('.um-set-image').show(); + field.siblings('.um-clear-image').hide(); + } + }); - if ( typeof wp !== 'undefined' && wp.media && wp.media.editor ) { - var frame; + if ( typeof wp !== 'undefined' && wp.media && wp.media.editor ) { + var frame; - jQuery( '.um-set-image' ).click( function(e) { - var button = jQuery(this); + jQuery( '.um-set-image' ).click( function(e) { + var button = jQuery(this); - e.preventDefault(); + e.preventDefault(); - // If the media frame already exists, reopen it. - if ( frame ) { - frame.remove(); - /*frame.open(); - return;*/ - } + // If the media frame already exists, reopen it. + if ( frame ) { + frame.remove(); + /*frame.open(); + return;*/ + } - // Create a new media frame - frame = wp.media({ - title: button.data('upload_frame'), - button: { - text: php_data.texts.select - }, - multiple: false // Set to true to allow multiple files to be selected - }); + // Create a new media frame + frame = wp.media({ + title: button.data('upload_frame'), + button: { + text: php_data.texts.select + }, + multiple: false // Set to true to allow multiple files to be selected + }); - // When an image is selected in the media frame... - frame.on( 'select', function() { - // Get media attachment details from the frame state - var attachment = frame.state().get('selection').first().toJSON(); + // When an image is selected in the media frame... + frame.on( 'select', function() { + // Get media attachment details from the frame state + var attachment = frame.state().get('selection').first().toJSON(); - // Send the attachment URL to our custom image input field. - button.siblings('.icon_preview').attr( 'src', attachment.url ).show(); + // Send the attachment URL to our custom image input field. + button.siblings('.icon_preview').attr( 'src', attachment.url ).show(); - button.siblings('.um-forms-field').val( attachment.url ); - button.siblings('.um-media-upload-data-id').val(attachment.id); - button.siblings('.um-media-upload-data-width').val(attachment.width); - button.siblings('.um-media-upload-data-height').val(attachment.height); - button.siblings('.um-media-upload-data-thumbnail').val(attachment.thumbnail); - button.siblings('.um-media-upload-data-url').trigger('change'); - button.siblings('.um-media-upload-url').val(attachment.url); + button.siblings('.um-forms-field').val( attachment.url ); + button.siblings('.um-media-upload-data-id').val(attachment.id); + button.siblings('.um-media-upload-data-width').val(attachment.width); + button.siblings('.um-media-upload-data-height').val(attachment.height); + button.siblings('.um-media-upload-data-thumbnail').val(attachment.thumbnail); + button.siblings('.um-media-upload-data-url').trigger('change'); + button.siblings('.um-media-upload-url').val(attachment.url); - button.siblings('.um-clear-image').show(); - button.hide(); + button.siblings('.um-clear-image').show(); + button.hide(); - jQuery( document ).trigger( 'um_media_upload_select', [button, attachment] ); - }); + jQuery( document ).trigger( 'um_media_upload_select', [button, attachment] ); + }); - frame.open(); - }); + frame.open(); + }); - jQuery('.icon_preview').click( function(e) { - jQuery(this).siblings('.um-set-image').trigger('click'); - }); + jQuery('.icon_preview').click( function(e) { + jQuery(this).siblings('.um-set-image').trigger('click'); + }); - jQuery('.um-clear-image').click( function(e) { - var clear_button = jQuery(this); - var default_image_url = clear_button.siblings('.um-forms-field').data('default'); - clear_button.siblings('.um-set-image').show(); - clear_button.hide(); - clear_button.siblings('.icon_preview').attr( 'src', default_image_url ); - clear_button.siblings('.um-media-upload-data-id').val(''); - clear_button.siblings('.um-media-upload-data-width').val(''); - clear_button.siblings('.um-media-upload-data-height').val(''); - clear_button.siblings('.um-media-upload-data-thumbnail').val(''); - clear_button.siblings('.um-forms-field').val( default_image_url ); - clear_button.siblings('.um-media-upload-data-url').trigger('change'); - clear_button.siblings('.um-media-upload-url').val( default_image_url ); + jQuery('.um-clear-image').click( function(e) { + var clear_button = jQuery(this); + var default_image_url = clear_button.siblings('.um-forms-field').data('default'); + clear_button.siblings('.um-set-image').show(); + clear_button.hide(); + clear_button.siblings('.icon_preview').attr( 'src', default_image_url ); + clear_button.siblings('.um-media-upload-data-id').val(''); + clear_button.siblings('.um-media-upload-data-width').val(''); + clear_button.siblings('.um-media-upload-data-height').val(''); + clear_button.siblings('.um-media-upload-data-thumbnail').val(''); + clear_button.siblings('.um-forms-field').val( default_image_url ); + clear_button.siblings('.um-media-upload-data-url').trigger('change'); + clear_button.siblings('.um-media-upload-url').val( default_image_url ); - jQuery( document ).trigger( 'um_media_upload_clear', clear_button ); - }); - } + jQuery( document ).trigger( 'um_media_upload_clear', clear_button ); + }); + } - /** - * On option fields change - */ - jQuery( document.body ).on('change', '.um-forms-field', function() { - if ( jQuery('.um-forms-line[data-conditional*=\'"' + jQuery(this).data('field_id') + '",\']').length > 0 ) { - run_check_conditions(); - } - }); + /** + * On option fields change + */ + jQuery( document.body ).on('change', '.um-forms-field', function() { + if ( jQuery('.um-forms-line[data-conditional*=\'"' + jQuery(this).data('field_id') + '",\']').length > 0 ) { + run_check_conditions(); + } + }); - //first load hide unconditional fields - run_check_conditions(); + //first load hide unconditional fields + run_check_conditions(); - /** - * Run conditional logic - */ - function run_check_conditions() { - jQuery( '.um-forms-line' ).removeClass('um-forms-line-conditioned').each( function() { - if ( typeof jQuery(this).data('conditional') === 'undefined' || jQuery(this).hasClass('um-forms-line-conditioned') ) - return; + /** + * Run conditional logic + */ + function run_check_conditions() { + jQuery( '.um-forms-line' ).removeClass('um-forms-line-conditioned').each( function() { + if ( typeof jQuery(this).data('conditional') === 'undefined' || jQuery(this).hasClass('um-forms-line-conditioned') ) + return; - if ( check_condition( jQuery(this) ) ) - jQuery(this).show(); - else - jQuery(this).hide(); - }); - } + if ( check_condition( jQuery(this) ) ) { + jQuery(this).show(); + } else { + jQuery(this).hide(); + } + }); + } - /** - * Conditional logic - * - * true - show field - * false - hide field - * - * @returns {boolean} - */ - function check_condition( form_line ) { + /** + * Conditional logic + * + * true - show field + * false - hide field + * + * @returns {boolean} + */ + function check_condition( form_line ) { - form_line.addClass( 'um-forms-line-conditioned' ); + form_line.addClass( 'um-forms-line-conditioned' ); - var conditional = form_line.data('conditional'); - var condition = conditional[1]; - var value = conditional[2]; + var conditional = form_line.data('conditional'); + var condition = conditional[1]; + var value = conditional[2]; - var prefix = form_line.data( 'prefix' ); - //var prefix = form_line.parents( '.um-form-table' ).data( 'prefix' ); + var prefix = form_line.data( 'prefix' ); + //var prefix = form_line.parents( '.um-form-table' ).data( 'prefix' ); - var condition_field = jQuery( '#' + prefix + '_' + conditional[0] ); - var parent_condition = true; - if ( typeof condition_field.parents('.um-forms-line').data('conditional') !== 'undefined' ) { - parent_condition = check_condition( condition_field.parents('.um-forms-line') ); - } + var condition_field = jQuery( '#' + prefix + '_' + conditional[0] ); + var parent_condition = true; + if ( typeof condition_field.parents('.um-forms-line').data('conditional') !== 'undefined' ) { + parent_condition = check_condition( condition_field.parents('.um-forms-line') ); + } - var own_condition = false; - if ( condition == '=' ) { - var tagName = condition_field.prop("tagName").toLowerCase(); + var own_condition = false; + if ( condition == '=' ) { + var tagName = condition_field.prop("tagName").toLowerCase(); - if ( tagName == 'input' ) { - var input_type = condition_field.attr('type'); - if ( input_type == 'checkbox' ) { - own_condition = ( value == '1' ) ? condition_field.is(':checked') : ! condition_field.is(':checked'); - } else { - own_condition = ( condition_field.val() == value ); - } - } else if ( tagName == 'select' ) { - own_condition = ( condition_field.val() == value ); - } - } else if ( condition == '!=' ) { - var tagName = condition_field.prop("tagName").toLowerCase(); + if ( tagName == 'input' ) { + var input_type = condition_field.attr('type'); + if ( input_type == 'checkbox' ) { + own_condition = ( value == '1' ) ? condition_field.is(':checked') : ! condition_field.is(':checked'); + } else { + own_condition = ( condition_field.val() == value ); + } + } else if ( tagName == 'select' ) { + own_condition = ( condition_field.val() == value ); + } + } else if ( condition == '!=' ) { + var tagName = condition_field.prop("tagName").toLowerCase(); - if ( tagName == 'input' ) { - var input_type = condition_field.attr('type'); - if ( input_type == 'checkbox' ) { - own_condition = ( value == '1' ) ? ! condition_field.is(':checked') : condition_field.is(':checked'); - } else { - own_condition = ( condition_field.val() != value ); - } - } else if ( tagName == 'select' ) { - own_condition = ( condition_field.val() != value ); - } - } + if ( tagName == 'input' ) { + var input_type = condition_field.attr('type'); + if ( input_type == 'checkbox' ) { + own_condition = ( value == '1' ) ? ! condition_field.is(':checked') : condition_field.is(':checked'); + } else { + own_condition = ( condition_field.val() != value ); + } + } else if ( tagName == 'select' ) { + own_condition = ( condition_field.val() != value ); + } + } - return ( own_condition && parent_condition ); - } + return ( own_condition && parent_condition ); + } }); \ No newline at end of file diff --git a/includes/admin/assets/js/um-admin-global.js b/includes/admin/assets/js/um-admin-global.js index 2121ec71..54721a04 100644 --- a/includes/admin/assets/js/um-admin-global.js +++ b/includes/admin/assets/js/um-admin-global.js @@ -1,44 +1,44 @@ jQuery(document).ready(function() { - jQuery(document).on('click', '#um_add_review_love', function (e) { + jQuery(document.body).on('click', '#um_add_review_love', function (e) { jQuery(this).parents('#um_start_review_notice').hide(); jQuery('.um_hidden_notice[data-key="love"]').show(); }); - jQuery(document).on('click', '#um_add_review_good', function (e) { + jQuery(document.body).on('click', '#um_add_review_good', function (e) { jQuery(this).parents('#um_start_review_notice').hide(); jQuery('.um_hidden_notice[data-key="good"]').show(); }); - jQuery(document).on('click', '#um_add_review_bad', function (e) { + jQuery(document.body).on('click', '#um_add_review_bad', function (e) { jQuery(this).parents('#um_start_review_notice').hide(); jQuery('.um_hidden_notice[data-key="bad"]').show(); }); - jQuery(document).on('click', '.um_review_link', function (e) { + jQuery(document.body).on('click', '.um_review_link', function (e) { jQuery(this).parents('.um-admin-notice').find( '.notice-dismiss' ).trigger('click'); }); - jQuery(document).on('click', '.um_secondary_dimiss', function (e) { + jQuery(document.body).on('click', '.um_secondary_dimiss', function (e) { jQuery(this).parents('.um-admin-notice').find( '.notice-dismiss' ).trigger('click'); }); - jQuery(document).on('click', '.um_opt_in_link', function (e) { + jQuery(document.body).on('click', '.um_opt_in_link', function (e) { jQuery(this).parents('.um-admin-notice').find( '.notice-dismiss' ).trigger('click'); }); - jQuery(document).on('click', '#um_opt_in_start', function (e) { + jQuery(document.body).on('click', '#um_opt_in_start', function (e) { jQuery(this).parents('.um-admin-notice').find( '.notice-dismiss' ).trigger('click'); }); - jQuery(document).on( 'click', '.um-admin-notice.is-dismissible .notice-dismiss', function(e) { + jQuery(document.body).on( 'click', '.um-admin-notice.is-dismissible .notice-dismiss', function(e) { var notice_key = jQuery(this).parents('.um-admin-notice').data('key'); wp.ajax.send( 'um_dismiss_notice', { diff --git a/includes/admin/assets/js/um-admin-modal.js b/includes/admin/assets/js/um-admin-modal.js index ed75f88b..994169c4 100644 --- a/includes/admin/assets/js/um-admin-modal.js +++ b/includes/admin/assets/js/um-admin-modal.js @@ -1,25 +1,20 @@ function um_admin_live_update_scripts() { + jQuery('.um-adm-conditional').each( function() { + jQuery(this).trigger('change'); + }); - /*jQuery('.um-admin-modal-body:visible select').select2({ - allowClear: false, - minimumResultsForSearch: 10 - });*/ - - jQuery('.um-adm-conditional').each(function(){jQuery(this).trigger('change');}); if ( jQuery('.um-admin-colorpicker').length ) { jQuery('.um-admin-colorpicker').wpColorPicker(); } - } -function um_admin_new_modal( id, ajax, size ){ - +function um_admin_new_modal( id, ajax, size ) { var modal = jQuery('body').find('.um-admin-overlay'); - + jQuery('.tipsy').hide(); - + um_admin_remove_modal(); - + jQuery('body').addClass('um-admin-modal-open').append('
    '); jQuery('#' + id).prependTo('.um-admin-modal'); jQuery('#' + id).show(); @@ -34,11 +29,9 @@ function um_admin_new_modal( id, ajax, size ){ } else { um_admin_modal_responsive(); } - } function um_admin_modal_ajaxcall( act_id, arg1, arg2, arg3 ) { - in_row = ''; in_sub_row = ''; in_column = ''; @@ -180,7 +173,7 @@ jQuery(document).ready(function() { /** disable link **/ - jQuery(document).on('click', '.um-admin-builder a, .um-admin-modal a', function(e){ + jQuery(document.body).on('click', '.um-admin-builder a, .um-admin-modal a', function(e){ e.preventDefault(); return false; }); @@ -188,7 +181,7 @@ jQuery(document).ready(function() { /** toggle area **/ - jQuery(document).on('click', '.um-admin-btn-toggle a', function(e){ + jQuery(document.body).on('click', '.um-admin-btn-toggle a', function(e){ var content = jQuery(this).parent().find('.um-admin-btn-content'); var link = jQuery(this); if ( content.is(':hidden') ) { @@ -208,7 +201,7 @@ jQuery(document).ready(function() { /** clone a condition **/ - jQuery(document).on('click', '.um-admin-new-condition', function() { + jQuery(document.body).on('click', '.um-admin-new-condition', function() { if ( jQuery(this).hasClass('disabled') ) return false; @@ -252,7 +245,7 @@ jQuery(document).ready(function() { /** reset conditions **/ - jQuery(document).on('click', '.um-admin-reset-conditions a', function(){ + jQuery(document.body).on('click', '.um-admin-reset-conditions a', function(){ var content = jQuery(this).parents('.um-admin-btn-content'); content.find('.um-admin-cur-condition').slice(1).remove(); content.find('input[type=text]').val(''); @@ -265,7 +258,7 @@ jQuery(document).ready(function() { /** remove a condition **/ - jQuery(document).on('click', '.um-admin-remove-condition', function(){ + jQuery(document.body).on('click', '.um-admin-remove-condition', function(){ var condition = jQuery(this).parents('.um-admin-cur-condition'); jQuery('.um-admin-new-condition').removeClass('disabled'); jQuery('.tipsy').remove(); @@ -290,14 +283,14 @@ jQuery(document).ready(function() { /** remove modal via action **/ - jQuery(document).on('click', '.um-admin-overlay, a[data-action="UM_remove_modal"]', function(){ + jQuery(document.body).on('click', '.um-admin-overlay, a[data-action="UM_remove_modal"]', function(){ um_admin_remove_modal(); }); /** fire new modal **/ - jQuery(document).on('click', 'a[data-modal^="UM_"], span[data-modal^="UM_"]', function(e){ + jQuery(document.body).on('click', 'a[data-modal^="UM_"], span[data-modal^="UM_"]', function(e){ e.preventDefault(); @@ -327,7 +320,7 @@ jQuery(document).ready(function() { /** choose font icon **/ - jQuery(document).on('click', '.um-admin-icons span', function(){ + jQuery(document.body).on('click', '.um-admin-icons span', function(){ var icon = jQuery(this).attr('data-code'); jQuery(this).parent().find('span').removeClass('highlighted'); jQuery(this).addClass('highlighted'); @@ -337,7 +330,7 @@ jQuery(document).ready(function() { /** submit font icon **/ - jQuery(document).on('click', '#UM_fonticons a.um-admin-modal-back:not(.um-admin-modal-cancel)', function(){ + jQuery(document.body).on('click', '#UM_fonticons a.um-admin-modal-back:not(.um-admin-modal-cancel)', function(){ var v_id = ''; var icon_selected = jQuery(this).attr('data-code'); if (icon_selected != ''){ @@ -359,7 +352,7 @@ jQuery(document).ready(function() { /** restore font icon **/ - jQuery(document).on('click', 'span.um-admin-icon-clear', function(){ + jQuery(document.body).on('click', 'span.um-admin-icon-clear', function(){ var element = jQuery(this).parents('p'); jQuery('#UM_fonticons a.um-admin-modal-back').attr('data-code', ''); element.find('input[type=hidden]').val(''); @@ -374,7 +367,7 @@ jQuery(document).ready(function() { /** search font icons **/ - jQuery(document).on('keyup blur', '#_icon_search', function(){ + jQuery(document.body).on('keyup blur', '#_icon_search', function(){ if ( jQuery(this).val().toLowerCase() != '' ) { jQuery('.um-admin-icons span').hide(); jQuery('.um-admin-icons span[data-code*="'+jQuery(this).val().toLowerCase()+'"]').show(); @@ -388,7 +381,7 @@ jQuery(document).ready(function() { /** * Retrieve options from a callback function */ - jQuery(document).on('blur',"#_custom_dropdown_options_source", function(){ + jQuery(document.body).on('blur',"#_custom_dropdown_options_source", function(){ var me = jQuery(this); var _options = jQuery('textarea[id=_options]'); diff --git a/includes/admin/assets/js/um-admin-nav-menu.js b/includes/admin/assets/js/um-admin-nav-menu.js index 8450a0ef..bde3a87f 100644 --- a/includes/admin/assets/js/um-admin-nav-menu.js +++ b/includes/admin/assets/js/um-admin-nav-menu.js @@ -1,36 +1,36 @@ jQuery(document).ready(function ($) { - var template = wp.template( 'um-nav-menus-fields' ); + var template = wp.template( 'um-nav-menus-fields' ); - $( document ).on( 'menu-item-added', function ( e, $menuMarkup ) { - var id = $( $menuMarkup ).attr('id').substr(10); + $( document.body ).on( 'menu-item-added', function ( e, $menuMarkup ) { + var id = $( $menuMarkup ).attr('id').substr(10); - var template_content = template({ - menuItemID: id, - restriction_data:{ - um_nav_public:0, - um_nav_roles:[] - } - }); + var template_content = template({ + menuItemID: id, + restriction_data:{ + um_nav_public:0, + um_nav_roles:[] + } + }); - if ( $( $menuMarkup ).find( 'fieldset.field-move' ).length > 0 ) { - $( $menuMarkup ).find( 'fieldset.field-move' ).before( template_content ); - } else { - $( $menuMarkup ).find( '.menu-item-actions' ).before( template_content ); - } - }); + if ( $( $menuMarkup ).find( 'fieldset.field-move' ).length > 0 ) { + $( $menuMarkup ).find( 'fieldset.field-move' ).before( template_content ); + } else { + $( $menuMarkup ).find( '.menu-item-actions' ).before( template_content ); + } + }); - $( 'ul#menu-to-edit > li' ).each( function(){ - var id = $(this).attr('id').substr(10); - var template_content = template({ - menuItemID: id, - restriction_data: um_menu_restriction_data[ id ] - }); + $( 'ul#menu-to-edit > li' ).each( function(){ + var id = $(this).attr('id').substr(10); + var template_content = template({ + menuItemID: id, + restriction_data: um_menu_restriction_data[ id ] + }); - if ( $( this ).find( 'fieldset.field-move' ).length > 0 ) { - $( this ).find( 'fieldset.field-move' ).before( template_content ); - } else { - $( this ).find( '.menu-item-actions' ).before( template_content ); - } - }); + if ( $( this ).find( 'fieldset.field-move' ).length > 0 ) { + $( this ).find( 'fieldset.field-move' ).before( template_content ); + } else { + $( this ).find( '.menu-item-actions' ).before( template_content ); + } + }); }); \ No newline at end of file diff --git a/includes/admin/assets/js/um-admin-role-wrapper.js b/includes/admin/assets/js/um-admin-role-wrapper.js index 81e6fbc0..020d3cd0 100644 --- a/includes/admin/assets/js/um-admin-role-wrapper.js +++ b/includes/admin/assets/js/um-admin-role-wrapper.js @@ -1,21 +1,21 @@ jQuery( document ).ready( function() { - jQuery( '#role' ).change( function() { - if ( jQuery.inArray( jQuery(this).val().substr(3), um_roles ) !== -1 ) { - jQuery( '#um_role_selector_wrapper' ).hide(); - jQuery( '#um-role' ).val(''); - } else { - jQuery( '#um_role_selector_wrapper' ).show(); - } - }).trigger('change'); + jQuery( '#role' ).change( function() { + if ( jQuery.inArray( jQuery(this).val().substr(3), um_roles ) !== -1 ) { + jQuery( '#um_role_selector_wrapper' ).hide(); + jQuery( '#um-role' ).val(''); + } else { + jQuery( '#um_role_selector_wrapper' ).show(); + } + }).trigger('change'); - jQuery( '#adduser-role' ).change( function() { - if ( jQuery.inArray( jQuery(this).val().substr(3), um_roles ) !== -1 ) { - jQuery( '#um_role_existing_selector_wrapper' ).hide(); - jQuery( '#um-role' ).val(''); - } else { - jQuery( '#um_role_existing_selector_wrapper' ).show(); - } - }).trigger('change'); + jQuery( '#adduser-role' ).change( function() { + if ( jQuery.inArray( jQuery(this).val().substr(3), um_roles ) !== -1 ) { + jQuery( '#um_role_existing_selector_wrapper' ).hide(); + jQuery( '#um-role' ).val(''); + } else { + jQuery( '#um_role_existing_selector_wrapper' ).show(); + } + }).trigger('change'); }); \ No newline at end of file diff --git a/includes/admin/assets/js/um-admin-scripts.js b/includes/admin/assets/js/um-admin-scripts.js index ab1d3d4c..069d500a 100644 --- a/includes/admin/assets/js/um-admin-scripts.js +++ b/includes/admin/assets/js/um-admin-scripts.js @@ -12,35 +12,10 @@ function um_init_tooltips() { jQuery(document).ready(function() { - /** - clone a field dropdown - **/ - jQuery(document).on( 'click', '#um_add_review_love', function(e){ - jQuery(this).parents('#um_start_review_notice').hide(); - jQuery('.um_hidden_notice[data-key="love"]').show(); - }); - - /** - clone a field dropdown - **/ - jQuery(document).on( 'click', '#um_add_review_good', function(e){ - jQuery(this).parents('#um_start_review_notice').hide(); - jQuery('.um_hidden_notice[data-key="good"]').show(); - }); - - /** - clone a field dropdown - **/ - jQuery(document).on( 'click', '#um_add_review_bad', function(e){ - jQuery(this).parents('#um_start_review_notice').hide(); - jQuery('.um_hidden_notice[data-key="bad"]').show(); - }); - - /** clone a field dropdown **/ - jQuery(document).on('click', '.um-admin-clone', function(e){ + jQuery(document.body).on('click', '.um-admin-clone', function(e){ e.preventDefault(); var container = jQuery(this).parents('.um-admin-field'); var parent = jQuery(this).parents('p').find('.um-admin-field:last-child'); @@ -59,7 +34,7 @@ jQuery(document).ready(function() { /** remove a field dropdown **/ - jQuery(document).on('click', '.um-admin-clone-remove', function(e){ + jQuery(document.body).on('click', '.um-admin-clone-remove', function(e){ e.preventDefault(); var container = jQuery(this).parents('.um-admin-field'); jQuery('.tipsy').remove(); @@ -74,7 +49,6 @@ jQuery(document).ready(function() { /** Ajax link **/ - jQuery('.um-admin-ajaxlink').click(function(e){ e.preventDefault(); return false; @@ -83,8 +57,7 @@ jQuery(document).ready(function() { /** On/Off Buttons **/ - - jQuery(document).on('click', '.um-admin-yesno span.btn', function(){ + jQuery(document.body).on('click', '.um-admin-yesno span.btn', function(){ if (!jQuery(this).parents('p').hasClass('disabled-on-off')){ if ( jQuery(this).parent().find('input[type=hidden]').val() == 0 ){ update_val = 1; @@ -104,20 +77,7 @@ jQuery(document).ready(function() { if ( jQuery('.um-admin-colorpicker').length ) { jQuery('.um-admin-colorpicker').wpColorPicker(); } - -/* /!** - Select Dropdowns - **!/ - - jQuery(".umaf-selectjs").select2({ - allowClear: false, - minimumResultsForSearch: 10 - }); - - jQuery('.um-admin-field select').select2({ - allowClear: true, - minimumResultsForSearch: 10 - });*/ + /** Tooltips @@ -130,58 +90,58 @@ jQuery(document).ready(function() { jQuery('.um-admin-tipsy-e').tipsy({gravity: 'e', opacity: 1, live: 'a.live' }); jQuery('.um-admin-tipsy-s').tipsy({gravity: 's', opacity: 1, live: 'a.live' }); } + /** Conditional fields **/ - - jQuery(document).on('change', '.um-adm-conditional', function(){ + jQuery( document.body ).on('change', '.um-adm-conditional', function(){ - var value; - if ( jQuery(this).attr("type") == 'checkbox' ) { - value = jQuery(this).is(':checked') ? 1 : 0; - } else { - value = jQuery(this).val(); - } + var value; + if ( jQuery(this).attr("type") == 'checkbox' ) { + value = jQuery(this).is(':checked') ? 1 : 0; + } else { + value = jQuery(this).val(); + } if ( jQuery(this).data('cond1') ) { - if ( value == jQuery(this).data('cond1') ) { - jQuery('.' + jQuery(this).data('cond1-show') ).show(); - jQuery('.' + jQuery(this).data('cond1-hide') ).hide(); + if ( value == jQuery(this).data('cond1') ) { + jQuery('.' + jQuery(this).data('cond1-show') ).show(); + jQuery('.' + jQuery(this).data('cond1-hide') ).hide(); - if ( jQuery(this).data('cond1-show') == '_roles' ) { - return false; - } + if ( jQuery(this).data('cond1-show') == '_roles' ) { + return false; + } - } else { - jQuery('.' + jQuery(this).data('cond1-show') ).hide(); - jQuery('.' + jQuery(this).data('cond1-hide') ).show(); - } + } else { + jQuery('.' + jQuery(this).data('cond1-show') ).hide(); + jQuery('.' + jQuery(this).data('cond1-hide') ).show(); + } } if ( jQuery(this).data('cond2') ) { - if ( value == jQuery(this).data('cond2') ) { - jQuery('.' + jQuery(this).data('cond2-show') ).show(); - jQuery('.' + jQuery(this).data('cond2-hide') ).hide(); + if ( value == jQuery(this).data('cond2') ) { + jQuery('.' + jQuery(this).data('cond2-show') ).show(); + jQuery('.' + jQuery(this).data('cond2-hide') ).hide(); - if ( jQuery(this).data('cond2-show') == '_roles' ) { - return false; - } + if ( jQuery(this).data('cond2-show') == '_roles' ) { + return false; + } - } else { - jQuery('.' + jQuery(this).data('cond2-show') ).hide(); - jQuery('.' + jQuery(this).data('cond2-hide') ).show(); - } + } else { + jQuery('.' + jQuery(this).data('cond2-show') ).hide(); + jQuery('.' + jQuery(this).data('cond2-hide') ).show(); + } } if ( jQuery(this).data('cond3') ) { - if ( value == jQuery(this).data('cond3') ) { - jQuery('.' + jQuery(this).data('cond3-show') ).show(); - jQuery('.' + jQuery(this).data('cond3-hide') ).hide(); - } else { - jQuery('.' + jQuery(this).data('cond3-show') ).hide(); - jQuery('.' + jQuery(this).data('cond3-hide') ).show(); - } + if ( value == jQuery(this).data('cond3') ) { + jQuery('.' + jQuery(this).data('cond3-show') ).show(); + jQuery('.' + jQuery(this).data('cond3-hide') ).hide(); + } else { + jQuery('.' + jQuery(this).data('cond3-show') ).hide(); + jQuery('.' + jQuery(this).data('cond3-hide') ).show(); + } } });jQuery('.um-adm-conditional').each(function(){jQuery(this).trigger('change');}); @@ -212,11 +172,6 @@ jQuery(document).ready(function() { } });jQuery('.um-conditional-radio-group input[type=radio]:checked').each(function(){jQuery(this).trigger('click');}); - - - - - @@ -226,19 +181,19 @@ jQuery(document).ready(function() { **/ jQuery('.um-nav-mode').each( function() { - if ( jQuery(this).find('select').val() == 2 ) { - jQuery(this).parents('.um-nav-edit').find('.um-nav-roles').show(); - } else { - jQuery(this).parents('.um-nav-edit').find('.um-nav-roles').hide(); - } + if ( jQuery(this).find('select').val() == 2 ) { + jQuery(this).parents('.um-nav-edit').find('.um-nav-roles').show(); + } else { + jQuery(this).parents('.um-nav-edit').find('.um-nav-roles').hide(); + } }); - jQuery(document).on('change', '.um-nav-mode select', function(){ - if ( jQuery(this).val() == 2 ) { - jQuery(this).parents('.um-nav-edit').find('.um-nav-roles').show(); - } else { - jQuery(this).parents('.um-nav-edit').find('.um-nav-roles').hide(); - } + jQuery( document.body ).on('change', '.um-nav-mode select', function(){ + if ( jQuery(this).val() == 2 ) { + jQuery(this).parents('.um-nav-edit').find('.um-nav-roles').show(); + } else { + jQuery(this).parents('.um-nav-edit').find('.um-nav-roles').hide(); + } }); }); \ No newline at end of file diff --git a/includes/admin/assets/js/um-admin-settings.js b/includes/admin/assets/js/um-admin-settings.js index 27533528..cd2ae1c6 100644 --- a/includes/admin/assets/js/um-admin-settings.js +++ b/includes/admin/assets/js/um-admin-settings.js @@ -1,35 +1,35 @@ jQuery( document ).ready( function() { - /** - * Licenses - */ - jQuery( 'body' ).on( 'click', '.um_license_deactivate', function() { - jQuery(this).siblings('.um-option-field').val(''); - jQuery(this).parents('form.um-settings-form').submit(); - }); + /** + * Licenses + */ + jQuery( document.body ).on( 'click', '.um_license_deactivate', function() { + jQuery(this).siblings('.um-option-field').val(''); + jQuery(this).parents('form.um-settings-form').submit(); + }); - /** - * Not licenses page - */ - if ( jQuery( '#licenses_settings' ).length == 0 ) { - var changed = false; + /** + * Not licenses page + */ + if ( jQuery( '#licenses_settings' ).length === 0 ) { + var changed = false; - jQuery( 'input, textarea, select' ).change( function() { - changed = true; - }); + jQuery( 'input, textarea, select' ).change( function() { + changed = true; + }); - jQuery( '#um-settings-wrap .um-nav-tab-wrapper a, #um-settings-wrap .subsubsub a' ).click( function() { - if ( changed ) { - window.onbeforeunload = function() { - return php_data.onbeforeunload_text; - }; - } else { - window.onbeforeunload = ''; - } - }); + jQuery( '#um-settings-wrap .um-nav-tab-wrapper a, #um-settings-wrap .subsubsub a' ).click( function() { + if ( changed ) { + window.onbeforeunload = function() { + return php_data.onbeforeunload_text; + }; + } else { + window.onbeforeunload = ''; + } + }); - jQuery( '.submit input' ).click( function() { - window.onbeforeunload = ''; - }); - } + jQuery( '.submit input' ).click( function() { + window.onbeforeunload = ''; + }); + } }); \ No newline at end of file diff --git a/includes/admin/core/class-admin-enqueue.php b/includes/admin/core/class-admin-enqueue.php index b592ab90..c6286140 100644 --- a/includes/admin/core/class-admin-enqueue.php +++ b/includes/admin/core/class-admin-enqueue.php @@ -1,9 +1,11 @@ js_url . 'um-admin-role-wrapper.js', '', ultimatemember_version, true ); - wp_enqueue_script( 'um_admin_role_wrapper' ); - + wp_register_script( 'um_admin_role_wrapper', $this->js_url . 'um-admin-role-wrapper.js', array( 'jquery' ), ultimatemember_version, true ); $localize_roles_data = get_option( 'um_roles' ); - - wp_localize_script( 'um_admin_settings', 'um_roles', $localize_roles_data ); + wp_localize_script( 'um_admin_role_wrapper', 'um_roles', $localize_roles_data ); + wp_enqueue_script( 'um_admin_role_wrapper' ); } @@ -71,11 +71,10 @@ if ( ! class_exists( 'um\admin\core\Admin_Enqueue' ) ) { */ function enter_title_here( $title ) { $screen = get_current_screen(); - if ( 'um_directory' == $screen->post_type ){ - $title = 'e.g. Member Directory'; - } - if ( 'um_form' == $screen->post_type ){ - $title = 'e.g. New Registration Form'; + if ( 'um_directory' == $screen->post_type ) { + $title = __( 'e.g. Member Directory', 'ultimate-member' ); + } elseif ( 'um_form' == $screen->post_type ) { + $title = __( 'e.g. New Registration Form', 'ultimate-member' ); } return $title; } @@ -100,10 +99,10 @@ if ( ! class_exists( 'um\admin\core\Admin_Enqueue' ) ) { * Load Form */ function load_form() { - wp_register_style( 'um_admin_form', $this->css_url . 'um-admin-form.css' ); + wp_register_style( 'um_admin_form', $this->css_url . 'um-admin-form.css', array(), ultimatemember_version ); wp_enqueue_style( 'um_admin_form' ); - wp_register_script( 'um_admin_form', $this->js_url . 'um-admin-form.js', '', '', true ); + wp_register_script( 'um_admin_form', $this->js_url . 'um-admin-form.js', array( 'jquery' ), ultimatemember_version, true ); wp_enqueue_script( 'um_admin_form' ); } @@ -112,10 +111,10 @@ if ( ! class_exists( 'um\admin\core\Admin_Enqueue' ) ) { * Load Forms */ function load_forms() { - wp_register_style( 'um_admin_forms', $this->css_url . 'um-admin-forms.css' ); + wp_register_style( 'um_admin_forms', $this->css_url . 'um-admin-forms.css', array( 'wp-color-picker' ), ultimatemember_version ); wp_enqueue_style( 'um_admin_forms' ); - wp_register_script( 'um_admin_forms', $this->js_url . 'um-admin-forms.js', '', '', true ); + wp_register_script( 'um_admin_forms', $this->js_url . 'um-admin-forms.js', array( 'jquery' ), ultimatemember_version, true ); wp_enqueue_script( 'um_admin_forms' ); $localize_data = array( @@ -133,11 +132,8 @@ if ( ! class_exists( 'um\admin\core\Admin_Enqueue' ) ) { * Load dashboard */ function load_dashboard() { - wp_register_style( 'um_admin_dashboard', $this->css_url . 'um-admin-dashboard.css' ); + wp_register_style( 'um_admin_dashboard', $this->css_url . 'um-admin-dashboard.css', array(), ultimatemember_version ); wp_enqueue_style( 'um_admin_dashboard' ); - - wp_register_script( 'um_admin_dashboard', $this->js_url . 'um-admin-dashboard.js', '', '', true ); - wp_enqueue_script( 'um_admin_dashboard' ); } @@ -145,10 +141,10 @@ if ( ! class_exists( 'um\admin\core\Admin_Enqueue' ) ) { * Load settings */ function load_settings() { - wp_register_style( 'um_admin_settings', $this->css_url . 'um-admin-settings.css' ); + wp_register_style( 'um_admin_settings', $this->css_url . 'um-admin-settings.css', array(), ultimatemember_version ); wp_enqueue_style( 'um_admin_settings' ); - wp_register_script( 'um_admin_settings', $this->js_url . 'um-admin-settings.js', '', '', true ); + wp_register_script( 'um_admin_settings', $this->js_url . 'um-admin-settings.js', array( 'jquery' ), ultimatemember_version, true ); wp_enqueue_script( 'um_admin_settings' ); $localize_data = array( @@ -167,10 +163,10 @@ if ( ! class_exists( 'um\admin\core\Admin_Enqueue' ) ) { * Load modal */ function load_modal() { - wp_register_style( 'um_admin_modal', $this->css_url . 'um-admin-modal.css' ); + wp_register_style( 'um_admin_modal', $this->css_url . 'um-admin-modal.css', array( 'wp-color-picker' ), ultimatemember_version ); wp_enqueue_style( 'um_admin_modal' ); - wp_register_script( 'um_admin_modal', $this->js_url . 'um-admin-modal.js', array('jquery', 'wp-util'), '', true ); + wp_register_script( 'um_admin_modal', $this->js_url . 'um-admin-modal.js', array( 'jquery', 'wp-util', 'wp-color-picker' ), ultimatemember_version, true ); wp_enqueue_script( 'um_admin_modal' ); } @@ -179,7 +175,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Enqueue' ) ) { * Field Processing */ function load_field() { - wp_register_script( 'um_admin_field', $this->js_url . 'um-admin-field.js', array('jquery', 'wp-util'), '', true ); + wp_register_script( 'um_admin_field', $this->js_url . 'um-admin-field.js', array('jquery', 'wp-util'), ultimatemember_version, true ); wp_enqueue_script( 'um_admin_field' ); } @@ -188,7 +184,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Enqueue' ) ) { * Load Builder */ function load_builder() { - wp_register_script( 'um_admin_builder', $this->js_url . 'um-admin-builder.js', array('jquery', 'wp-util'), '', true ); + wp_register_script( 'um_admin_builder', $this->js_url . 'um-admin-builder.js', array('jquery', 'wp-util'), ultimatemember_version, true ); wp_enqueue_script( 'um_admin_builder' ); //hide footer text on add/edit UM Forms @@ -207,11 +203,10 @@ if ( ! class_exists( 'um\admin\core\Admin_Enqueue' ) ) { ); wp_localize_script( 'um_admin_builder', 'um_admin_builder_data', $localize_data ); - wp_register_script( 'um_admin_dragdrop', $this->js_url . 'um-admin-dragdrop.js', array('jquery', 'wp-util'), '', true ); + wp_register_script( 'um_admin_dragdrop', $this->js_url . 'um-admin-dragdrop.js', array('jquery', 'wp-util'), ultimatemember_version, true ); wp_enqueue_script( 'um_admin_dragdrop' ); - - wp_register_style( 'um_admin_builder', $this->css_url . 'um-admin-builder.css' ); + wp_register_style( 'um_admin_builder', $this->css_url . 'um-admin-builder.css', array(), ultimatemember_version ); wp_enqueue_style( 'um_admin_builder' ); } @@ -220,9 +215,6 @@ if ( ! class_exists( 'um\admin\core\Admin_Enqueue' ) ) { * Load core WP styles/scripts */ function load_core_wp() { - wp_enqueue_style( 'wp-color-picker' ); - wp_enqueue_script( 'wp-color-picker' ); - wp_enqueue_script( 'jquery-ui-draggable' ); wp_enqueue_script( 'jquery-ui-sortable' ); @@ -234,13 +226,13 @@ if ( ! class_exists( 'um\admin\core\Admin_Enqueue' ) ) { * Load Admin Styles */ function load_css() { - wp_register_style( 'um_admin_menu', $this->css_url . 'um-admin-menu.css' ); + wp_register_style( 'um_admin_menu', $this->css_url . 'um-admin-menu.css', array(), ultimatemember_version ); wp_enqueue_style( 'um_admin_menu' ); - wp_register_style( 'um_admin_columns', $this->css_url . 'um-admin-columns.css' ); + wp_register_style( 'um_admin_columns', $this->css_url . 'um-admin-columns.css', array(), ultimatemember_version ); wp_enqueue_style( 'um_admin_columns' ); - wp_register_style( 'um_admin_misc', $this->css_url . 'um-admin-misc.css' ); + wp_register_style( 'um_admin_misc', $this->css_url . 'um-admin-misc.css', array(), ultimatemember_version ); wp_enqueue_style( 'um_admin_misc' ); } @@ -249,7 +241,8 @@ if ( ! class_exists( 'um\admin\core\Admin_Enqueue' ) ) { * Load functions js */ function load_functions() { - wp_register_script( 'um_functions', um_url . 'assets/js/um-functions' . '.js' ); + wp_register_script( 'um_scrollbar', um_url . 'assets/js/um-scrollbar.js', array( 'jquery' ), ultimatemember_version, true ); + wp_register_script( 'um_functions', um_url . 'assets/js/um-functions.js', array( 'jquery', 'jquery-masonry', 'wp-util', 'um_scrollbar' ), ultimatemember_version, true ); wp_enqueue_script( 'um_functions' ); } @@ -258,10 +251,10 @@ if ( ! class_exists( 'um\admin\core\Admin_Enqueue' ) ) { * Load Fonticons */ function load_fonticons() { - wp_register_style( 'um_fonticons_ii', um_url . 'assets/css/um-fonticons-ii.css' ); + wp_register_style( 'um_fonticons_ii', um_url . 'assets/css/um-fonticons-ii.css', array(), ultimatemember_version ); wp_enqueue_style( 'um_fonticons_ii' ); - wp_register_style( 'um_fonticons_fa', um_url . 'assets/css/um-fonticons-fa.css' ); + wp_register_style( 'um_fonticons_fa', um_url . 'assets/css/um-fonticons-fa.css', array(), ultimatemember_version ); wp_enqueue_style( 'um_fonticons_fa' ); } @@ -273,7 +266,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Enqueue' ) ) { wp_register_script( 'um_admin_global', $this->js_url . 'um-admin-global.js', array('jquery'), ultimatemember_version, true ); wp_enqueue_script( 'um_admin_global' ); - wp_register_style( 'um_admin_global', $this->css_url . 'um-admin-global.css' ); + wp_register_style( 'um_admin_global', $this->css_url . 'um-admin-global.css', array(), ultimatemember_version ); wp_enqueue_style( 'um_admin_global' ); } @@ -282,7 +275,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Enqueue' ) ) { * Load jQuery custom code */ function load_custom_scripts() { - wp_register_script( 'um_admin_scripts', $this->js_url . 'um-admin-scripts.js', array('jquery','wp-util', 'wp-color-picker'), '', true ); + wp_register_script( 'um_admin_scripts', $this->js_url . 'um-admin-scripts.js', array('jquery','wp-util', 'wp-color-picker'), ultimatemember_version, true ); wp_enqueue_script( 'um_admin_scripts' ); } @@ -291,7 +284,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Enqueue' ) ) { * Load jQuery custom code */ function load_nav_manus_scripts() { - wp_register_script( 'um_admin_nav_manus', $this->js_url . 'um-admin-nav-menu.js', array('jquery','wp-util'), '', true ); + wp_register_script( 'um_admin_nav_manus', $this->js_url . 'um-admin-nav-menu.js', array('jquery','wp-util'), ultimatemember_version, true ); wp_enqueue_script( 'um_admin_nav_manus' ); } @@ -300,7 +293,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Enqueue' ) ) { * Load AJAX */ function load_ajax_js() { - wp_register_script( 'um_admin_ajax', $this->js_url . 'um-admin-ajax.js', array('jquery','wp-util'), '', true ); + wp_register_script( 'um_admin_ajax', $this->js_url . 'um-admin-ajax.js', array('jquery','wp-util'), ultimatemember_version, true ); wp_enqueue_script( 'um_admin_ajax' ); } @@ -380,7 +373,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Enqueue' ) ) { wp_enqueue_style( 'um_default_css' ); if ( is_rtl() ) { - wp_register_style( 'um_admin_rtl', $this->css_url . 'um-admin-rtl.css' ); + wp_register_style( 'um_admin_rtl', $this->css_url . 'um-admin-rtl.css', array(), ultimatemember_version ); wp_enqueue_style( 'um_admin_rtl' ); } diff --git a/languages/ultimate-member-en_US.po b/languages/ultimate-member-en_US.po index 332e9f49..b2a34ea6 100644 --- a/languages/ultimate-member-en_US.po +++ b/languages/ultimate-member-en_US.po @@ -1,8 +1,8 @@ msgid "" msgstr "" "Project-Id-Version: Ultimate Member\n" -"POT-Creation-Date: 2018-12-07 18:03+0200\n" -"PO-Revision-Date: 2018-12-07 18:04+0200\n" +"POT-Creation-Date: 2018-12-09 15:45+0200\n" +"PO-Revision-Date: 2018-12-09 15:45+0200\n" "Last-Translator: \n" "Language-Team: \n" "Language: en_US\n" @@ -249,8 +249,16 @@ msgstr "" msgid "Yes" msgstr "" -#: includes/admin/core/class-admin-enqueue.php:123 -#: includes/admin/core/class-admin-enqueue.php:157 +#: includes/admin/core/class-admin-enqueue.php:75 +msgid "e.g. Member Directory" +msgstr "" + +#: includes/admin/core/class-admin-enqueue.php:77 +msgid "e.g. New Registration Form" +msgstr "" + +#: includes/admin/core/class-admin-enqueue.php:122 +#: includes/admin/core/class-admin-enqueue.php:153 #: includes/admin/core/class-admin-forms.php:823 #: includes/admin/core/class-admin-forms.php:837 #: includes/admin/core/class-admin-forms.php:942 @@ -260,13 +268,13 @@ msgstr "" msgid "Remove" msgstr "" -#: includes/admin/core/class-admin-enqueue.php:124 -#: includes/admin/core/class-admin-enqueue.php:158 +#: includes/admin/core/class-admin-enqueue.php:123 +#: includes/admin/core/class-admin-enqueue.php:154 #: includes/admin/core/class-admin-forms.php:1019 msgid "Select" msgstr "" -#: includes/admin/core/class-admin-enqueue.php:155 +#: includes/admin/core/class-admin-enqueue.php:151 msgid "Are sure, maybe some settings not saved" msgstr "" diff --git a/readme.txt b/readme.txt index 42288919..70e7c04e 100644 --- a/readme.txt +++ b/readme.txt @@ -6,7 +6,7 @@ Donate link: Tags: community, member, membership, user-profile, user-registration Requires at least: 4.7 Tested up to: 5.0 -Stable tag: 2.0.34 +Stable tag: 2.0.35 License: GNU Version 2 or Any Later Version License URI: http://www.gnu.org/licenses/gpl-3.0.txt @@ -137,6 +137,11 @@ The plugin works with popular caching plugins by automatically excluding Ultimat = Important: UM2.0+ is a significant update to the code base from 1.3.88. Please make sure you take a full-site backup with restore point before updating the plugin = += 2.0.35: December 9, 2018 = + +* Bugfixes: + - Fixed JS/CSS enqueue at wp-admin + = 2.0.34: December 7, 2018 = * Enhancements: diff --git a/ultimate-member.php b/ultimate-member.php index 898b99bb..d723c87f 100644 --- a/ultimate-member.php +++ b/ultimate-member.php @@ -3,7 +3,7 @@ Plugin Name: Ultimate Member Plugin URI: http://ultimatemember.com/ Description: The easiest way to create powerful online communities and beautiful user profiles with WordPress -Version: 2.0.34 +Version: 2.0.35 Author: Ultimate Member Author URI: http://ultimatemember.com/ Text Domain: ultimate-member