diff --git src/bp-xprofile/admin/js/admin.js src/bp-xprofile/admin/js/admin.js
index 80b43c9..ae9ab27 100644
|
|
|
function add_option(forWhat) {
|
| 61 | 61 | document.getElementById(forWhat + '_option_number').value = theId; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | | function show_options(forWhat) { |
| 65 | | document.getElementById( 'radio' ).style.display = 'none'; |
| 66 | | document.getElementById( 'selectbox' ).style.display = 'none'; |
| 67 | | document.getElementById( 'multiselectbox' ).style.display = 'none'; |
| 68 | | document.getElementById( 'checkbox' ).style.display = 'none'; |
| 69 | | |
| 70 | | if ( forWhat === 'radio' ) { |
| 71 | | document.getElementById( 'radio' ).style.display = ''; |
| | 64 | /** |
| | 65 | * Hide all "options" sections, and show the options section for the forWhat type. |
| | 66 | */ |
| | 67 | function show_options( forWhat ) { |
| | 68 | for ( var i = 0; i < XProfileAdmin.supports_options_field_types.length; i++ ) { |
| | 69 | document.getElementById( XProfileAdmin.supports_options_field_types[i] ).style.display = 'none'; |
| 72 | 70 | } |
| 73 | 71 | |
| 74 | | if ( forWhat === 'selectbox' ) { |
| 75 | | document.getElementById( 'selectbox' ).style.display = ''; |
| 76 | | } |
| 77 | | |
| 78 | | if ( forWhat === 'multiselectbox' ) { |
| 79 | | document.getElementById( 'multiselectbox' ).style.display = ''; |
| 80 | | } |
| 81 | | |
| 82 | | if ( forWhat === 'checkbox' ) { |
| 83 | | document.getElementById( 'checkbox' ).style.display = ''; |
| | 72 | if ( XProfileAdmin.supports_options_field_types.indexOf( forWhat ) >= 0 ) { |
| | 73 | document.getElementById( forWhat ).style.display = ''; |
| 84 | 74 | } |
| 85 | 75 | } |
| 86 | 76 | |
| … |
… |
jQuery( document ).ready( function() {
|
| 124 | 114 | |
| 125 | 115 | // Set focus in Field Title, if we're on the right page |
| 126 | 116 | jQuery( '#bp-xprofile-add-field #title' ).focus(); |
| 127 | | |
| | 117 | |
| 128 | 118 | // Set up deleting options ajax |
| 129 | 119 | jQuery( 'a.ajax-option-delete' ).on( 'click', function() { |
| 130 | 120 | var theId = this.id.split( '-' ); |
diff --git src/bp-xprofile/bp-xprofile-cssjs.php src/bp-xprofile/bp-xprofile-cssjs.php
index 8fb4f67..98ccaf9 100644
|
|
|
function xprofile_add_admin_js() {
|
| 39 | 39 | |
| 40 | 40 | $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
| 41 | 41 | wp_enqueue_script( 'xprofile-admin-js', buddypress()->plugin_url . "bp-xprofile/admin/js/admin{$min}.js", array( 'jquery', 'jquery-ui-sortable' ), bp_get_version() ); |
| | 42 | |
| | 43 | // Localize strings. |
| | 44 | // supports_options_field_types is a dynamic list of field |
| | 45 | // types that support options, for use in showing/hiding the |
| | 46 | // "please enter options for this field" section |
| | 47 | $strings = array( |
| | 48 | 'supports_options_field_types' => array(), |
| | 49 | ); |
| | 50 | |
| | 51 | foreach ( bp_xprofile_get_field_types() as $field_type => $field_type_class ) { |
| | 52 | $field = new $field_type_class(); |
| | 53 | if ( $field->supports_options ) { |
| | 54 | $strings['supports_options_field_types'][] = $field_type; |
| | 55 | } |
| | 56 | } |
| | 57 | |
| | 58 | wp_localize_script( 'xprofile-admin-js', 'XProfileAdmin', $strings ); |
| 42 | 59 | } |
| 43 | 60 | } |
| 44 | 61 | add_action( 'admin_enqueue_scripts', 'xprofile_add_admin_js', 1 ); |