Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion assets/src/js/_acf-field-accordion.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,15 @@
accordionManager.iconHtml( { open: this.get( 'open' ) } )
);

$label.attr( {
tabindex: 0,
role: 'button',
'aria-expanded': this.get( 'open' ) ? 'true' : 'false',
} );
$input.attr( {
role: 'region',
} );

// classes
// - remove 'inside' which is a #poststuff WP class
var $parent = $field.parent();
Expand Down Expand Up @@ -131,6 +140,7 @@

events: {
'click .acf-accordion-title': 'onClick',
'keydown .acf-accordion-title': 'onKeydown',
'invalidField .acf-accordion': 'onInvalidField',
},

Expand Down Expand Up @@ -174,6 +184,10 @@
this.iconHtml( { open: true } )
);
$el.addClass( '-open' );
$el.find( '.acf-accordion-title:first' ).attr(
'aria-expanded',
'true'
);

// action
acf.doAction( 'show', $el );
Expand All @@ -195,6 +209,10 @@
this.iconHtml( { open: false } )
);
$el.removeClass( '-open' );
$el.find( '.acf-accordion-title:first' ).attr(
'aria-expanded',
'false'
);

// action
acf.doAction( 'hide', $el );
Expand All @@ -207,7 +225,15 @@
// open close
this.toggle( $el.parent() );
},

onKeydown: function ( e, $el ) {
// check for enter or space
if ( 13 === e.which ) {
// prevent Default
e.preventDefault();
// open close
this.toggle( $el.parent() );
}
},
onInvalidField: function ( e, $el ) {
// bail early if already focused
if ( this.busy ) {
Expand Down
30 changes: 23 additions & 7 deletions assets/src/js/_acf-field-google-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
wait: 'load',

events: {
'click a[data-name="clear"]': 'onClickClear',
'click a[data-name="locate"]': 'onClickLocate',
'click a[data-name="search"]': 'onClickSearch',
'click button[data-name="clear"]': 'onClickClear',
'click button[data-name="locate"]': 'onClickLocate',
'click button[data-name="search"]': 'onClickSearch',
'keydown .search': 'onKeydownSearch',
'keyup .search': 'onKeyupSearch',
'focus .search': 'onFocusSearch',
Expand Down Expand Up @@ -513,8 +513,13 @@
this.searchAddress( this.$search().val() );
},

onFocusSearch: function ( e, $el ) {
this.setState( 'searching' );
onFocusSearch: function ( event, searchInput ) {
const currentValue = this.val();
const currentAddress = currentValue ? currentValue.address : '';

if ( searchInput.val() !== currentAddress ) {
this.setState( 'searching' );
}
},

onBlurSearch: function ( e, $el ) {
Expand All @@ -529,9 +534,20 @@
},

onKeyupSearch: function ( e, $el ) {
// Clear empty value.
if ( ! $el.val() ) {
const val = this.val();
const address = val ? val.address : '';

if ( $el.val() ) {
// If search input has value
if ( $el.val() !== address ) {
this.setState( 'searching' );
} else {
this.setState( 'default' );
}
} else {
// If search input is empty
this.val( false );
this.setState( 'default' );
}
},

Expand Down
12 changes: 11 additions & 1 deletion assets/src/js/_acf-tinymce.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,22 @@
init.setup = function ( ed ) {
ed.on( 'change', function ( e ) {
ed.save(); // save to textarea
if ( ! $textarea.closest( '.attachment-info' ).length ) {
$textarea.trigger( 'change' );
}
$textarea.trigger( 'change' );
} );

ed.on( 'blur', function ( e ) {
if ( $textarea.closest( '.attachment-info' ).length ) {
ed.save();
$textarea.trigger( 'change' );
}
} );

// Fix bug where Gutenberg does not hear "mouseup" event and tries to select multiple blocks.
ed.on( 'mouseup', function ( e ) {
var event = new MouseEvent( 'mouseup' );
const event = new MouseEvent( 'mouseup' );
window.dispatchEvent( event );
} );

Expand Down
7 changes: 4 additions & 3 deletions assets/src/js/_acf-validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -1177,9 +1177,10 @@
new CustomEvent(
'acf/block/has-error',
{
acfBlocksWithValidationErrors: [
block,
],
detail: {
acfBlocksWithValidationErrors:
block.clientId,
},
}
)
);
Expand Down
12 changes: 11 additions & 1 deletion assets/src/js/_field-group-field.js
Original file line number Diff line number Diff line change
Expand Up @@ -407,11 +407,21 @@

// update label
$handle.find( '.li-field-label strong a' ).html( label );
let shouldConvertToLowercase = name === name.toLowerCase();
shouldConvertToLowercase = acf.applyFilters(
'convert_field_name_to_lowercase',
shouldConvertToLowercase,
this
);

// update name
$handle
.find( '.li-field-name' )
.html( this.makeCopyable( acf.strSanitize( name ) ) );
.html(
this.makeCopyable(
acf.strSanitize( name, shouldConvertToLowercase )
)
);

// update type
const iconName = acf.strSlugify( this.getType() );
Expand Down
54 changes: 27 additions & 27 deletions assets/src/js/pro/_acf-blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,33 @@ const md5 = require( 'md5' );
return name;
}

/**
* A react Component for inline scripts.
*
* This Component uses a combination of React references and jQuery to append the
* inline <script> HTML each time the component is rendered.
*
* @date 29/05/2020
* @since ACF 5.9.0
*
* @param type Var Description.
* @return type Description.
*/
class Script extends Component {
render() {
return <div ref={ ( el ) => ( this.el = el ) } />;
}
setHTML( html ) {
$( this.el ).html( `<script>${ html }</script>` );
}
componentDidUpdate() {
this.setHTML( this.props.children );
}
componentDidMount() {
this.setHTML( this.props.children );
}
}

/**
* Converts the given name into a React friendly name or component.
*
Expand Down Expand Up @@ -1009,33 +1036,6 @@ const md5 = require( 'md5' );
}
}

/**
* A react Component for inline scripts.
*
* This Component uses a combination of React references and jQuery to append the
* inline <script> HTML each time the component is rendered.
*
* @date 29/05/2020
* @since ACF 5.9.0
*
* @param type Var Description.
* @return type Description.
*/
class Script extends Component {
render() {
return <div ref={ ( el ) => ( this.el = el ) } />;
}
setHTML( html ) {
$( this.el ).html( `<script>${ html }</script>` );
}
componentDidUpdate() {
this.setHTML( this.props.children );
}
componentDidMount() {
this.setHTML( this.props.children );
}
}

/**
* DynamicHTML Class.
*
Expand Down
Loading
Loading