Skip to content
Merged
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
7f590c2
Show slider type selection modal
AbdiTolesa May 2, 2025
fcdcf77
Load gap settings for dual range sliders
AbdiTolesa May 7, 2025
07c9dda
Move range gap field settings to Pro
AbdiTolesa May 7, 2025
437dbb1
Add new action hook after number format
AbdiTolesa May 7, 2025
bb2bac5
Intercept field dragging for Slider field modal
AbdiTolesa May 12, 2025
db582e1
Merge branch 'master' into project/range_slider_field_lite_part
AbdiTolesa May 13, 2025
74dac24
Reduce repeated code
AbdiTolesa May 19, 2025
5f62666
Update function params comment
AbdiTolesa May 19, 2025
ce7ce93
Change hook's name
AbdiTolesa May 20, 2025
8c6b907
Merge branch 'master' into project/range_slider_field_lite_part
AbdiTolesa May 20, 2025
700e0b5
Bring back deleted code
AbdiTolesa May 20, 2025
9668c63
Add space below new action hook for code clarity
AbdiTolesa Jun 2, 2025
40fc022
Remove new hook not needed
AbdiTolesa Jun 2, 2025
f1ec9ef
Add comment to function
AbdiTolesa Jun 2, 2025
9504ca0
Use CustomEvent instead of a MouseEvent
AbdiTolesa Jun 13, 2025
eb10814
Merge branch 'master' into project/range_slider_field_lite_part
AbdiTolesa Jun 13, 2025
6b992c9
Merge branch 'master' into project/range_slider_field_lite_part
AbdiTolesa Jun 17, 2025
8f99633
Reduce repeated code
AbdiTolesa Jun 18, 2025
20b4966
Add since tag
AbdiTolesa Jul 16, 2025
10c7f92
Revert unintentionally set section id to 0
AbdiTolesa Jul 21, 2025
7458d62
Pass more params to frm_insert_field_args
AbdiTolesa Jul 23, 2025
1464e7b
Fix function params order in descriptions
AbdiTolesa Jul 23, 2025
5e49802
Merge branch 'master' into project/range_slider_field_lite_part
Crabcyborg Aug 7, 2025
ad0e6c0
Improve equality check
AbdiTolesa Aug 7, 2025
5ecadfb
Merge branch 'project/range_slider_field_lite_part' of https://github…
AbdiTolesa Aug 7, 2025
0cbac0f
Merge branch 'master' into project/range_slider_field_lite_part
Crabcyborg Aug 7, 2025
9dd33a6
Merge branch 'master' into project/range_slider_field_lite_part
AbdiTolesa Aug 7, 2025
4070d64
Cleanup code
AbdiTolesa Aug 7, 2025
356d429
Remove unused function params
AbdiTolesa Aug 7, 2025
1009689
Cleanup code
AbdiTolesa Aug 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 49 additions & 20 deletions js/formidable_admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -1571,12 +1571,52 @@ function frmAdminBuildJS() {
document.getElementById( 'frm_in_section_' + fieldId ).value = sectionId;
}

/**
* Get the arguments for inserting a new field.
*
* @since x.x
*
* @param {string} fieldType
* @param {string} sectionId
* @param {string} formId
* @param {Number} hasBreak
*
* @returns {Object}
*/
function getInsertNewFieldArgs( fieldType, sectionId, formId, hasBreak ) {
const args = {
action: 'frm_insert_field',
form_id: formId,
field_type: fieldType,
section_id: sectionId,
nonce: frmGlobal.nonce,
has_break: hasBreak,
last_row_field_ids: getFieldIdsInSubmitRow()
};
return wp.hooks.applyFilters( 'frm_insert_field_args', args, fieldType, formId, sectionId, hasBreak );
}

/**
* Returns true if it's a range field type and slider type is not selected.
*
* @since x.x
*
* @param {string} fieldType
* @returns {boolean}
*/
function shouldStopInsertingField( fieldType ) {
return wp.hooks.applyFilters( 'frm_should_stop_inserting_field', false, fieldType );
}

/**
* Add a new field by dragging and dropping it from the Fields sidebar
*
* @param {string} fieldType
*/
function insertNewFieldByDragging( fieldType ) {
function insertNewFieldByDragging( fieldType ) {
if ( shouldStopInsertingField( fieldType ) ) {
return;
}
const placeholder = document.getElementById( 'frm_drag_placeholder' );
const loadingID = fieldType.replace( '|', '-' ) + '_' + getAutoId();
const loading = tag(
Expand All @@ -1603,16 +1643,9 @@ function frmAdminBuildJS() {
}

jQuery.ajax({
type: 'POST', url: ajaxurl,
data: {
action: 'frm_insert_field',
form_id: formId,
field_type: fieldType,
section_id: sectionId,
Comment thread
AbdiTolesa marked this conversation as resolved.
nonce: frmGlobal.nonce,
has_break: hasBreak,
last_row_field_ids: getFieldIdsInSubmitRow()
},
type: 'POST',
url: ajaxurl,
data: getInsertNewFieldArgs( fieldType, sectionId, formId, hasBreak ),
success: function( msg ) {
let replaceWith;
document.getElementById( 'frm_form_editor_container' ).classList.add( 'frm-has-fields' );
Expand Down Expand Up @@ -2016,6 +2049,10 @@ function frmAdminBuildJS() {
const $button = $thisObj.closest( '.frmbutton' );
const fieldType = $button.attr( 'id' );

if ( shouldStopInsertingField( fieldType ) ) {
return;
}

let hasBreak = 0;
if ( 'summary' === fieldType ) {
hasBreak = $newFields.children( 'li[data-type="break"]' ).length > 0 ? 1 : 0;
Expand All @@ -2025,15 +2062,7 @@ function frmAdminBuildJS() {
jQuery.ajax({
type: 'POST',
url: ajaxurl,
data: {
action: 'frm_insert_field',
form_id: formId,
field_type: fieldType,
section_id: 0,
nonce: frmGlobal.nonce,
has_break: hasBreak,
last_row_field_ids: getFieldIdsInSubmitRow()
},
data: getInsertNewFieldArgs( fieldType, 0, formId, hasBreak ),
success: function( msg ) {
document.getElementById( 'frm_form_editor_container' ).classList.add( 'frm-has-fields' );
const replaceWith = wrapFieldLi( msg );
Expand Down