Making WordPress.org


Ignore:
Timestamp:
03/01/2019 09:09:58 AM (8 years ago)
Author:
dd32
Message:

WordPress.tv: Autofill Event Name field based on Category selection.

This isn't bulletproof and is disabled once the submitter focuses on the event field.

Fixes #1431.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.tv/public_html/wp-content/themes/wptv2/anon-upload-template.php

    r8380 r8381  
    361361                        $( 'ul.cats-checkboxes input' ).prop( 'disabled', false );
    362362
     363                        $( '#wptv_video_wordcamp, ul.cats-checkboxes input' ).on( 'change', function() {
     364                                if ( $( '#wptv_event' ).data('user-altered') ) {
     365                                        return;
     366                                }
     367
     368                                var title = '';
     369                                // Get the Location
     370                                title += $( '#category-6418 ul.children input:checked' ).parent().text().trim() + " ";
     371
     372                                // .. and the Year
     373                                title += $( '#category-91093 ul.children input:checked' ).parent().text().trim();
     374
     375                                // If a location or year has been selected, build the Event Name.
     376                                if ( $.trim( title ) ) {
     377                                        if ( $( '#wptv_video_wordcamp' ).prop( 'checked' ) ) {
     378                                                title = "WordCamp " + title;
     379                                        } else if ( $( '#in-category-107686937:checked, #in-category-467571547:checked' ).length ) {
     380                                                /* BuddyCamp * Global Translation Day */
     381                                                title = $( '#in-category-107686937:checked, #in-category-467571547:checked' ).parent().text().trim() + " " + title;
     382                                        } else {
     383                                                title = "WordPress Meetup " + title;
     384                                        }
     385
     386                                        $( '#wptv_event' ).val( $.trim( title ) );
     387                                }
     388                        });
     389                        $( '#wptv_event' ).on( 'focus', function() {
     390                                // Not perfect, but will do.
     391                                $( '#wptv_event' ).data( 'user-altered', true );
     392                        });
     393
    363394                        $( '#video-upload-form' ).submit( function( e ) {
    364395                                var scroll = false;
Note: See TracChangeset for help on using the changeset viewer.