-
Notifications
You must be signed in to change notification settings - Fork 314
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2503 from 10up/feature/2496
Refactor Features page script
- Loading branch information
Showing
14 changed files
with
30,640 additions
and
9,236 deletions.
There are no files selected for viewing
This file contains 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 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 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 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,46 @@ | ||
import jQuery from 'jquery'; | ||
|
||
const $epCredentialsTab = jQuery(document.getElementsByClassName('ep-credentials-tab')); | ||
const $epCredentialsHostLabel = jQuery('.ep-host-row label'); | ||
const $epCredentialsHostLegend = jQuery(document.getElementsByClassName('ep-host-legend')); | ||
const $epCredentialsAdditionalFields = jQuery( | ||
document.getElementsByClassName('ep-additional-fields'), | ||
); | ||
const epHostField = document.getElementById('ep_host'); | ||
const epHost = epHostField ? epHostField.value : null; | ||
let epHostNewValue = ''; | ||
|
||
if (epHostField) { | ||
epHostField.addEventListener('input', (e) => { | ||
epHostNewValue = e.target.value; | ||
}); | ||
} | ||
|
||
$epCredentialsTab.on('click', (e) => { | ||
const epio = e.currentTarget.getAttribute('data-epio') !== null; | ||
const $target = jQuery(e.currentTarget); | ||
const initial = $target.hasClass('initial'); | ||
|
||
e.preventDefault(); | ||
|
||
if (initial && !epHostField.disabled) { | ||
epHostField.value = epHost; | ||
} else { | ||
epHostField.value = epHostNewValue; | ||
} | ||
|
||
$epCredentialsTab.removeClass('nav-tab-active'); | ||
$target.addClass('nav-tab-active'); | ||
|
||
if (epio) { | ||
$epCredentialsHostLabel.text('ElasticPress.io Host URL'); | ||
$epCredentialsHostLegend.text('Plug in your ElasticPress.io server here!'); | ||
$epCredentialsAdditionalFields.show(); | ||
$epCredentialsAdditionalFields.attr('aria-hidden', 'false'); | ||
} else { | ||
$epCredentialsHostLabel.text('Elasticsearch Host URL'); | ||
$epCredentialsHostLegend.text('Plug in your Elasticsearch server here!'); | ||
$epCredentialsAdditionalFields.hide(); | ||
$epCredentialsAdditionalFields.attr('aria-hidden', 'true'); | ||
} | ||
}); |
Oops, something went wrong.