Skip to content
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

fix: Separate dial code is renamed by intltelinput #39

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ Wordpress plugin for entering and validating international telephone numbers bas
<img width="600" alt="IP Lookup" src="https://user-images.githubusercontent.com/46939084/204006934-5ac1d6df-848f-436d-82ac-dd0e62f67b03.png">

Change default country depends on user IP
* **Separate Dial Code**
<img width="600" alt="Separate Dial Code" src="https://user-images.githubusercontent.com/46939084/204007378-50a3db49-4f07-4ab4-91f4-5c42fd2f2c73.png">
* **Show Selected Dial Code**
<img width="600" alt="Show Selected Dial Code" src="https://user-images.githubusercontent.com/46939084/204007378-50a3db49-4f07-4ab4-91f4-5c42fd2f2c73.png">
<img src="https://camo.githubusercontent.com/200f3411c2f34ad772b7492a80b6a25297ad9d3ce1235c07238dbb405834e31e/68747470733a2f2f7261772e6769746875622e636f6d2f6a61636b6f636e722f696e746c2d74656c2d696e7075742f6d61737465722f73637265656e73686f74732f73657061726174654469616c436f64652e706e67" width="257px" height="46px" data-canonical-src="https://raw.github.com/jackocnr/intl-tel-input/master/screenshots/separateDialCode.png" >
Display the country dial code next to the selected flag so it's not part of the typed number. Note that this will disable National Mode because technically we are dealing with international numbers, but with the dial code separated.

Expand Down
10 changes: 5 additions & 5 deletions admin/ninja-forms-fields/class-spn-field.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,19 @@ protected function add_options() {
);

/**
* Add toggle Separate Dial Code
* Add toggle Show Selected Dial Code
* Display the country dial code next to the selected flag so it's not part of the typed number.
* Note that this will disable nationalMode because technically we are dealing with international numbers, but with the dial code separated.
*
* @since 1.0.0
*/
$this->_settings['separate_dial_code'] = array(
'name' => 'separate_dial_code',
$this->_settings['show_selected_dial_code'] = array(
'name' => 'show_selected_dial_code',
'type' => 'toggle',
'label' => esc_html__( 'Separate Dial Code', 'ninja-forms-spn-addon' ),
'label' => esc_html__( 'Show Selected Dial Code', 'ninja-forms-spn-addon' ),
'width' => 'full',
'group' => 'restrictions',
'help' => esc_html__( 'Display the country dial code next to the selected flag so it\'s not part of the typed number. Note that this will disable nationalMode because technically we are dealing with international numbers, but with the dial code separated.', 'ninja-forms-spn-addon' ),
'help' => wp_kses_post( __( 'Display the country dial code next to the selected flag. Play with this option on <a href="https://intl-tel-input.com/storybook/?path=/docs/intltelinput--showselecteddialcode" target="_blank" rel="noopener">Storybook</a> (using the React component).', 'ninja-forms-spn-addon' ) ),
'value' => false,
);

Expand Down
2 changes: 1 addition & 1 deletion dist/public/spn-front-main.min.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions public/js/modules/ITIInitializer.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class IntlTelInputInitializer {
const allowDropdown = Boolean($input.data('allow-dropdown'))
const nationalMode = Boolean($input.data('national-mode'))
const autoHideDialCode = Boolean($input.data('auto-hide-dial-code'))
const separateDialCode = Boolean($input.data('separate-dial-code'))
const showSelectedDialCode = Boolean($input.data('show-selected-dial-code'))
const formatOnDisplay = Boolean($input.data('format-on-display'))

return {
Expand All @@ -69,7 +69,7 @@ class IntlTelInputInitializer {
autoHideDialCode,
excludeCountries,
allowIpLookUp,
separateDialCode,
showSelectedDialCode,
formatOnDisplay
}
}
Expand All @@ -89,7 +89,7 @@ class IntlTelInputInitializer {
autoHideDialCode: dataAttributes.autoHideDialCode,
excludeCountries: dataAttributes.excludeCountries,
geoIpLookup: dataAttributes.allowIpLookUp,
separateDialCode: dataAttributes.separateDialCode,
showSelectedDialCode: dataAttributes.showSelectedDialCode,
formatOnDisplay: dataAttributes.formatOnDisplay,
utilsScript: intlTelInputUtils
})
Expand Down
4 changes: 2 additions & 2 deletions public/ninja-forms-fields/templates/fields-spn.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
data-allow-ip-lookup="{{{ data.allow_ip_lookup }}}"
<# } #>

<# if( data.separate_dial_code ){ #>
data-separate-dial-code="{{{ data.separate_dial_code }}}"
<# if( data.show_selected_dial_code ){ #>
data-show-selected-dial-code="{{{ data.show_selected_dial_code }}}"
<# } #>

data-default-country="{{{ data.default_country }}}"
Expand Down