Guest User

Untitled

a guest
Jun 27th, 2019
99
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. group.toggle.updateTitle = function ( index, element ) {
  2.         var $group = $( element ),
  3.             $title = $group.find( '> .rwmb-group-title-wrapper > .rwmb-group-title, > .rwmb-input > .rwmb-group-title-wrapper > .rwmb-group-title' ),
  4.             options = $title.data( 'options' );
  5.  
  6.         function processField( field ) {
  7.             if ( -1 === content.indexOf( '{' + field + '}' ) ) {
  8.                 return;
  9.             }
  10.  
  11.             var selectors = 'input[name*="[' + field + ']"], textarea[name*="[' + field + ']"], select[name*="[' + field + ']"], button[name*="[' + field + ']"]',
  12.                 $field = $group.find( selectors ),
  13.                 fieldValue = $field.val();
  14.  
  15.             if ( $field.is( 'select' ) && fieldValue ) {
  16.                 fieldValue = $field.find( 'option:selected' ).text();
  17.             }
  18.  
  19.             content = content.replace( '{' + field + '}', fieldValue );
  20.  
  21.             // Update title when field's value is changed.
  22.             if ( ! $field.data( 'update-group-title' ) ) {
  23.                 $field.on( 'keyup change', _.debounce( function () {
  24.                     group.toggle.updateTitle( 0, element );
  25.                 }, 250 ) ).data( 'update-group-title', true );
  26.             }
  27.         }
  28.  
  29.         if ( 'undefined' === typeof options ) {
  30.             return;
  31.         }
  32.  
  33.         var content = options.content || '',
  34.             fields = options.fields || [];
  35.  
  36.         content = content.replace( '{#}', index );
  37.         fields.forEach( processField );
  38.  
  39.         $title.text( content );
  40.     };
RAW Paste Data