Feature #1386 » custom-order-profile-options-3.diff
bp-xprofile/bp-xprofile-classes.php (working copy) | ||
---|---|---|
737 | 737 | |
738 | 738 |
<div id="<?php echo $type; ?>" class="options-box" style="<?php echo $class; ?> margin-left: 15px;"> |
739 | 739 |
<h4><?php _e( 'Please enter options for this Field:', 'buddypress' ); ?></h4> |
740 |
<p><label for="sort_order_<?php echo $type; ?>"><?php _e( 'Order By:', 'buddypress' ); ?></label>
|
|
740 |
<p><label for="sort_order_<?php echo $type; ?>"><?php _e( 'Sort Order:', 'buddypress' ); ?></label>
|
|
741 | 741 |
<select name="sort_order_<?php echo $type; ?>" id="sort_order_<?php echo $type; ?>" > |
742 |
<option value="default" <?php if ( 'default' == $this->order_by ) {?> selected="selected"<?php } ?> ><?php _e( 'Order Entered', 'buddypress' ); ?></option>
|
|
743 |
<option value="asc" <?php if ( 'asc' == $this->order_by ) {?> selected="selected"<?php } ?>><?php _e( 'Name - Ascending', 'buddypress' ); ?></option>
|
|
744 |
<option value="desc" <?php if ( 'desc' == $this->order_by ) {?> selected="selected"<?php } ?>><?php _e( 'Name - Descending', 'buddypress' ); ?></option>
|
|
742 |
<option value="custom" <?php if ( 'custom' == $this->order_by ) {?> selected="selected"<?php } ?> ><?php _e( 'Custom', 'buddypress' ); ?></option>
|
|
743 |
<option value="asc" <?php if ( 'asc' == $this->order_by ) {?> selected="selected"<?php } ?>><?php _e( 'Ascending', 'buddypress' ); ?></option> |
|
744 |
<option value="desc" <?php if ( 'desc' == $this->order_by ) {?> selected="selected"<?php } ?>><?php _e( 'Descending', 'buddypress' ); ?></option> |
|
745 | 745 |
</select> |
746 | 746 | |
747 | 747 |
<?php if ( !$options = $this->get_children( true ) ) { |
... | ... | |
765 | 765 |
if ( 'multiselectbox' == $type || 'checkbox' == $type ) |
766 | 766 |
$default_name = '[' . $j . ']'; ?> |
767 | 767 | |
768 |
<p><?php _e( 'Option', 'buddypress' ); ?> <?php echo $j; ?>: |
|
769 |
<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 ) ); ?>" /> |
|
770 |
<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' ); ?> |
|
771 | ||
772 |
<?php if ( $j != 1 && $options[$i]->id != -1 ) : ?> |
|
773 | ||
774 |
<a href="admin.php?page=bp-profile-setup&mode=delete_option&option_id=<?php echo $options[$i]->id ?>" class="ajax-option-delete" id="delete-<?php echo $options[$i]->id; ?>">[x]</a> |
|
775 | ||
776 |
<?php endif; ?> |
|
777 | ||
768 |
<p class="sortable"> |
|
769 |
<span> Ξ </span> |
|
770 |
<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 ) ); ?>" /> |
|
771 |
<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; ?>" /> |
|
772 |
<span><?php _e( 'Default Value', 'buddypress' ); ?></span> |
|
773 |
<a href="admin.php?page=bp-profile-setup&mode=delete_option&option_id=<?php echo $options[$i]->id ?>" class="ajax-option-delete" id="delete-<?php echo $options[$i]->id; ?>">[x]</a> |
|
778 | 774 |
</p> |
779 | 775 | |
780 | 776 |
<?php } /* end for */ ?> |
... | ... | |
786 | 782 |
if ( 'multiselectbox' == $type || 'checkbox' == $type ) |
787 | 783 |
$default_name = '[1]'; ?> |
788 | 784 | |
789 |
<p><?php _e( 'Option', 'buddypress' ); ?> 1: <input type="text" name="<?php echo $type; ?>_option[1]" id="<?php echo $type; ?>_option1" /> |
|
790 |
<input type="<?php echo $default_input; ?>" name="isDefault_<?php echo $type; ?>_option<?php echo $default_name; ?>" id="isDefault_<?php echo $type; ?>_option" value="1" /> <?php _e( 'Default Value', 'buddypress' ); ?> |
|
791 |
<input type="hidden" name="<?php echo $type; ?>_option_number" id="<?php echo $type; ?>_option_number" value="2" /> |
|
785 |
<p class="sortable"> |
|
786 |
<span> Ξ </span> |
|
787 |
<input type="text" name="<?php echo $type; ?>_option[1]" id="<?php echo $type; ?>_option1" /> |
|
788 |
<input type="<?php echo $default_input; ?>" name="isDefault_<?php echo $type; ?>_option<?php echo $default_name; ?>" id="isDefault_<?php echo $type; ?>_option" value="1" /> |
|
789 |
<span><?php _e( 'Default Value', 'buddypress' ); ?></span> |
|
790 |
<input type="hidden" name="<?php echo $type; ?>_option_number" id="<?php echo $type; ?>_option_number" value="2" /> |
|
791 |
</p> |
|
792 | 792 | |
793 | 793 |
<?php } /* end if */ ?> |
794 | 794 |
bp-xprofile/admin/js/admin.dev.js (working copy) | ||
---|---|---|
3 | 3 |
var theId = document.getElementById(forWhat + '_option_number').value; |
4 | 4 |
var newDiv = document.createElement('p'); |
5 | 5 |
var newOption = document.createElement('input'); |
6 |
var label = document.createElement( 'label' );
|
|
7 |
var txt = document.createTextNode( "Option " + theId + ": " );
|
|
6 |
var span = document.createElement( 'span' );
|
|
7 |
var txt = document.createTextNode( "\u00A0\u039E\u00A0" );
|
|
8 | 8 |
var isDefault = document.createElement( 'input' ); |
9 |
var label1 = document.createElement( 'label' );
|
|
9 |
var span1 = document.createElement( 'span' );
|
|
10 | 10 |
var txt1 = document.createTextNode( " Default Value " ); |
11 | 11 | |
12 | 12 |
newDiv.setAttribute('id', forWhat + '_div' + theId); |
13 |
newDiv.setAttribute('class', 'sortable'); |
|
13 | 14 |
|
14 | 15 |
newOption.setAttribute( 'type', 'text' ); |
15 | 16 |
newOption.setAttribute( 'name', forWhat + '_option[' + theId + ']' ); |
16 | 17 |
newOption.setAttribute( 'id', forWhat + '_option' + theId ); |
17 | 18 | |
18 |
label.setAttribute( 'for', forWhat + '_option' + theId ); |
|
19 |
label.appendChild( txt ); |
|
19 |
span.appendChild( txt ); |
|
20 | 20 | |
21 | 21 |
if ( forWhat == 'checkbox' || forWhat == 'multiselectbox' ) { |
22 | 22 |
isDefault.setAttribute( 'type', 'checkbox' ); |
... | ... | |
28 | 28 | |
29 | 29 |
isDefault.setAttribute( 'value', theId ); |
30 | 30 | |
31 |
label1.appendChild( txt1 ); |
|
32 |
label1.setAttribute( 'for', 'isDefault_' + forWhat + '_option[]' ); |
|
31 |
span1.appendChild( txt1 ); |
|
33 | 32 | |
34 | 33 |
var toDelete = document.createElement( 'a' ); |
35 | 34 |
var toDeleteText = document.createTextNode( '[x]' ); |
... | ... | |
38 | 37 |
toDelete.setAttribute( 'class', 'delete' ); |
39 | 38 |
toDelete.appendChild( toDeleteText ); |
40 | 39 | |
41 |
newDiv.appendChild( label );
|
|
40 |
newDiv.appendChild( span );
|
|
42 | 41 |
newDiv.appendChild( newOption ); |
43 | 42 |
newDiv.appendChild( document.createTextNode( " " ) ); |
44 | 43 |
newDiv.appendChild( isDefault ); |
45 |
newDiv.appendChild( label1 );
|
|
44 |
newDiv.appendChild( span1 );
|
|
46 | 45 |
newDiv.appendChild( toDelete ); |
47 | 46 |
holder.appendChild( newDiv ); |
48 | 47 | |
48 |
// re-initialize the sorable ui |
|
49 |
enableSortableFieldOptions( forWhat ); |
|
49 | 50 | |
50 | 51 |
theId++; |
51 | 52 | |
... | ... | |
85 | 86 |
return ui; |
86 | 87 |
}; |
87 | 88 | |
88 |
// Set up deleting options ajax |
|
89 |
function enableSortableFieldOptions( forWhat ) { |
|
90 |
if ( jQuery( '#' + forWhat + ' p.sortable' ).length > 1 ) { |
|
91 |
jQuery( '.options-box' ).sortable( { |
|
92 |
items: 'p.sortable', |
|
93 |
tolerance: 'pointer', |
|
94 |
axis: 'y', |
|
95 |
handle: 'span' |
|
96 |
}); |
|
97 | ||
98 |
jQuery( '.sortable span' ).css( 'cursor', 'move' ); |
|
99 |
} |
|
100 |
} |
|
101 | ||
102 |
function destroySortableFieldOptions() { |
|
103 |
jQuery( '.options-box' ).sortable( 'destroy' ); |
|
104 |
jQuery( '.sortable span' ).css( 'cursor', 'default' ); |
|
105 |
} |
|
106 | ||
89 | 107 |
jQuery( document ).ready( function() { |
90 | 108 | |
109 |
// Set up deleting options ajax |
|
91 | 110 |
jQuery( 'a.ajax-option-delete' ).click( |
92 | 111 |
function() { |
93 | 112 |
var theId = this.id.split( '-' ); |
... | ... | |
103 | 122 |
} |
104 | 123 |
); |
105 | 124 | |
125 |
// |
|
126 |
jQuery( '[id^="sort_order_"]' ).change(function() { |
|
127 |
if ( jQuery( this ).val() != 'custom' ) { |
|
128 |
destroySortableFieldOptions(); |
|
129 |
} else { |
|
130 |
enableSortableFieldOptions( jQuery('#fieldtype :selected').val() ); |
|
131 |
} |
|
132 |
}); |
|
133 | ||
106 | 134 |
// Show object if JS is enabled |
107 | 135 |
jQuery( 'ul#field-group-tabs' ).show(); |
108 | 136 | |
... | ... | |
150 | 178 |
// Change cursor to move if JS is enabled |
151 | 179 |
.css( 'cursor', 'move' ); |
152 | 180 | |
181 |
// Allow reordering of field options |
|
182 |
enableSortableFieldOptions( jQuery('#fieldtype :selected').val() ); |
|
183 | ||
153 | 184 |
// tabs init with a custom tab template and an "add" callback filling in the content |
154 | 185 |
var $tab_items; |
155 | 186 |
var $tabs = jQuery( '#tabs' ).tabs(); |
- « Previous
- 1
- 2
- 3
- Next »