Changeset 2682
- Timestamp:
- 03/03/2016 07:33:42 PM (9 years ago)
- Location:
- sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments/css/wordcamp-budgets.css
r2633 r2682 54 54 color: #dc3232; 55 55 } 56 57 /* Make room for the required field indicator (*) */ 58 body.post-type-wcp_payment_request input.large-text, 59 body.post-type-wcp_payment_request input.regular-text, 60 body.post-type-wcp_payment_request textarea.large-text, 61 body.post-type-wcp_payment_request .meta-box-sortables select { 62 width: 95%; 63 } 64 65 @media screen and ( max-width: 782px ) { 66 body.post-type-wcp_payment_request .form-table td textarea { 67 display: inline; 68 width: 95%; 69 } 70 } 71 56 72 57 73 /* margins from above selector aren't applied */ -
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments/includes/payment-request.php
r2676 r2682 180 180 plugins_url( 'javascript/payment-requests.js', __DIR__ ), 181 181 array( 'wordcamp-budgets', 'wcb-attached-files', 'jquery' ), 182 2,182 3, 183 183 true 184 184 ); … … 339 339 * @param string $name 340 340 * @param string $description 341 */ 342 protected function render_textarea_input( $post, $label, $name, $description = '' ) { 341 * @param bool $required 342 */ 343 protected function render_textarea_input( $post, $label, $name, $description = '', $required = true ) { 343 344 $text = $this->get_field_value( $name, $post ); 344 345 … … 352 353 * @param string $label 353 354 * @param string $name 354 */ 355 protected function render_select_input( $post, $label, $name ) { 355 * @param bool $required 356 */ 357 protected function render_select_input( $post, $label, $name, $required = true ) { 356 358 $selected = get_post_meta( $post->ID, '_camppayments_' . $name, true ); 357 359 $options = $this->get_field_value( $name, $post ); … … 360 362 } 361 363 362 protected function render_country_input( $post, $label, $name ) { 364 /** 365 * Render a select dropdown for countries 366 * 367 * @param WP_Post $post 368 * @param string $label 369 * @param string $name 370 * @param bool $required 371 */ 372 protected function render_country_input( $post, $label, $name, $required = true ) { 363 373 $selected = $this->get_field_value( $name, $post ); 364 374 $options = WordCamp_Budgets::get_valid_countries_iso3166(); … … 373 383 * @param string $label 374 384 * @param string $name 375 */ 376 protected function render_radio_input( $post, $label, $name ) { 385 * @param bool $required 386 */ 387 protected function render_radio_input( $post, $label, $name, $required = true ) { 377 388 $selected = get_post_meta( $post->ID, "_{$this->meta_key_prefix}_" . $name, true ); 378 389 $options = $this->get_field_value( $name, $post ); … … 387 398 * @param string $label 388 399 * @param string $name 389 */ 390 protected function render_checkbox_input( $post, $label, $name, $description = '' ) { 400 * @param bool $required 401 */ 402 protected function render_checkbox_input( $post, $label, $name, $description = '', $required = true ) { 391 403 $value = $this->get_field_value( $name, $post ); 392 404 … … 400 412 * @param string $label 401 413 * @param string $name 402 */ 403 protected function render_text_input( $post, $label, $name, $description = '', $variant = 'text', $row_classes = array(), $readonly = false ) { 414 * @param string $description 415 * @param string $variant 416 * @param array $row_classes 417 * @param bool $readonly 418 * @param bool $required 419 */ 420 protected function render_text_input( $post, $label, $name, $description = '', $variant = 'text', $row_classes = array(), $readonly = false, $required = true ) { 404 421 $value = $this->get_field_value( $name, $post ); 405 422 array_walk( $row_classes, 'sanitize_html_class' ); -
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments/includes/wordcamp-budgets.php
r2677 r2682 129 129 plugins_url( 'javascript/wordcamp-budgets.js', __DIR__ ), 130 130 array( 'jquery', 'jquery-ui-datepicker', 'media-upload', 'media-views' ), 131 1,131 2, 132 132 true 133 133 ); … … 161 161 plugins_url( 'css/wordcamp-budgets.css', __DIR__ ), 162 162 $soft_deps, 163 2163 3 164 164 ); 165 165 } -
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments/javascript/payment-requests.js
r2633 r2682 24 24 registerEventHandlers : function() { 25 25 var currency = $( '#currency' ); 26 var paymentCategory = $( '#payment_category' ); 26 var paymentCategory = $( '#payment_category' ), 27 paymentDetails = $( '#wcp_payment_details' ); 27 28 28 $( '#wcp_payment_details' ).find( 'input[name=payment_method]' ).change( wcb.togglePaymentMethodFields ); 29 paymentDetails.find( 'input[name=payment_method]' ).change( wcb.togglePaymentMethodFields ); 30 paymentDetails.find( 'input[name=payment_method]:checked' ).trigger( 'change' ); // Set the initial state 31 29 32 paymentCategory.change( app.toggleOtherCategoryDescription ); 30 33 paymentCategory.trigger( 'change' ); // Set the initial state 34 31 35 currency.change( wcb.setDefaultPaymentMethod ); 32 36 currency.trigger( 'change' ); // Set the initial state 37 33 38 $( '#row-files' ).find( 'a.wcb-insert-media' ).click( wcb.showUploadModal ); 34 39 … … 53 58 if ( 'other' == $( this ).find( 'option:selected' ).val() ) { 54 59 $( otherCategoryDescription ).removeClass( 'hidden' ); 60 $( otherCategoryDescription ).find( ':input' ).prop( 'required', true ); 55 61 } else { 56 62 $( otherCategoryDescription ).addClass( 'hidden' ); 63 $( otherCategoryDescription ).find( ':input' ).prop( 'required', false ); 57 64 } 58 65 -
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments/javascript/reimbursement-requests.js
r2646 r2682 31 31 registerEventHandlers : function() { 32 32 var reason = $( '#_wcbrr_reason' ), 33 currency = $( '#_wcbrr_currency' ); 33 currency = $( '#_wcbrr_currency' ), 34 paymentMethod = $( '#row-payment-method' ); 34 35 35 36 reason.change( app.toggleOtherReasonDescription ); … … 39 40 currency.trigger( 'change' ); // Set the initial state 40 41 41 $( '#row-payment-method' ).find( 'input[name=payment_method]' ).change( wcb.togglePaymentMethodFields ); 42 paymentMethod.find( 'input[name=payment_method]' ).change( wcb.togglePaymentMethodFields ); 43 paymentMethod.find( 'input[name=payment_method]:checked' ).trigger( 'change' ); // Set the initial state 44 42 45 $( '#wcbrr_general_information' ).find( 'a.wcb-insert-media' ).click( wcb.showUploadModal ); 43 46 $( '#wcbrr-add-another-expense' ).click( app.addNewExpense ); -
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments/javascript/wordcamp-budgets.js
r2677 r2682 31 31 togglePaymentMethodFields : function( event ) { 32 32 var active_fields_container = '#' + $( this ).attr( 'id' ) + '_fields'; 33 var payment_method_fields = '.payment_method_fields'; 33 var payment_method_fields = '.payment_method_fields', 34 optionalFields = [ 'needs_intermediary_bank' ]; 34 35 35 36 $( payment_method_fields ).removeClass( 'active' ); 36 37 $( payment_method_fields ).addClass( 'hidden' ); 38 39 $( payment_method_fields ).each( function( containerIndex, fieldContainer ) { 40 $( fieldContainer ).find( ':input' ).each( function( fieldIndex, inputField ) { 41 $( inputField ).prop( 'required', false ); 42 } ); 43 } ); 44 37 45 $( active_fields_container ).removeClass( 'hidden' ); 38 46 $( active_fields_container ).addClass( 'active' ); 47 48 $( active_fields_container ).find( ':input' ).each( function( index, field ) { 49 if ( $.inArray( $( field ).prop( 'id' ), optionalFields ) > -1 ) { 50 return; 51 } 52 53 $( field ).prop( 'required', true ); 54 } ); 55 56 /* 57 * Also toggle intermediary bank fields, because otherwise switching to Wire from another method 58 * wouldn't remove `required` attributes. 59 */ 60 app.toggleIntermediaryBankFields( event ); 39 61 40 62 // todo make the transition smoother … … 55 77 if ( isWirePayment && needsIntermediaryBank ) { 56 78 $( row ).removeClass( 'hidden' ); 79 $( row ).find( ':input' ).prop( 'required', true ); 57 80 } else { 58 81 $( row ).addClass( 'hidden' ); 82 $( row ).find( ':input' ).prop( 'required', false ); 59 83 } 60 84 } ); -
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments/views/payment-request/input-country.php
r2494 r2682 5 5 </label> 6 6 </th> 7 7 8 <td> 8 <select id="<?php echo esc_attr( $name ); ?>" name="<?php echo esc_attr( $name ); ?>"> 9 <select 10 id="<?php echo esc_attr( $name ); ?>" 11 name="<?php echo esc_attr( $name ); ?>" 12 <?php __checked_selected_helper( $required, true, true, 'required' ); ?> 13 > 9 14 <option value="">(None)</option> 10 15 <?php foreach ( $options as $value => $option_label ) : ?> … … 14 19 <?php endforeach; ?> 15 20 </select> 21 22 <?php 23 if ( $required ) { 24 WordCamp_Budgets::render_form_field_required_indicator(); 25 } 26 ?> 16 27 </td> 17 28 </tr> -
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments/views/payment-request/input-radio.php
r995 r2682 14 14 value="<?php echo esc_attr( $option ); ?>" 15 15 <?php checked( $option, $selected ); ?> 16 <?php __checked_selected_helper( $required, true, true, 'required' ); ?> 16 17 /> 17 18 … … 20 21 </label> 21 22 <?php endforeach; ?> 23 24 <?php 25 if ( $required ) { 26 WordCamp_Budgets::render_form_field_required_indicator(); 27 } 28 ?> 22 29 </td> 23 30 </tr> -
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments/views/payment-request/input-select.php
r995 r2682 7 7 8 8 <td> 9 <select id="<?php echo esc_attr( $name ); ?>" name="<?php echo esc_attr( $name ); ?>"> 9 <select 10 id="<?php echo esc_attr( $name ); ?>" 11 name="<?php echo esc_attr( $name ); ?>" 12 <?php __checked_selected_helper( $required, true, true, 'required' ); ?> 13 > 10 14 <option value="null-select-one"> 11 15 <?php printf( __( '-- Select a %s --', 'wordcamporg' ), $label ); ?> … … 19 23 <?php endforeach; ?> 20 24 </select> 25 26 <?php 27 if ( $required ) { 28 WordCamp_Budgets::render_form_field_required_indicator(); 29 } 30 ?> 21 31 </td> 22 32 </tr> -
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments/views/payment-request/input-text.php
r2060 r2682 13 13 value="<?php echo esc_attr( $value ); ?>" 14 14 <?php if ( $readonly ) { echo 'readonly="readonly"'; } ?> 15 <?php __checked_selected_helper( $required, true, true, 'required' ); ?> 15 16 class="regular-text" 16 17 /> 18 19 <?php 20 if ( $required ) { 21 WordCamp_Budgets::render_form_field_required_indicator(); 22 } 23 ?> 17 24 18 25 <?php if ( ! empty( $description ) ) : ?> -
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments/views/payment-request/input-textarea.php
r2416 r2682 7 7 8 8 <td> 9 <textarea id="<?php echo esc_attr( $name ); ?>" name="<?php echo esc_attr( $name ); ?>" class="large-text"><?php 9 <textarea 10 id="<?php echo esc_attr( $name ); ?>" 11 name="<?php echo esc_attr( $name ); ?>" 12 class="large-text" 13 <?php __checked_selected_helper( $required, true, true, 'required' ); ?> 14 ><?php 10 15 echo esc_html( $text ); 11 16 ?></textarea> 17 18 <?php 19 if ( $required ) { 20 WordCamp_Budgets::render_form_field_required_indicator(); 21 } 22 ?> 12 23 13 24 <?php if ( ! empty( $description ) ) : ?> -
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments/views/payment-request/metabox-general.php
r2676 r2682 24 24 <?php $this->render_textarea_input( $post, 'Notes', 'general_notes', 'Any other details you want to share.' ); ?> 25 25 </table> 26 27 <p class="wcb-form-required"> 28 <?php _e( '* required', 'wordcamporg' ); ?> 29 </p> -
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments/views/payment-request/metabox-payment.php
r2677 r2682 9 9 <table class="form-table"> 10 10 <?php if ( $box['args']['show_vendor_requested_payment_method'] ) : ?> 11 <?php $this->render_textarea_input( $post, 'Did the vendor request a specific type of payment?', 'vendor_requested_payment_method', 'Add any relevant details' ); ?>11 <?php $this->render_textarea_input( $post, 'Did the vendor request a specific type of payment?', 'vendor_requested_payment_method', 'Add any relevant details', false ); ?> 12 12 <?php endif;?> 13 13 … … 77 77 ); ?> 78 78 79 <table >79 <table id="intermediary_bank_fields"> 80 80 <?php $this->render_text_input( $post, 'Intermediary Bank Name', 'interm_bank_name' ); ?> 81 81 <?php $this->render_text_input( $post, 'Intermediary Bank Street Address', 'interm_bank_street_address' ); ?> … … 104 104 </div> 105 105 </fieldset> 106 107 <p class="wcb-form-required"> 108 <?php _e( '* required', 'wordcamporg' ); ?> 109 </p> -
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments/views/payment-request/metabox-status.php
r2643 r2682 29 29 <?php if ( $post->post_status != 'auto-draft' ) : ?> 30 30 <div class="misc-pub-section"> 31 <?php $this->render_text_input( $post, 'Date Vendor was Paid', 'date_vendor_paid', '', 'date', array(), $date_vendor_paid_readonly ); ?>31 <?php $this->render_text_input( $post, 'Date Vendor was Paid', 'date_vendor_paid', '', 'date', array(), $date_vendor_paid_readonly, false ); ?> 32 32 </div> 33 33 -
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments/views/payment-request/metabox-vendor.php
r2494 r2682 13 13 ?> 14 14 </table> 15 16 <p class="wcb-form-required"> 17 <?php _e( '* required', 'wordcamporg' ); ?> 18 </p> -
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments/views/wordcamp-budgets/form-field-required-indicator.php
r2605 r2682 1 1 2 <span class="wcb-form-required" aria-hidden="true"> 3 <?php // translators: The symbol to indicate the form field is required ?> 4 <?php _e( '*', 'wordcamporg' ); ?> 2 <span class="wcb-form-required"> 3 <span aria-hidden="true"> 4 <?php // translators: The symbol to indicate the form field is required ?> 5 <?php _e( '*', 'wordcamporg' ); ?> 6 </span> 7 8 <span class="screen-reader-text"> 9 <?php _e( 'required field', 'wordcamporg' ); ?> 10 </span> 5 11 </span> 6 7 <span class="screen-reader-text">8 <?php _e( 'required field', 'wordcamporg' ); ?>9 </span>
Note: See TracChangeset
for help on using the changeset viewer.