Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- group.toggle.updateTitle = function ( index, element ) {
- var $group = $( element ),
- $title = $group.find( '> .rwmb-group-title-wrapper > .rwmb-group-title, > .rwmb-input > .rwmb-group-title-wrapper > .rwmb-group-title' ),
- options = $title.data( 'options' );
- function processField( field ) {
- if ( -1 === content.indexOf( '{' + field + '}' ) ) {
- return;
- }
- var selectors = 'input[name*="[' + field + ']"], textarea[name*="[' + field + ']"], select[name*="[' + field + ']"], button[name*="[' + field + ']"]',
- $field = $group.find( selectors ),
- fieldValue = $field.val();
- if ( $field.is( 'select' ) && fieldValue ) {
- fieldValue = $field.find( 'option:selected' ).text();
- }
- content = content.replace( '{' + field + '}', fieldValue );
- // Update title when field's value is changed.
- if ( ! $field.data( 'update-group-title' ) ) {
- $field.on( 'keyup change', _.debounce( function () {
- group.toggle.updateTitle( 0, element );
- }, 250 ) ).data( 'update-group-title', true );
- }
- }
- if ( 'undefined' === typeof options ) {
- return;
- }
- var content = options.content || '',
- fields = options.fields || [];
- content = content.replace( '{#}', index );
- fields.forEach( processField );
- $title.text( content );
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement