diff options
Diffstat (limited to 'srcs/wordpress/wp-admin/js')
105 files changed, 42420 insertions, 0 deletions
diff --git a/srcs/wordpress/wp-admin/js/accordion.js b/srcs/wordpress/wp-admin/js/accordion.js new file mode 100644 index 0000000..0bec1ce --- /dev/null +++ b/srcs/wordpress/wp-admin/js/accordion.js @@ -0,0 +1,94 @@ +/** + * Accordion-folding functionality. + * + * Markup with the appropriate classes will be automatically hidden, + * with one section opening at a time when its title is clicked. + * Use the following markup structure for accordion behavior: + * + * <div class="accordion-container"> + * <div class="accordion-section open"> + * <h3 class="accordion-section-title"></h3> + * <div class="accordion-section-content"> + * </div> + * </div> + * <div class="accordion-section"> + * <h3 class="accordion-section-title"></h3> + * <div class="accordion-section-content"> + * </div> + * </div> + * <div class="accordion-section"> + * <h3 class="accordion-section-title"></h3> + * <div class="accordion-section-content"> + * </div> + * </div> + * </div> + * + * Note that any appropriate tags may be used, as long as the above classes are present. + * + * @since 3.6.0 + * @output wp-admin/js/accordion.js + */ + +( function( $ ){ + + $( document ).ready( function () { + + // Expand/Collapse accordion sections on click. + $( '.accordion-container' ).on( 'click keydown', '.accordion-section-title', function( e ) { + if ( e.type === 'keydown' && 13 !== e.which ) { // "return" key + return; + } + + e.preventDefault(); // Keep this AFTER the key filter above + + accordionSwitch( $( this ) ); + }); + + }); + + /** + * Close the current accordion section and open a new one. + * + * @param {Object} el Title element of the accordion section to toggle. + * @since 3.6.0 + */ + function accordionSwitch ( el ) { + var section = el.closest( '.accordion-section' ), + sectionToggleControl = section.find( '[aria-expanded]' ).first(), + container = section.closest( '.accordion-container' ), + siblings = container.find( '.open' ), + siblingsToggleControl = siblings.find( '[aria-expanded]' ).first(), + content = section.find( '.accordion-section-content' ); + + // This section has no content and cannot be expanded. + if ( section.hasClass( 'cannot-expand' ) ) { + return; + } + + // Add a class to the container to let us know something is happening inside. + // This helps in cases such as hiding a scrollbar while animations are executing. + container.addClass( 'opening' ); + + if ( section.hasClass( 'open' ) ) { + section.toggleClass( 'open' ); + content.toggle( true ).slideToggle( 150 ); + } else { + siblingsToggleControl.attr( 'aria-expanded', 'false' ); + siblings.removeClass( 'open' ); + siblings.find( '.accordion-section-content' ).show().slideUp( 150 ); + content.toggle( false ).slideToggle( 150 ); + section.toggleClass( 'open' ); + } + + // We have to wait for the animations to finish + setTimeout(function(){ + container.removeClass( 'opening' ); + }, 150); + + // If there's an element with an aria-expanded attribute, assume it's a toggle control and toggle the aria-expanded value. + if ( sectionToggleControl ) { + sectionToggleControl.attr( 'aria-expanded', String( sectionToggleControl.attr( 'aria-expanded' ) === 'false' ) ); + } + } + +})(jQuery); diff --git a/srcs/wordpress/wp-admin/js/accordion.min.js b/srcs/wordpress/wp-admin/js/accordion.min.js new file mode 100644 index 0000000..1f5d422 --- /dev/null +++ b/srcs/wordpress/wp-admin/js/accordion.min.js @@ -0,0 +1 @@ +!function(e){e(document).ready(function(){e(".accordion-container").on("click keydown",".accordion-section-title",function(n){"keydown"===n.type&&13!==n.which||(n.preventDefault(),function(n){var e=n.closest(".accordion-section"),o=e.find("[aria-expanded]").first(),a=e.closest(".accordion-container"),i=a.find(".open"),t=i.find("[aria-expanded]").first(),s=e.find(".accordion-section-content");if(e.hasClass("cannot-expand"))return;a.addClass("opening"),e.hasClass("open")?(e.toggleClass("open"),s.toggle(!0).slideToggle(150)):(t.attr("aria-expanded","false"),i.removeClass("open"),i.find(".accordion-section-content").show().slideUp(150),s.toggle(!1).slideToggle(150),e.toggleClass("open"));setTimeout(function(){a.removeClass("opening")},150),o&&o.attr("aria-expanded",String("false"===o.attr("aria-expanded")))}(e(this)))})})}(jQuery);
\ No newline at end of file |
