Project

General

Profile

Feature #1386 » custom-order-profile-options-1.diff

Dominic Giglio, 2012-07-16 01:11 PM

View differences:

bp-xprofile/admin/js/admin.dev.js (working copy)
150 150
	// Change cursor to move if JS is enabled
151 151
	.css( 'cursor', 'move' );
152 152

  
153
	// Allow reordering of field options
154
	jQuery( '.options-box' ).sortable( {
155
		cursor: 'move',
156
		opacity: 0.3,
157
		items: 'p.sortable',
158
		tolerance: 'pointer',
159

  
160
		update: function() {
161
			jQuery.post( ajaxurl, {
162
				action: 'xprofile_reorder_options',
163
				'cookie': encodeURIComponent( document.cookie ),
164
				'_wpnonce_reorder_options': jQuery( 'input#_wpnonce_reorder_options' ).val(),
165
				'option_order': jQuery( this ).sortable( 'serialize' )
166
			},
167
			function( response ) {} );
168

  
169
			// we need to reset the label counts
170
			jQuery('.sortable', this).each(function(i) {
171
				$this = jQuery(this);
172
				$this.find('span').text('Option ' + ( i + 1 ) + ':');
173
			});
174
		}
175
	}).disableSelection().css( 'cursor', 'move' );
176

  
153 177
	// tabs init with a custom tab template and an "add" callback filling in the content
154 178
	var $tab_items;
155 179
	var $tabs = jQuery( '#tabs' ).tabs();
bp-xprofile/bp-xprofile-cssjs.php (working copy)
43 43
		if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {
44 44
			wp_enqueue_script( 'xprofile-admin-js', BP_PLUGIN_URL . 'bp-xprofile/admin/js/admin.dev.js', array( 'jquery', 'jquery-ui-sortable' ), bp_get_version() );
45 45
		} else {
46
			wp_enqueue_script( 'xprofile-admin-js', BP_PLUGIN_URL . 'bp-xprofile/admin/js/admin.js',     array( 'jquery', 'jquery-ui-sortable' ), bp_get_version() );
46
			wp_enqueue_script( 'xprofile-admin-js', BP_PLUGIN_URL . 'bp-xprofile/admin/js/admin.dev.js',     array( 'jquery', 'jquery-ui-sortable' ), bp_get_version() );
47 47
		}
48 48
	}
49 49
}
bp-xprofile/bp-xprofile-classes.php (working copy)
739 739

  
740 740
			<div id="<?php echo $type; ?>" class="options-box" style="<?php echo $class; ?> margin-left: 15px;">
741 741
				<h4><?php _e( 'Please enter options for this Field:', 'buddypress' ); ?></h4>
742
				<p><label for="sort_order_<?php echo $type; ?>"><?php _e( 'Order By:', 'buddypress' ); ?></label>
742
				<p><label for="sort_order_<?php echo $type; ?>"><?php _e( 'Sort Order:', 'buddypress' ); ?></label>
743 743
					<select name="sort_order_<?php echo $type; ?>" id="sort_order_<?php echo $type; ?>" >
744
						<option value="default" <?php if ( 'default' == $this->order_by ) {?> selected="selected"<?php } ?> ><?php _e( 'Order Entered', 'buddypress' ); ?></option>
745
						<option value="asc" <?php if ( 'asc' == $this->order_by ) {?> selected="selected"<?php } ?>><?php _e( 'Name - Ascending', 'buddypress' ); ?></option>
746
						<option value="desc" <?php if ( 'desc' == $this->order_by ) {?> selected="selected"<?php } ?>><?php _e( 'Name - Descending', 'buddypress' ); ?></option>
744
						<option value="default" <?php if ( 'default' == $this->order_by ) {?> selected="selected"<?php } ?> ><?php _e( 'Custom', 'buddypress' ); ?></option>
745
						<option value="asc" <?php if ( 'asc' == $this->order_by ) {?> selected="selected"<?php } ?>><?php _e( 'Ascending', 'buddypress' ); ?></option>
746
						<option value="desc" <?php if ( 'desc' == $this->order_by ) {?> selected="selected"<?php } ?>><?php _e( 'Descending', 'buddypress' ); ?></option>
747 747
					</select>
748 748

  
749 749
				<?php if ( !$options = $this->get_children( true ) ) {
......
767 767
						if ( 'multiselectbox' == $type || 'checkbox' == $type )
768 768
							$default_name = '[' . $j . ']'; ?>
769 769

  
770
						<p><?php _e( 'Option', 'buddypress' ); ?> <?php echo $j; ?>:
771
						   <input type="text" name="<?php echo $type; ?>_option[<?php echo $j; ?>]" id="<?php echo $type; ?>_option<?php echo $j; ?>" value="<?php echo stripslashes( esc_attr( $options[$i]->name ) ); ?>" />
772
						   <input type="<?php echo $default_input; ?>" name="isDefault_<?php echo $type; ?>_option<?php echo $default_name; ?>" <?php if ( (int) $options[$i]->is_default_option ) {?> checked="checked"<?php } ?> " value="<?php echo $j; ?>" /> <?php _e( 'Default Value', 'buddypress' ); ?>
770
						<p class="sortable">
771
							<span><?php _e( 'Option', 'buddypress' ); ?> <?php echo $j; ?>:</span>
772
						  <input type="text" name="<?php echo $type; ?>_option[<?php echo $j; ?>]" id="<?php echo $type; ?>_option<?php echo $j; ?>" value="<?php echo stripslashes( esc_attr( $options[$i]->name ) ); ?>" />
773
						  <input type="<?php echo $default_input; ?>" name="isDefault_<?php echo $type; ?>_option<?php echo $default_name; ?>" <?php if ( (int) $options[$i]->is_default_option ) {?> checked="checked"<?php } ?> " value="<?php echo $j; ?>" /> <?php _e( 'Default Value', 'buddypress' ); ?>
773 774

  
774 775
							<?php if ( $j != 1 && $options[$i]->id != -1 ) : ?>
775 776

  
(1-1/3)