-
Notifications
You must be signed in to change notification settings - Fork 846
Contact Info & Map Widget: Remove Geocoding and add map to form #12474
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
Merged
jeherve
merged 15 commits into
Automattic:master
from
kbrown9:update/contact_info_widget_remove_geocoding
Aug 22, 2019
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
019646c
Contact Info & Map Widget: Remove Geocoding and add map to form
kbrown9 309cbd2
Rely on esc_url_raw for remote call
jeherve 555327a
Clarify update process for the map, and coding standard changes
jeherve 6739813
Simplify addition of query params to Google embed URL.
jeherve e060203
Only attempt to display the map when we have info to display it
jeherve fe2a033
Enqueue CSS on widgets page as well
jeherve f29db56
Display output from API request in widget area when error
jeherve 5466b03
Improve code readability and remove an API call.
kbrown9 27db35c
Show the API key error in the widget in the customizer preview
kbrown9 0522434
Contact Info & Map Widget: Dynamically update customizer admin form
kbrown9 3021b2c
Contact Info: fix linting warnings in js file
jeherve 65e6910
Contact Info CSS: update version so cache can be busted
jeherve 055d08d
Do not output notice container when no map has been set up yet
jeherve 1f643d6
Contact Info & Map Widget: Protect the Ajax request
kbrown9 04cf9ac
Fix stylesheet enqueue problem
kbrown9 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
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 |
|---|---|---|
| @@ -1,11 +1,57 @@ | ||
| /* global ajaxurl, contact_info_api_key_ajax_obj */ | ||
|
|
||
| ( function( $ ) { | ||
| $( document ).on( 'change', '.jp-contact-info-showmap', function() { | ||
| var $checkbox = $( this ), | ||
| isChecked = $checkbox.is( ':checked' ); | ||
|
|
||
| $checkbox | ||
| .closest( '.widget' ) | ||
| .find( '.jp-contact-info-apikey' ) | ||
| .find( '.jp-contact-info-admin-map' ) | ||
| .toggle( isChecked ); | ||
| } ); | ||
|
|
||
| $( document ).on( 'widget-synced', function( event, widgetContainer ) { | ||
| // This event fires for all widgets, so restrict this to Contact Info widgets and the API key input. | ||
| if ( | ||
| ! widgetContainer.is( '[id*="widget_contact_info"]' ) || | ||
| ! $( document.activeElement ).is( 'input[id*="apikey"]' ) | ||
| ) { | ||
| return; | ||
| } | ||
|
|
||
| event.preventDefault(); | ||
|
|
||
| var $apikey_input = widgetContainer.find( 'input[id*="apikey"]' ); | ||
|
|
||
| $.post( | ||
| ajaxurl, | ||
| { | ||
| _ajax_nonce: contact_info_api_key_ajax_obj.nonce, | ||
| action: 'customize-contact-info-api-key', | ||
| apikey: $apikey_input.val(), | ||
| }, | ||
| function( data ) { | ||
| var $map_element = $apikey_input | ||
| .closest( '.jp-contact-info-admin-map' ) | ||
| .parent() | ||
| .find( '.jp-contact-info-embed-map' ); | ||
| var $warning_span = $map_element.find( '[class*="notice"]' ); | ||
|
|
||
| if ( '1' !== data.result ) { | ||
| if ( $warning_span.length === 0 ) { | ||
| $map_element.append( | ||
| '<span class="notice notice-warning" style="display: block;">' + | ||
| data.result + | ||
| '</span>' | ||
| ); | ||
| } else if ( $warning_span.text() !== data.result ) { | ||
| $warning_span.text( data.result ); | ||
| } | ||
| } else { | ||
| $map_element.empty(); | ||
| } | ||
| } | ||
| ); | ||
| } ); | ||
| } )( window.jQuery ); |
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 |
|---|---|---|
| @@ -1,4 +1,13 @@ | ||
| .contact-map { | ||
| max-width: 100%; | ||
| border: 0; | ||
| } | ||
|
|
||
| .contact-map-api-error { | ||
| border-left-color: #ffb900; | ||
| border-left-style: solid; | ||
| border-left-width: 4px; | ||
| box-shadow: 0 1px 1px 0 rgba(0,0,0,.1); | ||
| margin: 5px 0 15px; | ||
| padding: 1px 12px; | ||
| } |
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.