Repository navigation
Add some whimsical fun with an easter egg #13152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
adamsilverstein
wants to merge
42
commits into
WordPress:trunk
Choose a base branch
from
adamsilverstein:65907-restore-easter-egg
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
45886c7
Script Loader: Restore the admin easter egg behind the command palette.
adamsilverstein a27c5b5
Script Loader: Fix overlay coverage, accessibility, and ending of the…
adamsilverstein a686785
Script Loader: Use single quotes for the easter egg closing line.
adamsilverstein 9597553
Script Loader: Trigger the easter egg without listing a command.
adamsilverstein b2150a3
Script Loader: Rename the easter egg files to teletype.
adamsilverstein 182a994
Script Loader: Correct the easter egg's provenance and cipher its dia…
adamsilverstein bbd8f3a
Script Loader: Trim the easter egg's inline commentary.
adamsilverstein 5230403
Script Loader: Soften the easter egg's dialogue and let it exit on it…
adamsilverstein 3517a62
Script Loader: Only claim Enter when the command palette found nothing.
adamsilverstein f7bcded
Script Loader: Add the falling glyph rain to the easter egg's Matrix …
adamsilverstein 57e9174
Script Loader: Give the easter egg to screen reader users too.
adamsilverstein 7ba8542
Merge branch 'trunk' into 65907-restore-easter-egg
adamsilverstein 3121e0f
Administration: Translate the easter egg's dialog label and Exit button.
adamsilverstein 1f10f8f
Administration: Make the teletype loader's comment less revealing.
adamsilverstein 8b28dcb
Administration: Shorten the teletype dialog's accessible label.
adamsilverstein 4d4d44d
Administration: Make the teletype's inline comments less revealing.
adamsilverstein ce721d4
Merge branch 'trunk' into 65907-restore-easter-egg
adamsilverstein 0073796
Merge branch 'trunk' into 65907-restore-easter-egg
peterwilsoncc 56eb699
Move styles to HEREDOC for IDE highlighting.
peterwilsoncc f3aab92
Docblocks.
peterwilsoncc 2257da9
CS: Fix undefined variable.
peterwilsoncc 2cb7511
IIFE dockblock.
peterwilsoncc 0f06f20
JavaScript is JavaScript, not CSS.
peterwilsoncc e44de84
Use unmodifed .
peterwilsoncc 3e5334e
Merge branch 'trunk' into 65907-restore-easter-egg
peterwilsoncc dc20329
`$wp_version` now used in script loader three times.
peterwilsoncc d3b962f
Merge branch 'trunk' into 65907-restore-easter-egg
adamsilverstein 12154fd
Administration: Tighten the teletype doc blocks.
adamsilverstein c743895
Administration: Tidy the teletype styles.
adamsilverstein 303769b
Administration: Make the teletype strings translatable.
adamsilverstein 35cc7a9
Administration: Add context to the teletype trigger string.
adamsilverstein 34f5cbe
Administration: Make the teletype countdown digits translatable.
adamsilverstein 94be79c
Merge branch 'trunk' into 65907-restore-easter-egg
adamsilverstein 4b5c566
Apply batched suggestions from code review
adamsilverstein 445fe66
Build/Test Tools: Type-check the teletype scripts.
adamsilverstein 53af1f2
Administration: Modernize the teletype scripts with ES6+ syntax.
adamsilverstein 8a91d03
Administration: Move the teletype styles into a stylesheet.
adamsilverstein 8596683
Merge remote-tracking branch 'origin/trunk' into pr13152-review-1128
adamsilverstein 78f4375
Docs: Align the teletype loader's `@param` types.
adamsilverstein 5f75aec
Docs: Describe the teletype rain glyphs as katakana.
adamsilverstein db904b7
Administration: Match the teletype trigger across scripts and punctua…
adamsilverstein 90c6405
I18N: Give the teletype scene strings a gettext context.
adamsilverstein File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| /** | ||
| * Listens to the command palette for the teletype. | ||
| * | ||
| * @output wp-admin/js/teletype-loader.js | ||
| */ | ||
|
|
||
| /** | ||
| * Watches Enter in the command palette and loads the teletype on a match. | ||
| * | ||
| * @param {any} wp The global WordPress JS object. | ||
| * @param {WPTeletypeSettings|undefined} settings Settings printed by wp_enqueue_command_palette_assets(). | ||
| */ | ||
| ( ( wp, settings ) => { | ||
| 'use strict'; | ||
|
|
||
| if ( ! wp || ! wp.data || ! settings || ! settings.i18n ) { | ||
| return; | ||
| } | ||
|
|
||
| /** | ||
| * Lowercases text and strips its whitespace and punctuation, in any script. | ||
| * | ||
| * @param {string} value Text to normalize. | ||
| * @return {string} Normalized text. | ||
| */ | ||
| const normalize = ( value ) => | ||
| value.normalize( 'NFKC' ).toLowerCase().replace( /[\s\p{P}]/gu, '' ); | ||
|
|
||
| const { name, src, i18n } = settings; | ||
| const trigger = normalize( i18n.trigger || '' ); | ||
|
|
||
| /** | ||
| * Loads the teletype if needed, then runs it. | ||
| */ | ||
| const play = () => { | ||
| if ( wp.teletype ) { | ||
| wp.teletype.run( name, i18n ); | ||
| return; | ||
| } | ||
|
|
||
| const script = document.createElement( 'script' ); | ||
| script.src = src; | ||
| script.addEventListener( 'load', () => { | ||
| wp.teletype?.run( name, i18n ); | ||
| } ); | ||
|
|
||
| document.head.appendChild( script ); | ||
| }; | ||
|
|
||
| document.addEventListener( | ||
| 'keydown', | ||
| ( event ) => { | ||
| const input = event.target; | ||
|
|
||
| if ( 'Enter' !== event.key || ! ( input instanceof HTMLInputElement ) || ! input.value ) { | ||
| return; | ||
| } | ||
|
|
||
| const store = wp.data.select( 'core/commands' ); | ||
|
|
||
| if ( ! store?.isOpen() ) { | ||
| return; | ||
| } | ||
|
|
||
| // Leave Enter to the palette whenever one of its results is active. | ||
| if ( | ||
| 'combobox' !== input.getAttribute( 'role' ) || | ||
| input.getAttribute( 'aria-activedescendant' ) | ||
| ) { | ||
| return; | ||
| } | ||
|
|
||
| const value = normalize( input.value ); | ||
|
|
||
| if ( ! value || value !== trigger ) { | ||
| return; | ||
| } | ||
|
|
||
| event.preventDefault(); | ||
| event.stopPropagation(); | ||
|
|
||
| wp.data.dispatch( 'core/commands' ).close(); | ||
| play(); | ||
| }, | ||
| true | ||
| ); | ||
| } )( window.wp, window.wpTeletype ); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.