diff --git a/.eslines.json b/.eslines.json deleted file mode 100644 index 236c65421..000000000 --- a/.eslines.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "branches": { - "default": ["downgrade-unmodified-lines"] - }, - "processors": { - "downgrade-unmodified-lines": { - "remote": "origin/master", - "rulesNotToDowngrade": ["no-unused-vars"] - } - } -} diff --git a/.eslintignore b/.eslintignore index 560e3dbb0..50f443537 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1 +1,4 @@ *.build.js +node_modules +vendor +*.php diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 000000000..fe197efc2 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,38 @@ +require( '@automattic/eslint-plugin-wpvip/init' ); + +module.exports = { + extends: [ 'plugin:@automattic/wpvip/recommended' ], + root: true, + env: { + jest: true, + }, + rules: { + "no-prototype-builtins": 0, + "no-eval": 0, + "complexity": 0, + "camelcase": 0, + "no-undef": 0, + "wpcalypso/import-docblock": 0, + "valid-jsdoc": 0, + "react/prop-types": 0, + "react/react-in-jsx-scope": 0, + "react-hooks/rules-of-hooks": 0, + "no-redeclare": 0, + "no-shadow": 0, + "no-nested-ternary": 0, + "no-var": 0, + "no-unused-vars": 0, + "no-useless-escape": 0, + "prefer-const": 0, + "no-global-assign": 0, + "no-constant-binary-expression": 0, + "valid-typeof": 0, + "eqeqeq": 0, + "radix": 0, + "no-eq-null": 0, + "array-callback-return": 0, + "no-unused-expressions": 0, + "no-alert": 0, + "no-lonely-if": 0, + } +}; diff --git a/.github/workflows/e2e-and-js-tests.yml b/.github/workflows/e2e-and-js-tests.yml index c50a8b5e3..6c2139434 100644 --- a/.github/workflows/e2e-and-js-tests.yml +++ b/.github/workflows/e2e-and-js-tests.yml @@ -31,11 +31,11 @@ jobs: - name: Install WordPress with wp-env run: npm run wp-env start + - name: Run Lint JS + run: npm run lint-js + - name: Run JS tests (Jest) run: npm run test-jest - name: Run E2E tests run: npm run test-e2e - - - name: Run Lint JS - run: npm run lint-js diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 000000000..b1d9a501f --- /dev/null +++ b/.prettierignore @@ -0,0 +1,6 @@ +node_modules +vendor +*.php +package-lock.json +package.json +*.build.js diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 000000000..fd45d3e2f --- /dev/null +++ b/.prettierrc @@ -0,0 +1 @@ +"@automattic/eslint-plugin-wpvip/prettierrc" diff --git a/blocks/dist/custom-status.build.js b/blocks/dist/custom-status.build.js index 3fcab0525..258592f84 100644 --- a/blocks/dist/custom-status.build.js +++ b/blocks/dist/custom-status.build.js @@ -1,2 +1,2 @@ -!function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=1)}([function(t,e){t.exports=React},function(t,e,n){"use strict";n.r(e);var r=n(0),o=n.n(r),i=(n(2),n(4),wp.i18n.__),u=wp.editPost.PluginPostStatusInfo,s=wp.plugins.registerPlugin,a=wp.data,l=a.subscribe,c=a.dispatch,d=a.select,f=a.withSelect,p=a.withDispatch,v=wp.compose.compose,b=wp.components.SelectControl,m=window.EditFlowCustomStatuses.map(function(t){return{label:t.name,value:t.slug}}),w=null;function y(t){t&&t.children<1&&(t.innerText===i("Save Draft")||t.innerText===i("Save as Pending"))&&(t.innerText=i("Save"))}l(function(){d("core/editor").getCurrentPostId()&&(d("core/editor").isCleanNewPost()&&c("core/editor").editPost({status:ef_default_custom_status}),y(document.querySelector(".editor-post-save-draft")),null===w&&window.MutationObserver&&d("core/editor").isSavingPost()&&(w=function(t){if(!t)return null;var e=new MutationObserver(function(t){var e=!0,n=!1,r=void 0;try{for(var o,i=t[Symbol.iterator]();!(e=(o=i.next()).done);e=!0){var u=o.value,s=!0,a=!1,l=void 0;try{for(var c,d=u.addedNodes[Symbol.iterator]();!(s=(c=d.next()).done);s=!0){var f=c.value;y(f)}}catch(t){a=!0,l=t}finally{try{s||null==d.return||d.return()}finally{if(a)throw l}}}}catch(t){n=!0,r=t}finally{try{e||null==i.return||i.return()}finally{if(n)throw r}}});return e.observe(t,{childList:!0}),e}(document.querySelector(".edit-post-header__settings"))))});s("edit-flow-custom-status",{icon:"edit-flow",render:v(f(function(t){return{status:t("core/editor").getEditedPostAttribute("status")}}),p(function(t){return{onUpdate:function(e){t("core/editor").editPost({status:e})}}}))(function(t){var e=t.onUpdate,n=t.status;return o.a.createElement(u,{className:"edit-flow-extended-post-status edit-flow-extended-post-status-".concat(n)},o.a.createElement("h4",null,i("publish"!==n?"Extended Post Status":"Extended Post Status Disabled.","edit-flow")),"publish"!==n?o.a.createElement(b,{label:"",value:n,options:m,onChange:e}):null,o.a.createElement("small",{className:"edit-flow-extended-post-status-note"},i("publish"!==n?"Note: this will override all status settings above.":"To select a custom status, please unpublish the content first.","edit-flow")))})})},function(t,e){},,function(t,e){}]); +!function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=1)}([function(t,e){t.exports=React},function(t,e,n){"use strict";n.r(e);var r=n(0),o=n.n(r);n(2),n(4);function i(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(!t)return;if("string"==typeof t)return u(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return u(t,e)}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,o=function(){};return{s:o,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){s=!0,i=t},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw i}}}}function u(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n ({ label: s.name, value: s.slug }) ); +const statuses = window.EditFlowCustomStatuses.map( s => ( { label: s.name, value: s.slug } ) ); /** * Subscribe to changes so we can set a default status and update a button's text. @@ -28,7 +28,7 @@ subscribe( function () { const isCleanNewPost = select( 'core/editor' ).isCleanNewPost(); if ( isCleanNewPost ) { dispatch( 'core/editor' ).editPost( { - status: ef_default_custom_status + status: ef_default_custom_status, } ); } @@ -36,8 +36,14 @@ subscribe( function () { maybeUpdateButtonText( document.querySelector( '.editor-post-save-draft' ) ); // The post is being saved, so we need to set up an observer to update the button text when it's back. - if ( buttonTextObserver === null && window.MutationObserver && select( 'core/editor' ).isSavingPost() ) { - buttonTextObserver = createButtonObserver( document.querySelector( '.edit-post-header__settings' ) ); + if ( + buttonTextObserver === null && + window.MutationObserver && + select( 'core/editor' ).isSavingPost() + ) { + buttonTextObserver = createButtonObserver( + document.querySelector( '.edit-post-header__settings' ) + ); } } ); @@ -53,7 +59,7 @@ function createButtonObserver( parentNode ) { return null; } - const observer = new MutationObserver( ( mutationsList ) => { + const observer = new MutationObserver( mutationsList => { for ( const mutation of mutationsList ) { for ( const node of mutation.addedNodes ) { maybeUpdateButtonText( node ); @@ -66,11 +72,16 @@ function createButtonObserver( parentNode ) { } function maybeUpdateButtonText( saveButton ) { - /* + /* * saveButton.children < 1 accounts for when a user hovers over the save button * and a tooltip is rendered - */ - if ( saveButton && saveButton.children < 1 && ( saveButton.innerText === __( 'Save Draft' ) || saveButton.innerText === __( 'Save as Pending' ) ) ) { + */ + if ( + saveButton && + saveButton.children < 1 && + ( saveButton.innerText === __( 'Save Draft' ) || + saveButton.innerText === __( 'Save as Pending' ) ) + ) { saveButton.innerText = __( 'Save' ); } } @@ -79,48 +90,51 @@ function maybeUpdateButtonText( saveButton ) { * Custom status component * @param object props */ -let EditFlowCustomPostStati = ( { onUpdate, status } ) => ( - -

{ status !== 'publish' ? __( 'Extended Post Status', 'edit-flow' ) : __( 'Extended Post Status Disabled.', 'edit-flow' ) }

- - { status !== 'publish' ? : null } - - - { status !== 'publish' ? __( `Note: this will override all status settings above.`, 'edit-flow' ) : __( 'To select a custom status, please unpublish the content first.', 'edit-flow' ) } - -
+const EditFlowCustomPostStati = ( { onUpdate, status } ) => ( + +

+ { status !== 'publish' + ? __( 'Extended Post Status', 'edit-flow' ) + : __( 'Extended Post Status Disabled.', 'edit-flow' ) } +

+ + { status !== 'publish' ? ( + + ) : null } + + + { status !== 'publish' + ? __( 'Note: this will override all status settings above.', 'edit-flow' ) + : __( 'To select a custom status, please unpublish the content first.', 'edit-flow' ) } + +
); -const mapSelectToProps = ( select ) => { - return { - status: select('core/editor').getEditedPostAttribute('status'), - }; +const mapSelectToProps = select => { + return { + status: select( 'core/editor' ).getEditedPostAttribute( 'status' ), + }; }; -const mapDispatchToProps = ( dispatch ) => { - return { - onUpdate( status ) { - dispatch( 'core/editor' ).editPost( { status } ); - }, - }; +const mapDispatchToProps = dispatch => { + return { + onUpdate( status ) { + dispatch( 'core/editor' ).editPost( { status } ); + }, + }; }; -let plugin = compose( - withSelect( mapSelectToProps ), - withDispatch( mapDispatchToProps ) +const plugin = compose( + withSelect( mapSelectToProps ), + withDispatch( mapDispatchToProps ) )( EditFlowCustomPostStati ); /** * Kick it off */ registerPlugin( 'edit-flow-custom-status', { - icon: 'edit-flow', - render: plugin + icon: 'edit-flow', + render: plugin, } ); diff --git a/modules/calendar/lib/calendar.js b/modules/calendar/lib/calendar.js index c553af8bc..879f5ef4e 100644 --- a/modules/calendar/lib/calendar.js +++ b/modules/calendar/lib/calendar.js @@ -1,56 +1,50 @@ -var dispatch = wp.data.dispatch; +const dispatch = wp.data.dispatch; -jQuery(document).ready(function ($) { - - $('a.show-more').on( 'click', function(){ - var parent = $(this).closest('td.day-unit'); - $('ul li', parent).removeClass('hidden'); - $(this).hide(); +jQuery( document ).ready( function ( $ ) { + $( 'a.show-more' ).on( 'click', function () { + const parent = $( this ).closest( 'td.day-unit' ); + $( 'ul li', parent ).removeClass( 'hidden' ); + $( this ).hide(); return false; - }); + } ); /** * Listen for click event and subsitute correct type of replacement * html given the input type */ - $('.day-unit').on('click', '.editable-value', function( event ) { + $( '.day-unit' ).on( 'click', '.editable-value', function ( event ) { //Reset anything that was currently being edited. reset_editorial_metadata(); - var t = this, - $editable_el = $(this).addClass('hidden').next('.editable-html'); - - if( $editable_el.children().first().is( 'select' ) ) { - $editable_el.find('option') - .each( function() { - if( $(this).text() == $(t).text() ) { - $(this).attr('selected', 'selected' ); - } - }); - } + const t = this; + const $editable_el = $( this ).addClass( 'hidden' ).next( '.editable-html' ); - $editable_el.removeClass('hidden') - .addClass('editing') - .closest('.day-item') - .find('.item-actions .save') - .removeClass('hidden'); + if ( $editable_el.children().first().is( 'select' ) ) { + $editable_el.find( 'option' ).each( function () { + if ( $( this ).text() == $( t ).text() ) { + $( this ).attr( 'selected', 'selected' ); + } + } ); + } - }); + $editable_el + .removeClass( 'hidden' ) + .addClass( 'editing' ) + .closest( '.day-item' ) + .find( '.item-actions .save' ) + .removeClass( 'hidden' ); + } ); //Save the editorial metadata we've changed - $('.day-unit').on('click', 'a#save-editorial-metadata', function() { - var post_id = $(this).attr('class').replace('post-', ''); - save_editorial_metadata(post_id); + $( '.day-unit' ).on( 'click', 'a#save-editorial-metadata', function () { + const post_id = $( this ).attr( 'class' ).replace( 'post-', '' ); + save_editorial_metadata( post_id ); return false; - }); - + } ); function reset_editorial_metadata() { - $('.editing').removeClass('editing') - .addClass('hidden') - .prev() - .removeClass('hidden'); + $( '.editing' ).removeClass( 'editing' ).addClass( 'hidden' ).prev().removeClass( 'hidden' ); - $('.item-actions .save').addClass('hidden'); + $( '.item-actions .save' ).addClass( 'hidden' ); } /** @@ -58,191 +52,198 @@ jQuery(document).ready(function ($) { * Save the editorial metadata that's been edited (whatever is marked '#actively-editing'). * @param post_id Id of post we're editing */ - function save_editorial_metadata(post_id) { - var metadata_info = { + function save_editorial_metadata( post_id ) { + const metadata_info = { action: 'ef_calendar_update_metadata', - nonce: $("#ef-calendar-modify").val(), - metadata_type: $('.editing').attr('data-type'), - metadata_value: $('.editing').children().first().val(), - metadata_term: $('.editing').attr('data-metadataterm'), - post_id: post_id + nonce: $( '#ef-calendar-modify' ).val(), + metadata_type: $( '.editing' ).attr( 'data-type' ), + metadata_value: $( '.editing' ).children().first().val(), + metadata_term: $( '.editing' ).attr( 'data-metadataterm' ), + post_id, }; - $('.editing').addClass('hidden') - .after($('
').show()); + $( '.editing' ) + .addClass( 'hidden' ) + .after( $( '
' ).show() ); // Send the request - jQuery.ajax({ - type : 'POST', - url : (ajaxurl) ? ajaxurl : wpListL10n.url, - data : metadata_info, - success : function(x) { - var val = $('.editing').children().first(); - if( val.is('select') ) { - val = val.find('option:selected').text(); + jQuery.ajax( { + type: 'POST', + url: ajaxurl ? ajaxurl : wpListL10n.url, + data: metadata_info, + success( x ) { + let val = $( '.editing' ).children().first(); + if ( val.is( 'select' ) ) { + val = val.find( 'option:selected' ).text(); } else { val = val.val(); } - $('.editing').next() - .remove(); + $( '.editing' ).next().remove(); - $('.editing').addClass('hidden') - .removeClass('editing') + $( '.editing' ) + .addClass( 'hidden' ) + .removeClass( 'editing' ) .prev() - .removeClass('hidden') - .text(val); + .removeClass( 'hidden' ) + .text( val ); - reset_editorial_metadata(); + reset_editorial_metadata(); }, - error : function(r) { - $('.editing').next('.spinner').replaceWith('Error saving metadata.'); - } - }); - + error( r ) { + $( '.editing' ) + .next( '.spinner' ) + .replaceWith( 'Error saving metadata.' ); + }, + } ); } - + // Hide a message. Used by setTimeout() function edit_flow_calendar_hide_message() { - $('.edit-flow-message').fadeOut(function(){ $(this).remove(); }); + $( '.edit-flow-message' ).fadeOut( function () { + $( this ).remove(); + } ); } - + // Close out all of the overlays with your escape key, // or by clicking anywhere other than inside an existing overlay - $(document).on( 'keydown', function(event) { - if (event.keyCode == '27') { + $( document ).on( 'keydown', function ( event ) { + if ( event.keyCode == '27' ) { edit_flow_calendar_close_overlays(); } - }); - + } ); + /** * Somewhat hackish way to close overlays automagically when you click outside an overlay */ - $(document).on( 'click', function(event){ + $( document ).on( 'click', function ( event ) { //Did we click on a list item? How do we figure that out? //First let's see if we directly clicked on a .day-item - var target = $(event.target); + let target = $( event.target ); //Case where we've clicked on the list item directly - if( target.hasClass('day-item') ) { - if( target.hasClass('active') ) { + if ( target.hasClass( 'day-item' ) ) { + if ( target.hasClass( 'active' ) ) { return; - } - else if( target.hasClass( 'post-insert-overlay' ) ) { + } else if ( target.hasClass( 'post-insert-overlay' ) ) { return; } - else { - edit_flow_calendar_close_overlays(); - target.addClass('active') - .find('.item-static') - .removeClass('item-static') - .addClass('item-overlay'); + edit_flow_calendar_close_overlays(); - return; - } + target + .addClass( 'active' ) + .find( '.item-static' ) + .removeClass( 'item-static' ) + .addClass( 'item-overlay' ); + + return; } //Case where we've clicked in the list item - target = target.closest('.day-item'); - if( target.length ) { - if( target.hasClass('day-item') ) { - if( target.hasClass('active') ) { + target = target.closest( '.day-item' ); + if ( target.length ) { + if ( target.hasClass( 'day-item' ) ) { + if ( target.hasClass( 'active' ) ) { return; - } - else if( target.hasClass( 'post-insert-overlay' ) ) { + } else if ( target.hasClass( 'post-insert-overlay' ) ) { return; } - else { - edit_flow_calendar_close_overlays(); - target.addClass('active') - .find('.item-static') - .removeClass('item-static') - .addClass('item-overlay'); + edit_flow_calendar_close_overlays(); - return; - } + target + .addClass( 'active' ) + .find( '.item-static' ) + .removeClass( 'item-static' ) + .addClass( 'item-overlay' ); + + return; } } - target = $(event.target).closest('#ui-datepicker-div'); - if( target.length ) + target = $( event.target ).closest( '#ui-datepicker-div' ); + if ( target.length ) { return; + } - target = $(event.target).closest('.post-insert-dialog'); - if( target.length ) + target = $( event.target ).closest( '.post-insert-dialog' ); + if ( target.length ) { return; + } edit_flow_calendar_close_overlays(); - }); + } ); function edit_flow_calendar_close_overlays() { reset_editorial_metadata(); - $('.day-item.active').removeClass('active') - .find('.item-overlay').removeClass('item-overlay') - .addClass('item-static'); + $( '.day-item.active' ) + .removeClass( 'active' ) + .find( '.item-overlay' ) + .removeClass( 'item-overlay' ) + .addClass( 'item-static' ); - $('.post-insert-overlay').remove(); + $( '.post-insert-overlay' ).remove(); } - + /** * Instantiates drag and drop sorting for posts on the calendar */ let snackbarMessageTimeout = null; - $('td.day-unit ul').sortable({ + $( 'td.day-unit ul' ).sortable( { items: 'li.day-item.sortable', connectWith: 'td.day-unit ul', placeholder: 'ui-state-highlight', - start: function(event, ui) { - $(this).disableSelection(); + start( event, ui ) { + $( this ).disableSelection(); edit_flow_calendar_close_overlays(); - $('td.day-unit ul li').unbind('click.ef-calendar-show-overlay'); - $(this).css('cursor','move'); + $( 'td.day-unit ul li' ).unbind( 'click.ef-calendar-show-overlay' ); + $( this ).css( 'cursor', 'move' ); }, - sort: function(event, ui) { - $('td.day-unit').removeClass('ui-wrapper-highlight'); - $('.ui-state-highlight').closest('td.day-unit').addClass('ui-wrapper-highlight'); + sort( event, ui ) { + $( 'td.day-unit' ).removeClass( 'ui-wrapper-highlight' ); + $( '.ui-state-highlight' ).closest( 'td.day-unit' ).addClass( 'ui-wrapper-highlight' ); }, - stop: function(event, ui) { - $(this).css('cursor','auto'); - $('td.day-unit').removeClass('ui-wrapper-highlight'); + stop( event, ui ) { + $( this ).css( 'cursor', 'auto' ); + $( 'td.day-unit' ).removeClass( 'ui-wrapper-highlight' ); // Only do a POST request if we moved the post off today - if ( $(this).closest('.day-unit').attr('id') != $(ui.item).closest('.day-unit').attr('id') ) { - var post_id = $(ui.item).attr('id').split('-'); - post_id = post_id[post_id.length - 1]; - var prev_date = $(this).closest('.day-unit').attr('id'); - var next_date = $(ui.item).closest('.day-unit').attr('id'); - var nonce = $(document).find('#ef-calendar-modify').val(); - $('.edit-flow-message').remove(); + if ( + $( this ).closest( '.day-unit' ).attr( 'id' ) != + $( ui.item ).closest( '.day-unit' ).attr( 'id' ) + ) { + let post_id = $( ui.item ).attr( 'id' ).split( '-' ); + post_id = post_id[ post_id.length - 1 ]; + const prev_date = $( this ).closest( '.day-unit' ).attr( 'id' ); + const next_date = $( ui.item ).closest( '.day-unit' ).attr( 'id' ); + const nonce = $( document ).find( '#ef-calendar-modify' ).val(); + $( '.edit-flow-message' ).remove(); dispatch( 'edit-flow/calendar' ).setCalendarIsLoading( true ); // $('li.ajax-actions .waiting').show(); // make ajax request - var params = { + const params = { action: 'ef_calendar_drag_and_drop', - post_id: post_id, - prev_date: prev_date, - next_date: next_date, - nonce: nonce + post_id, + prev_date, + next_date, + nonce, }; - jQuery.post(ajaxurl, params, - function(response) { - if ( snackbarMessageTimeout ) { - clearTimeout( snackbarMessageTimeout ); - } + jQuery.post( ajaxurl, params, function ( response ) { + if ( snackbarMessageTimeout ) { + clearTimeout( snackbarMessageTimeout ); + } - dispatch( 'edit-flow/calendar' ).setPostSaved( response.message ); + dispatch( 'edit-flow/calendar' ).setPostSaved( response.message ); - snackbarMessageTimeout = setTimeout( () => { - dispatch( 'edit-flow/calendar' ).clearCalendarSnackbarMessage(); - }, 2500 ); - - setTimeout( edit_flow_calendar_hide_message, 10000 ); - } - ); + snackbarMessageTimeout = setTimeout( () => { + dispatch( 'edit-flow/calendar' ).clearCalendarSnackbarMessage(); + }, 2500 ); + + setTimeout( edit_flow_calendar_hide_message, 10000 ); + } ); } - $(this).enableSelection(); - } - }); + $( this ).enableSelection(); + }, + } ); // Enables quick creation/edit of drafts on a particular date from the calendar var EFQuickPublish = { @@ -251,16 +252,21 @@ jQuery(document).ready(function ($) { * double clicks on a calendar square pop up a form that allows * them to create a post for that date */ - init : function(){ - - var $day_units = $('td.day-unit'); + init() { + const $day_units = $( 'td.day-unit' ); // Bind the form display to the '+' button // or to a double click on the calendar square - $day_units.find('.schedule-new-post-button').on('click.editFlow.quickPublish', EFQuickPublish.open_quickpost_dialogue ); - $day_units.on('dblclick.editFlow.quickPublish', EFQuickPublish.open_quickpost_dialogue ); - $day_units.on( 'mouseenter', function(){ $(this).find('.schedule-new-post-button').stop().delay(500).fadeIn(100);}); - $day_units.on( 'mouseleave', function(){ $(this).find('.schedule-new-post-button').stop().hide();}); + $day_units + .find( '.schedule-new-post-button' ) + .on( 'click.editFlow.quickPublish', EFQuickPublish.open_quickpost_dialogue ); + $day_units.on( 'dblclick.editFlow.quickPublish', EFQuickPublish.open_quickpost_dialogue ); + $day_units.on( 'mouseenter', function () { + $( this ).find( '.schedule-new-post-button' ).stop().delay( 500 ).fadeIn( 100 ); + } ); + $day_units.on( 'mouseleave', function () { + $( this ).find( '.schedule-new-post-button' ).stop().hide(); + } ); }, // init /** @@ -268,106 +274,106 @@ jQuery(document).ready(function ($) { * quickpost dialogue * @param Event e The user interaction event */ - open_quickpost_dialogue : function(e){ - + open_quickpost_dialogue( e ) { e.preventDefault(); // Close other overlays edit_flow_calendar_close_overlays(); - $this = $(this); + $this = $( this ); // Get the current calendar square - if( $this.is('td.day-unit') ) + if ( $this.is( 'td.day-unit' ) ) { EFQuickPublish.$current_date_square = $this; - else if( $this.is('.schedule-new-post-button') ) + } else if ( $this.is( '.schedule-new-post-button' ) ) { EFQuickPublish.$current_date_square = $this.parent(); + } //Get our form content - var $new_post_form_content = EFQuickPublish.$current_date_square.find('.post-insert-dialog'); + const $new_post_form_content = + EFQuickPublish.$current_date_square.find( '.post-insert-dialog' ); //Inject the form (it will automatically be removed on click-away because of its 'item-overlay' class) - EFQuickPublish.$new_post_form = $new_post_form_content.clone().addClass('item-overlay post-insert-overlay').appendTo(EFQuickPublish.$current_date_square); - + EFQuickPublish.$new_post_form = $new_post_form_content + .clone() + .addClass( 'item-overlay post-insert-overlay' ) + .appendTo( EFQuickPublish.$current_date_square ); + // Get the inputs and controls for this injected form and focus the cursor on the post title box - var $edit_post_link = EFQuickPublish.$new_post_form.find('.post-insert-dialog-edit-post-link'); - EFQuickPublish.$post_title_input = EFQuickPublish.$new_post_form.find('.post-insert-dialog-post-title').focus(); + const $edit_post_link = EFQuickPublish.$new_post_form.find( + '.post-insert-dialog-edit-post-link' + ); + EFQuickPublish.$post_title_input = EFQuickPublish.$new_post_form + .find( '.post-insert-dialog-post-title' ) + .focus(); // Setup the ajax mechanism for form submit - EFQuickPublish.$new_post_form.on( 'submit', function(e){ + EFQuickPublish.$new_post_form.on( 'submit', function ( e ) { e.preventDefault(); - EFQuickPublish.ajax_ef_create_post(false); - }); + EFQuickPublish.ajax_ef_create_post( false ); + } ); // Setup direct link to new draft - $edit_post_link.on( 'click', function(e){ + $edit_post_link.on( 'click', function ( e ) { e.preventDefault(); - EFQuickPublish.ajax_ef_create_post(true); + EFQuickPublish.ajax_ef_create_post( true ); } ); return false; // prevent bubbling up - }, /** * Sends an ajax request to create a new post * @param bool redirect_to_draft Whether or not we should be redirected to the post's edit screen on success */ - ajax_ef_create_post : function( redirect_to_draft ){ - + ajax_ef_create_post( redirect_to_draft ) { // Get some of the form elements for later use - var $submit_controls = EFQuickPublish.$new_post_form.find('.post-insert-dialog-controls'); - var $spinner = EFQuickPublish.$new_post_form.find('.spinner'); + const $submit_controls = EFQuickPublish.$new_post_form.find( '.post-insert-dialog-controls' ); + const $spinner = EFQuickPublish.$new_post_form.find( '.spinner' ); // Set loading animation $submit_controls.hide(); $spinner.show(); // Delay submit to prevent spinner flashing - setTimeout( function(){ - - jQuery.ajax({ - + setTimeout( function () { + jQuery.ajax( { type: 'POST', url: ajaxurl, dataType: 'json', data: { action: 'ef_insert_post', - ef_insert_date: EFQuickPublish.$new_post_form.find('input.post-insert-dialog-post-date').val(), + ef_insert_date: EFQuickPublish.$new_post_form + .find( 'input.post-insert-dialog-post-date' ) + .val(), ef_insert_title: EFQuickPublish.$post_title_input.val(), - nonce: $(document).find('#ef-calendar-modify').val() + nonce: $( document ).find( '#ef-calendar-modify' ).val(), }, - success: function( response, textStatus, XMLHttpRequest ) { - - if( response.status == 'success' ){ - + success( response, textStatus, XMLHttpRequest ) { + if ( response.status == 'success' ) { //The response message on success is the html for the a post list item - var $new_post = $(response.message); + const $new_post = $( response.message ); - if( redirect_to_draft ) { + if ( redirect_to_draft ) { //If user clicked on the 'edit post' link, let's send them to the new post - var edit_url = $new_post.find('.item-actions .edit a').attr('href'); + const edit_url = $new_post.find( '.item-actions .edit a' ).attr( 'href' ); window.location = edit_url; } else { // Otherwise, inject the new post and bind the appropriate click event - $new_post.appendTo( EFQuickPublish.$current_date_square.find('ul.post-list') ); + $new_post.appendTo( EFQuickPublish.$current_date_square.find( 'ul.post-list' ) ); edit_flow_calendar_close_overlays(); } - } else { EFQuickPublish.display_errors( EFQuickPublish.$new_post_form, response.message ); } }, - error: function( XMLHttpRequest, textStatus, errorThrown ) { + error( XMLHttpRequest, textStatus, errorThrown ) { EFQuickPublish.display_errors( EFQuickPublish.$new_post_form, errorThrown ); - } - - }); // .ajax + }, + } ); // .ajax return false; // prevent bubbling up - - }, 200); // setTimout - + }, 200 ); // setTimout }, // ajax_ef_create_post /** @@ -375,20 +381,19 @@ jQuery(document).ready(function ($) { * @param jQueryObj $form The form to display the errors in * @param str error_msg Error message */ - display_errors : function( $form, error_msg ){ - - $form.find('.error').remove(); // clear out old errors - $form.find('.spinner').hide(); // stop the loading animation + display_errors( $form, error_msg ) { + $form.find( '.error' ).remove(); // clear out old errors + $form.find( '.spinner' ).hide(); // stop the loading animation // show submit controls and the error - $form.find('.post-insert-dialog-controls').show().before('
Error: '+error_msg+'
'); - - } // display_errors - + $form + .find( '.post-insert-dialog-controls' ) + .show() + .before( '
Error: ' + error_msg + '
' ); + }, // display_errors }; - if( ef_calendar_params.can_add_posts === 'true' ) + if ( ef_calendar_params.can_add_posts === 'true' ) { EFQuickPublish.init(); - -}); - + } +} ); diff --git a/modules/calendar/lib/dist/calendar.react.build.js b/modules/calendar/lib/dist/calendar.react.build.js index eaa4590ec..5484e2cd3 100644 --- a/modules/calendar/lib/dist/calendar.react.build.js +++ b/modules/calendar/lib/dist/calendar.react.build.js @@ -1,15 +1,9 @@ !function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=14)}([function(e,t,n){e.exports=n(11)()},function(e,t){e.exports=React},function(e,t){e.exports=wp.i18n},function(e,t){e.exports=wp.components},function(e,t,n){var r; /*! - Copyright (c) 2017 Jed Watson. - Licensed under the MIT License (MIT), see - http://jedwatson.github.io/classnames -*/ -/*! - Copyright (c) 2017 Jed Watson. - Licensed under the MIT License (MIT), see - http://jedwatson.github.io/classnames -*/ -!function(){"use strict";var n={}.hasOwnProperty;function o(){for(var e=[],t=0;t=0||(o[n]=e[n]);return o}function h(){return(h=Object.assign||function(e){for(var t=1;tt||a>e&&i=t&&u>=n?a-e-r:i>t&&un?i-t+o:0}var S=function(e,t){var n=t.scrollMode,r=t.block,o=t.inline,a=t.boundary,i=t.skipOverflowHiddenElements,u="function"==typeof a?a:function(e){return e!==a};if(!y(e))throw new TypeError("Invalid target");for(var l=document.scrollingElement||document.documentElement,s=[],c=e;y(c)&&u(c);){if((c=c.parentNode)===l){s.push(c);break}c===document.body&&I(c)&&!I(document.documentElement)||I(c,i)&&s.push(c)}for(var f=window.visualViewport?visualViewport.width:innerWidth,p=window.visualViewport?visualViewport.height:innerHeight,d=window.scrollX||pageXOffset,m=window.scrollY||pageYOffset,g=e.getBoundingClientRect(),h=g.height,b=g.width,v=g.top,S=g.right,E=g.bottom,w=g.left,A="start"===r||"nearest"===r?v:"end"===r?E:v+h/2,C="center"===o?w+b/2:"end"===o?S:w,_=[],x=0;x=0&&w>=0&&E<=p&&S<=f&&v>=N&&E<=M&&w>=j&&S<=P)return _;var D=getComputedStyle(k),H=parseInt(D.borderLeftWidth,10),V=parseInt(D.borderTopWidth,10),B=parseInt(D.borderRightWidth,10),F=parseInt(D.borderBottomWidth,10),U=0,K=0,W="offsetWidth"in k?k.offsetWidth-k.clientWidth-H-B:0,Y="offsetHeight"in k?k.offsetHeight-k.clientHeight-V-F:0;if(l===k)U="start"===r?A:"end"===r?A-p:"nearest"===r?O(m,m+p,p,V,F,m+A,m+A+h,h):A-p/2,K="start"===o?C:"center"===o?C-f/2:"end"===o?C-f:O(d,d+f,f,H,B,d+C,d+C+b,b),U=Math.max(0,U+m),K=Math.max(0,K+d);else{U="start"===r?A-N-V:"end"===r?A-M+F+Y:"nearest"===r?O(N,M,L,V,F+Y,A,A+h,h):A-(N+L/2)+Y/2,K="start"===o?C-j-H:"center"===o?C-(j+R/2)+W/2:"end"===o?C-P+B+W:O(j,P,R,H,B+W,C,C+b,b);var $=k.scrollLeft,G=k.scrollTop;A+=G-(U=Math.max(0,Math.min(G+U,k.scrollHeight-L+Y))),C+=$-(K=Math.max(0,Math.min($+K,k.scrollWidth-R+W)))}_.push({el:k,top:U,left:K})}return _},E=0;function w(e){return"function"==typeof e?e:A}function A(){}function C(e,t){null!==e&&S(e,{boundary:t,block:"nearest",scrollMode:"if-needed"}).forEach(function(e){var t=e.el,n=e.top,r=e.left;t.scrollTop=n,t.scrollLeft=r})}function _(e,t){return e===t||e.contains&&e.contains(t)}function x(e,t){var n;function r(){n&&clearTimeout(n)}function o(){for(var o=arguments.length,a=new Array(o),i=0;i1?n-1:0),o=1;o=37&&n<=40&&0!==t.indexOf("Arrow")?"Arrow"+t:t}function F(e,t,n,r,o){void 0===o&&(o=!0);var a=n-1;("number"!=typeof t||t<0||t>=n)&&(t=e>0?-1:a+1);var i=t+e;i<0?i=o?a:0:i>a&&(i=o?0:a);var u=U(e,i,n,r,o);return-1===u?t:u}function U(e,t,n,r,o){var a=r(t);if(!a||!a.hasAttribute("disabled"))return t;if(e>0){for(var i=t+1;i=0;u--)if(!r(u).hasAttribute("disabled"))return u;return o?e>0?U(1,0,n,r,!1):U(-1,n-1,n,r,!1):-1}function K(e,t,n,r){return void 0===r&&(r=!0),t.some(function(t){return t&&(_(t,e)||r&&_(t,n.activeElement))})}var W=x(function(){$().textContent=""},500);function Y(e,t){var n=$(t);e&&(n.textContent=e,W())}function $(e){void 0===e&&(e=document);var t=e.getElementById("a11y-status-message");return t||((t=e.createElement("div")).setAttribute("id","a11y-status-message"),t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t.setAttribute("aria-relevant","additions text"),Object.assign(t.style,{border:"0",clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:"0",position:"absolute",width:"1px"}),e.body.appendChild(t),t)}var G=0,X=2,Q=3,z=4,q=5,Z=6,J=7,ee=8,te=9,ne=10,re=11,oe=12,ae=13,ie=14,ue=Object.freeze({__proto__:null,unknown:G,mouseUp:1,itemMouseEnter:X,keyDownArrowUp:Q,keyDownArrowDown:z,keyDownEscape:q,keyDownEnter:Z,keyDownHome:J,keyDownEnd:ee,clickItem:te,blurInput:ne,changeInput:re,keyDownSpaceButton:oe,clickButton:ae,blurButton:ie,controlledPropUpdatedSelectedItem:15,touchEnd:16}),le=function(){var e=function(e){var t,n;function o(t){var n=e.call(this,t)||this;n.id=n.props.id||"downshift-"+L(),n.menuId=n.props.menuId||n.id+"-menu",n.labelId=n.props.labelId||n.id+"-label",n.inputId=n.props.inputId||n.id+"-input",n.getItemId=n.props.getItemId||function(e){return n.id+"-item-"+e},n.input=null,n.items=[],n.itemCount=null,n.previousResultCount=0,n.timeoutIds=[],n.internalSetTimeout=function(e,t){var r=setTimeout(function(){n.timeoutIds=n.timeoutIds.filter(function(e){return e!==r}),e()},t);n.timeoutIds.push(r)},n.setItemCount=function(e){n.itemCount=e},n.unsetItemCount=function(){n.itemCount=null},n.setHighlightedIndex=function(e,t){void 0===e&&(e=n.props.defaultHighlightedIndex),void 0===t&&(t={}),t=D(t),n.internalSetState(h({highlightedIndex:e},t))},n.clearSelection=function(e){n.internalSetState({selectedItem:null,inputValue:"",highlightedIndex:n.props.defaultHighlightedIndex,isOpen:n.props.defaultIsOpen},e)},n.selectItem=function(e,t,r){t=D(t),n.internalSetState(h({isOpen:n.props.defaultIsOpen,highlightedIndex:n.props.defaultHighlightedIndex,selectedItem:e,inputValue:n.props.itemToString(e)},t),r)},n.selectItemAtIndex=function(e,t,r){var o=n.items[e];null!=o&&n.selectItem(o,t,r)},n.selectHighlightedItem=function(e,t){return n.selectItemAtIndex(n.getState().highlightedIndex,e,t)},n.internalSetState=function(e,t){var r,o,a={},i="function"==typeof e;return!i&&e.hasOwnProperty("inputValue")&&n.props.onInputValueChange(e.inputValue,h({},n.getStateAndHelpers(),{},e)),n.setState(function(t){t=n.getState(t);var u=i?e(t):e;u=n.props.stateReducer(t,u),r=u.hasOwnProperty("selectedItem");var l={},s={};return r&&u.selectedItem!==t.selectedItem&&(o=u.selectedItem),u.type=u.type||G,Object.keys(u).forEach(function(e){t[e]!==u[e]&&(a[e]=u[e]),"type"!==e&&(s[e]=u[e],V(n.props,e)||(l[e]=u[e]))}),i&&u.hasOwnProperty("inputValue")&&n.props.onInputValueChange(u.inputValue,h({},n.getStateAndHelpers(),{},u)),l},function(){w(t)(),Object.keys(a).length>1&&n.props.onStateChange(a,n.getStateAndHelpers()),r&&n.props.onSelect(e.selectedItem,n.getStateAndHelpers()),void 0!==o&&n.props.onChange(o,n.getStateAndHelpers()),n.props.onUserAction(a,n.getStateAndHelpers())})},n.rootRef=function(e){return n._rootNode=e},n.getRootProps=function(e,t){var r,o=void 0===e?{}:e,a=o.refKey,i=void 0===a?"ref":a,u=o.ref,l=g(o,["refKey","ref"]),s=(void 0===t?{}:t).suppressRefError,c=void 0!==s&&s;n.getRootProps.called=!0,n.getRootProps.refKey=i,n.getRootProps.suppressRefError=c;var f=n.getState().isOpen;return h(((r={})[i]=T(u,n.rootRef),r.role="combobox",r["aria-expanded"]=f,r["aria-haspopup"]="listbox",r["aria-owns"]=f?n.menuId:null,r["aria-labelledby"]=n.labelId,r),l)},n.keyDownHandlers={ArrowDown:function(e){var t=this;if(e.preventDefault(),this.getState().isOpen){var n=e.shiftKey?5:1;this.moveHighlightedIndex(n,{type:z})}else this.internalSetState({isOpen:!0,type:z},function(){var e=t.getItemCount();if(e>0){var n=F(1,t.getState().highlightedIndex,e,function(e){return t.getItemNodeFromIndex(e)});t.setHighlightedIndex(n,{type:z})}})},ArrowUp:function(e){var t=this;if(e.preventDefault(),this.getState().isOpen){var n=e.shiftKey?-5:-1;this.moveHighlightedIndex(n,{type:Q})}else this.internalSetState({isOpen:!0,type:Q},function(){var e=t.getItemCount();if(e>0){var n=F(-1,t.getState().highlightedIndex,e,function(e){return t.getItemNodeFromIndex(e)});t.setHighlightedIndex(n,{type:Q})}})},Enter:function(e){if(229!==e.which){var t=this.getState(),n=t.isOpen,r=t.highlightedIndex;if(n&&null!=r){e.preventDefault();var o=this.items[r],a=this.getItemNodeFromIndex(r);if(null==o||a&&a.hasAttribute("disabled"))return;this.selectHighlightedItem({type:Z})}}},Escape:function(e){e.preventDefault(),this.reset({type:q,selectedItem:null,inputValue:""})}},n.buttonKeyDownHandlers=h({},n.keyDownHandlers,{" ":function(e){e.preventDefault(),this.toggleMenu({type:oe})}}),n.inputKeyDownHandlers=h({},n.keyDownHandlers,{Home:function(e){var t=this;e.preventDefault();var n=this.getItemCount(),r=this.getState().isOpen;if(!(n<=0)&&r){var o=U(1,0,n,function(e){return t.getItemNodeFromIndex(e)},!1);this.setHighlightedIndex(o,{type:J})}},End:function(e){var t=this;e.preventDefault();var n=this.getItemCount(),r=this.getState().isOpen;if(!(n<=0)&&r){var o=U(-1,n-1,n,function(e){return t.getItemNodeFromIndex(e)},!1);this.setHighlightedIndex(o,{type:ee})}}}),n.getToggleButtonProps=function(e){var t=void 0===e?{}:e,r=t.onClick,o=(t.onPress,t.onKeyDown),a=t.onKeyUp,i=t.onBlur,u=g(t,["onClick","onPress","onKeyDown","onKeyUp","onBlur"]),l=n.getState().isOpen,s={onClick:k(r,n.buttonHandleClick),onKeyDown:k(o,n.buttonHandleKeyDown),onKeyUp:k(a,n.buttonHandleKeyUp),onBlur:k(i,n.buttonHandleBlur)};return h({type:"button",role:"button","aria-label":l?"close menu":"open menu","aria-haspopup":!0,"data-toggle":!0},u.disabled?{}:s,{},u)},n.buttonHandleKeyUp=function(e){e.preventDefault()},n.buttonHandleKeyDown=function(e){var t=B(e);n.buttonKeyDownHandlers[t]&&n.buttonKeyDownHandlers[t].call(b(n),e)},n.buttonHandleClick=function(e){e.preventDefault(),n.props.environment.document.activeElement===n.props.environment.document.body&&e.target.focus(),n.internalSetTimeout(function(){return n.toggleMenu({type:ae})})},n.buttonHandleBlur=function(e){var t=e.target;n.internalSetTimeout(function(){n.isMouseDown||null!=n.props.environment.document.activeElement&&n.props.environment.document.activeElement.id===n.inputId||n.props.environment.document.activeElement===t||n.reset({type:ie})})},n.getLabelProps=function(e){return h({htmlFor:n.inputId,id:n.labelId},e)},n.getInputProps=function(e){var t=void 0===e?{}:e,r=t.onKeyDown,o=t.onBlur,a=t.onChange,i=t.onInput,u=(t.onChangeText,g(t,["onKeyDown","onBlur","onChange","onInput","onChangeText"])),l={};var s,c=n.getState(),f=c.inputValue,p=c.isOpen,d=c.highlightedIndex;u.disabled||((s={}).onChange=k(a,i,n.inputHandleChange),s.onKeyDown=k(r,n.inputHandleKeyDown),s.onBlur=k(o,n.inputHandleBlur),l=s);return h({"aria-autocomplete":"list","aria-activedescendant":p&&"number"==typeof d&&d>=0?n.getItemId(d):null,"aria-controls":p?n.menuId:null,"aria-labelledby":n.labelId,autoComplete:"off",value:f,id:n.inputId},l,{},u)},n.inputHandleKeyDown=function(e){var t=B(e);t&&n.inputKeyDownHandlers[t]&&n.inputKeyDownHandlers[t].call(b(n),e)},n.inputHandleChange=function(e){n.internalSetState({type:re,isOpen:!0,inputValue:e.target.value,highlightedIndex:n.props.defaultHighlightedIndex})},n.inputHandleBlur=function(){n.internalSetTimeout(function(){var e=n.props.environment.document&&!!n.props.environment.document.activeElement&&!!n.props.environment.document.activeElement.dataset&&n.props.environment.document.activeElement.dataset.toggle&&n._rootNode&&n._rootNode.contains(n.props.environment.document.activeElement);n.isMouseDown||e||n.reset({type:ne})})},n.menuRef=function(e){n._menuNode=e},n.getMenuProps=function(e,t){var r,o=void 0===e?{}:e,a=o.refKey,i=void 0===a?"ref":a,u=o.ref,l=g(o,["refKey","ref"]),s=(void 0===t?{}:t).suppressRefError,c=void 0!==s&&s;return n.getMenuProps.called=!0,n.getMenuProps.refKey=i,n.getMenuProps.suppressRefError=c,h(((r={})[i]=T(u,n.menuRef),r.role="listbox",r["aria-labelledby"]=l&&l["aria-label"]?null:n.labelId,r.id=n.menuId,r),l)},n.getItemProps=function(e){var t,r=void 0===e?{}:e,o=r.onMouseMove,a=r.onMouseDown,i=r.onClick,u=(r.onPress,r.index),l=r.item,s=void 0===l?void 0:l,c=g(r,["onMouseMove","onMouseDown","onClick","onPress","index","item"]);void 0===u?(n.items.push(s),u=n.items.indexOf(s)):n.items[u]=s;var f=i,p=((t={onMouseMove:k(o,function(){u!==n.getState().highlightedIndex&&(n.setHighlightedIndex(u,{type:X}),n.avoidScrolling=!0,n.internalSetTimeout(function(){return n.avoidScrolling=!1},250))}),onMouseDown:k(a,function(e){e.preventDefault()})}).onClick=k(f,function(){n.selectItemAtIndex(u,{type:te})}),t),d=c.disabled?{onMouseDown:p.onMouseDown}:p;return h({id:n.getItemId(u),role:"option","aria-selected":n.getState().highlightedIndex===u},d,{},c)},n.clearItems=function(){n.items=[]},n.reset=function(e,t){void 0===e&&(e={}),e=D(e),n.internalSetState(function(t){var r=t.selectedItem;return h({isOpen:n.props.defaultIsOpen,highlightedIndex:n.props.defaultHighlightedIndex,inputValue:n.props.itemToString(r)},e)},t)},n.toggleMenu=function(e,t){void 0===e&&(e={}),e=D(e),n.internalSetState(function(t){var r=t.isOpen;return h({isOpen:!r},r&&{highlightedIndex:n.props.defaultHighlightedIndex},{},e)},function(){var r=n.getState(),o=r.isOpen,a=r.highlightedIndex;o&&n.getItemCount()>0&&"number"==typeof a&&n.setHighlightedIndex(a,e),w(t)()})},n.openMenu=function(e){n.internalSetState({isOpen:!0},e)},n.closeMenu=function(e){n.internalSetState({isOpen:!1},e)},n.updateStatus=x(function(){var e=n.getState(),t=n.items[e.highlightedIndex],r=n.getItemCount(),o=n.props.getA11yStatusMessage(h({itemToString:n.props.itemToString,previousResultCount:n.previousResultCount,resultCount:r,highlightedItem:t},e));n.previousResultCount=r,Y(o,n.props.environment.document)},200);var r=n.props,o=r.defaultHighlightedIndex,a=r.initialHighlightedIndex,i=void 0===a?o:a,u=r.defaultIsOpen,l=r.initialIsOpen,s=void 0===l?u:l,c=r.initialInputValue,f=void 0===c?"":c,p=r.initialSelectedItem,d=void 0===p?null:p,m=n.getState({highlightedIndex:i,isOpen:s,inputValue:f,selectedItem:d});return null!=m.selectedItem&&void 0===n.props.initialInputValue&&(m.inputValue=n.props.itemToString(m.selectedItem)),n.state=m,n}n=e,(t=o).prototype=Object.create(n.prototype),t.prototype.constructor=t,t.__proto__=n;var a=o.prototype;return a.internalClearTimeouts=function(){this.timeoutIds.forEach(function(e){clearTimeout(e)}),this.timeoutIds=[]},a.getState=function(e){return void 0===e&&(e=this.state),H(e,this.props)},a.getItemCount=function(){var e=this.items.length;return null!=this.itemCount?e=this.itemCount:void 0!==this.props.itemCount&&(e=this.props.itemCount),e},a.getItemNodeFromIndex=function(e){return this.props.environment.document.getElementById(this.getItemId(e))},a.scrollHighlightedItemIntoView=function(){var e=this.getItemNodeFromIndex(this.getState().highlightedIndex);this.props.scrollIntoView(e,this._menuNode)},a.moveHighlightedIndex=function(e,t){var n=this,r=this.getItemCount(),o=this.getState().highlightedIndex;if(r>0){var a=F(e,o,r,function(e){return n.getItemNodeFromIndex(e)});this.setHighlightedIndex(a,t)}},a.getStateAndHelpers=function(){var e=this.getState(),t=e.highlightedIndex,n=e.inputValue,r=e.selectedItem,o=e.isOpen,a=this.props.itemToString,i=this.id,u=this.getRootProps,l=this.getToggleButtonProps,s=this.getLabelProps,c=this.getMenuProps,f=this.getInputProps,p=this.getItemProps,d=this.openMenu,m=this.closeMenu,g=this.toggleMenu,h=this.selectItem,b=this.selectItemAtIndex,y=this.selectHighlightedItem,v=this.setHighlightedIndex,I=this.clearSelection,O=this.clearItems;return{getRootProps:u,getToggleButtonProps:l,getLabelProps:s,getMenuProps:c,getInputProps:f,getItemProps:p,reset:this.reset,openMenu:d,closeMenu:m,toggleMenu:g,selectItem:h,selectItemAtIndex:b,selectHighlightedItem:y,setHighlightedIndex:v,clearSelection:I,clearItems:O,setItemCount:this.setItemCount,unsetItemCount:this.unsetItemCount,setState:this.internalSetState,itemToString:a,id:i,highlightedIndex:t,inputValue:n,isOpen:o,selectedItem:r}},a.componentDidMount=function(){var e=this;var t=function(){e.isMouseDown=!0},n=function(t){e.isMouseDown=!1,!K(t.target,[e._rootNode,e._menuNode],e.props.environment.document)&&e.getState().isOpen&&e.reset({type:1},function(){return e.props.onOuterClick(e.getStateAndHelpers())})},r=function(){e.isTouchMove=!1},o=function(){e.isTouchMove=!0},a=function(t){var n=K(t.target,[e._rootNode,e._menuNode],e.props.environment.document,!1);e.isTouchMove||n||!e.getState().isOpen||e.reset({type:16},function(){return e.props.onOuterClick(e.getStateAndHelpers())})},i=this.props.environment;i.addEventListener("mousedown",t),i.addEventListener("mouseup",n),i.addEventListener("touchstart",r),i.addEventListener("touchmove",o),i.addEventListener("touchend",a),this.cleanup=function(){e.internalClearTimeouts(),e.updateStatus.cancel(),i.removeEventListener("mousedown",t),i.removeEventListener("mouseup",n),i.removeEventListener("touchstart",r),i.removeEventListener("touchmove",o),i.removeEventListener("touchend",a)}},a.shouldScroll=function(e,t){var n=(void 0===this.props.highlightedIndex?this.getState():this.props).highlightedIndex,r=(void 0===t.highlightedIndex?e:t).highlightedIndex;return n&&this.getState().isOpen&&!e.isOpen||n!==r},a.componentDidUpdate=function(e,t){V(this.props,"selectedItem")&&this.props.selectedItemChanged(e.selectedItem,this.props.selectedItem)&&this.internalSetState({type:15,inputValue:this.props.itemToString(this.props.selectedItem)}),!this.avoidScrolling&&this.shouldScroll(t,e)&&this.scrollHighlightedItemIntoView(),this.updateStatus()},a.componentWillUnmount=function(){this.cleanup()},a.render=function(){var e=N(this.props.children,A);this.clearItems(),this.getRootProps.called=!1,this.getRootProps.refKey=void 0,this.getRootProps.suppressRefError=void 0,this.getMenuProps.called=!1,this.getMenuProps.refKey=void 0,this.getMenuProps.suppressRefError=void 0,this.getLabelProps.called=!1,this.getInputProps.called=!1;var t=N(e(this.getStateAndHelpers()));return t?this.getRootProps.called||this.props.suppressRefError?t:P(t)?Object(r.cloneElement)(t,this.getRootProps(M(t))):void 0:null},o}(r.Component);return e.defaultProps={defaultHighlightedIndex:null,defaultIsOpen:!1,getA11yStatusMessage:R,itemToString:function(e){return null==e?"":String(e)},onStateChange:A,onInputValueChange:A,onUserAction:A,onChange:A,onSelect:A,onOuterClick:A,selectedItemChanged:function(e,t){return e!==t},environment:"undefined"==typeof window?{}:window,stateReducer:function(e,t){return t},suppressRefError:!1,scrollIntoView:C},e.stateChangeTypes=ue,e}();var se={itemToString:function(e){return e?String(e):""},stateReducer:function(e,t){return t.changes},getA11ySelectionMessage:function(e){var t=e.selectedItem;return(0,e.itemToString)(t)+" has been selected."},scrollIntoView:C,circularNavigation:!1,environment:"undefined"==typeof window?{}:window};s.a.array.isRequired,s.a.func,s.a.func,s.a.func,s.a.bool,s.a.number,s.a.number,s.a.number,s.a.bool,s.a.bool,s.a.bool,s.a.any,s.a.any,s.a.any,s.a.string,s.a.string,s.a.string,s.a.func,s.a.string,s.a.func,s.a.func,s.a.func,s.a.func,s.a.func,s.a.shape({addEventListener:s.a.func,removeEventListener:s.a.func,document:s.a.shape({getElementById:s.a.func,activeElement:s.a.any,body:s.a.any})});h({},se,{getA11yStatusMessage:function(e){var t=e.isOpen,n=e.resultCount;return t?n?n+" result"+(1===n?" is":"s are")+" available, use up and down arrow keys to navigate. Press Enter or Space Bar keys to select.":"No results are available.":""}});s.a.array.isRequired,s.a.func,s.a.func,s.a.func,s.a.bool,s.a.number,s.a.number,s.a.number,s.a.bool,s.a.bool,s.a.bool,s.a.any,s.a.any,s.a.any,s.a.string,s.a.string,s.a.string,s.a.string,s.a.string,s.a.string,s.a.func,s.a.string,s.a.string,s.a.func,s.a.func,s.a.func,s.a.func,s.a.func,s.a.func,s.a.shape({addEventListener:s.a.func,removeEventListener:s.a.func,document:s.a.shape({getElementById:s.a.func,activeElement:s.a.any,body:s.a.any})}),h({},se,{getA11yStatusMessage:R,circularNavigation:!0});s.a.array,s.a.array,s.a.array,s.a.func,s.a.func,s.a.func,s.a.number,s.a.number,s.a.number,s.a.func,s.a.func,s.a.string,s.a.string,s.a.shape({addEventListener:s.a.func,removeEventListener:s.a.func,document:s.a.shape({getElementById:s.a.func,activeElement:s.a.any,body:s.a.any})});var ce=le;function fe(){return(fe=Object.assign||function(e){for(var t=1;t=me.MATCHES?f=d:f>m&&(f=m),f>a&&(a=f,u=o,l=g,p=s),{rankedItem:p,rank:a,keyIndex:u,keyThreshold:l}},{rank:me.NO_MATCH,keyIndex:-1,keyThreshold:r.threshold})}(r,o,t,n),l=u.rankedItem,s=u.rank,c=u.keyIndex,f=u.keyThreshold;s>=(void 0===f?i:f)&&e.push({rankedItem:l,item:r,rank:s,index:a,keyIndex:c});return e},[]).sort(ye).map(function(e){return e.item})}function be(e,t,n){if(e=ve(e,n),(t=ve(t,n)).length>e.length)return me.NO_MATCH;if(e===t)return me.CASE_SENSITIVE_EQUAL;var r,o,a=function(e){var t=e.toLowerCase()!==e,n=e.indexOf("-")>=0,r=e.indexOf("_")>=0;if(!t&&!r&&n)return ge.KEBAB;if(!t&&r&&!n)return ge.SNAKE;if(t&&!n&&!r){var o=e[0].toUpperCase()===e[0];return o?ge.PASCAL:ge.CAMEL}return ge.NO_CASE}(e),i=function(e,t,n){var r=e.toLowerCase().indexOf(t.toLowerCase());switch(n){case ge.SNAKE:return"_"===e[r-1];case ge.KEBAB:return"-"===e[r-1];case ge.PASCAL:case ge.CAMEL:return-1!==r&&e[r]===e[r].toUpperCase();default:return!1}}(e,t,a),u=function(e,t,n){var r=null;switch(n){case ge.SNAKE:r="_";break;case ge.KEBAB:r="-";break;case ge.PASCAL:case ge.CAMEL:r=/(?=[A-Z])/;break;default:r=null}var o=e.split(r);return t.toLowerCase().split("").reduce(function(e,t,n){var r=o[n];return e&&r&&r[0].toLowerCase()===t},!0)}(e,t,a);return(e=e.toLowerCase())===(t=t.toLowerCase())?me.EQUAL+a:0===e.indexOf(t)?me.STARTS_WITH+a:-1!==e.indexOf(" "+t)?me.WORD_STARTS_WITH+a:i?me.STRING_CASE+a:a>0&&u?me.STRING_CASE_ACRONYM+a:-1!==e.indexOf(t)?me.CONTAINS+a:1===t.length?me.NO_MATCH:-1!==(r=e,o="",r.split(" ").forEach(function(e){e.split("-").forEach(function(e){o+=e.substr(0,1)})}),o).indexOf(t)?me.ACRONYM+a:function(e,t){var n=0,r=0;function o(e,t,r){for(var o=r;o-1;if(!l)return me.NO_MATCH}return function(e){var r=n/t.length;return me.MATCHES+r*(1/e)}(r-a)}(e,t)}function ye(e,t){var n=e.rankedItem,r=e.rank,o=e.keyIndex,a=t.rankedItem,i=t.rank,u=t.keyIndex;return r===i?o===u?String(n).localeCompare(a):oi?-1:1}function ve(e,t){return e=""+e,t.keepDiacritics||(e=de()(e)),e}function Ie(e){return"string"==typeof e&&(e={key:e}),fe({maxRanking:1/0,minRanking:-1/0},e)}he.rankings=me,he.caseRankings=ge;var Oe=he;n(15);function Se(){return(Se=Object.assign||function(e){for(var t=1;t=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}var we=parseFloat(EF_CALENDAR.WP_VERSION)>=5.3?c.Button:c.IconButton;var Ae=function(e){var t=e.className,n=e.placeholder,r=e.inputLabel,a=e.buttonOpenLabel,i=e.buttonCloseLabel,u=e.buttonClearLabel,l=e.items,s=e.noMatchText,f=void 0===s?"No items match":s,p=e.onInputBlur,m=Ee(e,["className","placeholder","inputLabel","buttonOpenLabel","buttonCloseLabel","buttonClearLabel","items","noMatchText","onInputBlur"]);return o.a.createElement("div",{className:d()("ef-combobox",t)},o.a.createElement(ce,m,function(e){var t=e.getInputProps,s=e.getToggleButtonProps,m=e.getMenuProps,g=e.getItemProps,h=e.isOpen,b=e.openMenu,y=e.clearSelection,v=e.selectedItem,I=e.inputValue,O=e.highlightedIndex,S=[],E=[];return h&&(S=(E=function(e,t){return e?Oe(t,e,{keys:["name"]}):t}(I,l)).map(function(e,t){return o.a.createElement("li",Se({"aria-label":e.name,className:d()({"is-active":O===t}),key:e.value},g({item:e,index:t})),e.level&&!I?new Array(e.level).fill(" ").join(""):null,e.parent&&I?o.a.createElement("span",{className:"ef-combobox-item-parent"},function(e,t){return e.find(function(e){return e.value===t})}(l,e.parent).name):null,e.parent&&I?" ":null,e.name)})),h&&S.length<1&&(S=[o.a.createElement("li",Se({"aria-label":f,className:"disabled",key:"no-items-match"},g({item:f,disabled:!0})),f)]),o.a.createElement("div",null,o.a.createElement("div",{className:"ef-combobox-input-wrapper"},o.a.createElement(c.BaseControl,{label:r},o.a.createElement("input",Se({className:d()({"is-open":h},"ef-combobox-input components-text-control__input")},t({onBlur:function(){p&&p(E,I)},onFocus:b,type:"text",placeholder:n})))),v?o.a.createElement(we,Se({},s({"aria-label":u}),{onClick:y,key:"no-alt",className:"ef-combobox-input-button",icon:"no-alt"})):o.a.createElement(we,Se({},s({"aria-label":h?i:a}),{className:"ef-combobox-input-button",icon:h?"arrow-up-alt2":"arrow-down-alt2"}))),o.a.createElement("ul",Se({className:d()("ef-combobox-menu-wrapper",{"ef-combobox-menu-wrapper-hidden":!h})},m()),h?S:null))}))};Ae.propTypes={className:s.a.string,placeholder:s.a.string,inputLabel:s.a.string,buttonOpenLabel:s.a.string,buttonCloseLabel:s.a.string,buttonClearLabel:s.a.string,label:s.a.string,items:s.a.arrayOf(s.a.shape({name:s.a.string.isRequired,id:s.a.oneOfType([s.a.string,s.a.number]),parent:s.a.oneOfType([s.a.string,s.a.number]),level:s.a.number})),noMatchText:s.a.string,onInputBlur:s.a.func};n(17);function Ce(e){return(Ce="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _e(){return(_e=Object.assign||function(e){for(var t=1;t=5.4?{isSecondary:!0}:{isDefault:!0};var Me=function(e){function t(e){var n;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(n=ke(this,Te(t).call(this,e))).state=Re({},e.filters.reduce(function(e,t){var n=Ne({},t.name,t.initialValue||"");return"combobox"===t.filterType&&(n["".concat(t.name,"InputValue")]=t.initialValue?t.initialValue.name:""),Re({},e,n)},[])),n.formRef=o.a.createRef(),n}var n,r,a;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Le(e,t)}(t,o.a.Component),n=t,(r=[{key:"updateFilter",value:function(e){var t=e.name,n=e.value;this.setState(Re({},this.state,Ne({},t,n)))}},{key:"render",value:function(){var e=this,t=this.props,n=t.filters,r=t.pageUrl,a=t.isLoading,i=this.state;return o.a.createElement("div",{className:"ef-calendar-navigation"},o.a.createElement("div",{className:"ef-calendar-filters"},o.a.createElement("form",{ref:this.formRef,action:"",method:"GET",className:"ef-calendar-filters-form"},o.a.createElement("input",{type:"hidden",name:"page",value:"calendar"}),n.map(function(t){switch(t.filterType){case"select":return o.a.createElement("div",{className:"ef-calendar-filter ef-calendar-filter-".concat(t.name),key:"ef-calendar-filter-".concat(t.name)},o.a.createElement(c.SelectControl,{className:"label-screen-reader-text",key:t.name,name:t.name,label:t.label,value:i[t.name],options:t.options,onChange:function(n){return e.updateFilter({name:t.name,value:n})}}));case"combobox":return o.a.createElement("div",{className:"ef-calendar-filter ef-calendar-filter-".concat(t.name),key:"ef-calendar-filter-".concat(t.name)},o.a.createElement(Ae,{key:t.name,className:"ef-calendar-filter-combobox label-screen-reader-text",inputLabel:t.inputLabel,buttonOpenLabel:t.buttonOpenLabel,buttonCloseLabel:t.buttonCloseLabel,buttonClearLabel:t.buttonClearLabel,placeholder:t.placeholder,items:t.options,selectedItem:i[t.name],inputValue:i["".concat(t.name,"InputValue")],itemToString:function(e){return e?e.name:""},onInputBlur:function(n,r){!t.selectFirstItemOnBlur||n.length<1||!r||r.toLowerCase()!==n[0].name.toLowerCase()||e.updateFilter({name:t.name,value:n[0]})},onStateChange:function(n){n.hasOwnProperty("selectedItem")?e.updateFilter({name:t.name,value:n.selectedItem}):n.hasOwnProperty("inputValue")&&e.updateFilter({name:"".concat(t.name,"InputValue"),value:n.inputValue})}}),o.a.createElement("input",{key:"".concat(t.name,"-input"),type:"hidden",name:t.name,value:i[t.name]?i[t.name].value:""}))}}),o.a.createElement("div",{className:"ef-calendar-filters-buttons"},o.a.createElement(c.Button,{type:"submit",isPrimary:!0},Object(u.__)("Apply","edit-flow")),o.a.createElement(c.Button,_e({type:"button'",href:Object(m.addQueryArgs)(r,n.reduce(function(e,t){return Re({},e,Ne({},t.name,""))},{})),name:"ef-calendar-reset-filters"},Pe),Object(u.__)("Reset","edit-flow")),a?o.a.createElement(c.Spinner,null):null))))}}])&&xe(n.prototype,r),a&&xe(n,a),t}();Me.propTypes={filters:s.a.arrayOf(s.a.shape({name:s.a.string,filterType:s.a.string,label:s.a.string,options:s.a.arrayOf(s.a.shape({name:s.a.string,value:s.a.any})),initialValue:s.a.any})),pageUrl:s.a.string,isLoading:s.a.bool};var je=n(10),De=n.n(je);n(18);function He(){return(He=Object.assign||function(e){for(var t=1;t=5.4?{isSecondary:!0}:{isDefault:!0},Fe=function(e,t,n,r,o){var a=function(e){for(var t=1;t1?o.a.createElement(c.Button,He({},Be,{className:"ef-calendar-date-change-button",title:Object(u.sprintf)(Object(u.__)("Backwards %d weeks","edit-flow"),t),href:Ke(t,n,r,a)}),Object(u.__)("«","edit-flow")):null,o.a.createElement(c.Button,He({},Be,{className:"ef-calendar-date-change-button",title:Object(u.__)("Backwards 1 week","edit-flow"),href:Ke(1,n,r,a)}),Object(u.__)("‹","edit-flow")),o.a.createElement(c.Button,He({},Be,{className:"ef-calendar-date-change-button",title:Object(u.__)("Today","edit-flow"),href:Ue(0,n,r,a)}),Object(u.__)("Today","edit-flow")),o.a.createElement(c.Button,He({},Be,{className:"ef-calendar-date-change-button",title:Object(u.__)("Forward 1 week","edit-flow"),href:Ue(1,n,r,a)}),Object(u.__)("›","edit-flow")),t>1?o.a.createElement(c.Button,He({},Be,{className:"ef-calendar-date-change-button",title:Object(u.sprintf)(Object(u.__)("Forward %d weeks","edit-flow"),t),href:Ue(t,n,r,a)}),Object(u.__)("»","edit-flow")):null)};We.propTypes={numberOfWeeks:s.a.number,beginningOfWeek:s.a.string,pageUrl:s.a.string,filterValues:s.a.object};n(19);function Ye(e){for(var t=1;t0&&void 0!==arguments[0]?arguments[0]:Ge,t=arguments.length>1?arguments[1]:void 0;switch(t.type){case"SET_POST_SAVED":return Ye({},e,{calendarSnackbarMessage:t.message,calendarIsLoading:!1});case"CLEAR_CALENDAR_SNACKBAR_MESSAGE":return Ye({},e,{calendarSnackbarMessage:null});case"SET_CALENDAR_IS_LOADING":return Ye({},e,{calendarIsLoading:t.isLoading})}return e},actions:{setPostSaved:function(e){return{type:"SET_POST_SAVED",message:e}},clearCalendarSnackbarMessage:function(){return{type:"CLEAR_CALENDAR_SNACKBAR_MESSAGE"}},setCalendarIsLoading:function(e){return{type:"SET_CALENDAR_IS_LOADING",isLoading:e}}},selectors:{getCalendarSnackbarMessage:function(e){return e.calendarSnackbarMessage},getCalendarIsLoading:function(e){return e.calendarIsLoading}}});var Xe=function(e){var t=e.snackbarMessage,n=e.isLoading,r=e.filters,a=e.filterValues,i=e.numberOfWeeks,u=e.beginningOfWeek,l=e.pageUrl;return o.a.createElement("div",{className:"ef-calendar-header"},o.a.createElement(Me,{isLoading:n,pageUrl:l,filters:r}),o.a.createElement(We,{beginningOfWeek:u,pageUrl:l,numberOfWeeks:i,filterValues:a}),t?o.a.createElement(c.Animate,{options:{origin:"bottom left"},type:"appear"},function(e){var n=e.className;return o.a.createElement(c.Snackbar,{className:d()(n,"ef-calendar-snackbar")},o.a.createElement("div",null,t))}):null)};Xe.propTypes={filters:s.a.arrayOf(s.a.shape({name:s.a.string,filterType:s.a.string,label:s.a.string,options:s.a.arrayOf(s.a.shape({label:s.a.string,value:s.a.any})),initialValue:s.a.any})),filterValues:s.a.object,numberOfWeeks:s.a.number,beginningOfWeek:s.a.string,pageUrl:s.a.string,snackbarMessage:s.a.string,isLoading:s.a.bool};var Qe=Object(f.withSelect)(function(e){var t=e("edit-flow/calendar"),n=t.getCalendarSnackbarMessage,r=t.getCalendarIsLoading;return{snackbarMessage:n(),isLoading:r()}})(Xe);n(20);function ze(e){for(var t=1;t1&&void 0!==arguments[1]?arguments[1]:1;return n>0?t.reduce(function(t,r){return t.concat(Array.isArray(r)?e(r,n-1):r)},[]):t.slice()}(function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return t.filter(function(e){return e.parent===n}).map(function(n){return[ze({},n,{level:r})].concat(e(t,n.value,r+1))})}(EF_CALENDAR.CATEGORIES.map(Je),0),1/0),initialValue:tt||null,selectFirstItemOnBlur:!0}];EF_CALENDAR.POST_TYPES&&EF_CALENDAR.POST_TYPES.length>1&&rt.push({name:"cpt",filterType:"select",label:Object(u.__)("Select a type","edit-flow"),options:[{value:"",label:Object(u.__)("Select a type","edit-flow")}].concat(EF_CALENDAR.POST_TYPES.map(function(e){return{value:e.name,label:e.label}})),initialValue:EF_CALENDAR.FILTERS.cpt}),rt.push({name:"num_weeks",filterType:"select",label:Object(u.__)("Number of weeks","edit-flow"),options:et,initialValue:EF_CALENDAR.FILTERS.num_weeks}),i.a.render(o.a.createElement(Qe,{numberOfWeeks:EF_CALENDAR.FILTERS.num_weeks,beginningOfWeek:EF_CALENDAR.BEGINNING_OF_WEEK,pageUrl:EF_CALENDAR.PAGE_URL,filters:rt,filterValues:EF_CALENDAR.FILTERS}),document.getElementById("ef-calendar-navigation-mount"))},function(e,t){},,function(e,t){},function(e,t){},function(e,t){},function(e,t){}]); + */var r="function"==typeof Symbol&&Symbol.for,o=r?Symbol.for("react.element"):60103,a=r?Symbol.for("react.portal"):60106,i=r?Symbol.for("react.fragment"):60107,u=r?Symbol.for("react.strict_mode"):60108,l=r?Symbol.for("react.profiler"):60114,s=r?Symbol.for("react.provider"):60109,c=r?Symbol.for("react.context"):60110,f=r?Symbol.for("react.async_mode"):60111,p=r?Symbol.for("react.concurrent_mode"):60111,d=r?Symbol.for("react.forward_ref"):60112,m=r?Symbol.for("react.suspense"):60113,g=r?Symbol.for("react.suspense_list"):60120,h=r?Symbol.for("react.memo"):60115,b=r?Symbol.for("react.lazy"):60116,y=r?Symbol.for("react.block"):60121,v=r?Symbol.for("react.fundamental"):60117,O=r?Symbol.for("react.responder"):60118,S=r?Symbol.for("react.scope"):60119;function I(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case o:switch(e=e.type){case f:case p:case i:case l:case u:case m:return e;default:switch(e=e&&e.$$typeof){case c:case d:case b:case h:case s:return e;default:return t}}case a:return t}}}function E(e){return I(e)===p}t.AsyncMode=f,t.ConcurrentMode=p,t.ContextConsumer=c,t.ContextProvider=s,t.Element=o,t.ForwardRef=d,t.Fragment=i,t.Lazy=b,t.Memo=h,t.Portal=a,t.Profiler=l,t.StrictMode=u,t.Suspense=m,t.isAsyncMode=function(e){return E(e)||I(e)===f},t.isConcurrentMode=E,t.isContextConsumer=function(e){return I(e)===c},t.isContextProvider=function(e){return I(e)===s},t.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===o},t.isForwardRef=function(e){return I(e)===d},t.isFragment=function(e){return I(e)===i},t.isLazy=function(e){return I(e)===b},t.isMemo=function(e){return I(e)===h},t.isPortal=function(e){return I(e)===a},t.isProfiler=function(e){return I(e)===l},t.isStrictMode=function(e){return I(e)===u},t.isSuspense=function(e){return I(e)===m},t.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===i||e===p||e===l||e===u||e===m||e===g||"object"==typeof e&&null!==e&&(e.$$typeof===b||e.$$typeof===h||e.$$typeof===s||e.$$typeof===c||e.$$typeof===d||e.$$typeof===v||e.$$typeof===O||e.$$typeof===S||e.$$typeof===y)},t.typeOf=I},function(e,t,n){"use strict";n.r(t);var r=n(2),o=n(1),a=n.n(o),i=n(8),u=n.n(i),l=n(3),s=n(6),c=n(4),f=n.n(c),p=n(0),d=n.n(p),m=n(5),g=n(9),h=n.n(g);n(15);function b(e){return(b="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function y(){return(y=Object.assign?Object.assign.bind():function(e){for(var t=1;t=5.4?{isSecondary:!0}:{isDefault:!0},I=function(e,t,n,r,o){var a=function(e){for(var t=1;t1?a.a.createElement(l.Button,y({},S,{className:"ef-calendar-date-change-button",title:Object(r.sprintf)(Object(r.__)("Backwards %d weeks","edit-flow"),t),href:w(t,n,o,i)}),Object(r.__)("«","edit-flow")):null,a.a.createElement(l.Button,y({},S,{className:"ef-calendar-date-change-button",title:Object(r.__)("Backwards 1 week","edit-flow"),href:w(1,n,o,i)}),Object(r.__)("‹","edit-flow")),a.a.createElement(l.Button,y({},S,{className:"ef-calendar-date-change-button",title:Object(r.__)("Today","edit-flow"),href:E(0,n,o,i)}),Object(r.__)("Today","edit-flow")),a.a.createElement(l.Button,y({},S,{className:"ef-calendar-date-change-button",title:Object(r.__)("Forward 1 week","edit-flow"),href:E(1,n,o,i)}),Object(r.__)("›","edit-flow")),t>1?a.a.createElement(l.Button,y({},S,{className:"ef-calendar-date-change-button",title:Object(r.sprintf)(Object(r.__)("Forward %d weeks","edit-flow"),t),href:E(t,n,o,i)}),Object(r.__)("»","edit-flow")):null)};function C(e,t){if(null==e)return{};var n={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}function _(){return(_=Object.assign?Object.assign.bind():function(e){for(var t=1;tt||a>e&&i=t&&u>=n?a-e-r:i>t&&un?i-t+o:0}var R=0;function N(e){return"function"==typeof e?e:D}function D(){}function M(e,t){e&&function(e,t){var n=window,r=t.scrollMode,o=t.block,a=t.inline,i=t.boundary,u=t.skipOverflowHiddenElements,l="function"==typeof i?i:function(e){return e!==i};if(!j(e))throw new TypeError("Invalid target");for(var s,c,f=document.scrollingElement||document.documentElement,p=[],d=e;j(d)&&l(d);){if((d=null==(c=(s=d).parentElement)?s.getRootNode().host||null:c)===f){p.push(d);break}null!=d&&d===document.body&&k(d)&&!k(document.documentElement)||null!=d&&k(d,u)&&p.push(d)}for(var m=n.visualViewport?n.visualViewport.width:innerWidth,g=n.visualViewport?n.visualViewport.height:innerHeight,h=window.scrollX||pageXOffset,b=window.scrollY||pageYOffset,y=e.getBoundingClientRect(),v=y.height,O=y.width,S=y.top,I=y.right,E=y.bottom,w=y.left,A="start"===o||"nearest"===o?S:"end"===o?E:S+v/2,C="center"===a?w+O/2:"end"===a?I:w,_=[],x=0;x=0&&w>=0&&E<=g&&I<=m&&S>=D&&E<=H&&w>=V&&I<=M)return _;var B=getComputedStyle(P),F=parseInt(B.borderLeftWidth,10),U=parseInt(B.borderTopWidth,10),K=parseInt(B.borderRightWidth,10),W=parseInt(B.borderBottomWidth,10),Y=0,$=0,G="offsetWidth"in P?P.offsetWidth-P.clientWidth-F-K:0,X="offsetHeight"in P?P.offsetHeight-P.clientHeight-U-W:0,Q="offsetWidth"in P?0===P.offsetWidth?0:N/P.offsetWidth:0,z="offsetHeight"in P?0===P.offsetHeight?0:R/P.offsetHeight:0;if(f===P)Y="start"===o?A:"end"===o?A-g:"nearest"===o?L(b,b+g,g,U,W,b+A,b+A+v,v):A-g/2,$="start"===a?C:"center"===a?C-m/2:"end"===a?C-m:L(h,h+m,m,F,K,h+C,h+C+O,O),Y=Math.max(0,Y+b),$=Math.max(0,$+h);else{Y="start"===o?A-D-U:"end"===o?A-H+W+X:"nearest"===o?L(D,H,R,U,W+X,A,A+v,v):A-(D+R/2)+X/2,$="start"===a?C-V-F:"center"===a?C-(V+N/2)+G/2:"end"===a?C-M+K+G:L(V,M,N,F,K+G,C,C+O,O);var q=P.scrollLeft,Z=P.scrollTop;A+=Z-(Y=Math.max(0,Math.min(Z+Y/z,P.scrollHeight-R/z+X))),C+=q-($=Math.max(0,Math.min(q+$/Q,P.scrollWidth-N/Q+G)))}_.push({el:P,top:Y,left:$})}return _}(e,{boundary:t,block:"nearest",scrollMode:"if-needed"}).forEach((function(e){var t=e.el,n=e.top,r=e.left;t.scrollTop=n,t.scrollLeft=r}))}function H(e,t){return e===t||e.contains&&e.contains(t)}function V(e,t){var n;function r(){n&&clearTimeout(n)}function o(){for(var o=arguments.length,a=new Array(o),i=0;i1?n-1:0),o=1;o=37&&n<=40&&0!==t.indexOf("Arrow")?"Arrow"+t:t}function Z(e,t,n,r,o){if(void 0===o&&(o=!0),0===n)return-1;var a=n-1;("number"!=typeof t||t<0||t>=n)&&(t=e>0?-1:a+1);var i=t+e;i<0?i=o?a:0:i>a&&(i=o?0:a);var u=J(e,i,n,r,o);return-1===u?t>=n?-1:t:u}function J(e,t,n,r,o){var a=r(t);if(!a||!a.hasAttribute("disabled"))return t;if(e>0){for(var i=t+1;i=0;u--)if(!r(u).hasAttribute("disabled"))return u;return o?e>0?J(1,0,n,r,!1):J(-1,n-1,n,r,!1):-1}function ee(e,t,n,r){return void 0===r&&(r=!0),t.some((function(t){return t&&(H(t,e)||r&&H(t,n.activeElement))}))}var te=V((function(){re().textContent=""}),500);function ne(e,t){var n=re(t);e&&(n.textContent=e,te())}function re(e){void 0===e&&(e=document);var t=e.getElementById("a11y-status-message");return t||((t=e.createElement("div")).setAttribute("id","a11y-status-message"),t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t.setAttribute("aria-relevant","additions text"),Object.assign(t.style,{border:"0",clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:"0",position:"absolute",width:"1px"}),e.body.appendChild(t),t)}var oe=Object.freeze({__proto__:null,unknown:0,mouseUp:1,itemMouseEnter:2,keyDownArrowUp:3,keyDownArrowDown:4,keyDownEscape:5,keyDownEnter:6,keyDownHome:7,keyDownEnd:8,clickItem:9,blurInput:10,changeInput:11,keyDownSpaceButton:12,clickButton:13,blurButton:14,controlledPropUpdatedSelectedItem:15,touchEnd:16}),ae=function(){var e=function(e){var t,n;function r(t){var n=e.call(this,t)||this;n.id=n.props.id||"downshift-"+U(),n.menuId=n.props.menuId||n.id+"-menu",n.labelId=n.props.labelId||n.id+"-label",n.inputId=n.props.inputId||n.id+"-input",n.getItemId=n.props.getItemId||function(e){return n.id+"-item-"+e},n.input=null,n.items=[],n.itemCount=null,n.previousResultCount=0,n.timeoutIds=[],n.internalSetTimeout=function(e,t){var r=setTimeout((function(){n.timeoutIds=n.timeoutIds.filter((function(e){return e!==r})),e()}),t);n.timeoutIds.push(r)},n.setItemCount=function(e){n.itemCount=e},n.unsetItemCount=function(){n.itemCount=null},n.setHighlightedIndex=function(e,t){void 0===e&&(e=n.props.defaultHighlightedIndex),void 0===t&&(t={}),t=X(t),n.internalSetState(_({highlightedIndex:e},t))},n.clearSelection=function(e){n.internalSetState({selectedItem:null,inputValue:"",highlightedIndex:n.props.defaultHighlightedIndex,isOpen:n.props.defaultIsOpen},e)},n.selectItem=function(e,t,r){t=X(t),n.internalSetState(_({isOpen:n.props.defaultIsOpen,highlightedIndex:n.props.defaultHighlightedIndex,selectedItem:e,inputValue:n.props.itemToString(e)},t),r)},n.selectItemAtIndex=function(e,t,r){var o=n.items[e];null!=o&&n.selectItem(o,t,r)},n.selectHighlightedItem=function(e,t){return n.selectItemAtIndex(n.getState().highlightedIndex,e,t)},n.internalSetState=function(e,t){var r,o,a={},i="function"==typeof e;return!i&&e.hasOwnProperty("inputValue")&&n.props.onInputValueChange(e.inputValue,_({},n.getStateAndHelpers(),e)),n.setState((function(t){t=n.getState(t);var u=i?e(t):e;u=n.props.stateReducer(t,u),r=u.hasOwnProperty("selectedItem");var l={},s={};return r&&u.selectedItem!==t.selectedItem&&(o=u.selectedItem),u.type=u.type||0,Object.keys(u).forEach((function(e){t[e]!==u[e]&&(a[e]=u[e]),"type"!==e&&(s[e]=u[e],z(n.props,e)||(l[e]=u[e]))})),i&&u.hasOwnProperty("inputValue")&&n.props.onInputValueChange(u.inputValue,_({},n.getStateAndHelpers(),u)),l}),(function(){N(t)(),Object.keys(a).length>1&&n.props.onStateChange(a,n.getStateAndHelpers()),r&&n.props.onSelect(e.selectedItem,n.getStateAndHelpers()),void 0!==o&&n.props.onChange(o,n.getStateAndHelpers()),n.props.onUserAction(a,n.getStateAndHelpers())}))},n.rootRef=function(e){return n._rootNode=e},n.getRootProps=function(e,t){var r,o=void 0===e?{}:e,a=o.refKey,i=void 0===a?"ref":a,u=o.ref,l=C(o,["refKey","ref"]),s=(void 0===t?{}:t).suppressRefError,c=void 0!==s&&s;n.getRootProps.called=!0,n.getRootProps.refKey=i,n.getRootProps.suppressRefError=c;var f=n.getState().isOpen;return _(((r={})[i]=F(u,n.rootRef),r.role="combobox",r["aria-expanded"]=f,r["aria-haspopup"]="listbox",r["aria-owns"]=f?n.menuId:null,r["aria-labelledby"]=n.labelId,r),l)},n.keyDownHandlers={ArrowDown:function(e){var t=this;if(e.preventDefault(),this.getState().isOpen){var n=e.shiftKey?5:1;this.moveHighlightedIndex(n,{type:4})}else this.internalSetState({isOpen:!0,type:4},(function(){var e=t.getItemCount();if(e>0){var n=Z(1,t.getState().highlightedIndex,e,(function(e){return t.getItemNodeFromIndex(e)}));t.setHighlightedIndex(n,{type:4})}}))},ArrowUp:function(e){var t=this;if(e.preventDefault(),this.getState().isOpen){var n=e.shiftKey?-5:-1;this.moveHighlightedIndex(n,{type:3})}else this.internalSetState({isOpen:!0,type:3},(function(){var e=t.getItemCount();if(e>0){var n=Z(-1,t.getState().highlightedIndex,e,(function(e){return t.getItemNodeFromIndex(e)}));t.setHighlightedIndex(n,{type:3})}}))},Enter:function(e){if(229!==e.which){var t=this.getState(),n=t.isOpen,r=t.highlightedIndex;if(n&&null!=r){e.preventDefault();var o=this.items[r],a=this.getItemNodeFromIndex(r);if(null==o||a&&a.hasAttribute("disabled"))return;this.selectHighlightedItem({type:6})}}},Escape:function(e){e.preventDefault(),this.reset({type:5,selectedItem:null,inputValue:""})}},n.buttonKeyDownHandlers=_({},n.keyDownHandlers,{" ":function(e){e.preventDefault(),this.toggleMenu({type:12})}}),n.inputKeyDownHandlers=_({},n.keyDownHandlers,{Home:function(e){var t=this;e.preventDefault();var n=this.getItemCount(),r=this.getState().isOpen;if(!(n<=0)&&r){var o=J(1,0,n,(function(e){return t.getItemNodeFromIndex(e)}),!1);this.setHighlightedIndex(o,{type:7})}},End:function(e){var t=this;e.preventDefault();var n=this.getItemCount(),r=this.getState().isOpen;if(!(n<=0)&&r){var o=J(-1,n-1,n,(function(e){return t.getItemNodeFromIndex(e)}),!1);this.setHighlightedIndex(o,{type:8})}}}),n.getToggleButtonProps=function(e){var t=void 0===e?{}:e,r=t.onClick,o=(t.onPress,t.onKeyDown),a=t.onKeyUp,i=t.onBlur,u=C(t,["onClick","onPress","onKeyDown","onKeyUp","onBlur"]),l=n.getState().isOpen,s={onClick:B(r,n.buttonHandleClick),onKeyDown:B(o,n.buttonHandleKeyDown),onKeyUp:B(a,n.buttonHandleKeyUp),onBlur:B(i,n.buttonHandleBlur)};return _({type:"button",role:"button","aria-label":l?"close menu":"open menu","aria-haspopup":!0,"data-toggle":!0},u.disabled?{}:s,u)},n.buttonHandleKeyUp=function(e){e.preventDefault()},n.buttonHandleKeyDown=function(e){var t=q(e);n.buttonKeyDownHandlers[t]&&n.buttonKeyDownHandlers[t].call(x(n),e)},n.buttonHandleClick=function(e){e.preventDefault(),n.props.environment.document.activeElement===n.props.environment.document.body&&e.target.focus(),n.internalSetTimeout((function(){return n.toggleMenu({type:13})}))},n.buttonHandleBlur=function(e){var t=e.target;n.internalSetTimeout((function(){n.isMouseDown||null!=n.props.environment.document.activeElement&&n.props.environment.document.activeElement.id===n.inputId||n.props.environment.document.activeElement===t||n.reset({type:14})}))},n.getLabelProps=function(e){return _({htmlFor:n.inputId,id:n.labelId},e)},n.getInputProps=function(e){var t=void 0===e?{}:e,r=t.onKeyDown,o=t.onBlur,a=t.onChange,i=t.onInput,u=(t.onChangeText,C(t,["onKeyDown","onBlur","onChange","onInput","onChangeText"])),l={};var s,c=n.getState(),f=c.inputValue,p=c.isOpen,d=c.highlightedIndex;u.disabled||((s={}).onChange=B(a,i,n.inputHandleChange),s.onKeyDown=B(r,n.inputHandleKeyDown),s.onBlur=B(o,n.inputHandleBlur),l=s);return _({"aria-autocomplete":"list","aria-activedescendant":p&&"number"==typeof d&&d>=0?n.getItemId(d):null,"aria-controls":p?n.menuId:null,"aria-labelledby":n.labelId,autoComplete:"off",value:f,id:n.inputId},l,u)},n.inputHandleKeyDown=function(e){var t=q(e);t&&n.inputKeyDownHandlers[t]&&n.inputKeyDownHandlers[t].call(x(n),e)},n.inputHandleChange=function(e){n.internalSetState({type:11,isOpen:!0,inputValue:e.target.value,highlightedIndex:n.props.defaultHighlightedIndex})},n.inputHandleBlur=function(){n.internalSetTimeout((function(){var e=n.props.environment.document&&!!n.props.environment.document.activeElement&&!!n.props.environment.document.activeElement.dataset&&n.props.environment.document.activeElement.dataset.toggle&&n._rootNode&&n._rootNode.contains(n.props.environment.document.activeElement);n.isMouseDown||e||n.reset({type:10})}))},n.menuRef=function(e){n._menuNode=e},n.getMenuProps=function(e,t){var r,o=void 0===e?{}:e,a=o.refKey,i=void 0===a?"ref":a,u=o.ref,l=C(o,["refKey","ref"]),s=(void 0===t?{}:t).suppressRefError,c=void 0!==s&&s;return n.getMenuProps.called=!0,n.getMenuProps.refKey=i,n.getMenuProps.suppressRefError=c,_(((r={})[i]=F(u,n.menuRef),r.role="listbox",r["aria-labelledby"]=l&&l["aria-label"]?null:n.labelId,r.id=n.menuId,r),l)},n.getItemProps=function(e){var t,r=void 0===e?{}:e,o=r.onMouseMove,a=r.onMouseDown,i=r.onClick,u=(r.onPress,r.index),l=r.item,s=void 0===l?void 0:l,c=C(r,["onMouseMove","onMouseDown","onClick","onPress","index","item"]);void 0===u?(n.items.push(s),u=n.items.indexOf(s)):n.items[u]=s;var f=i,p=((t={onMouseMove:B(o,(function(){u!==n.getState().highlightedIndex&&(n.setHighlightedIndex(u,{type:2}),n.avoidScrolling=!0,n.internalSetTimeout((function(){return n.avoidScrolling=!1}),250))})),onMouseDown:B(a,(function(e){e.preventDefault()}))}).onClick=B(f,(function(){n.selectItemAtIndex(u,{type:9})})),t),d=c.disabled?{onMouseDown:p.onMouseDown}:p;return _({id:n.getItemId(u),role:"option","aria-selected":n.getState().highlightedIndex===u},d,c)},n.clearItems=function(){n.items=[]},n.reset=function(e,t){void 0===e&&(e={}),e=X(e),n.internalSetState((function(t){var r=t.selectedItem;return _({isOpen:n.props.defaultIsOpen,highlightedIndex:n.props.defaultHighlightedIndex,inputValue:n.props.itemToString(r)},e)}),t)},n.toggleMenu=function(e,t){void 0===e&&(e={}),e=X(e),n.internalSetState((function(t){var r=t.isOpen;return _({isOpen:!r},r&&{highlightedIndex:n.props.defaultHighlightedIndex},e)}),(function(){var r=n.getState(),o=r.isOpen,a=r.highlightedIndex;o&&n.getItemCount()>0&&"number"==typeof a&&n.setHighlightedIndex(a,e),N(t)()}))},n.openMenu=function(e){n.internalSetState({isOpen:!0},e)},n.closeMenu=function(e){n.internalSetState({isOpen:!1},e)},n.updateStatus=V((function(){var e=n.getState(),t=n.items[e.highlightedIndex],r=n.getItemCount(),o=n.props.getA11yStatusMessage(_({itemToString:n.props.itemToString,previousResultCount:n.previousResultCount,resultCount:r,highlightedItem:t},e));n.previousResultCount=r,ne(o,n.props.environment.document)}),200);var r=n.props,o=r.defaultHighlightedIndex,a=r.initialHighlightedIndex,i=void 0===a?o:a,u=r.defaultIsOpen,l=r.initialIsOpen,s=void 0===l?u:l,c=r.initialInputValue,f=void 0===c?"":c,p=r.initialSelectedItem,d=void 0===p?null:p,m=n.getState({highlightedIndex:i,isOpen:s,inputValue:f,selectedItem:d});return null!=m.selectedItem&&void 0===n.props.initialInputValue&&(m.inputValue=n.props.itemToString(m.selectedItem)),n.state=m,n}n=e,(t=r).prototype=Object.create(n.prototype),t.prototype.constructor=t,P(t,n);var a=r.prototype;return a.internalClearTimeouts=function(){this.timeoutIds.forEach((function(e){clearTimeout(e)})),this.timeoutIds=[]},a.getState=function(e){return void 0===e&&(e=this.state),Q(e,this.props)},a.getItemCount=function(){var e=this.items.length;return null!=this.itemCount?e=this.itemCount:void 0!==this.props.itemCount&&(e=this.props.itemCount),e},a.getItemNodeFromIndex=function(e){return this.props.environment.document.getElementById(this.getItemId(e))},a.scrollHighlightedItemIntoView=function(){var e=this.getItemNodeFromIndex(this.getState().highlightedIndex);this.props.scrollIntoView(e,this._menuNode)},a.moveHighlightedIndex=function(e,t){var n=this,r=this.getItemCount(),o=this.getState().highlightedIndex;if(r>0){var a=Z(e,o,r,(function(e){return n.getItemNodeFromIndex(e)}));this.setHighlightedIndex(a,t)}},a.getStateAndHelpers=function(){var e=this.getState(),t=e.highlightedIndex,n=e.inputValue,r=e.selectedItem,o=e.isOpen,a=this.props.itemToString,i=this.id,u=this.getRootProps,l=this.getToggleButtonProps,s=this.getLabelProps,c=this.getMenuProps,f=this.getInputProps,p=this.getItemProps,d=this.openMenu,m=this.closeMenu,g=this.toggleMenu,h=this.selectItem,b=this.selectItemAtIndex,y=this.selectHighlightedItem,v=this.setHighlightedIndex,O=this.clearSelection,S=this.clearItems;return{getRootProps:u,getToggleButtonProps:l,getLabelProps:s,getMenuProps:c,getInputProps:f,getItemProps:p,reset:this.reset,openMenu:d,closeMenu:m,toggleMenu:g,selectItem:h,selectItemAtIndex:b,selectHighlightedItem:y,setHighlightedIndex:v,clearSelection:O,clearItems:S,setItemCount:this.setItemCount,unsetItemCount:this.unsetItemCount,setState:this.internalSetState,itemToString:a,id:i,highlightedIndex:t,inputValue:n,isOpen:o,selectedItem:r}},a.componentDidMount=function(){var e=this;var t=function(){e.isMouseDown=!0},n=function(t){e.isMouseDown=!1,!ee(t.target,[e._rootNode,e._menuNode],e.props.environment.document)&&e.getState().isOpen&&e.reset({type:1},(function(){return e.props.onOuterClick(e.getStateAndHelpers())}))},r=function(){e.isTouchMove=!1},o=function(){e.isTouchMove=!0},a=function(t){var n=ee(t.target,[e._rootNode,e._menuNode],e.props.environment.document,!1);e.isTouchMove||n||!e.getState().isOpen||e.reset({type:16},(function(){return e.props.onOuterClick(e.getStateAndHelpers())}))},i=this.props.environment;i.addEventListener("mousedown",t),i.addEventListener("mouseup",n),i.addEventListener("touchstart",r),i.addEventListener("touchmove",o),i.addEventListener("touchend",a),this.cleanup=function(){e.internalClearTimeouts(),e.updateStatus.cancel(),i.removeEventListener("mousedown",t),i.removeEventListener("mouseup",n),i.removeEventListener("touchstart",r),i.removeEventListener("touchmove",o),i.removeEventListener("touchend",a)}},a.shouldScroll=function(e,t){var n=(void 0===this.props.highlightedIndex?this.getState():this.props).highlightedIndex,r=(void 0===t.highlightedIndex?e:t).highlightedIndex;return n&&this.getState().isOpen&&!e.isOpen||n!==r},a.componentDidUpdate=function(e,t){z(this.props,"selectedItem")&&this.props.selectedItemChanged(e.selectedItem,this.props.selectedItem)&&this.internalSetState({type:15,inputValue:this.props.itemToString(this.props.selectedItem)}),!this.avoidScrolling&&this.shouldScroll(t,e)&&this.scrollHighlightedItemIntoView(),this.updateStatus()},a.componentWillUnmount=function(){this.cleanup()},a.render=function(){var e=W(this.props.children,D);this.clearItems(),this.getRootProps.called=!1,this.getRootProps.refKey=void 0,this.getRootProps.suppressRefError=void 0,this.getMenuProps.called=!1,this.getMenuProps.refKey=void 0,this.getMenuProps.suppressRefError=void 0,this.getLabelProps.called=!1,this.getInputProps.called=!1;var t=W(e(this.getStateAndHelpers()));return t?this.getRootProps.called||this.props.suppressRefError?t:Y(t)?Object(o.cloneElement)(t,this.getRootProps($(t))):void 0:null},r}(o.Component);return e.defaultProps={defaultHighlightedIndex:null,defaultIsOpen:!1,getA11yStatusMessage:K,itemToString:function(e){return null==e?"":String(e)},onStateChange:D,onInputValueChange:D,onUserAction:D,onChange:D,onSelect:D,onOuterClick:D,selectedItemChanged:function(e,t){return e!==t},environment:"undefined"==typeof window?{}:window,stateReducer:function(e,t){return t},suppressRefError:!1,scrollIntoView:M},e.stateChangeTypes=oe,e}();V((function(e,t){ne(e(),t)}),200);var ie={itemToString:function(e){return e?String(e):""},stateReducer:function(e,t){return t.changes},getA11ySelectionMessage:function(e){var t=e.selectedItem,n=e.itemToString;return t?n(t)+" has been selected.":""},scrollIntoView:M,circularNavigation:!1,environment:"undefined"==typeof window?{}:window};d.a.array.isRequired,d.a.func,d.a.func,d.a.func,d.a.bool,d.a.number,d.a.number,d.a.number,d.a.bool,d.a.bool,d.a.bool,d.a.any,d.a.any,d.a.any,d.a.string,d.a.string,d.a.string,d.a.func,d.a.string,d.a.func,d.a.func,d.a.func,d.a.func,d.a.func,d.a.shape({addEventListener:d.a.func,removeEventListener:d.a.func,document:d.a.shape({getElementById:d.a.func,activeElement:d.a.any,body:d.a.any})});_({},ie,{getA11yStatusMessage:function(e){var t=e.isOpen,n=e.resultCount,r=e.previousResultCount;return t?n?n!==r?n+" result"+(1===n?" is":"s are")+" available, use up and down arrow keys to navigate. Press Enter or Space Bar keys to select.":"":"No results are available.":""}});d.a.array.isRequired,d.a.func,d.a.func,d.a.func,d.a.bool,d.a.number,d.a.number,d.a.number,d.a.bool,d.a.bool,d.a.bool,d.a.any,d.a.any,d.a.any,d.a.string,d.a.string,d.a.string,d.a.string,d.a.string,d.a.string,d.a.func,d.a.string,d.a.string,d.a.func,d.a.func,d.a.func,d.a.func,d.a.func,d.a.func,d.a.shape({addEventListener:d.a.func,removeEventListener:d.a.func,document:d.a.shape({getElementById:d.a.func,activeElement:d.a.any,body:d.a.any})});_({},ie,{getA11yStatusMessage:K,circularNavigation:!0});d.a.array,d.a.array,d.a.array,d.a.func,d.a.func,d.a.func,d.a.number,d.a.number,d.a.number,d.a.func,d.a.func,d.a.string,d.a.string,d.a.shape({addEventListener:d.a.func,removeEventListener:d.a.func,document:d.a.shape({getElementById:d.a.func,activeElement:d.a.any,body:d.a.any})});var ue=ae,le=n(10),se=n.n(le),ce={CASE_SENSITIVE_EQUAL:9,EQUAL:8,STARTS_WITH:7,WORD_STARTS_WITH:6,STRING_CASE:5,STRING_CASE_ACRONYM:4,CONTAINS:3,ACRONYM:2,MATCHES:1,NO_MATCH:0},fe={CAMEL:.8,PASCAL:.6,KEBAB:.4,SNAKE:.2,NO_CASE:0};de.rankings=ce,de.caseRankings=fe;var pe=function(e,t){return String(e.rankedItem).localeCompare(t.rankedItem)};function de(e,t,n){void 0===n&&(n={});var r=n,o=r.keys,a=r.threshold,i=void 0===a?ce.MATCHES:a,u=r.baseSort,l=void 0===u?pe:u;return e.reduce((function(e,r,a){var u=function(e,t,n,r){if(!t)return{rankedItem:e,rank:me(e,n,r),keyIndex:-1,keyThreshold:r.threshold};return function(e,t){return t.reduce((function(t,n){var r=function(e,t){"object"==typeof t&&(t=t.key);var n;n="function"==typeof t?t(e):-1!==t.indexOf(".")?t.split(".").reduce((function(e,t){return e?e[t]:null}),e):e[t];return null!=n?[].concat(n):null}(e,n);return r&&r.forEach((function(e){t.push({itemValue:e,attributes:he(n)})})),t}),[])}(e,t).reduce((function(e,t,o){var a=e.rank,i=e.rankedItem,u=e.keyIndex,l=e.keyThreshold,s=t.itemValue,c=t.attributes,f=me(s,n,r),p=i,d=c.minRanking,m=c.maxRanking,g=c.threshold;return f=ce.MATCHES?f=d:f>m&&(f=m),f>a&&(a=f,u=o,l=g,p=s),{rankedItem:p,rank:a,keyIndex:u,keyThreshold:l}}),{rank:ce.NO_MATCH,keyIndex:-1,keyThreshold:r.threshold})}(r,o,t,n),l=u.rankedItem,s=u.rank,c=u.keyIndex,f=u.keyThreshold;s>=(void 0===f?i:f)&&e.push({rankedItem:l,item:r,rank:s,index:a,keyIndex:c});return e}),[]).sort((function(e,t){return function(e,t,n){var r=e.rank,o=e.keyIndex,a=t.rank,i=t.keyIndex;return r===a?o===i?n(e,t):oa?-1:1}(e,t,l)})).map((function(e){return e.item}))}function me(e,t,n){if(e=ge(e,n),(t=ge(t,n)).length>e.length)return ce.NO_MATCH;if(e===t)return ce.CASE_SENSITIVE_EQUAL;var r,o,a=function(e){var t=e.toLowerCase()!==e,n=e.indexOf("-")>=0,r=e.indexOf("_")>=0;if(!t&&!r&&n)return fe.KEBAB;if(!t&&r&&!n)return fe.SNAKE;if(t&&!n&&!r){return e[0].toUpperCase()===e[0]?fe.PASCAL:fe.CAMEL}return fe.NO_CASE}(e),i=function(e,t,n){var r=e.toLowerCase().indexOf(t.toLowerCase());switch(n){case fe.SNAKE:return"_"===e[r-1];case fe.KEBAB:return"-"===e[r-1];case fe.PASCAL:case fe.CAMEL:return-1!==r&&e[r]===e[r].toUpperCase();default:return!1}}(e,t,a),u=function(e,t,n){var r=null;switch(n){case fe.SNAKE:r="_";break;case fe.KEBAB:r="-";break;case fe.PASCAL:case fe.CAMEL:r=/(?=[A-Z])/;break;default:r=null}var o=e.split(r);return t.toLowerCase().split("").reduce((function(e,t,n){var r=o[n];return e&&r&&r[0].toLowerCase()===t}),!0)}(e,t,a);return(e=e.toLowerCase())===(t=t.toLowerCase())?ce.EQUAL+a:0===e.indexOf(t)?ce.STARTS_WITH+a:-1!==e.indexOf(" "+t)?ce.WORD_STARTS_WITH+a:i?ce.STRING_CASE+a:a>0&&u?ce.STRING_CASE_ACRONYM+a:-1!==e.indexOf(t)?ce.CONTAINS+a:1===t.length?ce.NO_MATCH:-1!==(r=e,o="",r.split(" ").forEach((function(e){e.split("-").forEach((function(e){o+=e.substr(0,1)}))})),o).indexOf(t)?ce.ACRONYM+a:function(e,t){var n=0,r=0;function o(e,t,r){for(var o=r;o-1))return ce.NO_MATCH}return function(e){var r=n/t.length;return ce.MATCHES+r*(1/e)}(r-a)}(e,t)}function ge(e,t){return e=""+e,t.keepDiacritics||(e=se()(e)),e}function he(e){return"string"==typeof e&&(e={key:e}),_({maxRanking:1/0,minRanking:-1/0},e)}var be=de,ye=(n(17),["className","placeholder","inputLabel","buttonOpenLabel","buttonCloseLabel","buttonClearLabel","items","noMatchText","onInputBlur"]);function ve(){return(ve=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0)continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}var Se=parseFloat(EF_CALENDAR.WP_VERSION)>=5.3?l.Button:l.IconButton;var Ie=function(e){var t=e.className,n=e.placeholder,r=e.inputLabel,o=e.buttonOpenLabel,i=e.buttonCloseLabel,u=e.buttonClearLabel,s=e.items,c=e.noMatchText,p=void 0===c?"No items match":c,d=e.onInputBlur,m=Oe(e,ye);return a.a.createElement("div",{className:f()("ef-combobox",t)},a.a.createElement(ue,m,(function(e){var t=e.getInputProps,c=e.getToggleButtonProps,m=e.getMenuProps,g=e.getItemProps,h=e.isOpen,b=e.openMenu,y=e.clearSelection,v=e.selectedItem,O=e.inputValue,S=e.highlightedIndex,I=[],E=[];return h&&(I=(E=function(e,t){return e?be(t,e,{keys:["name"]}):t}(O,s)).map((function(e,t){return a.a.createElement("li",ve({"aria-label":e.name,className:f()({"is-active":S===t}),key:e.value},g({item:e,index:t})),e.level&&!O?new Array(e.level).fill(" ").join(""):null,e.parent&&O?a.a.createElement("span",{className:"ef-combobox-item-parent"},function(e,t){return e.find((function(e){return e.value===t}))}(s,e.parent).name):null,e.parent&&O?" ":null,e.name)}))),h&&I.length<1&&(I=[a.a.createElement("li",ve({"aria-label":p,className:"disabled",key:"no-items-match"},g({item:p,disabled:!0})),p)]),a.a.createElement("div",null,a.a.createElement("div",{className:"ef-combobox-input-wrapper"},a.a.createElement(l.BaseControl,{label:r},a.a.createElement("input",ve({className:f()({"is-open":h},"ef-combobox-input components-text-control__input")},t({onBlur:function(){d&&d(E,O)},onFocus:b,type:"text",placeholder:n})))),v?a.a.createElement(Se,ve({},c({"aria-label":u}),{onClick:y,key:"no-alt",className:"ef-combobox-input-button",icon:"no-alt"})):a.a.createElement(Se,ve({},c({"aria-label":h?i:o}),{className:"ef-combobox-input-button",icon:h?"arrow-up-alt2":"arrow-down-alt2"}))),a.a.createElement("ul",ve({className:f()("ef-combobox-menu-wrapper",{"ef-combobox-menu-wrapper-hidden":!h})},m()),h?I:null))})))};Ie.propTypes={className:d.a.string,placeholder:d.a.string,inputLabel:d.a.string,buttonOpenLabel:d.a.string,buttonCloseLabel:d.a.string,buttonClearLabel:d.a.string,label:d.a.string,items:d.a.arrayOf(d.a.shape({name:d.a.string.isRequired,id:d.a.oneOfType([d.a.string,d.a.number]),parent:d.a.oneOfType([d.a.string,d.a.number]),level:d.a.number})),noMatchText:d.a.string,onInputBlur:d.a.func};n(18);function Ee(e){return(Ee="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function we(){return(we=Object.assign?Object.assign.bind():function(e){for(var t=1;t=5.4?{isSecondary:!0}:{isDefault:!0};var Re=function(e){function t(e){var n;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(n=Ce(this,t,[e])).state=je({},e.filters.reduce((function(e,t){var n=Te({},t.name,t.initialValue||"");return"combobox"===t.filterType&&(n["".concat(t.name,"InputValue")]=t.initialValue?t.initialValue.name:""),je(je({},e),n)}),[])),n.formRef=a.a.createRef(),n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&xe(e,t)}(t,e),n=t,(o=[{key:"updateFilter",value:function(e){var t=e.name,n=e.value;this.setState(je(je({},this.state),{},Te({},t,n)))}},{key:"render",value:function(){var e=this,t=this.props,n=t.filters,o=t.pageUrl,i=t.isLoading,u=this.state;return a.a.createElement("div",{className:"ef-calendar-navigation"},a.a.createElement("div",{className:"ef-calendar-filters"},a.a.createElement("form",{ref:this.formRef,action:"",method:"GET",className:"ef-calendar-filters-form"},a.a.createElement("input",{type:"hidden",name:"page",value:"calendar"}),n.map((function(t){switch(t.filterType){case"select":return a.a.createElement("div",{className:"ef-calendar-filter ef-calendar-filter-".concat(t.name),key:"ef-calendar-filter-".concat(t.name)},a.a.createElement(l.SelectControl,{className:"label-screen-reader-text",key:t.name,name:t.name,label:t.label,value:u[t.name],options:t.options,onChange:function(n){return e.updateFilter({name:t.name,value:n})}}));case"combobox":return a.a.createElement("div",{className:"ef-calendar-filter ef-calendar-filter-".concat(t.name),key:"ef-calendar-filter-".concat(t.name)},a.a.createElement(Ie,{key:t.name,className:"ef-calendar-filter-combobox label-screen-reader-text",inputLabel:t.inputLabel,buttonOpenLabel:t.buttonOpenLabel,buttonCloseLabel:t.buttonCloseLabel,buttonClearLabel:t.buttonClearLabel,placeholder:t.placeholder,items:t.options,selectedItem:u[t.name],inputValue:u["".concat(t.name,"InputValue")],itemToString:function(e){return e?e.name:""},onInputBlur:function(n,r){!t.selectFirstItemOnBlur||n.length<1||!r||r.toLowerCase()!==n[0].name.toLowerCase()||e.updateFilter({name:t.name,value:n[0]})},onStateChange:function(n){n.hasOwnProperty("selectedItem")?e.updateFilter({name:t.name,value:n.selectedItem}):n.hasOwnProperty("inputValue")&&e.updateFilter({name:"".concat(t.name,"InputValue"),value:n.inputValue})}}),a.a.createElement("input",{key:"".concat(t.name,"-input"),type:"hidden",name:t.name,value:u[t.name]?u[t.name].value:""}))}})),a.a.createElement("div",{className:"ef-calendar-filters-buttons"},a.a.createElement(l.Button,{type:"submit",isPrimary:!0},Object(r.__)("Apply","edit-flow")),a.a.createElement(l.Button,we({type:"button'",href:Object(m.addQueryArgs)(o,n.reduce((function(e,t){return je(je({},e),{},Te({},t.name,""))}),{})),name:"ef-calendar-reset-filters"},Le),Object(r.__)("Reset","edit-flow")),i?a.a.createElement(l.Spinner,null):null))))}}])&&Ae(n.prototype,o),i&&Ae(n,i),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,o,i}(a.a.Component);Re.propTypes={filters:d.a.arrayOf(d.a.shape({name:d.a.string,filterType:d.a.string,label:d.a.string,options:d.a.arrayOf(d.a.shape({name:d.a.string,value:d.a.any})),initialValue:d.a.any})),pageUrl:d.a.string,isLoading:d.a.bool};n(19);function Ne(e){return(Ne="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function De(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Me(e){for(var t=1;t0&&void 0!==arguments[0]?arguments[0]:Ve,t=arguments.length>1?arguments[1]:void 0;switch(t.type){case"SET_POST_SAVED":return Me(Me({},e),{},{calendarSnackbarMessage:t.message,calendarIsLoading:!1});case"CLEAR_CALENDAR_SNACKBAR_MESSAGE":return Me(Me({},e),{},{calendarSnackbarMessage:null});case"SET_CALENDAR_IS_LOADING":return Me(Me({},e),{},{calendarIsLoading:t.isLoading})}return e},actions:{setPostSaved:function(e){return{type:"SET_POST_SAVED",message:e}},clearCalendarSnackbarMessage:function(){return{type:"CLEAR_CALENDAR_SNACKBAR_MESSAGE"}},setCalendarIsLoading:function(e){return{type:"SET_CALENDAR_IS_LOADING",isLoading:e}}},selectors:{getCalendarSnackbarMessage:function(e){return e.calendarSnackbarMessage},getCalendarIsLoading:function(e){return e.calendarIsLoading}}});var Be=function(e){var t=e.snackbarMessage,n=e.isLoading,r=e.filters,o=e.filterValues,i=e.numberOfWeeks,u=e.beginningOfWeek,s=e.pageUrl;return a.a.createElement("div",{className:"ef-calendar-header"},a.a.createElement(Re,{isLoading:n,pageUrl:s,filters:r}),a.a.createElement(A,{beginningOfWeek:u,pageUrl:s,numberOfWeeks:i,filterValues:o}),t?a.a.createElement(l.Animate,{options:{origin:"bottom left"},type:"appear"},(function(e){var n=e.className;return a.a.createElement(l.Snackbar,{className:f()(n,"ef-calendar-snackbar")},a.a.createElement("div",null,t))})):null)};Be.propTypes={filters:d.a.arrayOf(d.a.shape({name:d.a.string,filterType:d.a.string,label:d.a.string,options:d.a.arrayOf(d.a.shape({label:d.a.string,value:d.a.any})),initialValue:d.a.any})),filterValues:d.a.object,numberOfWeeks:d.a.number,beginningOfWeek:d.a.string,pageUrl:d.a.string,snackbarMessage:d.a.string,isLoading:d.a.bool};var Fe=Object(s.withSelect)((function(e){var t=e("edit-flow/calendar"),n=t.getCalendarSnackbarMessage,r=t.getCalendarIsLoading;return{snackbarMessage:n(),isLoading:r()}}))(Be);n(20);function Ue(e){return(Ue="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Ke(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function We(e){for(var t=1;t1&&void 0!==arguments[1]?arguments[1]:1;return n>0?t.reduce((function(t,r){return t.concat(Array.isArray(r)?e(r,n-1):r)}),[]):t.slice()}(function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return t.filter((function(e){return e.parent===n})).map((function(n){return[We(We({},n),{},{level:r})].concat(e(t,n.value,r+1))}))}(EF_CALENDAR.CATEGORIES.map(Ge),0),1/0),initialValue:Qe||null,selectFirstItemOnBlur:!0}];EF_CALENDAR.POST_TYPES&&EF_CALENDAR.POST_TYPES.length>1&&qe.push({name:"cpt",filterType:"select",label:Object(r.__)("Select a type","edit-flow"),options:[{value:"",label:Object(r.__)("Select a type","edit-flow")}].concat(EF_CALENDAR.POST_TYPES.map((function(e){return{value:e.name,label:e.label}}))),initialValue:EF_CALENDAR.FILTERS.cpt}),qe.push({name:"num_weeks",filterType:"select",label:Object(r.__)("Number of weeks","edit-flow"),options:Xe,initialValue:EF_CALENDAR.FILTERS.num_weeks}),u.a.render(a.a.createElement(Fe,{numberOfWeeks:EF_CALENDAR.FILTERS.num_weeks,beginningOfWeek:EF_CALENDAR.BEGINNING_OF_WEEK,pageUrl:EF_CALENDAR.PAGE_URL,filters:qe,filterValues:EF_CALENDAR.FILTERS}),document.getElementById("ef-calendar-navigation-mount"))},function(e,t){},,function(e,t){},function(e,t){},function(e,t){},function(e,t){}]); //# sourceMappingURL=calendar.react.build.js.map \ No newline at end of file diff --git a/modules/calendar/lib/dist/calendar.react.style.build.css b/modules/calendar/lib/dist/calendar.react.style.build.css index 73149bc53..07f33e6eb 100644 --- a/modules/calendar/lib/dist/calendar.react.style.build.css +++ b/modules/calendar/lib/dist/calendar.react.style.build.css @@ -1,7 +1,7 @@ .label-screen-reader-text .components-base-control__label{border:0;clip:rect(1px, 1px, 1px, 1px);-webkit-clip-path:inset(50%);clip-path:inset(50%);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;word-wrap:normal !important} -.ef-calendar-navigation{display:flex;flex-direction:row;margin-right:auto}.ef-calendar-navigation .ef-calendar-filters-form{display:flex;flex-direction:row;align-items:center;margin-top:5px;margin-bottom:5px;margin-right:10px;flex-wrap:wrap}.ef-calendar-navigation .ef-calendar-filters-form .components-base-control .components-base-control__field{margin-bottom:0}.ef-calendar-navigation .ef-calendar-filters-form .ef-calendar-filter{margin-right:5px;margin-bottom:5px}.ef-calendar-navigation .ef-calendar-filters-form .ef-calendar-filters-buttons{display:flex;align-items:center;margin-bottom:5px}.ef-calendar-navigation .ef-calendar-filters-form .ef-calendar-filters-buttons button{padding-right:12px;padding-left:12px}.ef-calendar-navigation .ef-calendar-filters-form .ef-calendar-filters-buttons button:first-child{margin-right:5px} -.ef-combobox{position:relative}.ef-combobox .ef-combobox-input-wrapper{position:relative}.ef-combobox .ef-combobox-input-wrapper .ef-combobox-input.is-open{border-color:#007cba;box-shadow:0 0 0 1px #007cba;outline:2px solid transparent}.ef-combobox .ef-combobox-input-wrapper .ef-combobox-input:focus::placeholder{color:transparent}.ef-combobox .ef-combobox-input-wrapper .ef-combobox-input::placeholder{color:#32373c}.ef-combobox .ef-combobox-input-wrapper .ef-combobox-input-button{position:absolute;top:0;right:0;height:calc(100% - 5px);margin-top:3px;box-shadow:none !important;background-color:white}.ef-combobox .ef-combobox-input-wrapper .ef-combobox-input-button svg{height:16px;width:16px}.ef-combobox .ef-combobox-menu-wrapper{position:absolute;width:calc(100% - 2px);background-color:white;border-top:2px solid #007cba;border-left:2px solid #007cba;border-right:2px solid #007cba;border-bottom:2px solid #007cba;outline:2px solid transparent;z-index:999;box-shadow:0 2px 3px 0 rgba(34,36,38,0.15);margin:-3px 0 0 0;max-height:20rem;overflow-y:auto;overflow-x:hidden}.ef-combobox .ef-combobox-menu-wrapper li{padding:6px 10px;margin:0}.ef-combobox .ef-combobox-menu-wrapper li.is-active{background-color:#007cba;color:#ffffff;cursor:pointer}.ef-combobox .ef-combobox-menu-wrapper li.disabled{color:#81858a}.ef-combobox .ef-combobox-menu-wrapper li .ef-combobox-item-parent{display:block;font-size:9px;color:#AEAEAE}.ef-combobox .ef-combobox-menu-wrapper-hidden{display:none} .ef-calendar-date-change-buttons{display:flex;align-items:center;margin-bottom:5px}.ef-calendar-date-change-buttons .ef-calendar-date-change-button{height:30px;margin-right:5px;padding-left:10px;padding-right:10px}.ef-calendar-date-change-buttons .ef-calendar-date-change-button:last-child{margin-right:0} +.ef-combobox{position:relative}.ef-combobox .ef-combobox-input-wrapper{position:relative}.ef-combobox .ef-combobox-input-wrapper .ef-combobox-input.is-open{border-color:#007cba;box-shadow:0 0 0 1px #007cba;outline:2px solid transparent}.ef-combobox .ef-combobox-input-wrapper .ef-combobox-input:focus::placeholder{color:transparent}.ef-combobox .ef-combobox-input-wrapper .ef-combobox-input::placeholder{color:#32373c}.ef-combobox .ef-combobox-input-wrapper .ef-combobox-input-button{position:absolute;top:0;right:0;height:calc(100% - 5px);margin-top:3px;box-shadow:none !important;background-color:white}.ef-combobox .ef-combobox-input-wrapper .ef-combobox-input-button svg{height:16px;width:16px}.ef-combobox .ef-combobox-menu-wrapper{position:absolute;width:calc(100% - 2px);background-color:white;border-top:2px solid #007cba;border-left:2px solid #007cba;border-right:2px solid #007cba;border-bottom:2px solid #007cba;outline:2px solid transparent;z-index:999;box-shadow:0 2px 3px 0 rgba(34,36,38,0.15);margin:-3px 0 0 0;max-height:20rem;overflow-y:auto;overflow-x:hidden}.ef-combobox .ef-combobox-menu-wrapper li{padding:6px 10px;margin:0}.ef-combobox .ef-combobox-menu-wrapper li.is-active{background-color:#007cba;color:#ffffff;cursor:pointer}.ef-combobox .ef-combobox-menu-wrapper li.disabled{color:#81858a}.ef-combobox .ef-combobox-menu-wrapper li .ef-combobox-item-parent{display:block;font-size:9px;color:#AEAEAE}.ef-combobox .ef-combobox-menu-wrapper-hidden{display:none} +.ef-calendar-navigation{display:flex;flex-direction:row;margin-right:auto}.ef-calendar-navigation .ef-calendar-filters-form{display:flex;flex-direction:row;align-items:center;margin-top:5px;margin-bottom:5px;margin-right:10px;flex-wrap:wrap}.ef-calendar-navigation .ef-calendar-filters-form .components-base-control .components-base-control__field{margin-bottom:0}.ef-calendar-navigation .ef-calendar-filters-form .ef-calendar-filter{margin-right:5px;margin-bottom:5px}.ef-calendar-navigation .ef-calendar-filters-form .ef-calendar-filters-buttons{display:flex;align-items:center;margin-bottom:5px}.ef-calendar-navigation .ef-calendar-filters-form .ef-calendar-filters-buttons button{padding-right:12px;padding-left:12px}.ef-calendar-navigation .ef-calendar-filters-form .ef-calendar-filters-buttons button:first-child{margin-right:5px} .ef-calendar-header{display:flex;flex-direction:row;flex-wrap:wrap;margin-bottom:5px}.ef-calendar-snackbar{position:fixed;bottom:10px;z-index:999} /*# sourceMappingURL=calendar.react.style.build.css.map*/ \ No newline at end of file diff --git a/modules/calendar/lib/react/calendar-date-change-buttons/index.js b/modules/calendar/lib/react/calendar-date-change-buttons/index.js index b2ede5c42..92139fa1a 100644 --- a/modules/calendar/lib/react/calendar-date-change-buttons/index.js +++ b/modules/calendar/lib/react/calendar-date-change-buttons/index.js @@ -3,15 +3,16 @@ /** * External dependencies */ -import React from 'react'; -import PropTypes from 'prop-types'; -import moment from 'moment'; -import { __, sprintf } from '@wordpress/i18n'; import { Button } from '@wordpress/components'; +import { __, sprintf } from '@wordpress/i18n'; import { addQueryArgs } from '@wordpress/url'; +import moment from 'moment'; +import PropTypes from 'prop-types'; +import React from 'react'; // Get rid of this eventually -const BUTTON_TYPE_PROPS = parseFloat( EF_CALENDAR.WP_VERSION ) >= 5.4 ? { isSecondary: true } : { isDefault: true }; +const BUTTON_TYPE_PROPS = + parseFloat( EF_CALENDAR.WP_VERSION ) >= 5.4 ? { isSecondary: true } : { isDefault: true }; /** * Internal dependencies @@ -34,7 +35,9 @@ const moveByWeeks = ( addOrSubtract, beginningOfWeek, pageUrl, filterValues, wee queryArgFilters.start_date = beginningOfWeek; } - queryArgFilters.start_date = ( ( moment( queryArgFilters.start_date, 'YYYY-MM-DD' ) )[ addOrSubtract ]( weeksNumber, 'weeks' ) ).format( 'YYYY-MM-DD' ); + queryArgFilters.start_date = moment( queryArgFilters.start_date, 'YYYY-MM-DD' ) + [ addOrSubtract ]( weeksNumber, 'weeks' ) + .format( 'YYYY-MM-DD' ); return addQueryArgs( pageUrl, queryArgFilters ); }; @@ -65,55 +68,55 @@ const moveBackByWeeks = ( weeksNumber, beginningOfWeek, pageUrl, filterValues ) return moveByWeeks( 'subtract', beginningOfWeek, pageUrl, filterValues, weeksNumber ); }; -const CalendarDateChangeButtons = ( { - numberOfWeeks, - beginningOfWeek, - pageUrl, - filterValues, -} ) => { +const CalendarDateChangeButtons = ( { numberOfWeeks, beginningOfWeek, pageUrl, filterValues } ) => { return (
- {numberOfWeeks > 1 ? ( + { numberOfWeeks > 1 ? ( - ) : null} + ) : null } - {numberOfWeeks > 1 ? ( + { numberOfWeeks > 1 ? ( - ) : null} + ) : null }
); }; diff --git a/modules/calendar/lib/react/calendar-filters/index.js b/modules/calendar/lib/react/calendar-filters/index.js index 8d89f7268..1f1d8a1c7 100644 --- a/modules/calendar/lib/react/calendar-filters/index.js +++ b/modules/calendar/lib/react/calendar-filters/index.js @@ -3,15 +3,16 @@ /** * External Dependencies */ -import React from 'react'; -import PropTypes from 'prop-types'; -import classnames from 'classnames'; -import { __ } from '@wordpress/i18n'; import { SelectControl, Button, Spinner } from '@wordpress/components'; +import { __ } from '@wordpress/i18n'; import { addQueryArgs } from '@wordpress/url'; +import classnames from 'classnames'; +import PropTypes from 'prop-types'; +import React from 'react'; // Get rid of this eventually -const BUTTON_TYPE_PROPS = parseFloat( EF_CALENDAR.WP_VERSION ) >= 5.4 ? { isSecondary: true } : { isDefault: true }; +const BUTTON_TYPE_PROPS = + parseFloat( EF_CALENDAR.WP_VERSION ) >= 5.4 ? { isSecondary: true } : { isDefault: true }; /** * Internal Dependencies @@ -19,9 +20,7 @@ const BUTTON_TYPE_PROPS = parseFloat( EF_CALENDAR.WP_VERSION ) >= 5.4 ? { isSeco import { ComboBox } from '../combobox'; import './style.react.scss'; -function init( { - filters, -} ) { +function init( { filters } ) { return { ...filters.reduce( ( acc, next ) => { const filter = { @@ -62,98 +61,113 @@ class CalendarFilters extends React.Component { return (
-
+ - { - filters.map( filter => { - switch ( filter.filterType ) { - case 'select': - return ( -
- - this.updateFilter( { - name: filter.name, - value: newValue, - } ) + { filters.map( filter => { + switch ( filter.filterType ) { + case 'select': + return ( +
+ + this.updateFilter( { + name: filter.name, + value: newValue, + } ) + } + /> +
+ ); + case 'combobox': + return ( +
+ ( item ? item.name : '' ) } + onInputBlur={ ( items, inputValue ) => { + /** + * If this is set, if a user has typed out a name + * and it matches an item in the list, select it for them + */ + if ( + ! filter.selectFirstItemOnBlur || + items.length < 1 || + ! inputValue || + inputValue.toLowerCase() !== items[ 0 ].name.toLowerCase() + ) { + return; } - /> -
- ); - case 'combobox': - return ( -
- item ? item.name : ''} - onInputBlur={( items, inputValue ) => { - /** - * If this is set, if a user has typed out a name - * and it matches an item in the list, select it for them - */ - if ( ! filter.selectFirstItemOnBlur || - items.length < 1 || - ! inputValue || - inputValue.toLowerCase() !== items[ 0 ].name.toLowerCase() ) { - return; - } + this.updateFilter( { + name: filter.name, + value: items[ 0 ], + } ); + } } + onStateChange={ changes => { + if ( changes.hasOwnProperty( 'selectedItem' ) ) { this.updateFilter( { name: filter.name, - value: items[ 0 ], + value: changes.selectedItem, } ); - }} - onStateChange={changes => { - if ( - changes.hasOwnProperty( 'selectedItem' ) - ) { - this.updateFilter( { - name: filter.name, - value: changes.selectedItem, - } ); - } else if ( - changes.hasOwnProperty( 'inputValue' ) - ) { - this.updateFilter( { - name: `${ filter.name }InputValue`, - value: changes.inputValue, - } ); - } - }} - /> - -
- ); - } - } ) - } + } else if ( changes.hasOwnProperty( 'inputValue' ) ) { + this.updateFilter( { + name: `${ filter.name }InputValue`, + value: changes.inputValue, + } ); + } + } } + /> + +
+ ); + } + } ) }
- + + { ...BUTTON_TYPE_PROPS } + > + { __( 'Reset', 'edit-flow' ) } + { isLoading ? : null }
@@ -164,16 +178,20 @@ class CalendarFilters extends React.Component { } CalendarFilters.propTypes = { - filters: PropTypes.arrayOf( PropTypes.shape( { - name: PropTypes.string, - filterType: PropTypes.string, - label: PropTypes.string, - options: PropTypes.arrayOf( PropTypes.shape( { + filters: PropTypes.arrayOf( + PropTypes.shape( { name: PropTypes.string, - value: PropTypes.any, - } ) ), - initialValue: PropTypes.any, - } ) ), + filterType: PropTypes.string, + label: PropTypes.string, + options: PropTypes.arrayOf( + PropTypes.shape( { + name: PropTypes.string, + value: PropTypes.any, + } ) + ), + initialValue: PropTypes.any, + } ) + ), pageUrl: PropTypes.string, isLoading: PropTypes.bool, }; diff --git a/modules/calendar/lib/react/calendar-header/index.js b/modules/calendar/lib/react/calendar-header/index.js index 4eddf3ee9..cefaa386e 100644 --- a/modules/calendar/lib/react/calendar-header/index.js +++ b/modules/calendar/lib/react/calendar-header/index.js @@ -3,17 +3,17 @@ /** * External dependencies */ -import React from 'react'; -import PropTypes from 'prop-types'; import { Snackbar, Animate } from '@wordpress/components'; import { withSelect, registerStore } from '@wordpress/data'; import classnames from 'classnames'; +import PropTypes from 'prop-types'; +import React from 'react'; /** * Internal dependencies */ -import { CalendarFilters } from '../calendar-filters'; import { CalendarDateChangeButtons } from '../calendar-date-change-buttons'; +import { CalendarFilters } from '../calendar-filters'; import './style.react.scss'; const DEFAULT_STORE_STATE = { @@ -76,43 +76,52 @@ registerStore( 'edit-flow/calendar', { }, } ); -const CalendarHeader = ( ( { snackbarMessage, isLoading, filters, filterValues, numberOfWeeks, beginningOfWeek, pageUrl } ) => { +const CalendarHeader = ( { + snackbarMessage, + isLoading, + filters, + filterValues, + numberOfWeeks, + beginningOfWeek, + pageUrl, +} ) => { return (
- + - { - snackbarMessage ? ( - - { ( { className } ) => ( - -
{snackbarMessage}
-
- ) } -
- ) : null - } - + { snackbarMessage ? ( + + { ( { className } ) => ( + +
{ snackbarMessage }
+
+ ) } +
+ ) : null }
); -} ); +}; CalendarHeader.propTypes = { - filters: PropTypes.arrayOf( PropTypes.shape( { - name: PropTypes.string, - filterType: PropTypes.string, - label: PropTypes.string, - options: PropTypes.arrayOf( PropTypes.shape( { + filters: PropTypes.arrayOf( + PropTypes.shape( { + name: PropTypes.string, + filterType: PropTypes.string, label: PropTypes.string, - value: PropTypes.any, - } ) ), - initialValue: PropTypes.any, - } ) ), + options: PropTypes.arrayOf( + PropTypes.shape( { + label: PropTypes.string, + value: PropTypes.any, + } ) + ), + initialValue: PropTypes.any, + } ) + ), filterValues: PropTypes.object, // FilterValues is an object of key value pairs numberOfWeeks: PropTypes.number, beginningOfWeek: PropTypes.string, // Formatted 'YYYY-MM-DD' @@ -122,10 +131,7 @@ CalendarHeader.propTypes = { }; const CalendarHeaderWithData = withSelect( select => { - const { - getCalendarSnackbarMessage, - getCalendarIsLoading, - } = select( 'edit-flow/calendar' ); + const { getCalendarSnackbarMessage, getCalendarIsLoading } = select( 'edit-flow/calendar' ); return { snackbarMessage: getCalendarSnackbarMessage(), diff --git a/modules/calendar/lib/react/calendar.react.js b/modules/calendar/lib/react/calendar.react.js index 93eec4bb4..d8b65cf35 100644 --- a/modules/calendar/lib/react/calendar.react.js +++ b/modules/calendar/lib/react/calendar.react.js @@ -3,9 +3,9 @@ /** * External dependencies */ +import { _n, __, sprintf } from '@wordpress/i18n'; import React from 'react'; import ReactDOM from 'react-dom'; -import { _n, __, sprintf } from '@wordpress/i18n'; /** * Internal dependencies @@ -15,7 +15,11 @@ import './style.react.scss'; // See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat function flatDeep( arr, d = 1 ) { - return d > 0 ? arr.reduce( ( acc, val ) => acc.concat( Array.isArray( val ) ? flatDeep( val, d - 1 ) : val ), [] ) + return d > 0 + ? arr.reduce( + ( acc, val ) => acc.concat( Array.isArray( val ) ? flatDeep( val, d - 1 ) : val ), + [] + ) : arr.slice(); } @@ -30,10 +34,7 @@ function organizeItems( items, parent = 0, level = 0 ) { return items .filter( item => item.parent === parent ) .map( item => { - return [ { ...item, level } ] - .concat( - organizeItems( items, item.value, level + 1 ) - ); + return [ { ...item, level } ].concat( organizeItems( items, item.value, level + 1 ) ); } ); } @@ -44,12 +45,19 @@ const EF_CATEGORY_MAP = ( { term_id: value, name, parent } ) => ( { value, name, * The number of weeks is a drop listing the maximum number of weeks a user can select (usually 12). This creates an array and fills * it with null so we can map over the length of the array and fill it with the labels we need */ -const NUM_WEEKS_OPTIONS = ( new Array( EF_CALENDAR.NUM_WEEKS.MAX ) ) +const NUM_WEEKS_OPTIONS = new Array( EF_CALENDAR.NUM_WEEKS.MAX ) .fill( null ) - .map( ( value, index ) => ( { value: index + 1, label: sprintf( _n( '%d week', '%d weeks', index + 1, 'text-domain' ), index + 1 ) } ) ); + .map( ( value, index ) => ( { + value: index + 1, + label: sprintf( _n( '%d week', '%d weeks', index + 1, 'text-domain' ), index + 1 ), + } ) ); -const INITIAL_CATEGORY = EF_CALENDAR.CATEGORIES.filter( category => category.term_id === EF_CALENDAR.FILTERS.cat ).map( EF_CATEGORY_MAP )[ 0 ]; -const INITIAL_USER = EF_CALENDAR.USERS.filter( user => user.id === EF_CALENDAR.FILTERS.author ).map( EF_USER_MAP )[ 0 ]; +const INITIAL_CATEGORY = EF_CALENDAR.CATEGORIES.filter( + category => category.term_id === EF_CALENDAR.FILTERS.cat +).map( EF_CATEGORY_MAP )[ 0 ]; +const INITIAL_USER = EF_CALENDAR.USERS.filter( user => user.id === EF_CALENDAR.FILTERS.author ).map( + EF_USER_MAP +)[ 0 ]; /** * Filters are hardcoded here for the moment, eventually should introduce some filtering to support custom filters @@ -60,8 +68,9 @@ const filters = [ name: 'post_status', filterType: 'select', label: __( 'Select a status', 'edit-flow' ), - options: [ { value: '', label: __( 'Select a status', 'edit-flow' ) } ] - .concat( EF_CALENDAR.POST_STATI.map( ( { name: value, label } ) => ( { value, label } ) ) ), + options: [ { value: '', label: __( 'Select a status', 'edit-flow' ) } ].concat( + EF_CALENDAR.POST_STATI.map( ( { name: value, label } ) => ( { value, label } ) ) + ), initialValue: EF_CALENDAR.FILTERS.post_status, }, { @@ -98,8 +107,9 @@ if ( EF_CALENDAR.POST_TYPES && EF_CALENDAR.POST_TYPES.length > 1 ) { name: 'cpt', filterType: 'select', label: __( 'Select a type', 'edit-flow' ), - options: [ { value: '', label: __( 'Select a type', 'edit-flow' ) } ] - .concat( EF_CALENDAR.POST_TYPES.map( ( { name: value, label } ) => ( { value, label } ) ) ), + options: [ { value: '', label: __( 'Select a type', 'edit-flow' ) } ].concat( + EF_CALENDAR.POST_TYPES.map( ( { name: value, label } ) => ( { value, label } ) ) + ), initialValue: EF_CALENDAR.FILTERS.cpt, } ); } @@ -114,11 +124,11 @@ filters.push( { ReactDOM.render( , document.getElementById( 'ef-calendar-navigation-mount' ) ); diff --git a/modules/calendar/lib/react/combobox/index.js b/modules/calendar/lib/react/combobox/index.js index 06cc947bb..de97a7411 100644 --- a/modules/calendar/lib/react/combobox/index.js +++ b/modules/calendar/lib/react/combobox/index.js @@ -3,12 +3,12 @@ /** * External dependencies */ -import React from 'react'; +import { BaseControl, Button, IconButton } from '@wordpress/components'; +import classnames from 'classnames'; import Downshift from 'downshift'; import matchSorter from 'match-sorter'; -import classnames from 'classnames'; import PropTypes from 'prop-types'; -import { BaseControl, Button, IconButton } from '@wordpress/components'; +import React from 'react'; // Get rid of this eventually const ACTIVE_ICON_BUTTON = parseFloat( EF_CALENDAR.WP_VERSION ) >= 5.3 ? Button : IconButton; @@ -28,8 +28,8 @@ import './style.react.scss'; function getItems( filter, items ) { return filter ? matchSorter( items, filter, { - keys: [ 'name' ], - } ) + keys: [ 'name' ], + } ) : items; } @@ -66,9 +66,9 @@ const ComboBox = ( { ...comboboxPropsRest } ) => { return ( -
- - {( { +
+ + { ( { getInputProps, getToggleButtonProps, getMenuProps, @@ -88,25 +88,26 @@ const ComboBox = ( { foundItems = filteredItems.map( ( item, index ) => { return (
  • - {item.level && ! inputValue + { item.level && ! inputValue ? new Array( item.level ).fill( '\xa0' ).join( '' ) - : null} - {item.parent && inputValue ? ( + : null } + { item.parent && inputValue ? ( - {getItem( items, item.parent ).name} + { getItem( items, item.parent ).name } - ) : null} - {item.parent && inputValue ? '\xa0' : null}{item.name} + ) : null } + { item.parent && inputValue ? '\xa0' : null } + { item.name }
  • ); } ); @@ -115,15 +116,15 @@ const ComboBox = ( { if ( isOpen && foundItems.length < 1 ) { foundItems = [
  • - {noMatchText} + { noMatchText }
  • , ]; } @@ -131,55 +132,53 @@ const ComboBox = ( { return (
    - + { onInputBlur && onInputBlur( filteredItems, inputValue ); }, onFocus: openMenu, type: 'text', - placeholder: placeholder, - } )} + placeholder, + } ) } /> - {selectedItem ? ( + { selectedItem ? ( ) : ( - )} + ) }
      - {isOpen ? foundItems : null} + { isOpen ? foundItems : null }
    ); - }} + } }
    ); @@ -193,12 +192,14 @@ ComboBox.propTypes = { buttonCloseLabel: PropTypes.string, buttonClearLabel: PropTypes.string, label: PropTypes.string, - items: PropTypes.arrayOf( PropTypes.shape( { - name: PropTypes.string.isRequired, - id: PropTypes.oneOfType( [ PropTypes.string, PropTypes.number ] ), - parent: PropTypes.oneOfType( [ PropTypes.string, PropTypes.number ] ), - level: PropTypes.number, - } ) ), + items: PropTypes.arrayOf( + PropTypes.shape( { + name: PropTypes.string.isRequired, + id: PropTypes.oneOfType( [ PropTypes.string, PropTypes.number ] ), + parent: PropTypes.oneOfType( [ PropTypes.string, PropTypes.number ] ), + level: PropTypes.number, + } ) + ), noMatchText: PropTypes.string, // What to display in the menu dropdown if no items match onInputBlur: PropTypes.func, // Arguments to function: (filtered items at the time of blur, the value in the input) }; diff --git a/modules/custom-status/lib/custom-status-configure.js b/modules/custom-status/lib/custom-status-configure.js index 0faae970d..aa1ff590e 100644 --- a/modules/custom-status/lib/custom-status-configure.js +++ b/modules/custom-status/lib/custom-status-configure.js @@ -1,174 +1,208 @@ +( function ( $ ) { + inlineEditCustomStatus = { + init() { + const t = this; + const row = $( '#inline-edit' ); + + t.what = '#term-'; + + $( document ).on( 'click', '.editinline', function () { + inlineEditCustomStatus.edit( this ); + return false; + } ); + + // prepare the edit row + row.on( 'keyup', function ( e ) { + if ( e.which == 27 ) { + return inlineEditCustomStatus.revert(); + } + } ); + + $( 'a.cancel', row ).on( 'click', function () { + return inlineEditCustomStatus.revert(); + } ); + $( 'a.save', row ).on( 'click', function () { + return inlineEditCustomStatus.save( this ); + } ); + $( 'input, select', row ).on( 'keydown', function ( e ) { + if ( e.which == 13 ) { + return inlineEditCustomStatus.save( this ); + } + } ); -(function($) { -inlineEditCustomStatus = { - - init : function() { - var t = this, row = $('#inline-edit'); - - t.what = '#term-'; - - $( document ).on( 'click', '.editinline', function(){ - inlineEditCustomStatus.edit(this); - return false; - }); - - // prepare the edit row - row.on( 'keyup', function(e) { if(e.which == 27) return inlineEditCustomStatus.revert(); }); + $( '#posts-filter input[type="submit"]' ).on( 'mousedown', function ( e ) { + t.revert(); + } ); + }, - $('a.cancel', row).on( 'click', function() { return inlineEditCustomStatus.revert(); }); - $('a.save', row).on( 'click', function() { return inlineEditCustomStatus.save(this); }); - $('input, select', row).on( 'keydown', function(e) { if(e.which == 13) return inlineEditCustomStatus.save(this); }); + toggle( el ) { + const t = this; + $( t.what + t.getId( el ) ).css( 'display' ) == 'none' ? t.revert() : t.edit( el ); + }, - $('#posts-filter input[type="submit"]').on( 'mousedown', function(e){ + edit( id ) { + const t = this; + let editRow; t.revert(); - }); - }, - toggle : function(el) { - var t = this; - $(t.what+t.getId(el)).css('display') == 'none' ? t.revert() : t.edit(el); - }, - - edit : function(id) { - var t = this, editRow; - t.revert(); - - if ( typeof(id) == 'object' ) - id = t.getId(id); + if ( typeof id === 'object' ) { + id = t.getId( id ); + } - editRow = $('#inline-edit').clone(true), rowData = $('#inline_'+id); - $('td', editRow).attr('colspan', $('.widefat:first thead th:visible').length); + ( editRow = $( '#inline-edit' ).clone( true ) ), ( rowData = $( '#inline_' + id ) ); + $( 'td', editRow ).attr( 'colspan', $( '.widefat:first thead th:visible' ).length ); - if ( $(t.what+id).hasClass('alternate') ) - $(editRow).addClass('alternate'); + if ( $( t.what + id ).hasClass( 'alternate' ) ) { + $( editRow ).addClass( 'alternate' ); + } - $(t.what+id).hide().after(editRow); + $( t.what + id ) + .hide() + .after( editRow ); - var name_text = $('.name', rowData).text() - $(':input[name="name"]', editRow).val( name_text ); - $(':input[name="description"]', editRow).val( $('.description', rowData).text() ); + const name_text = $( '.name', rowData ).text(); + $( ':input[name="name"]', editRow ).val( name_text ); + $( ':input[name="description"]', editRow ).val( $( '.description', rowData ).text() ); - $(editRow).attr('id', 'edit-'+id).addClass('inline-editor').show(); + $( editRow ) + .attr( 'id', 'edit-' + id ) + .addClass( 'inline-editor' ) + .show(); - var $name_field = $('.ptitle', editRow).eq(0) - if( 'draft' === name_text.trim().toLowerCase() ) { - $name_field.attr('readonly', 'readonly'); - } else { - $name_field.focus(); - } + const $name_field = $( '.ptitle', editRow ).eq( 0 ); + if ( 'draft' === name_text.trim().toLowerCase() ) { + $name_field.attr( 'readonly', 'readonly' ); + } else { + $name_field.focus(); + } + return false; + }, - return false; - }, + save( id ) { + let params; + let fields; + const tax = $( 'input[name="taxonomy"]' ).val() || ''; - save : function(id) { - var params, fields, tax = $('input[name="taxonomy"]').val() || ''; + if ( typeof id === 'object' ) { + id = this.getId( id ); + } - if( typeof(id) == 'object' ) - id = this.getId(id); + $( 'table.widefat .inline-edit-save .waiting' ).show(); - $('table.widefat .inline-edit-save .waiting').show(); + params = { + action: 'inline_save_status', + status_id: id, + }; - params = { - action: 'inline_save_status', - status_id: id, - }; + fields = $( '#edit-' + id + ' :input' ).serialize(); + params = fields + '&' + $.param( params ); - fields = $('#edit-'+id+' :input').serialize(); - params = fields + '&' + $.param(params); + // make ajax request + $.post( ajaxurl, params, function ( r ) { + let row; + let new_id; + $( 'table.widefat .inline-edit-save .waiting' ).hide(); + if ( r ) { + if ( -1 != r.indexOf( ''; + var message = + '' + + retval.message + + ''; } else { - var message = '' + retval.message + ''; + var message = + '' + retval.message + ''; } - jQuery('.edit-flow-admin h2').append( message ); + jQuery( '.edit-flow-admin h2' ).append( message ); // Set a timeout to eventually remove it setTimeout( edit_flow_hide_message, 8000 ); - }); + } ); }, - }); - jQuery( "#the-list tr.term-static" ).disableSelection(); - -}); + } ); + jQuery( '#the-list tr.term-static' ).disableSelection(); +} ); diff --git a/modules/custom-status/lib/custom-status.js b/modules/custom-status/lib/custom-status.js index f9747eb4e..8e8d71cca 100644 --- a/modules/custom-status/lib/custom-status.js +++ b/modules/custom-status/lib/custom-status.js @@ -1,190 +1,212 @@ -jQuery(document).ready(function() { +jQuery( document ).ready( function () { + const i18n = window.__ef_localize_custom_status; - var i18n = window.__ef_localize_custom_status; + jQuery( 'label[for=post_status]' ).show(); + jQuery( '#post-status-display' ).show(); - jQuery('label[for=post_status]').show(); - jQuery('#post-status-display').show(); - - if ( jQuery('select[name="_status"]').length == 0 ) { // not on quick edit - - if ( current_user_can_publish_posts || ( current_status == 'publish' && current_user_can_edit_published_posts ) ) { + if ( jQuery( 'select[name="_status"]' ).length == 0 ) { + // not on quick edit + if ( + current_user_can_publish_posts || + ( current_status == 'publish' && current_user_can_edit_published_posts ) + ) { // show publish button if allowed to publish - jQuery('#publish').show(); + jQuery( '#publish' ).show(); } else { // mimic default post status dropdown - jQuery(' ' + i18n.edit + '' + - '
    ' + - ' ' + - ' ' + - ' ' + i18n.ok + '' + - ' ' + i18n.cancel + '' + - '
    ').insertAfter('#post-status-display'); - - if (!status_dropdown_visible) { - jQuery('#post-status-select').hide(); - jQuery('.edit-post-status').show(); + jQuery( + ' ' + + i18n.edit + + '' + + '
    ' + + ' ' + + " ' + + ' ' + + i18n.ok + + '' + + ' ' + + i18n.cancel + + '' + + '
    ' + ).insertAfter( '#post-status-display' ); + + if ( ! status_dropdown_visible ) { + jQuery( '#post-status-select' ).hide(); + jQuery( '.edit-post-status' ).show(); } - jQuery('.edit-post-status').on( 'click', function() { - jQuery('#post-status-select').slideDown(); - jQuery('.edit-post-status').hide(); + jQuery( '.edit-post-status' ).on( 'click', function () { + jQuery( '#post-status-select' ).slideDown(); + jQuery( '.edit-post-status' ).hide(); return false; - }); - jQuery('.cancel-post-status, .save-post-status').on( 'click', function() { - jQuery('#post-status-select').slideUp(); - jQuery('.edit-post-status').show(); + } ); + jQuery( '.cancel-post-status, .save-post-status' ).on( 'click', function () { + jQuery( '#post-status-select' ).slideUp(); + jQuery( '.edit-post-status' ).show(); return false; - }); - jQuery('.save-post-status').on( 'click', function() { - jQuery('#post-status-display').text(jQuery('select[name="post_status"] :selected').text()); + } ); + jQuery( '.save-post-status' ).on( 'click', function () { + jQuery( '#post-status-display' ).text( + jQuery( 'select[name="post_status"] :selected' ).text() + ); return false; - }); + } ); } } // 1. Add custom statuses to post.php Status dropdown // Or 2. Add custom statuses to quick-edit status dropdowns on edit.php // Or 3. Hide two inputs with the default workflow status to override 'Draft' as the default contributor status - if ( jQuery('select[name="post_status"]').length > 0 ) { - + if ( jQuery( 'select[name="post_status"]' ).length > 0 ) { // Set the Save button to generic text by default - ef_update_save_button(i18n.save); - + ef_update_save_button( i18n.save ); + // Bind event when OK button is clicked - jQuery('.save-post-status').on( 'click', function() { + jQuery( '.save-post-status' ).on( 'click', function () { ef_update_save_button(); - }); - + } ); + // Add custom statuses to Status dropdown - ef_append_to_dropdown('select[name="post_status"]'); - + ef_append_to_dropdown( 'select[name="post_status"]' ); + // Make status dropdown visible on load if enabled if ( status_dropdown_visible ) { - jQuery('#post-status-select').show(); - jQuery('.edit-post-status').hide(); + jQuery( '#post-status-select' ).show(); + jQuery( '.edit-post-status' ).hide(); } - + // Hide status dropdown if not allowed to edit - if ( !ef_can_change_status(current_status) ) { - jQuery('#post-status-select').hide(); - jQuery('.edit-post-status').hide(); - + if ( ! ef_can_change_status( current_status ) ) { + jQuery( '#post-status-select' ).hide(); + jQuery( '.edit-post-status' ).hide(); + // set the current status as the selected one - var $option = jQuery('').text(current_status_name).attr('value', current_status).attr('selected', 'selected'); + const $option = jQuery( '' ) + .text( current_status_name ) + .attr( 'value', current_status ) + .attr( 'selected', 'selected' ); - $option.appendTo('select[name="post_status"]'); + $option.appendTo( 'select[name="post_status"]' ); } - - // If custom status set for post, then set is as #post-status-display - jQuery('#post-status-display').text(ef_get_status_name(current_status)); - } else if ( jQuery('select[name="_status"]').length > 0 ) { - ef_append_to_dropdown('select[name="_status"]'); + // If custom status set for post, then set is as #post-status-display + jQuery( '#post-status-display' ).text( ef_get_status_name( current_status ) ); + } else if ( jQuery( 'select[name="_status"]' ).length > 0 ) { + ef_append_to_dropdown( 'select[name="_status"]' ); // Clean up the bulk edit selector because it's non-standard - jQuery( '#bulk-edit' ).find( 'select[name="_status"]' ).prepend( '' ); + jQuery( '#bulk-edit' ) + .find( 'select[name="_status"]' ) + .prepend( '' ); jQuery( '#bulk-edit' ).find( 'select[name="_status"] option' ).prop( 'selected', false ); - jQuery( '#bulk-edit' ).find( 'select[name="_status"] option[value="future"]').remove(); + jQuery( '#bulk-edit' ).find( 'select[name="_status"] option[value="future"]' ).remove(); } else { - // Set the Save button to generic text by default - ef_update_save_button(i18n.save); + ef_update_save_button( i18n.save ); // If custom status set for post, then set is as #post-status-display - jQuery('#post-status-display').text(ef_get_status_name(current_status)); - + jQuery( '#post-status-display' ).text( ef_get_status_name( current_status ) ); } - - if (jQuery('ul.subsubsub')) { - ef_add_tooltips_to_filter_links('ul.subsubsub li a'); + + if ( jQuery( 'ul.subsubsub' ) ) { + ef_add_tooltips_to_filter_links( 'ul.subsubsub li a' ); } - + // Add custom statuses to Status dropdown function ef_append_to_dropdown( id ) { - // Empty dropdown except for 'future' because we need to persist that - jQuery(id + ' option').not('[value="future"]').remove(); - + jQuery( id + ' option' ) + .not( '[value="future"]' ) + .remove(); + // Add "Published" status to quick-edit for users that can publish - if ( id=='select[name="_status"]' && current_user_can_publish_posts ) { - jQuery(id).append(jQuery('') - .text(this.name) - .attr('value', this.slug) - .attr('title', (this.description) ? this.description : '') - ; - - if( current_status == this.slug ) $option.attr('selected','selected'); - - $option.appendTo( jQuery(id) ); - }); + } + + const $option = jQuery( '' ) + .text( this.name ) + .attr( 'value', this.slug ) + .attr( 'title', this.description ? this.description : '' ); + if ( current_status == this.slug ) { + $option.attr( 'selected', 'selected' ); + } + + $option.appendTo( jQuery( id ) ); + } ); } - - function ef_can_change_status(slug) { - var change = false; - - jQuery.each(custom_statuses, function() { - if(this.slug==slug) change = true; - }); - if (slug == 'publish' && !current_user_can_publish_posts) { + + function ef_can_change_status( slug ) { + let change = false; + + jQuery.each( custom_statuses, function () { + if ( this.slug == slug ) { + change = true; + } + } ); + if ( slug == 'publish' && ! current_user_can_publish_posts ) { change = false; } return change; } - - function ef_add_tooltips_to_filter_links(selector) { - jQuery.each(custom_statuses, function() { - jQuery(selector + ':contains("'+ this.name +'")') - .attr('title', this.description) - }) - + + function ef_add_tooltips_to_filter_links( selector ) { + jQuery.each( custom_statuses, function () { + jQuery( selector + ':contains("' + this.name + '")' ).attr( 'title', this.description ); + } ); } - + // Update "Save" button text function ef_update_save_button( text ) { - if(!text) text = i18n.save_as + ' ' + jQuery('select[name="post_status"] :selected').text(); - jQuery(':input#save-post').attr('value', text); + if ( ! text ) { + text = i18n.save_as + ' ' + jQuery( 'select[name="post_status"] :selected' ).text(); + } + jQuery( ':input#save-post' ).attr( 'value', text ); } - + // Returns the name of the status given a slug - function ef_get_status_name (slug) { - var name = ''; - jQuery.each(custom_statuses, function() { - if(this.slug==slug) name = this.name; - }); - - if (!name) { + function ef_get_status_name( slug ) { + let name = ''; + jQuery.each( custom_statuses, function () { + if ( this.slug == slug ) { + name = this.name; + } + } ); + + if ( ! name ) { name = current_status_name; } - + return name; } // If we're on the Manage Posts screen, remove the trailing dashes left behind once we hide the post-state span (the status). // We do this since we already add a custom column for post status on the screen since custom statuses are a core part of EF. - if ( jQuery('.post-state').length > 0 ) { + if ( jQuery( '.post-state' ).length > 0 ) { ef_remove_post_title_trailing_dashes(); } // Remove the " - " in between a post title and the post-state span (separately hidden via CSS). // This will not affect the dash before post-state-format spans. function ef_remove_post_title_trailing_dashes() { - jQuery('.post-title.column-title strong').each(function() { - jQuery(this).html(jQuery(this).html().replace(/(.*) - ()$/g, "$1$2")); - }); + jQuery( '.post-title.column-title strong' ).each( function () { + jQuery( this ).html( + jQuery( this ) + .html() + .replace( /(.*) - ()$/g, '$1$2' ) + ); + } ); } - -}); \ No newline at end of file +} ); diff --git a/modules/editorial-comments/lib/editorial-comments.js b/modules/editorial-comments/lib/editorial-comments.js index 6b690bcb0..312f245e1 100644 --- a/modules/editorial-comments/lib/editorial-comments.js +++ b/modules/editorial-comments/lib/editorial-comments.js @@ -1,124 +1,128 @@ -jQuery(document).ready(function () { +jQuery( document ).ready( function () { editorialCommentReply.init(); // Check if certain hash flag set and take action - if (location.hash == '#editorialcomments/add') { + if ( location.hash == '#editorialcomments/add' ) { editorialCommentReply.open(); - } else if (location.hash.search(/#editorialcomments\/reply/) > -1) { - var reply_id = location.hash.substring(location.hash.lastIndexOf('/')+1); - editorialCommentReply.open(reply_id); + } else if ( location.hash.search( /#editorialcomments\/reply/ ) > -1 ) { + const reply_id = location.hash.substring( location.hash.lastIndexOf( '/' ) + 1 ); + editorialCommentReply.open( reply_id ); } -}); +} ); /** * Blatantly stolen and modified from /wp-admin/js/edit-comment.dev.js -- yay! */ editorialCommentReply = { + init() { + const row = jQuery( '#ef-replyrow' ); - init : function() { - var row = jQuery('#ef-replyrow'); - // Bind click events to cancel and submit buttons - jQuery('a.ef-replycancel', row).on( 'click', function() { return editorialCommentReply.revert(); }); - jQuery('a.ef-replysave', row).on( 'click', function() { return editorialCommentReply.send(); }); + jQuery( 'a.ef-replycancel', row ).on( 'click', function () { + return editorialCommentReply.revert(); + } ); + jQuery( 'a.ef-replysave', row ).on( 'click', function () { + return editorialCommentReply.send(); + } ); // Watch for changes to the subscribed users. - jQuery( '#ef-post_following_box' ).on( 'following_list_updated', function() { + jQuery( '#ef-post_following_box' ).on( 'following_list_updated', function () { editorialCommentReply.notifiedMessage(); } ); }, - revert : function() { - // Fade out slowly, slowly, slowly... - jQuery('#ef-replyrow').fadeOut('fast', function(){ + revert() { + // Fade out slowly, slowly, slowly... + jQuery( '#ef-replyrow' ).fadeOut( 'fast', function () { editorialCommentReply.close(); - }); + } ); return false; }, - close : function() { - - jQuery('#ef-comment_respond').show(); - + close() { + jQuery( '#ef-comment_respond' ).show(); + // Move reply form back after the main "Respond" form - jQuery('#ef-post_comment').after( jQuery('#ef-replyrow') ); - + jQuery( '#ef-post_comment' ).after( jQuery( '#ef-replyrow' ) ); + // Empty out all the form values - jQuery('#ef-replycontent').val(''); - jQuery('#ef-comment_parent').val(''); + jQuery( '#ef-replycontent' ).val( '' ); + jQuery( '#ef-comment_parent' ).val( '' ); // Hide error and waiting - jQuery('#ef-replysubmit .error').html('').hide(); - jQuery('#ef-comment_loading').hide(); + jQuery( '#ef-replysubmit .error' ).html( '' ).hide(); + jQuery( '#ef-comment_loading' ).hide(); }, /** * @id = comment id */ - open : function(id) { - var parent; - + open( id ) { + let parent; + // Close any open reply boxes this.close(); - + // Check if reply or new comment - if(id) { - jQuery('input#ef-comment_parent').val(id); - parent = '#comment-'+id; + if ( id ) { + jQuery( 'input#ef-comment_parent' ).val( id ); + parent = '#comment-' + id; } else { parent = '#ef-comments_wrapper'; } - - jQuery('#ef-comment_respond').hide(); + + jQuery( '#ef-comment_respond' ).hide(); // Display who will be notified for this comment this.notifiedMessage(); - + // Show reply textbox - jQuery('#ef-replyrow') - .show() - .appendTo(jQuery(parent)) - ; - - jQuery('#ef-replycontent').focus(); + jQuery( '#ef-replyrow' ).show().appendTo( jQuery( parent ) ); + + jQuery( '#ef-replycontent' ).focus(); return false; }, /** * Sends the ajax response to save the commment - * @param bool reply - indicates whether the comment is a reply or not + * @param bool reply - indicates whether the comment is a reply or not */ - send : function(reply) { - var post = {}; - var containter_id = '#ef-replyrow'; - - jQuery('#ef-replysubmit .error').html('').hide(); - + send( reply ) { + const post = {}; + const containter_id = '#ef-replyrow'; + + jQuery( '#ef-replysubmit .error' ).html( '' ).hide(); + // Validation: check to see if comment entered - post.content = jQuery.trim(jQuery('#ef-replycontent').val()); - if(!post.content) { - jQuery('#ef-replyrow .error').text('Please enter a comment').show(); + post.content = jQuery.trim( jQuery( '#ef-replycontent' ).val() ); + if ( ! post.content ) { + jQuery( '#ef-replyrow .error' ).text( 'Please enter a comment' ).show(); return; } - - jQuery('#ef-comment_loading').show(); + + jQuery( '#ef-comment_loading' ).show(); // Prepare data post.action = 'editflow_ajax_insert_comment'; - post.parent = (jQuery("#ef-comment_parent").val()=='') ? 0 : jQuery("#ef-comment_parent").val(); - post._nonce = jQuery("#ef_comment_nonce").val(); - post.post_id = jQuery("#ef-post_id").val(); - post.notification = jQuery('#ef-reply-notifier').val(); + post.parent = + jQuery( '#ef-comment_parent' ).val() == '' ? 0 : jQuery( '#ef-comment_parent' ).val(); + post._nonce = jQuery( '#ef_comment_nonce' ).val(); + post.post_id = jQuery( '#ef-post_id' ).val(); + post.notification = jQuery( '#ef-reply-notifier' ).val(); // Send the request - jQuery.ajax({ - type : 'POST', - url : (ajaxurl) ? ajaxurl : wpListL10n.url, - data : post, - success : function(x) { editorialCommentReply.show(x); }, - error : function(r) { editorialCommentReply.error(r); } - }); + jQuery.ajax( { + type: 'POST', + url: ajaxurl ? ajaxurl : wpListL10n.url, + data: post, + success( x ) { + editorialCommentReply.show( x ); + }, + error( r ) { + editorialCommentReply.error( r ); + }, + } ); return false; }, @@ -126,14 +130,14 @@ editorialCommentReply = { /** * Display who will be notified of the new comment. */ - notifiedMessage : function() { - var message_wrapper = jQuery( '#ef-reply-notifier' ); + notifiedMessage() { + const message_wrapper = jQuery( '#ef-reply-notifier' ); - if ( ! message_wrapper[0] ) { + if ( ! message_wrapper[ 0 ] ) { return; } - var subscribed_users = jQuery( '.ef-post_following_list li input:checkbox:checked' ); + const subscribed_users = jQuery( '.ef-post_following_list li input:checkbox:checked' ); // No users will be notified, so return early with a default message. if ( 0 === subscribed_users.length ) { @@ -142,16 +146,23 @@ editorialCommentReply = { return; } - var usernames = []; - subscribed_users.each( function() { + const usernames = []; + subscribed_users.each( function () { // Add usernames of checked users to the list if they don't have a blocking class - if ( ! jQuery( this ).siblings().is( '.post_following_list-no_email,.post_following_list-no_access' ) && ! jQuery( this ).hasClass( 'post_following_list-current_user' ) ) { - usernames.push( jQuery( this ).parent().siblings( '.ef-user_displayname, .ef-usergroup_name' ).text() ); + if ( + ! jQuery( this ) + .siblings() + .is( '.post_following_list-no_email,.post_following_list-no_access' ) && + ! jQuery( this ).hasClass( 'post_following_list-current_user' ) + ) { + usernames.push( + jQuery( this ).parent().siblings( '.ef-user_displayname, .ef-usergroup_name' ).text() + ); } } ); // Convert array of usernames into a sentence. - var message = usernames.pop(); + let message = usernames.pop(); if ( usernames.length > 0 ) { message = usernames.join( ', ' ) + ' ' + __ef_localize_post_comment.and + ' ' + message + '.'; } @@ -160,72 +171,70 @@ editorialCommentReply = { message_wrapper.val( message ); }, - show : function(xml) { - var response, comment, supplemental, id, bg; - + show( xml ) { + let response; + let comment; + let supplemental; + let id; + let bg; + // Didn't pass validation, so let's throw an error - if ( typeof(xml) == 'string' ) { - this.error({'responseText': xml}); + if ( typeof xml === 'string' ) { + this.error( { responseText: xml } ); return false; } - + // Parse the response - response = wpAjax.parseAjaxResponse(xml); + response = wpAjax.parseAjaxResponse( xml ); if ( response.errors ) { // Uh oh, errors found - this.error({'responseText': wpAjax.broken}); + this.error( { responseText: wpAjax.broken } ); return false; } - - response = response.responses[0]; + + response = response.responses[ 0 ]; comment = response.data; supplemental = response.supplemental; - - jQuery(comment).hide() - - if(response.action.indexOf('reply') == -1 || !ef_thread_comments) { + + jQuery( comment ).hide(); + + if ( response.action.indexOf( 'reply' ) == -1 || ! ef_thread_comments ) { // Not a reply, so add it to the bottom - jQuery('#ef-comments').append(comment); + jQuery( '#ef-comments' ).append( comment ); } else { - // This is a reply, so add it after the comment replied to - - if(jQuery('#ef-replyrow').parent().next().is('ul')) { + + if ( jQuery( '#ef-replyrow' ).parent().next().is( 'ul' ) ) { // Already been replied to, so just add to the list - jQuery('#ef-replyrow').parent().next().append(comment); + jQuery( '#ef-replyrow' ).parent().next().append( comment ); } else { // This is a first reply, so create an unordered list to house the comment - var newUL = jQuery('
      ') - .addClass('children') - .append(comment) - ; - jQuery('#ef-replyrow').parent().after(newUL) + const newUL = jQuery( '
        ' ).addClass( 'children' ).append( comment ); + jQuery( '#ef-replyrow' ).parent().after( newUL ); } } - - // Get the comment contaner's id - this.o = id = '#comment-'+response.id; + + // Get the comment contaner's id + this.o = id = '#comment-' + response.id; // Close the reply box this.revert(); - + // Show the new comment - jQuery(id) - .animate( { 'backgroundColor':'#CCEEBB' }, 600 ) - .animate( { 'backgroundColor':'#fff' }, 600 ); - + jQuery( id ) + .animate( { backgroundColor: '#CCEEBB' }, 600 ) + .animate( { backgroundColor: '#fff' }, 600 ); }, - error : function(r) { + error( r ) { // Oh noes! We haz an error! - jQuery('#ef-comment_loading').hide(); + jQuery( '#ef-comment_loading' ).hide(); if ( r.responseText ) { er = r.responseText.replace( /<.[^<>]*?>/g, '' ); } if ( er ) { - jQuery('#ef-replysubmit .error').html(er).show(); + jQuery( '#ef-replysubmit .error' ).html( er ).show(); } - - } -}; \ No newline at end of file + }, +}; diff --git a/modules/editorial-metadata/lib/editorial-metadata-configure.js b/modules/editorial-metadata/lib/editorial-metadata-configure.js index 3b34633f7..25d45f546 100644 --- a/modules/editorial-metadata/lib/editorial-metadata-configure.js +++ b/modules/editorial-metadata/lib/editorial-metadata-configure.js @@ -1,166 +1,201 @@ +( function ( $ ) { + inlineEditMetadataTerm = { + init() { + const t = this; + const row = $( '#inline-edit' ); + + t.what = '#term-'; + + $( document ).on( 'click', '.editinline', function () { + inlineEditMetadataTerm.edit( this ); + return false; + } ); + + // prepare the edit row + row.on( 'keyup', function ( e ) { + if ( e.which == 27 ) { + return inlineEditMetadataTerm.revert(); + } + } ); + + $( 'a.cancel', row ).on( 'click', function () { + return inlineEditMetadataTerm.revert(); + } ); + $( 'a.save', row ).on( 'click', function () { + return inlineEditMetadataTerm.save( this ); + } ); + $( 'input, select', row ).on( 'keydown', function ( e ) { + if ( e.which == 13 ) { + return inlineEditMetadataTerm.save( this ); + } + } ); -(function($) { -inlineEditMetadataTerm = { - - init : function() { - var t = this, row = $('#inline-edit'); - - t.what = '#term-'; - - $( document ).on( 'click', '.editinline', function(){ - inlineEditMetadataTerm.edit(this); - return false; - }); - - // prepare the edit row - row.on( 'keyup', function(e) { if(e.which == 27) return inlineEditMetadataTerm.revert(); }); + $( '#posts-filter input[type="submit"]' ).on( 'mousedown', function ( e ) { + t.revert(); + } ); + }, - $('a.cancel', row).on( 'click', function() { return inlineEditMetadataTerm.revert(); }); - $('a.save', row).on( 'click', function() { return inlineEditMetadataTerm.save(this); }); - $('input, select', row).on( 'keydown', function(e) { if(e.which == 13) return inlineEditMetadataTerm.save(this); }); + toggle( el ) { + const t = this; + $( t.what + t.getId( el ) ).css( 'display' ) == 'none' ? t.revert() : t.edit( el ); + }, - $('#posts-filter input[type="submit"]').on( 'mousedown', function(e){ + edit( id ) { + const t = this; + let editRow; t.revert(); - }); - }, - - toggle : function(el) { - var t = this; - $(t.what+t.getId(el)).css('display') == 'none' ? t.revert() : t.edit(el); - }, - edit : function(id) { - var t = this, editRow; - t.revert(); + if ( typeof id === 'object' ) { + id = t.getId( id ); + } - if ( typeof(id) == 'object' ) - id = t.getId(id); + ( editRow = $( '#inline-edit' ).clone( true ) ), ( rowData = $( '#inline_' + id ) ); + $( 'td', editRow ).attr( 'colspan', $( '.widefat:first thead th:visible' ).length ); - editRow = $('#inline-edit').clone(true), rowData = $('#inline_'+id); - $('td', editRow).attr('colspan', $('.widefat:first thead th:visible').length); + if ( $( t.what + id ).hasClass( 'alternate' ) ) { + $( editRow ).addClass( 'alternate' ); + } - if ( $(t.what+id).hasClass('alternate') ) - $(editRow).addClass('alternate'); + $( t.what + id ) + .hide() + .after( editRow ); - $(t.what+id).hide().after(editRow); + $( ':input[name="name"]', editRow ).val( $( '.name', rowData ).text() ); + $( ':input[name="description"]', editRow ).val( $( '.description', rowData ).text() ); - $(':input[name="name"]', editRow).val( $('.name', rowData).text() ); - $(':input[name="description"]', editRow).val( $('.description', rowData).text() ); - - $(editRow).attr('id', 'edit-'+id).addClass('inline-editor').show(); - $('.ptitle', editRow).eq(0).focus(); + $( editRow ) + .attr( 'id', 'edit-' + id ) + .addClass( 'inline-editor' ) + .show(); + $( '.ptitle', editRow ).eq( 0 ).focus(); - return false; - }, + return false; + }, - save : function(id) { - var params, fields, tax = $('input[name="taxonomy"]').val() || ''; + save( id ) { + let params; + let fields; + const tax = $( 'input[name="taxonomy"]' ).val() || ''; - if( typeof(id) == 'object' ) - id = this.getId(id); + if ( typeof id === 'object' ) { + id = this.getId( id ); + } - $('table.widefat .inline-edit-save .waiting').show(); + $( 'table.widefat .inline-edit-save .waiting' ).show(); - params = { - action: 'inline_save_term', - term_id: id, - }; - - fields = $('#edit-'+id+' :input').serialize(); - params = fields + '&' + $.param(params); + params = { + action: 'inline_save_term', + term_id: id, + }; + fields = $( '#edit-' + id + ' :input' ).serialize(); + params = fields + '&' + $.param( params ); - // make ajax request - $.post(ajaxurl, params, - function(r) { - var row, new_id; - $('table.widefat .inline-edit-save .waiting').hide(); + // make ajax request + $.post( ajaxurl, params, function ( r ) { + let row; + let new_id; + $( 'table.widefat .inline-edit-save .waiting' ).hide(); - if (r) { - if ( -1 != r.indexOf(''; + var message = + '' + + retval.message + + ''; } else { - var message = '' + retval.message + ''; + var message = + '' + retval.message + ''; } - jQuery('.edit-flow-admin h2').append( message ); + jQuery( '.edit-flow-admin h2' ).append( message ); // Set a timeout to eventually remove it setTimeout( edit_flow_hide_message, 8000 ); - }); + } ); }, - }); - jQuery( "#the-list tr.term-static" ).disableSelection(); - -}); + } ); + jQuery( '#the-list tr.term-static' ).disableSelection(); +} ); diff --git a/modules/notifications/lib/notifications.js b/modules/notifications/lib/notifications.js index 65b161915..47fdf2a10 100644 --- a/modules/notifications/lib/notifications.js +++ b/modules/notifications/lib/notifications.js @@ -1,19 +1,21 @@ -jQuery(document).ready(function($) { - $('#ef-post_following_users_box ul').listFilterizer(); +jQuery( document ).ready( function ( $ ) { + $( '#ef-post_following_users_box ul' ).listFilterizer(); - var params = { + const params = { action: 'save_notifications', - post_id: $('#post_ID').val(), + post_id: $( '#post_ID' ).val(), }; - - var toggle_warning_badges = function( container, response ) { + + const toggle_warning_badges = function ( container, response ) { // Remove any existing badges if ( $( container ).siblings( 'span' ).length ) { $( container ).siblings( 'span' ).remove(); } - + // "No Access" If this user was flagged as not having access - var user_has_no_access = response.data.subscribers_with_no_access.includes( parseInt( $( container ).val() ) ); + const user_has_no_access = response.data.subscribers_with_no_access.includes( + parseInt( $( container ).val() ) + ); if ( user_has_no_access ) { var span = $( '' ).addClass( 'post_following_list-no_access' ); span.text( ef_notifications_localization.no_access ); @@ -21,60 +23,68 @@ jQuery(document).ready(function($) { warning_background = true; } // "No Email" If this user was flagged as not having an email - var user_has_no_email = response.data.subscribers_with_no_email.includes( parseInt( $( container ).val() ) ); + const user_has_no_email = response.data.subscribers_with_no_email.includes( + parseInt( $( container ).val() ) + ); if ( user_has_no_email ) { var span = $( '' ).addClass( 'post_following_list-no_email' ); span.text( ef_notifications_localization.no_email ); $( container ).parent().prepend( span ); warning_background = true; } - } + }; - $(document).on('click','.ef-post_following_list li input:checkbox, .ef-following_usergroups li input:checkbox', function() { - var user_group_ids = []; - var parent_this = $(this); - params.ef_notifications_name = $(this).attr('name'); - params._nonce = $("#ef_notifications_nonce").val(); + $( document ).on( + 'click', + '.ef-post_following_list li input:checkbox, .ef-following_usergroups li input:checkbox', + function () { + const user_group_ids = []; + const parent_this = $( this ); + params.ef_notifications_name = $( this ).attr( 'name' ); + params._nonce = $( '#ef_notifications_nonce' ).val(); - $(this) - .parents('.ef-post_following_list') - .find('input:checked') - .map(function(){ - user_group_ids.push($(this).val()); - }) + $( this ) + .parents( '.ef-post_following_list' ) + .find( 'input:checked' ) + .map( function () { + user_group_ids.push( $( this ).val() ); + } ); - params.user_group_ids = user_group_ids; + params.user_group_ids = user_group_ids; - $.ajax({ - type : 'POST', - url : (ajaxurl) ? ajaxurl : wpListL10n.url, - data : params, + $.ajax( { + type: 'POST', + url: ajaxurl ? ajaxurl : wpListL10n.url, + data: params, - success : function( response ) { - // Reset background color (set during toggle_warning_badges if there's a warning) - warning_background = false; - - // Toggle the warning badges ("No Access" and "No Email") to signal the user won't receive notifications - if ( undefined !== response.data ) { - toggle_warning_badges( $( parent_this ), response ); - } - // Green 40% by default - var backgroundHighlightColor = "#90d296"; - if ( warning_background ) { - // Red 40% if there's a warning - var backgroundHighlightColor = "#ea8484"; - } - var backgroundColor = parent_this.css( 'background-color' ); - $(parent_this.parents('li')) - .animate( { 'backgroundColor': backgroundHighlightColor }, 200 ) - .animate( { 'backgroundColor':backgroundColor }, 200 ); - - // This event is used to show an updated list of who will be notified of editorial comments and status updates. - $( '#ef-post_following_box' ).trigger( 'following_list_updated' ); - }, - error : function(r) { - $('#ef-post_following_users_box').prev().append('

        There was an error. Please reload the page.

        '); - } - }); - }); -}); \ No newline at end of file + success( response ) { + // Reset background color (set during toggle_warning_badges if there's a warning) + warning_background = false; + + // Toggle the warning badges ("No Access" and "No Email") to signal the user won't receive notifications + if ( undefined !== response.data ) { + toggle_warning_badges( $( parent_this ), response ); + } + // Green 40% by default + var backgroundHighlightColor = '#90d296'; + if ( warning_background ) { + // Red 40% if there's a warning + var backgroundHighlightColor = '#ea8484'; + } + const backgroundColor = parent_this.css( 'background-color' ); + $( parent_this.parents( 'li' ) ) + .animate( { backgroundColor: backgroundHighlightColor }, 200 ) + .animate( { backgroundColor }, 200 ); + + // This event is used to show an updated list of who will be notified of editorial comments and status updates. + $( '#ef-post_following_box' ).trigger( 'following_list_updated' ); + }, + error( r ) { + $( '#ef-post_following_users_box' ) + .prev() + .append( '

        There was an error. Please reload the page.

        ' ); + }, + } ); + } + ); +} ); diff --git a/modules/settings/lib/settings.js b/modules/settings/lib/settings.js index df610ca93..3d6e0986f 100644 --- a/modules/settings/lib/settings.js +++ b/modules/settings/lib/settings.js @@ -1,90 +1,120 @@ // Hide a given message function edit_flow_hide_message() { - jQuery('.edit-flow-message').fadeOut(function(){ jQuery(this).remove(); }); + jQuery( '.edit-flow-message' ).fadeOut( function () { + jQuery( this ).remove(); + } ); } -jQuery(document).ready(function(){ - +jQuery( document ).ready( function () { // Restore the Edit Flow submenu if there are no modules enabled // We need it down below for dynamically rebuilding the link list when on the settings page - var ef_settings_submenu_html = '
        Edit Flow
        '; + const ef_settings_submenu_html = + '
        Edit Flow
        '; if ( jQuery( 'li#toplevel_page_ef-settings .wp-submenu' ).length == 0 ) { - jQuery( 'li#toplevel_page_ef-settings' ).addClass('wp-has-submenu wp-has-current-submenu wp-menu-open'); + jQuery( 'li#toplevel_page_ef-settings' ).addClass( + 'wp-has-submenu wp-has-current-submenu wp-menu-open' + ); jQuery( 'li#toplevel_page_ef-settings' ).append( ef_settings_submenu_html ); jQuery( 'li#toplevel_page_ef-settings .wp-submenu' ).show(); } // Set auto-removal to 8 seconds - if ( jQuery('.edit-flow-message').length > 0 ) { + if ( jQuery( '.edit-flow-message' ).length > 0 ) { setTimeout( edit_flow_hide_message, 8000 ); } - jQuery('.enable-disable-edit-flow-module').on( 'click', function(){ - if ( jQuery(this).hasClass('button-primary') ) + jQuery( '.enable-disable-edit-flow-module' ).on( 'click', function () { + if ( jQuery( this ).hasClass( 'button-primary' ) ) { var module_action = 'enable'; - else if ( jQuery(this).hasClass('button-remove') ) + } else if ( jQuery( this ).hasClass( 'button-remove' ) ) { var module_action = 'disable'; - - var slug = jQuery(this).closest('.edit-flow-module').attr('id'); - var change_module_nonce = jQuery('#' + slug + ' #change-module-nonce-' + slug).val(); - var data = { - action: 'change_edit_flow_module_state', - module_action: module_action, - slug: slug, - change_module_nonce: change_module_nonce, } - - jQuery.post( ajaxurl, data, function(response) { - + + const slug = jQuery( this ).closest( '.edit-flow-module' ).attr( 'id' ); + const change_module_nonce = jQuery( '#' + slug + ' #change-module-nonce-' + slug ).val(); + const data = { + action: 'change_edit_flow_module_state', + module_action, + slug, + change_module_nonce, + }; + + jQuery.post( ajaxurl, data, function ( response ) { if ( response == 1 ) { - jQuery('#' + slug + ' .enable-disable-edit-flow-module' ).hide(); + jQuery( '#' + slug + ' .enable-disable-edit-flow-module' ).hide(); if ( module_action == 'disable' ) { - jQuery('#' + slug).addClass('module-disabled').removeClass('module-enabled'); - jQuery('#' + slug + ' .enable-disable-edit-flow-module.button-primary' ).show(); - jQuery('#' + slug + ' a.configure-edit-flow-module' ).hide().addClass('hidden'); + jQuery( '#' + slug ) + .addClass( 'module-disabled' ) + .removeClass( 'module-enabled' ); + jQuery( '#' + slug + ' .enable-disable-edit-flow-module.button-primary' ).show(); + jQuery( '#' + slug + ' a.configure-edit-flow-module' ) + .hide() + .addClass( 'hidden' ); // If there was a configuration URL in the module, let's hide it from the left nav too - if ( jQuery('#' + slug + ' a.configure-edit-flow-module' ).length > 0 ) { - var configure_url = jQuery('#' + slug + ' a.configure-edit-flow-module' ).attr('href').replace(ef_admin_url, ''); - var top_level_menu = jQuery('#' + adminpage ); - jQuery('.wp-submenu-wrap li a', top_level_menu ).each(function(){ - if ( jQuery(this).attr('href') == configure_url ) - jQuery(this).closest('li').fadeOut(function(){ jQuery(this).remove(); }); - }); + if ( jQuery( '#' + slug + ' a.configure-edit-flow-module' ).length > 0 ) { + var configure_url = jQuery( '#' + slug + ' a.configure-edit-flow-module' ) + .attr( 'href' ) + .replace( ef_admin_url, '' ); + var top_level_menu = jQuery( '#' + adminpage ); + jQuery( '.wp-submenu-wrap li a', top_level_menu ).each( function () { + if ( jQuery( this ).attr( 'href' ) == configure_url ) { + jQuery( this ) + .closest( 'li' ) + .fadeOut( function () { + jQuery( this ).remove(); + } ); + } + } ); } } else if ( module_action == 'enable' ) { - jQuery('#' + slug).addClass('module-enabled').removeClass('module-disabled'); - jQuery('#' + slug + ' .enable-disable-edit-flow-module.button-remove' ).show(); - jQuery('#' + slug + ' a.configure-edit-flow-module' ).show().removeClass('hidden'); + jQuery( '#' + slug ) + .addClass( 'module-enabled' ) + .removeClass( 'module-disabled' ); + jQuery( '#' + slug + ' .enable-disable-edit-flow-module.button-remove' ).show(); + jQuery( '#' + slug + ' a.configure-edit-flow-module' ) + .show() + .removeClass( 'hidden' ); // If there was a configuration URL in the module, let's go through the complex process of adding it again to the left nav - if ( jQuery('#' + slug + ' a.configure-edit-flow-module' ).length > 0 ) { + if ( jQuery( '#' + slug + ' a.configure-edit-flow-module' ).length > 0 ) { // Identify the order it should be in - var link_order = 0; - var counter = 0; - jQuery('.edit-flow-module.has-configure-link').each(function(key,item){ - if ( jQuery(this).attr('id') == slug && !jQuery('a.configure-edit-flow-module', this).hasClass('hidden') ) + let link_order = 0; + let counter = 0; + jQuery( '.edit-flow-module.has-configure-link' ).each( function ( key, item ) { + if ( + jQuery( this ).attr( 'id' ) == slug && + ! jQuery( 'a.configure-edit-flow-module', this ).hasClass( 'hidden' ) + ) { link_order = counter; - if ( !jQuery('a.configure-edit-flow-module', this).hasClass('hidden') ) + } + if ( ! jQuery( 'a.configure-edit-flow-module', this ).hasClass( 'hidden' ) ) { counter++; - }); + } + } ); // Build the HTML for the new link - var configure_url = jQuery('#' + slug + ' a.configure-edit-flow-module' ).attr('href').replace(ef_admin_url, ''); - var top_level_menu = jQuery('#' + adminpage ); - var html_title = jQuery('#' + slug + ' h4').html(); - var html_insert = '
      • '; - jQuery('.wp-submenu-wrap ul li', top_level_menu).each(function(key,item) { - if ( key == link_order ) - jQuery(this).after(html_insert); - }); + var configure_url = jQuery( '#' + slug + ' a.configure-edit-flow-module' ) + .attr( 'href' ) + .replace( ef_admin_url, '' ); + var top_level_menu = jQuery( '#' + adminpage ); + const html_title = jQuery( '#' + slug + ' h4' ).html(); + const html_insert = + '
      • '; + jQuery( '.wp-submenu-wrap ul li', top_level_menu ).each( function ( key, item ) { + if ( key == link_order ) { + jQuery( this ).after( html_insert ); + } + } ); // Trick way to do a fade in: add a class of 'ef-settings-fade-in' and run it after the action - jQuery('.ef-settings-fade-in').fadeIn().removeClass('ef-settings-fade-in'); + jQuery( '.ef-settings-fade-in' ).fadeIn().removeClass( 'ef-settings-fade-in' ); } } } return false; - - }); - + } ); + return false; - }); - -}); \ No newline at end of file + } ); +} ); diff --git a/modules/story-budget/lib/story-budget.js b/modules/story-budget/lib/story-budget.js index 53f4ac585..d6a2c8103 100644 --- a/modules/story-budget/lib/story-budget.js +++ b/modules/story-budget/lib/story-budget.js @@ -1,45 +1,46 @@ // Story Budget specific JS, assumes that ef_date.js has already been included -jQuery(document).ready(function($) { +jQuery( document ).ready( function ( $ ) { // Make print link open up print dialog - $("#print_link").on( 'click', function() { + $( '#print_link' ).on( 'click', function () { window.print(); return false; - }); + } ); // Hide a single section when directed - $("h3.hndle,div.handlediv").on( 'click', function() { - $(this).parent().children("div.inside").toggle(); - }); + $( 'h3.hndle,div.handlediv' ).on( 'click', function () { + $( this ).parent().children( 'div.inside' ).toggle(); + } ); // Change number of columns when choosing a new number from Screen Options - var columnsSwitch = $("input[name=ef_story_budget_screen_columns]"); - columnsSwitch.on( 'click', function() { - var numColumns = parseInt($(this).val()); - var classPrefix = 'columns-number-'; - $(".postbox-container").removeClass(function() { - for (var index = 1, c = []; index <= columnsSwitch.length; index++) { - c.push( classPrefix + index ) - } - return c.join(' '); - }).addClass(classPrefix + numColumns); - }); + const columnsSwitch = $( 'input[name=ef_story_budget_screen_columns]' ); + columnsSwitch.on( 'click', function () { + const numColumns = parseInt( $( this ).val() ); + const classPrefix = 'columns-number-'; + $( '.postbox-container' ) + .removeClass( function () { + for ( var index = 1, c = []; index <= columnsSwitch.length; index++ ) { + c.push( classPrefix + index ); + } + return c.join( ' ' ); + } ) + .addClass( classPrefix + numColumns ); + } ); - - $('h2 a.change-date').on( 'click', function(){ - $(this).hide(); - $('h2 form .form-value').hide(); - $('h2 form input').show(); - $('h2 form a.change-date-cancel').show(); + $( 'h2 a.change-date' ).on( 'click', function () { + $( this ).hide(); + $( 'h2 form .form-value' ).hide(); + $( 'h2 form input' ).show(); + $( 'h2 form a.change-date-cancel' ).show(); return false; - }); + } ); - $('h2 form a.change-date-cancel').on( 'click', function(){ - $(this).hide(); - $('h2 form .form-value').show(); - $('h2 form input').hide(); - $('h2 form a.change-date').show(); + $( 'h2 form a.change-date-cancel' ).on( 'click', function () { + $( this ).hide(); + $( 'h2 form .form-value' ).show(); + $( 'h2 form input' ).hide(); + $( 'h2 form a.change-date' ).show(); return false; - }); -}); + } ); +} ); diff --git a/modules/user-groups/lib/user-groups-configure.js b/modules/user-groups/lib/user-groups-configure.js index 0ab74c1e9..552477192 100644 --- a/modules/user-groups/lib/user-groups-configure.js +++ b/modules/user-groups/lib/user-groups-configure.js @@ -1,115 +1,147 @@ -(function($) { -inlineEditUsergroup = { - - init : function() { - var t = this, row = $('#inline-edit'); - - t.what = '#usergroup-'; - - $( document ).on( 'click', '.editinline', function(){ - inlineEditUsergroup.edit(this); - return false; - }); - - // prepare the edit row - row.on( 'keyup', function(e) { if(e.which == 27) return inlineEditUsergroup.revert(); }); - - $('a.cancel', row).on( 'click', function() { return inlineEditUsergroup.revert(); }); - $('a.save', row).on( 'click', function() { return inlineEditUsergroup.save(this); }); - $('input, select', row).on( 'keydown', function(e) { if(e.which == 13) return inlineEditUsergroup.save(this); }); - - $('#posts-filter input[type="submit"]').on( 'mousedown', function(e){ +( function ( $ ) { + inlineEditUsergroup = { + init() { + const t = this; + const row = $( '#inline-edit' ); + + t.what = '#usergroup-'; + + $( document ).on( 'click', '.editinline', function () { + inlineEditUsergroup.edit( this ); + return false; + } ); + + // prepare the edit row + row.on( 'keyup', function ( e ) { + if ( e.which == 27 ) { + return inlineEditUsergroup.revert(); + } + } ); + + $( 'a.cancel', row ).on( 'click', function () { + return inlineEditUsergroup.revert(); + } ); + $( 'a.save', row ).on( 'click', function () { + return inlineEditUsergroup.save( this ); + } ); + $( 'input, select', row ).on( 'keydown', function ( e ) { + if ( e.which == 13 ) { + return inlineEditUsergroup.save( this ); + } + } ); + + $( '#posts-filter input[type="submit"]' ).on( 'mousedown', function ( e ) { + t.revert(); + } ); + }, + + toggle( el ) { + const t = this; + $( t.what + t.getId( el ) ).css( 'display' ) == 'none' ? t.revert() : t.edit( el ); + }, + + edit( id ) { + const t = this; + let editRow; t.revert(); - }); - }, - toggle : function(el) { - var t = this; - $(t.what+t.getId(el)).css('display') == 'none' ? t.revert() : t.edit(el); - }, - - edit : function(id) { - var t = this, editRow; - t.revert(); + if ( typeof id === 'object' ) { + id = t.getId( id ); + } - if ( typeof(id) == 'object' ) - id = t.getId(id); + ( editRow = $( '#inline-edit' ).clone( true ) ), ( rowData = $( '#inline_' + id ) ); + $( 'td', editRow ).attr( 'colspan', $( '.widefat:first thead th:visible' ).length ); - editRow = $('#inline-edit').clone(true), rowData = $('#inline_'+id); - $('td', editRow).attr('colspan', $('.widefat:first thead th:visible').length); + if ( $( t.what + id ).hasClass( 'alternate' ) ) { + $( editRow ).addClass( 'alternate' ); + } - if ( $(t.what+id).hasClass('alternate') ) - $(editRow).addClass('alternate'); + $( t.what + id ) + .hide() + .after( editRow ); - $(t.what+id).hide().after(editRow); + $( ':input[name="name"]', editRow ).val( $( '.name', rowData ).text() ); + $( ':input[name="description"]', editRow ).val( $( '.description', rowData ).text() ); - $(':input[name="name"]', editRow).val( $('.name', rowData).text() ); - $(':input[name="description"]', editRow).val( $('.description', rowData).text() ); - - $(editRow).attr('id', 'edit-'+id).addClass('inline-editor').show(); - $('.ptitle', editRow).eq(0).focus(); + $( editRow ) + .attr( 'id', 'edit-' + id ) + .addClass( 'inline-editor' ) + .show(); + $( '.ptitle', editRow ).eq( 0 ).focus(); - return false; - }, + return false; + }, - save : function(id) { - var params, fields, tax = $('input[name="taxonomy"]').val() || ''; + save( id ) { + let params; + let fields; + const tax = $( 'input[name="taxonomy"]' ).val() || ''; - if( typeof(id) == 'object' ) - id = this.getId(id); + if ( typeof id === 'object' ) { + id = this.getId( id ); + } - $('table.widefat .inline-edit-save .waiting').show(); + $( 'table.widefat .inline-edit-save .waiting' ).show(); - params = { - action: 'inline_save_usergroup', - usergroup_id: id, - }; - - fields = $('#edit-'+id+' :input').serialize(); - params = fields + '&' + $.param(params); + params = { + action: 'inline_save_usergroup', + usergroup_id: id, + }; + fields = $( '#edit-' + id + ' :input' ).serialize(); + params = fields + '&' + $.param( params ); - // make ajax request - $.post(ajaxurl, params, - function(r) { - var row, new_id; - $('table.widefat .inline-edit-save .waiting').hide(); + // make ajax request + $.post( ajaxurl, params, function ( r ) { + let row; + let new_id; + $( 'table.widefat .inline-edit-save .waiting' ).hide(); - if (r) { - if ( -1 != r.indexOf(' { - const categoryPanelButton = await page.$x('//button[text()="Categories"]'); - - await categoryPanelButton[0].click(); + await page.waitForXPath('//button[text()="Categories"]'); + + await page.$$eval( + '.components-panel__body button', + ( sidebarButtons ) => { + const categoriesButton = sidebarButtons.filter( el => el.textContent === 'Categories' ); + + if ( categoriesButton.length === 1 ) { + categoriesButton[ 0 ].scrollIntoView(); + categoriesButton[ 0 ].click(); + } + } + ); - await page.waitForXPath( - '//button[text()="Add New Category"]', + await page.waitForSelector( + '.editor-post-taxonomies__hierarchical-terms-add', { timeout: 3000 } ); - const addCategoryLink = await page.$x('//button[text()="Add New Category"]'); - - addCategoryLink[0].click(); + // Click the "Add New Category" button + await page.click( + '.editor-post-taxonomies__hierarchical-terms-add' + ) await page.waitForSelector( '.editor-post-taxonomies__hierarchical-terms-input input',