Skip to content
Merged
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
3 changes: 3 additions & 0 deletions assets/images/icons/icon-add-alt.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions assets/images/icons/icon-duplicate.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions assets/images/icons/icon-edit.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions assets/images/icons/icon-hidden-alt.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions assets/images/icons/icon-more-vertical.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions assets/images/icons/icon-trash-alt.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions assets/images/icons/icon-visible.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 26 additions & 1 deletion assets/src/js/_acf-field-date-picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,32 @@
// add date picker
acf.newDatePicker( $inputText, args );

// action
// Check if default to today is enabled and field is empty
if (
$inputText.data( 'default-to-today' ) === 1 &&
! $input.val()
) {
// Get current date
const currentDate = new Date();

// Format display date
const displayDate = $.datepicker.formatDate(
args.dateFormat,
currentDate
);

// Set the display input value (what user sees)
$inputText.val( `${ displayDate }` );

// Format hidden field date (for database storage)
const hiddenDate = $.datepicker.formatDate(
'yymmdd',
currentDate
);

// Set the hidden input value (what gets saved)
$input.val( `${ hiddenDate }` );
}
acf.doAction( 'date_picker_init', $inputText, args, this );
},

Expand Down
37 changes: 37 additions & 0 deletions assets/src/js/_acf-field-date-time-picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,43 @@
// add date time picker
acf.newDateTimePicker( $inputText, args );

// Check if default to today is enabled and field is empty
if (
$inputText.data( 'default-to-today' ) === 1 &&
! $input.val()
) {
// Get current date
const currentDate = new Date();

// Format display date and time
const displayDate = $.datepicker.formatDate(
args.dateFormat,
currentDate
);
const displayTime = $.datepicker.formatTime( args.timeFormat, {
hour: currentDate.getHours(),
minute: currentDate.getMinutes(),
second: currentDate.getSeconds(),
} );

// Set the display input value (what user sees)
$inputText.val( `${ displayDate } ${ displayTime }` );

// Format hidden field date and time (for database storage)
const hiddenDate = $.datepicker.formatDate(
'yy-mm-dd',
currentDate
);
const hiddenTime = $.datepicker.formatTime( 'hh:mm:ss', {
hour: currentDate.getHours(),
minute: currentDate.getMinutes(),
second: currentDate.getSeconds(),
} );

// Set the hidden input value (what gets saved)
$input.val( `${ hiddenDate } ${ hiddenTime }` );
}

// action
acf.doAction( 'date_time_picker_init', $inputText, args, this );
},
Expand Down
76 changes: 36 additions & 40 deletions assets/src/js/_acf-field-icon-picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
// Initialize the state of the icon picker.
let typeAndValue = {
type: this.$typeInput().val(),
value: this.$valueInput().val()
value: this.$valueInput().val(),
};

