-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PLANET-7736: Move JS scripts away from PHP files (#2509)
This commit removes JS scripts from the PHP files and enqueue them correctly using WordPress methods and Webpack.
- Loading branch information
Showing
10 changed files
with
233 additions
and
63 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* global bulkExportText */ | ||
|
||
document.addEventListener('DOMContentLoaded', () => { | ||
jQuery(() => { | ||
jQuery('select[name=\'action\'], select[name=\'action2\']').each(function () { | ||
jQuery('<option>') | ||
.val('export') | ||
.text(bulkExportText) | ||
.appendTo(this); | ||
}); | ||
}); | ||
}); |
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,7 @@ | ||
/* global dismissDashboardNotice */ | ||
|
||
jQuery('#p4-notice').on('click', '.notice-dismiss', () => { | ||
jQuery.post(dismissDashboardNotice.ajaxurl, {'action': 'dismiss_dashboard_notice'}, () => { | ||
jQuery('#p4-notice').hide(); | ||
}); | ||
}); |
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,20 @@ | ||
document.addEventListener('DOMContentLoaded', () => { | ||
const nsSelect = document.getElementById('filter-by-ns'); | ||
const nameSelect = document.getElementById('filter-by-name'); | ||
|
||
nsSelect.addEventListener('change', () => { | ||
const selectedNs = nsSelect.selectedOptions[0].value; | ||
|
||
for (const option of nameSelect.options) { | ||
const display = selectedNs.length === 0 || | ||
option.value.length === 0 || | ||
option.value.startsWith(`${selectedNs}/`); | ||
option.style.display = display ? 'block' : 'none'; | ||
} | ||
|
||
if (selectedNs.length >= 1) { | ||
nameSelect.value = ''; | ||
} | ||
}); | ||
}); | ||
|
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,6 @@ | ||
/* global mediaImportLabel */ | ||
|
||
jQuery(() =>{ | ||
jQuery('.upload-php .wrap .page-title-action') | ||
.after(`<a href="upload.php?page=media-picker" class="add-new-h2">${mediaImportLabel}</a>`); | ||
}); |
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,12 @@ | ||
/* global metaboxSearchData */ | ||
|
||
$ = jQuery; | ||
|
||
$('#parent_id').off('change').on('change', function() { | ||
// Check selected Parent page and give bigger weight if it will be an Action page | ||
if ((metaboxSearchData.act_page ?? -1) === $(this).val()) { | ||
$('#weight').val(metaboxSearchData.action_weight); | ||
} else { | ||
$('#weight').val(metaboxSearchData.page_weight); | ||
} | ||
}); |
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
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