芝麻web文件管理V1.00
编辑当前文件:/var/www/cognitio.in/wp-content/plugins/wp-event-manager/assets/js/field-editor.js
var FieldEditor = function() { return { ///
///Initializes the form editor. ///
///
///
1.0.0
init: function() { jQuery('.wp-event-manager-event-form-field-editor').on( 'init',FieldEditor.actions.initSortable ); jQuery( '.wp-event-manager-event-form-field-editor').trigger( 'init' ); jQuery('.add-field').on( 'click', FieldEditor.actions.addNewFields); //add new field jQuery('body').on('click', '.child-add-field', FieldEditor.actions.addNewChildFields); jQuery( '.wp-event-manager-event-form-field-editor').on( 'change', '.field-type select', FieldEditor.actions.changeFieldTypeOptions); jQuery('.delete-field').on( 'click', FieldEditor.actions.deleteField); //delete field jQuery('.reset').on( 'click', FieldEditor.actions.resetFields); //reset field jQuery('.wp-event-manager-organizer-form-field-editor').on( 'init',FieldEditor.actions.initSortable ); jQuery( '.wp-event-manager-organizer-form-field-editor').trigger( 'init' ); }, actions: { ///
///Initializes sortable. ///
///
///
1.0
initSortable :function() { jQuery(this).sortable({ items:'tr:has(td)', cursor:'move', axis:'y', handle: 'td.sort-column', scrollSensitivity:40, helper:function(e,ui){ ui.children().each(function(){ jQuery(this).width(jQuery(this).width()); }); return ui; }, start:function(event,ui){ ui.item.css( 'background-color','#FEFEE6' ); }, stop:function(event,ui){ ui.item.removeAttr('style'); } }); jQuery(this).find( '.field-type select' ).each(FieldEditor.actions.changeFieldTypeOptions); jQuery(this).find( '.field-rules select:visible' ).chosen(); }, ///
///remove current field ///
///
///
1.0
deleteField :function() { if ( window.confirm( wp_event_manager_form_editor.cofirm_delete_i18n ) ) { var field_type = jQuery(this).closest('tr').data( 'field-type' ); if(field_type === 'group') { jQuery(this).closest('tr').next('tr.group').remove(); jQuery(this).closest('tr').remove(); } else { jQuery(this).closest('tr').remove(); } } return false; }, ///
///reset all fields ///
///
///
1.0
resetFields :function() { if ( window.confirm( wp_event_manager_form_editor.cofirm_reset_i18n ) ) { return true; } return false; }, ///
///reset all fields ///
///
///
1.0
addNewFields :function() { var $tbody = jQuery(this).closest('table').find('tbody#form-fields'); var row = $tbody.data( 'field' ); row = row.replace( /\[-1\]/g, "[" + $tbody.find('tr').size() + "]"); $tbody.append( row ); jQuery('.wp-event-manager-event-form-field-editor').trigger( 'init' ); jQuery('.delete-field').on( 'click', FieldEditor.actions.deleteField); //delete field return false; }, ///
///reset all fields ///
///
///
1.0
addNewChildFields :function() { var $tbody = jQuery(this).closest('table.child_table').find('tbody.child-form-fields'); var row = $tbody.data( 'field' ); row = row.replace( /\[-1\]/g, "[" + $tbody.find('tr').size() + "]"); var parnet_name = jQuery(this).closest('tr.group').prev().find('select.field_type').attr('name'); parnet_name = parnet_name.replace( /\[type\]/g, ""); row = row.replace( /\[\]/g, parnet_name); $tbody.append( row ); jQuery('.wp-event-manager-event-form-field-editor').trigger( 'init' ); jQuery('.delete-field').on( 'click', FieldEditor.actions.deleteField); //delete field return false; }, ///
///on change field type ///
///
///
1.0
changeFieldTypeOptions: function(){ jQuery(this).closest('tr').find('.field-options .placeholder').hide(); jQuery(this).closest('tr').find('.field-options .options').hide(); jQuery(this).closest('tr').find('.field-options .na').hide(); jQuery(this).closest('tr').find('.field-options .file-options').hide(); jQuery(this).closest('tr').find('.field-options .taxonomy-select').hide(); var field_type = jQuery(this).closest('tr').data( 'field-type' ); if ( 'select' === jQuery(this).val() || 'multiselect' === jQuery(this).val() || 'button-options' === jQuery(this).val() || 'radio' === jQuery(this).val() ) { jQuery(this).closest('tr').find('.field-options .options').show(); } else if ( 'file' === jQuery(this).val() ) { jQuery(this).closest('tr').find('.field-options .file-options').show(); } else if ( 'term-select' === jQuery(this).val() || 'term-checklist' === jQuery(this).val() || 'term-multiselect' === jQuery(this).val() ) { jQuery(this).closest('tr').find('.field-options .taxonomy-select').show(); } else if ( 'group' === jQuery(this).val() ) { if(jQuery(this).closest('tr').next().hasClass('group')) { } else { var obj = jQuery(this); jQuery.ajax({ url: wp_event_manager_form_editor.ajax_url, type: 'POST', dataType: 'HTML', data: { action: 'get_group_field_html', security: wp_event_manager_form_editor.wp_event_manager_form_editor_security, }, success: function (responce) { obj.closest('tr').attr('data-field-type', 'group'); obj.closest('tr').after(responce); } }); } } else { jQuery(this).closest('tr').find('.field-options .placeholder').show(); } if(field_type === 'group' && jQuery(this).val() !== 'group' ) { if(jQuery(this).closest('tr').next().hasClass('group')) { jQuery(this).closest('tr').next().remove(); } } jQuery(this).closest('tr').find('.field-rules .rules').hide(); jQuery(this).closest('tr').find('.field-rules .na').hide(); jQuery(this).closest('tr').find( '.field-rules .rules' ).show(); jQuery(this).closest('tr').find( '.field-rules select:visible' ).chosen(); } } } }; FieldEditor = FieldEditor(), jQuery(document).ready(function(t) { FieldEditor.init() });