// Store the type and value object.
Expand Down Expand Up @@ -135,15 +135,19 @@
initializeIconLists( typeAndValue ) {
const self = this;

this.$( '.acf-icon-list' ).each( function( i ) {
this.$( '.acf-icon-list' ).each( function ( i ) {
const tabName = $( this ).data( 'parent-tab' );
const icons = self.getIconsList( tabName ) || [];
self.set( tabName, icons );
self.renderIconList( $( this ) );

if ( typeAndValue.type === tabName ) {
// Select the correct icon.
self.selectIcon( $( this ), typeAndValue.value, false ).then( () => {
self.selectIcon(
$( this ),
typeAndValue.value,
false
).then( () => {
// Scroll to the selected icon.
self.scrollToSelectedIcon();
} );
Expand All @@ -152,13 +156,9 @@
},

alignIconListTabsToCurrentValue( typeAndValue ) {
const icons = this.$( '.acf-icon-list' ).filter(
function () {
return (
$( this ).data( 'parent-tab' ) !== typeAndValue.type
);
}
);
const icons = this.$( '.acf-icon-list' ).filter( function () {
return $( this ).data( 'parent-tab' ) !== typeAndValue.type;
} );
const self = this;
icons.each( function () {
self.unselectIcon( $( this ) );
Expand All @@ -179,12 +179,8 @@
icon.key
) } acf-icon-picker-list-icon" role="radio" data-icon="${ acf.strEscape(
icon.key
) }" style="${ style }" title="${ acf.strEscape(
icon.label
) }">
<label for="${ acf.strEscape( id ) }">${ acf.strEscape(
icon.label
) }</label>
) }" style="${ style }" title="${ acf.strEscape( icon.label ) }">
<label for="${ acf.strEscape( id ) }">${ acf.strEscape( icon.label ) }</label>
<input id="${ acf.strEscape(
id
) }" type="radio" class="acf-icon-picker-list-icon-radio" name="acf-icon-picker-list-icon-radio" value="${ acf.strEscape(
Expand All @@ -207,25 +203,29 @@
},

getIconsList( tabName ) {
let icons;

if ( 'dashicons' === tabName ) {
const iconPickeri10n = acf.get( 'iconPickeri10n' ) || [];

return Object.entries( iconPickeri10n ).map(
( [ key, value ] ) => {
return {
key,
label: value,
};
}
icons = Object.entries( iconPickeri10n ).map(
( [ key, label ] ) => ( { key, label } )
);
} else {
const iconList = this.$(
`.acf-icon-list[data-parent-tab="${ tabName }"]`
);
if ( iconList.length !== 0 ) {
const iconsData = iconList.data( 'icons' );
icons = Array.isArray( iconsData ) ? iconsData : [];
}
}

return acf.get( `iconPickerIcons_${ tabName }` );
return icons;
},

getIconsBySearch( searchTerm, tabName ) {
const lowercaseSearchTerm = searchTerm.toLowerCase();
const icons = this.getIconsList( tabName);
const icons = this.getIconsList( tabName );

const filteredIcons = icons.filter( function ( icon ) {
const lowercaseIconLabel = icon.label.toLowerCase();
Expand Down Expand Up @@ -258,17 +258,13 @@

unselectIcon( $el ) {
// Remove the currently active dashicon, if any.
$el
.find( '.acf-icon-picker-list-icon' )
.removeClass( 'active' );
$el.find( '.acf-icon-picker-list-icon' ).removeClass( 'active' );
this.set( 'selectedIcon', false );
},

onIconRadioFocus( e ) {
const icon = e.target.value;
const $tabs = this.$( e.target ).closest(
'.acf-icon-picker-tabs'
);
const $tabs = this.$( e.target ).closest( '.acf-icon-picker-tabs' );
const $iconsList = $tabs.find( '.acf-icon-list' );

const $newIcon = $iconsList.find(
Expand All @@ -292,9 +288,7 @@

onIconClick( e ) {
e.preventDefault();
const $iconList = this.$( e.target ).closest(
'.acf-icon-list'
);
const $iconList = this.$( e.target ).closest( '.acf-icon-list' );
const $iconElement = this.$( e.target );
const icon = $iconElement.find( 'input' ).val();

Expand All @@ -303,13 +297,14 @@
);

// By forcing focus on the input, we fire onIconRadioFocus.
$newIconElement.find( 'input' ).prop( 'checked', true ).trigger( 'focus' );
$newIconElement
.find( 'input' )
.prop( 'checked', true )
.trigger( 'focus' );
},

onIconSearch( e ) {
const $tabs = this.$( e.target ).closest(
'.acf-icon-picker-tabs'
);
const $tabs = this.$( e.target ).closest( '.acf-icon-picker-tabs' );
const $iconList = $tabs.find( '.acf-icon-list' );
const tabName = $tabs.data( 'tab' );
const searchTerm = e.target.value;
Expand All @@ -335,7 +330,8 @@
: searchTerm;

$tabs.find( '.acf-icon-list ' ).hide();
$tabs.find( '.acf-icon-list-empty' )
$tabs
.find( '.acf-icon-list-empty' )
.find( '.acf-invalid-icon-list-search-term' )
.text( visualSearchTerm );
$tabs.find( '.acf-icon-list-empty' ).css( 'display', 'flex' );
Expand Down
13 changes: 8 additions & 5 deletions assets/src/js/_acf-field-relationship.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
// Add sortable.
this.$list( 'values' ).sortable( {
items: 'li',
zIndex: 9999,
forceHelperSize: true,
forcePlaceholderSize: true,
scroll: true,
Expand Down Expand Up @@ -126,11 +127,11 @@
onKeypressFilter: function ( e, $el ) {
// Receive enter key when selecting relationship items.
if ( $el.hasClass( 'acf-rel-item-add' ) && e.which == 13 ) {
this.onClickAdd(e, $el);
this.onClickAdd( e, $el );
}
// Receive enter key when removing relationship items.
if ( $el.hasClass( 'acf-rel-item-remove' ) && e.which == 13 ) {
this.onClickRemove(e, $el);
this.onClickRemove( e, $el );
}
// don't submit form
if ( e.which == 13 ) {
Expand Down Expand Up @@ -213,7 +214,7 @@

let $span;
// Behavior if triggered from tabbed event.
if ( $el.hasClass( 'acf-rel-item-remove' )) {
if ( $el.hasClass( 'acf-rel-item-remove' ) ) {
$span = $el;
} else {
// Behavior if triggered through click event.
Expand All @@ -234,8 +235,10 @@
this.$input().trigger( 'change' );
},

onTouchStartValues: function( e, $el ) {
$( this.$listItems( 'values' ) ).removeClass( 'relationship-hover' );
onTouchStartValues: function ( e, $el ) {
$( this.$listItems( 'values' ) ).removeClass(
'relationship-hover'
);
$el.addClass( 'relationship-hover' );
},

Expand Down
35 changes: 26 additions & 9 deletions assets/src/js/_acf-notice.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@
this.type( this.get( 'type' ) );

// text
this.html( '<p>' + this.get( 'text' ) + '</p>' );
this.html( '<p>' + acf.strEscape( this.get( 'text' ) ) + '</p>' );

// close
if ( this.get( 'dismiss' ) ) {
this.$el.append( '<a href="#" class="acf-notice-dismiss acf-icon -cancel small"></a>' );
this.$el.append(
'<a href="#" class="acf-notice-dismiss acf-icon -cancel small"></a>'
);
this.$el.addClass( '-dismiss' );
}

Expand Down Expand Up @@ -144,14 +146,29 @@
$( this ).remove();
} else {
$( this ).show();
$( this ).on( 'click', '.notice-dismiss', function ( e ) {
dismissed = acf.getPreference( 'dismissed-notices' );
if ( ! dismissed || typeof dismissed != 'object' ) {
dismissed = [];
$( this ).on(
'click',
'.notice-dismiss',
function ( e ) {
dismissed =
acf.getPreference( 'dismissed-notices' );
if (
! dismissed ||
typeof dismissed != 'object'
) {
dismissed = [];
}
dismissed.push(
$( this )
.closest( '.acf-admin-notice' )
.data( 'persist-id' )
);
acf.setPreference(
'dismissed-notices',
dismissed
);
}
dismissed.push( $( this ).closest( '.acf-admin-notice' ).data( 'persist-id' ) );
acf.setPreference( 'dismissed-notices', dismissed );
} );
);
}
}
} );
Expand Down
Loading
Loading