Add PSR HTTP Message Interfaces and Dependencies
- Implemented StreamInterface, UploadedFileInterface, and UriInterface as per PSR standards. - Added getallheaders function to retrieve HTTP headers in a compatible manner. - Included LICENSE files for ralouphie/getallheaders and symfony/deprecation-contracts. - Introduced function for triggering deprecation notices in Symfony.
@@ -0,0 +1 @@
|
||||
<?php return array('dependencies' => array('react', 'react-dom', 'wp-blocks', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => '1f7ec3dfbd17a30f0ca3');
|
||||
@@ -0,0 +1 @@
|
||||
<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-components', 'wp-element', 'wp-rich-text'), 'version' => 'a63731a1391f5c864e74');
|
||||
@@ -0,0 +1 @@
|
||||
<?php return array('dependencies' => array('react', 'react-dom', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => '856cfb9b2784e105fa5e');
|
||||
@@ -0,0 +1 @@
|
||||
<?php return array('dependencies' => array('react', 'react-dom', 'wp-i18n'), 'version' => '3aba280d86d09cf46a55');
|
||||
@@ -0,0 +1,413 @@
|
||||
.atfp-custom-data-table-wrapper {
|
||||
width: 100%;
|
||||
margin-top: 25px;
|
||||
background: white;
|
||||
padding: 24px;
|
||||
border-radius: 8px;
|
||||
border: 1px solid var(--border-color);
|
||||
/* Keyframes: subtle pop + fade */
|
||||
/* Accessibility: honor reduced motion */
|
||||
}
|
||||
|
||||
.atfp-custom-data-table-wrapper .saving-text {
|
||||
margin-left: 8px;
|
||||
font-size: 13px;
|
||||
display: -webkit-box;
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
-webkit-box-align: center;
|
||||
-ms-flex-align: center;
|
||||
align-items: center;
|
||||
-webkit-box-pack: center;
|
||||
-ms-flex-pack: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.atfp-custom-data-table-wrapper .saving-text .dot {
|
||||
width: 4px;
|
||||
height: 4px;
|
||||
border-radius: 999px;
|
||||
background: #ffffff;
|
||||
margin-left: 1px;
|
||||
margin-top: 6px;
|
||||
opacity: 0.25;
|
||||
-webkit-animation: savingBlink 1.05s infinite ease-in-out;
|
||||
animation: savingBlink 1.05s infinite ease-in-out;
|
||||
-webkit-animation-delay: calc(var(--i) * 0.18s - 1.05s);
|
||||
animation-delay: calc(var(--i) * 0.18s - 1.05s);
|
||||
will-change: opacity, transform;
|
||||
}
|
||||
|
||||
.atfp-custom-data-table-wrapper h3 {
|
||||
display: -webkit-inline-box;
|
||||
display: -ms-inline-flexbox;
|
||||
display: inline-flex;
|
||||
margin: 5px 0 20px;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-box-direction: normal;
|
||||
-ms-flex-direction: column;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.atfp-custom-data-table-wrapper h3 p {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.atfp-custom-data-table-wrapper.atfp-custom-fields .atfp-save-custom-fields {
|
||||
float: right;
|
||||
height: 30px;
|
||||
display: -webkit-inline-box;
|
||||
display: -ms-inline-flexbox;
|
||||
display: inline-flex;
|
||||
-ms-flex-item-align: center;
|
||||
align-self: center;
|
||||
}
|
||||
|
||||
.atfp-custom-data-table-wrapper.atfp-custom-fields .atfp-save-custom-fields:focus {
|
||||
-webkit-box-shadow: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.atfp-custom-data-table-wrapper .atfp-custom-data-table-filters {
|
||||
display: -webkit-box;
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
-webkit-box-align: center;
|
||||
-ms-flex-align: center;
|
||||
align-items: center;
|
||||
-webkit-column-gap: 1rem;
|
||||
column-gap: 1rem;
|
||||
}
|
||||
|
||||
.atfp-custom-data-table-wrapper .atfp-custom-data-table-filters .atfp-search-tab {
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.atfp-custom-data-table-wrapper .atfp-custom-data-table-filters .atfp-search-tab #atfp-blocks-search {
|
||||
min-width: 220px;
|
||||
}
|
||||
|
||||
.atfp-custom-data-table-wrapper .atfp-custom-data-table-filters .atfp-filter-tab,
|
||||
.atfp-custom-data-table-wrapper .atfp-custom-data-table-filters .atfp-search-tab {
|
||||
display: -webkit-box;
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
-webkit-box-align: center;
|
||||
-ms-flex-align: center;
|
||||
align-items: center;
|
||||
-webkit-column-gap: 1rem;
|
||||
column-gap: 1rem;
|
||||
}
|
||||
|
||||
.atfp-custom-data-table-wrapper .atfp-custom-data-table-filters .atfp-filter-tab label,
|
||||
.atfp-custom-data-table-wrapper .atfp-custom-data-table-filters .atfp-search-tab label {
|
||||
margin: 0 0.5rem 0 0;
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
text-transform: capitalize;
|
||||
}
|
||||
|
||||
.atfp-custom-data-table-wrapper .atfp-custom-table-lists {
|
||||
margin: 20px 0px;
|
||||
font-family: Arial, sans-serif;
|
||||
}
|
||||
|
||||
.atfp-custom-data-table-wrapper .atfp-custom-table-lists .atfp-custom-data-table-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
margin-top: 10px;
|
||||
border: 1px solid #ddd;
|
||||
-webkit-box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
|
||||
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.atfp-custom-data-table-wrapper .atfp-custom-table-lists .atfp-custom-data-table-table thead {
|
||||
background-color: #f2f2f2;
|
||||
-webkit-box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
|
||||
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.atfp-custom-data-table-wrapper .atfp-custom-table-lists .atfp-custom-data-table-table thead th {
|
||||
padding: 10px;
|
||||
text-align: left;
|
||||
border-bottom: 2px solid #ddd;
|
||||
}
|
||||
|
||||
.atfp-custom-data-table-wrapper .atfp-custom-table-lists .atfp-custom-data-table-table thead th:last-child {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.atfp-custom-data-table-wrapper .atfp-custom-table-lists .atfp-custom-data-table-table tbody tr .atfp-search-highlight {
|
||||
background-color: orange;
|
||||
color: black;
|
||||
}
|
||||
|
||||
.atfp-custom-data-table-wrapper .atfp-custom-table-lists .atfp-custom-data-table-table tbody tr:nth-child(even) {
|
||||
background-color: #f9f9f9;
|
||||
}
|
||||
|
||||
.atfp-custom-data-table-wrapper .atfp-custom-table-lists .atfp-custom-data-table-table tbody tr td {
|
||||
padding: 10px;
|
||||
border-bottom: 1px solid #ddd;
|
||||
}
|
||||
|
||||
.atfp-custom-data-table-wrapper .atfp-custom-table-lists .atfp-custom-data-table-table tbody tr td:last-child {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.atfp-custom-data-table-wrapper .atfp-custom-table-lists .atfp-custom-data-table-table tbody tr td.dt-empty {
|
||||
text-align: center;
|
||||
font-size: 1.1rem;
|
||||
}
|
||||
|
||||
.atfp-custom-data-table-wrapper .atfp-custom-table-lists .atfp-custom-data-table-table tbody tr td a {
|
||||
color: #0073aa;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.atfp-custom-data-table-wrapper .atfp-custom-table-lists .atfp-custom-data-table-table tbody tr td a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.atfp-custom-data-table-wrapper .atfp-pagination {
|
||||
margin: 20px 0px;
|
||||
font-size: 14px;
|
||||
text-align: end;
|
||||
}
|
||||
|
||||
.atfp-custom-data-table-wrapper .atfp-pagination .page-numbers {
|
||||
display: inline-block;
|
||||
padding: 0.5em 1em;
|
||||
margin: 0 0.2em;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 3px;
|
||||
color: #0073aa;
|
||||
text-decoration: none;
|
||||
background-color: #fff;
|
||||
-webkit-transition: background-color 0.3s;
|
||||
transition: background-color 0.3s;
|
||||
}
|
||||
|
||||
.atfp-custom-data-table-wrapper .atfp-pagination .page-numbers.current {
|
||||
background-color: #0073aa;
|
||||
color: #fff;
|
||||
border: 1px solid #0073aa;
|
||||
}
|
||||
|
||||
.atfp-custom-data-table-wrapper .atfp-pagination .page-numbers:hover:not(.current) {
|
||||
background-color: #f0f0f0;
|
||||
}
|
||||
|
||||
.atfp-custom-data-table-wrapper .atfp-pagination .page-numbers.dots {
|
||||
padding: 0;
|
||||
color: #555;
|
||||
}
|
||||
|
||||
.atfp-custom-data-table-wrapper .atfp-pagination .page-numbers.next {
|
||||
margin-left: auto;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
@-webkit-keyframes savingBlink {
|
||||
0%,
|
||||
20% {
|
||||
opacity: 0.25;
|
||||
-webkit-transform: translateY(0);
|
||||
transform: translateY(0);
|
||||
}
|
||||
40% {
|
||||
opacity: 1;
|
||||
-webkit-transform: translateY(-1px);
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
60% {
|
||||
opacity: 0.9;
|
||||
-webkit-transform: translateY(0);
|
||||
transform: translateY(0);
|
||||
}
|
||||
100% {
|
||||
opacity: 0.25;
|
||||
-webkit-transform: translateY(0);
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes savingBlink {
|
||||
0%,
|
||||
20% {
|
||||
opacity: 0.25;
|
||||
-webkit-transform: translateY(0);
|
||||
transform: translateY(0);
|
||||
}
|
||||
40% {
|
||||
opacity: 1;
|
||||
-webkit-transform: translateY(-1px);
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
60% {
|
||||
opacity: 0.9;
|
||||
-webkit-transform: translateY(0);
|
||||
transform: translateY(0);
|
||||
}
|
||||
100% {
|
||||
opacity: 0.25;
|
||||
-webkit-transform: translateY(0);
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.atfp-custom-data-table-wrapper .saving-dot {
|
||||
-webkit-animation: none;
|
||||
animation: none;
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
#atfp-custom-datatable_wrapper {
|
||||
display: -webkit-box;
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
-ms-flex-wrap: wrap;
|
||||
flex-wrap: wrap;
|
||||
gap: 1rem;
|
||||
-webkit-box-pack: justify;
|
||||
-ms-flex-pack: justify;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
#atfp-custom-datatable_wrapper .dt-layout-row.dt-layout-table {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#atfp-custom-datatable_wrapper .dt-layout-row:last-child {
|
||||
margin-left: auto;
|
||||
display: -webkit-box;
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
-webkit-box-align: center;
|
||||
-ms-flex-align: center;
|
||||
align-items: center;
|
||||
-webkit-box-pack: end;
|
||||
-ms-flex-pack: end;
|
||||
justify-content: end;
|
||||
-webkit-column-gap: 1rem;
|
||||
column-gap: 1rem;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#atfp-custom-datatable_wrapper .dt-layout-row:last-child .dt-layout-start {
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
#atfp-custom-datatable_wrapper .dt-layout-row:last-child .dt-paging {
|
||||
margin: 1rem 0;
|
||||
}
|
||||
|
||||
#atfp-custom-datatable_wrapper .dt-layout-row:last-child .dt-paging .dt-paging-button {
|
||||
padding: 0.5em 1em;
|
||||
margin: 0 0.2em;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 3px;
|
||||
color: #0073aa;
|
||||
text-decoration: none;
|
||||
background-color: #fff;
|
||||
-webkit-transition: background-color 0.3s;
|
||||
transition: background-color 0.3s;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#atfp-custom-datatable_wrapper .dt-layout-row:last-child .dt-paging .dt-paging-button.current {
|
||||
background-color: #0073aa;
|
||||
color: #fff;
|
||||
border: 1px solid #0073aa;
|
||||
}
|
||||
|
||||
#atfp-custom-datatable_wrapper .dt-layout-row:last-child .dt-paging .dt-paging-button:hover:not(.current) {
|
||||
background-color: #f0f0f0;
|
||||
}
|
||||
|
||||
#atfp-custom-datatable_wrapper .dt-layout-row:last-child .dt-paging .dt-paging-button.disabled {
|
||||
color: #aaa;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
#atfp-custom-datatable_wrapper .dt-layout-row:last-child .dt-paging .dt-paging-button.dots {
|
||||
padding: 0;
|
||||
color: #555;
|
||||
}
|
||||
|
||||
#atfp-custom-datatable_wrapper .dt-layout-row:last-child .dt-paging .dt-paging-button.next {
|
||||
margin-left: auto;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
#atfp-custom-datatable_wrapper .dt-layout-row:last-child .dt-paging .ellipsis {
|
||||
padding: 0 1em;
|
||||
color: #555;
|
||||
}
|
||||
|
||||
#atfp-custom-datatable_wrapper .dt-layout-row:nth-child(2) {
|
||||
display: -webkit-box;
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
-webkit-box-pack: end;
|
||||
-ms-flex-pack: end;
|
||||
justify-content: end;
|
||||
-webkit-box-align: center;
|
||||
-ms-flex-align: center;
|
||||
align-items: center;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
#atfp-custom-datatable_wrapper .dt-layout-row:nth-child(2) .dt-length {
|
||||
display: -webkit-box;
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
-webkit-box-orient: horizontal;
|
||||
-webkit-box-direction: reverse;
|
||||
-ms-flex-direction: row-reverse;
|
||||
flex-direction: row-reverse;
|
||||
-webkit-box-align: center;
|
||||
-ms-flex-align: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
#atfp-custom-datatable_wrapper .dt-layout-row:nth-child(2) label {
|
||||
margin: 0 0.5rem 0 0;
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
text-transform: capitalize;
|
||||
}
|
||||
|
||||
#atfp-copy-btn {
|
||||
z-index: 999999;
|
||||
background-color: #333;
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 10px 20px;
|
||||
border-radius: 5px;
|
||||
cursor: pointer;
|
||||
-webkit-transition: all 0.3s;
|
||||
transition: all 0.3s;
|
||||
position: fixed;
|
||||
top: 50%;
|
||||
-webkit-transform: translateY(-50%) scale(0.9);
|
||||
transform: translateY(-50%) scale(0.9);
|
||||
left: 0px;
|
||||
}
|
||||
|
||||
#atfp-copy-btn:hover {
|
||||
font-weight: 600;
|
||||
-webkit-transform: translateY(-50%) scale(1);
|
||||
transform: translateY(-50%) scale(1);
|
||||
-webkit-box-shadow: 0 0 10px #949494, 0 0 30px #898787;
|
||||
box-shadow: 0 0 10px #949494, 0 0 30px #898787;
|
||||
}
|
||||
|
||||
#atfp-copy-text {
|
||||
display: fixed;
|
||||
bottom: -50%;
|
||||
left: -50%;
|
||||
}
|
||||
/*# sourceMappingURL=atfp-custom-data-table.css.map */
|
||||
1
wp-content/plugins/autopoly-ai-translation-for-polylang-pro/assets/css/atfp-custom.min.css
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
.atfp-elementor-translate-confirm-box{
|
||||
display: none;
|
||||
position: fixed;
|
||||
z-index: 99999;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 100vh;
|
||||
overflow: hidden;
|
||||
background-color: rgba(0,0,0,.75);
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;
|
||||
}
|
||||
|
||||
.atfp-elementor-translate-confirm-box .modal-content{
|
||||
padding: 16px;
|
||||
text-align: center;
|
||||
position: relative;
|
||||
background-color: #fefefe;
|
||||
width: clamp(200px,400px,80%);
|
||||
height: auto;
|
||||
overflow: hidden;
|
||||
border-radius: 5px;
|
||||
box-shadow: 0 4px 8px 0 rgba(0,0,0,.2),0 6px 20px 0 rgba(0,0,0,.19);
|
||||
-webkit-animation-name: animatetopsetting;
|
||||
-webkit-animation-duration: .6s;
|
||||
-webkit-animation-fill-mode: forwards;
|
||||
animation-name: animatetopsetting;
|
||||
animation-duration: .6s;
|
||||
animation-fill-mode: forwards;
|
||||
padding-block: 16px;
|
||||
color: #000;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.atfp-elementor-translate-confirm-box .modal-content p{
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.atfp-elementor-translate-confirm-box .modal-content button[data-value]{
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 13px;
|
||||
line-height: 1.3;
|
||||
min-height: 30px;
|
||||
margin: 0 0.3rem;
|
||||
cursor: pointer;
|
||||
border-width: 1px;
|
||||
border-style: solid;
|
||||
-webkit-appearance: none;
|
||||
border-radius: 3px;
|
||||
box-sizing: border-box;
|
||||
font-family: inherit;
|
||||
font-weight: inherit;
|
||||
vertical-align: top;
|
||||
text-decoration: none;
|
||||
text-shadow: none;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.atfp-elementor-translate-confirm-box .modal-content button[data-value="yes"]{
|
||||
padding: 2px 11px;
|
||||
white-space: nowrap;
|
||||
background: #3db63d;
|
||||
border-color: #33a133;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.atfp-elementor-translate-confirm-box .modal-content button[data-value="no"]{
|
||||
background: #ee4237;
|
||||
border-color: #dd362b;
|
||||
color: #fff;
|
||||
padding: 2px 11px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.atfp-elementor-translate-confirm-box .modal-content button[data-value="yes"]:hover{
|
||||
background: #37a737;
|
||||
border-color: #238b23;
|
||||
}
|
||||
|
||||
.atfp-elementor-translate-confirm-box .modal-content button[data-value="no"]:hover{
|
||||
background: #dd382e;
|
||||
border-color: #c72a20;
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
button.elementor-button.atfp-translate-button:enabled {
|
||||
border-radius: 0px;
|
||||
color: rgb(12, 13, 14);
|
||||
background-color: #F0ABFC
|
||||
}
|
||||
|
||||
button.elementor-button.atfp-translate-button:enabled:hover {
|
||||
background-color: rgb(235, 142, 251);
|
||||
}
|
||||
|
||||
button.elementor-button.atfp-translate-button:disabled {
|
||||
cursor: default;
|
||||
border-radius: 0px;
|
||||
color: rgb(12, 13, 14);
|
||||
}
|
||||
|
||||
/* Footer Close Button */
|
||||
button.atfp-setting-close {
|
||||
margin-top: .9rem;
|
||||
font-size: 1rem;
|
||||
padding: .1rem .4rem;
|
||||
cursor: pointer;
|
||||
opacity: .7;
|
||||
}
|
||||
|
||||
button.atfp-setting-close:hover {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
/* ******Popup***** */
|
||||
|
||||
.save_it.button-primary[disabled] {
|
||||
color: #a7aaad !important;
|
||||
background: #f6f7f7 !important;
|
||||
border-color: #dcdcde !important;
|
||||
box-shadow: none !important;
|
||||
text-shadow: none !important;
|
||||
cursor: default;
|
||||
padding: 8px 12px;
|
||||
border: none;
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
.save_it.button-primary {
|
||||
background: #2271b1;
|
||||
border-color: #2271b1;
|
||||
color: #fff;
|
||||
text-decoration: none;
|
||||
text-shadow: none;
|
||||
padding: 8px 12px;
|
||||
border: none;
|
||||
border-radius: 2px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#atfp_strings_model .save_btn_cont button:not([disabled])::before {
|
||||
line-height: 14px !important;
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
button.elementor-button.atfp-translate-button:enabled{border-radius:0;color:#0c0d0e;background-color:#f0abfc}button.elementor-button.atfp-translate-button:enabled:hover{background-color:#eb8efb}button.elementor-button.atfp-translate-button:disabled{cursor:default;border-radius:0;color:#0c0d0e}button.atfp-setting-close{margin-top:.9rem;font-size:1rem;padding:.1rem .4rem;cursor:pointer;opacity:.7}button.atfp-setting-close:hover{opacity:1}.save_it.button-primary[disabled]{color:#a7aaad!important;background:#f6f7f7!important;border-color:#dcdcde!important;box-shadow:none!important;text-shadow:none!important;cursor:default;padding:8px 12px;border:none;border-radius:2px}.save_it.button-primary{background:#2271b1;border-color:#2271b1;color:#fff;text-decoration:none;text-shadow:none;padding:8px 12px;border:none;border-radius:2px;cursor:pointer}#atfp_strings_model .save_btn_cont button:not([disabled])::before{line-height:14px!important}
|
||||
@@ -0,0 +1,94 @@
|
||||
/* lock scroll when overlay is open */
|
||||
body.atfp-overlay-open { overflow: hidden; }
|
||||
|
||||
/* overlay shell */
|
||||
.atfp-overlay {
|
||||
position: fixed; inset: 0; z-index: 100000;
|
||||
display: grid; place-items: center;
|
||||
animation: fade-in .15s ease-out forwards; opacity: 0;
|
||||
}
|
||||
.atfp-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.45); }
|
||||
|
||||
/* card */
|
||||
.atfp-box {
|
||||
position: relative; z-index: 1;
|
||||
width: min(92vw, 480px);
|
||||
background: #fff; color: #1d2327;
|
||||
border-radius: 12px; padding: 16px 16px 12px;
|
||||
box-shadow: 0 10px 30px rgba(0,0,0,.25);
|
||||
border: 1px solid #e6e8eb;
|
||||
animation: rise .18s ease-out forwards; transform: translateY(6px);
|
||||
font: 14px/1.45 system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji","Segoe UI Emoji";
|
||||
}
|
||||
|
||||
/* dark mode */
|
||||
@media (prefers-color-scheme: dark) {
|
||||
.atfp-box { background: #101418; color: #e8edf5; border-color: #1c232d; box-shadow: 0 10px 30px rgba(0,0,0,.6); }
|
||||
}
|
||||
|
||||
/* row */
|
||||
.atfp-row { display: grid; grid-template-columns: 28px 1fr; gap: 12px; align-items: center; }
|
||||
|
||||
/* spinner & icons */
|
||||
.atfp-spinner,
|
||||
.atfp-icon { width: 24px; height: 24px; display: none; }
|
||||
|
||||
.atfp-spinner {
|
||||
box-sizing: border-box;
|
||||
border: 3px solid rgba(0,0,0,.1);
|
||||
border-top-color: #3db63d;
|
||||
border-radius: 50%;
|
||||
animation: spin .9s linear infinite;
|
||||
}
|
||||
@media (prefers-color-scheme: dark) {
|
||||
.atfp-spinner { border-color: rgba(255,255,255,.2); border-top-color: #56ce56; }
|
||||
}
|
||||
|
||||
.atfp-icon { text-align: center; line-height: 24px; font-weight: 700; }
|
||||
.atfp-icon--ok { color: #19a35b; }
|
||||
.atfp-icon--err { color: #d23a3a; }
|
||||
|
||||
/* text */
|
||||
.atfp-title { display: none; font-weight: 600; }
|
||||
.atfp-desc { display: none; color: #55606e; margin-top: 2px; }
|
||||
@media (prefers-color-scheme: dark) { .atfp-desc { color: #a8b4c6; } }
|
||||
|
||||
/* progress bar */
|
||||
.atfp-bar { height: 6px; background: rgba(0,0,0,.08); border-radius: 999px; overflow: hidden; margin-top: 10px; }
|
||||
.atfp-bar > span { display: block; height: 100%; width: 40%;
|
||||
background: linear-gradient(90deg, #3db63d8e, #3db63d);
|
||||
animation: slide 1.5s ease-in-out infinite; border-radius: 999px;
|
||||
}
|
||||
@media (prefers-color-scheme: dark) { .atfp-bar { background: rgba(255,255,255,.12); } }
|
||||
|
||||
/* state toggles */
|
||||
.atfp-box[data-state="loading"] .atfp-spinner { display: block; }
|
||||
.atfp-box[data-state="loading"] .atfp-title[data-label="loading"],
|
||||
.atfp-box[data-state="loading"] .atfp-desc[data-label="loading"] { display: block; }
|
||||
|
||||
.atfp-box[data-state="success"] .atfp-icon--ok { display: block; }
|
||||
.atfp-box[data-state="success"] .atfp-title[data-label="success"],
|
||||
.atfp-box[data-state="success"] .atfp-desc[data-label="success"] { display: block; }
|
||||
.atfp-box[data-state="success"] .atfp-bar { display: none; }
|
||||
|
||||
.atfp-box[data-state="error"] .atfp-icon--err { display: block; }
|
||||
.atfp-box[data-state="error"] .atfp-title[data-label="error"],
|
||||
.atfp-box[data-state="error"] .atfp-desc[data-label="error"] { display: block; }
|
||||
.atfp-box[data-state="error"] .atfp-bar > span {
|
||||
background: linear-gradient(90deg, rgba(210,58,58,.2), rgba(210,58,58,.6));
|
||||
}
|
||||
|
||||
/* animations */
|
||||
@keyframes fade-in { to { opacity: 1; } }
|
||||
@keyframes rise { to { transform: translateY(0); } }
|
||||
@keyframes spin { to { transform: rotate(360deg); } }
|
||||
@keyframes slide {
|
||||
0% { transform: translateX(-60%); }
|
||||
50% { transform: translateX(6%); }
|
||||
100% { transform: translateX(110%); }
|
||||
}
|
||||
|
||||
/* reduced motion */
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.atfp-overlay, .atfp-box, .atfp-spinner, .atfp-bar > span { animation: none !important; }
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
body.atfp-overlay-open{overflow:hidden}.atfp-overlay{position:fixed;inset:0;z-index:100000;display:grid;place-items:center;animation:fade-in .15s ease-out forwards;opacity:0}.atfp-backdrop{position:absolute;inset:0;background:rgba(0,0,0,.45)}.atfp-box{position:relative;z-index:1;width:min(92vw,480px);background:#fff;color:#1d2327;border-radius:12px;padding:16px 16px 12px;box-shadow:0 10px 30px rgba(0,0,0,.25);border:1px solid #e6e8eb;animation:rise .18s ease-out forwards;transform:translateY(6px);font:14px/1.45 system-ui,-apple-system,Segoe UI,Roboto,"Helvetica Neue",Arial,"Noto Sans","Apple Color Emoji","Segoe UI Emoji"}@media (prefers-color-scheme:dark){.atfp-box{background:#101418;color:#e8edf5;border-color:#1c232d;box-shadow:0 10px 30px rgba(0,0,0,.6)}}.atfp-row{display:grid;grid-template-columns:28px 1fr;gap:12px;align-items:center}.atfp-icon,.atfp-spinner{width:24px;height:24px;display:none}.atfp-spinner{box-sizing:border-box;border:3px solid rgba(0,0,0,.1);border-top-color:#3db63d;border-radius:50%;animation:spin .9s linear infinite}@media (prefers-color-scheme:dark){.atfp-spinner{border-color:rgba(255,255,255,.2);border-top-color:#56ce56}}.atfp-icon{text-align:center;line-height:24px;font-weight:700}.atfp-icon--ok{color:#19a35b}.atfp-icon--err{color:#d23a3a}.atfp-title{display:none;font-weight:600}.atfp-desc{display:none;color:#55606e;margin-top:2px}@media (prefers-color-scheme:dark){.atfp-desc{color:#a8b4c6}}.atfp-bar{height:6px;background:rgba(0,0,0,.08);border-radius:999px;overflow:hidden;margin-top:10px}.atfp-bar>span{display:block;height:100%;width:40%;background:linear-gradient(90deg,#3db63d8e,#3db63d);animation:slide 1.5s ease-in-out infinite;border-radius:999px}@media (prefers-color-scheme:dark){.atfp-bar{background:rgba(255,255,255,.12)}}.atfp-box[data-state=loading] .atfp-spinner{display:block}.atfp-box[data-state=loading] .atfp-desc[data-label=loading],.atfp-box[data-state=loading] .atfp-title[data-label=loading]{display:block}.atfp-box[data-state=success] .atfp-icon--ok{display:block}.atfp-box[data-state=success] .atfp-desc[data-label=success],.atfp-box[data-state=success] .atfp-title[data-label=success]{display:block}.atfp-box[data-state=success] .atfp-bar{display:none}.atfp-box[data-state=error] .atfp-icon--err{display:block}.atfp-box[data-state=error] .atfp-desc[data-label=error],.atfp-box[data-state=error] .atfp-title[data-label=error]{display:block}.atfp-box[data-state=error] .atfp-bar>span{background:linear-gradient(90deg,rgba(210,58,58,.2),rgba(210,58,58,.6))}@keyframes fade-in{to{opacity:1}}@keyframes rise{to{transform:translateY(0)}}@keyframes spin{to{transform:rotate(360deg)}}@keyframes slide{0%{transform:translateX(-60%)}50%{transform:translateX(6%)}100%{transform:translateX(110%)}}@media (prefers-reduced-motion:reduce){.atfp-bar>span,.atfp-box,.atfp-overlay,.atfp-spinner{animation:none!important}}
|
||||
1
wp-content/plugins/autopoly-ai-translation-for-polylang-pro/assets/css/dataTables.min.css
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<?php return array('dependencies' => array('react', 'react-dom', 'wp-i18n'), 'version' => '194ccb285b472bc652c6');
|
||||
|
After Width: | Height: | Size: 106 KiB |
|
After Width: | Height: | Size: 5.9 KiB |
|
After Width: | Height: | Size: 3.1 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 7.9 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 106 KiB |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M12 17q.425 0 .713-.288T13 16t-.288-.712T12 15t-.712.288T11 16t.288.713T12 17m0-4q.425 0 .713-.288T13 12V8q0-.425-.288-.712T12 7t-.712.288T11 8v4q0 .425.288.713T12 13m0 9q-2.075 0-3.9-.788t-3.175-2.137T2.788 15.9T2 12t.788-3.9t2.137-3.175T8.1 2.788T12 2t3.9.788t3.175 2.137T21.213 8.1T22 12t-.788 3.9t-2.137 3.175t-3.175 2.138T12 22m0-2q3.35 0 5.675-2.325T20 12t-2.325-5.675T12 4T6.325 6.325T4 12t2.325 5.675T12 20m0-8"/></svg>
|
||||
|
After Width: | Height: | Size: 539 B |
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 314 KiB |
|
After Width: | Height: | Size: 3.6 KiB |
|
After Width: | Height: | Size: 6.5 KiB |
|
After Width: | Height: | Size: 40 KiB |
|
After Width: | Height: | Size: 8.6 KiB |
|
After Width: | Height: | Size: 3.7 KiB |
|
After Width: | Height: | Size: 4.5 KiB |
|
After Width: | Height: | Size: 4.4 KiB |
|
After Width: | Height: | Size: 24 KiB |
@@ -0,0 +1 @@
|
||||
<?php return array('dependencies' => array('react', 'wp-components', 'wp-element', 'wp-i18n'), 'version' => '1b54f74346c67e65fd98');
|
||||
@@ -0,0 +1,312 @@
|
||||
'use strict';
|
||||
|
||||
(() => {
|
||||
const { createBlock } = wp.blocks;
|
||||
const { dispatch, select } = wp.data;
|
||||
class atfpCreateNewBlock {
|
||||
constructor() {
|
||||
this.updateBlockStore = {};
|
||||
this.loaderRemove = null;
|
||||
this.loader = null;
|
||||
this.replaceAttributes = null;
|
||||
this.updateBlockId = new Array();
|
||||
}
|
||||
|
||||
copyTranslateText = () => {
|
||||
// Get the current selection object
|
||||
const selection = window.getSelection();
|
||||
// Create a new range object
|
||||
const range = document.createRange();
|
||||
// Select the contents of the copy text element
|
||||
range.selectNodeContents(document.getElementById('atfp-copy-text'));
|
||||
// Remove any existing selections
|
||||
selection.removeAllRanges();
|
||||
// Add the new range to the selection
|
||||
selection.addRange(range);
|
||||
// Execute the copy command
|
||||
document.execCommand('copy');
|
||||
// Clear the selection
|
||||
selection.removeAllRanges();
|
||||
}
|
||||
|
||||
noticeInitialize = () => {
|
||||
dispatch("core/notices").createNotice('info', 'To enable translation, please include the Make This Content Available for Translation text in your block content. For help, watch the video and click <b>"Copy Text"</b> to use. Then, paste it into the section of your block you want automatically translated',
|
||||
{
|
||||
isDismissible : false,
|
||||
id: 'atfp-notice-id',
|
||||
actions: [
|
||||
{
|
||||
label: 'Watch Video.',
|
||||
url: `${atfpAddBlockVars.atfp_demo_page_url}#custom-block-translate`,
|
||||
},
|
||||
],
|
||||
__unstableHTML: true
|
||||
}).then(()=>{
|
||||
const targetAnchor=document.querySelector(`a[href^="${atfpAddBlockVars.atfp_demo_page_url}#custom-block-translate"]`);
|
||||
|
||||
if(targetAnchor){
|
||||
targetAnchor.addEventListener('click', (e)=>{
|
||||
e.preventDefault();
|
||||
window.open(targetAnchor.href, '_blank');
|
||||
})
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
copyBtnInitialize = () => { // Initialize the copy button
|
||||
const copyBtn = document.createElement('div'); // Create a new div element for the copy button
|
||||
copyBtn.id = 'atfp-copy-btn'; // Set the ID of the copy button
|
||||
copyBtn.innerHTML = 'Copy Text'; // Set the inner HTML of the copy button
|
||||
copyBtn.addEventListener('click', this.copyTranslateText); // Add click event listener to copy text
|
||||
copyBtn.ariaLabel = 'Copy Text'; // Set the aria-label for accessibility
|
||||
copyBtn.title = 'Click to copy the text "Make This Content Available for Translation"'; // Tooltip message
|
||||
|
||||
const copyText = document.createElement('div'); // Create a new div element for the copy text
|
||||
copyText.id = 'atfp-copy-text'; // Set the ID of the copy text div
|
||||
copyText.innerHTML = 'Make This Content Available for Translation'; // Set the inner HTML of the copy text div
|
||||
|
||||
document.body.appendChild(copyBtn); // Append the copy button to the document body
|
||||
document.body.appendChild(copyText); // Append the copy text to the document body
|
||||
}
|
||||
|
||||
addBlockInitialize = (newBlock) => {
|
||||
this.newBlock = newBlock;
|
||||
this.creteNewBlock();
|
||||
this.skeletonLoader();
|
||||
}
|
||||
|
||||
removeLoader = () => {
|
||||
clearTimeout(this.loaderRemove);
|
||||
|
||||
this.loaderRemove = setTimeout(() => {
|
||||
if (this.loader) {
|
||||
this.loader.remove();
|
||||
}
|
||||
}, 2000);
|
||||
|
||||
}
|
||||
|
||||
creteNewBlock = () => {
|
||||
const newBlock = createBlock(this.newBlock);
|
||||
this.updateBlockData(newBlock);
|
||||
}
|
||||
|
||||
updateBlockData = async (Block) => {
|
||||
await dispatch('core/block-editor').insertBlocks([Block]);
|
||||
|
||||
setTimeout(() => {
|
||||
const blockWrp = document.getElementById(`block-${Block.clientId}`);
|
||||
if (blockWrp) {
|
||||
blockWrp.appendChild(this.loader);
|
||||
}
|
||||
}, 100);
|
||||
|
||||
setTimeout(() => {
|
||||
this.updateBlockContent(Block);
|
||||
}, 400);
|
||||
}
|
||||
|
||||
updateBlockContent = (Block) => {
|
||||
const newBlock = document.getElementById(`block-${Block.clientId}`);
|
||||
|
||||
if (newBlock) {
|
||||
this.updateContent(newBlock);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
updateContent = async (ele) => {
|
||||
const element = ele;
|
||||
let i = 1;
|
||||
this.removeLoader();
|
||||
|
||||
if (element) {
|
||||
if (element.contentEditable == 'true' && element.children.length < 2) {
|
||||
element.innerHTML = 'Make This Content Available for Translation';
|
||||
} else {
|
||||
const innerElements = element.getElementsByTagName('*');
|
||||
|
||||
for (let innerElement of innerElements) {
|
||||
if (i === innerElements.length) {
|
||||
this.removeLoader();
|
||||
setTimeout(() => {
|
||||
this.updateBlockFromStore();
|
||||
}, 500);
|
||||
}
|
||||
|
||||
i++;
|
||||
if (["SCRIPT", "STYLE", "META", "LINK", "TITLE", "NOSCRIPT", "STYLE", "SCRIPT", "NOSCRIPT", "STYLE", "SCRIPT", "NOSCRIPT", "STYLE", "SCRIPT", "NOSCRIPT"].includes(innerElement.tagName)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (innerElement.childNodes.length > 0) {
|
||||
innerElement.childNodes.forEach((child) => {
|
||||
if (child.nodeType === Node.TEXT_NODE) {
|
||||
this.updateBlockAttr(innerElement, child);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
updateBlockAttr = (innerElement, child) => {
|
||||
let blockId = false;
|
||||
if (innerElement.classList.contains('wp-block')) {
|
||||
blockId = innerElement.dataset.block;
|
||||
} else {
|
||||
const parentBlock = innerElement.closest('.wp-block');
|
||||
if (parentBlock) {
|
||||
blockId = parentBlock.dataset.block;
|
||||
}
|
||||
}
|
||||
|
||||
const blockAttributes = select('core/block-editor').getBlockAttributes(blockId);
|
||||
|
||||
let index = 0;
|
||||
|
||||
if (!this.updateBlockStore[blockId]) {
|
||||
let attributes = JSON.parse(JSON.stringify(blockAttributes));
|
||||
this.updateBlockStore[blockId] = { attributes: attributes };
|
||||
this.updateBlockStore[blockId].updateBlockData = {};
|
||||
}
|
||||
|
||||
const updateNestedAttributes = async (attributes, child) => {
|
||||
const updateAttributes = async (key) => {
|
||||
index++;
|
||||
|
||||
if (typeof attributes[key] === 'string' && attributes[key].trim() !== '' && (attributes[key].trim() === child.textContent.trim() || attributes[key] === child.textContent.trim())) {
|
||||
const originalValue = attributes[key];
|
||||
const newValue = 'Make This Content Available for Translation ' + index;
|
||||
this.updateBlockStore[blockId].updateBlockData[newValue.replace(/\s+/g, '-')] = originalValue;
|
||||
attributes[key] = newValue;
|
||||
}
|
||||
};
|
||||
|
||||
if (typeof attributes === 'object' && attributes !== null) {
|
||||
for (const key of Object.keys(attributes)) {
|
||||
await updateAttributes(key);
|
||||
|
||||
if (typeof attributes[key] === 'object' && attributes[key] !== null) {
|
||||
await updateNestedAttributes(attributes[key], child); // Recursively update nested objects
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const blockStoreAttributes = this.updateBlockStore[blockId].attributes;
|
||||
updateNestedAttributes(blockStoreAttributes, child);
|
||||
}
|
||||
|
||||
updateBlockFromStore = () => {
|
||||
const blockStoreAttributes = this.updateBlockStore;
|
||||
|
||||
Object.keys(blockStoreAttributes).forEach((blockId) => {
|
||||
const blockAttributes = blockStoreAttributes[blockId].attributes;
|
||||
this.removeLoader();
|
||||
dispatch('core/block-editor').updateBlockAttributes(blockId, blockAttributes).then(() => {
|
||||
clearTimeout(this.replaceAttributes);
|
||||
this.replaceAttributes = setTimeout(() => {
|
||||
this.removeLoader();
|
||||
const blockIds = Object.keys(this.updateBlockStore);
|
||||
this.replaceBlockContent(blockIds[0]);
|
||||
}, 500);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
replaceBlockContent = (blockId) => {
|
||||
const blockStoreAttributes = this.updateBlockStore;
|
||||
|
||||
const checkValidAttributes = (value = false, blockId) => {
|
||||
const blockElement = document.querySelector(`#block-${blockId}`);
|
||||
const regex = new RegExp(value, 'g'); // Create regex from the value parameter with global flag
|
||||
const matchFound = regex.test(blockElement.innerText); // Check if the regex matches
|
||||
return matchFound; // Return the result of the regex test directly
|
||||
};
|
||||
|
||||
const blockAttributes = blockStoreAttributes[blockId].attributes;
|
||||
|
||||
const upateNestedAttributes = async (attributes) => {
|
||||
const updateAttributes = async (key) => {
|
||||
|
||||
if (typeof attributes[key] === 'string' && attributes[key].includes('Make This Content Available for Translation')) {
|
||||
try {
|
||||
const keyWithDashes = attributes[key].replace(/\s+/g, '-');
|
||||
const originalValue = this.updateBlockStore[blockId].updateBlockData[keyWithDashes];
|
||||
|
||||
const status = checkValidAttributes(attributes[key], blockId);
|
||||
|
||||
if (!status) {
|
||||
attributes[key] = originalValue;
|
||||
} else {
|
||||
attributes[key] = 'Make This Content Available for Translation';
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(`${attributes[key]} is not valid JSON.`);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (typeof attributes === 'object' && attributes !== null) {
|
||||
for (const key of Object.keys(attributes)) {
|
||||
await updateAttributes(key);
|
||||
|
||||
if (typeof attributes[key] === 'object' && attributes[key] !== null) {
|
||||
await upateNestedAttributes(attributes[key]); // Recursively update nested objects
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
upateNestedAttributes(blockAttributes);
|
||||
|
||||
setTimeout(() => {
|
||||
dispatch('core/block-editor').updateBlockAttributes(blockId, blockAttributes).then(() => {
|
||||
const blockIds = Object.keys(this.updateBlockStore);
|
||||
if (blockIds.length > 0) {
|
||||
this.updateBlockId.push(blockId);
|
||||
dispatch('core/block-editor').selectBlock(null);
|
||||
this.removeLoader();
|
||||
const firstBlockId = blockIds.find(id => !this.updateBlockId.includes(id));
|
||||
if (firstBlockId) {
|
||||
this.replaceBlockContent(firstBlockId);
|
||||
}
|
||||
}
|
||||
});
|
||||
}, 500);
|
||||
}
|
||||
|
||||
skeletonLoader = () => {
|
||||
const loader = document.createElement('div');
|
||||
|
||||
const loaderContainer = () => {
|
||||
const container = '<style>.atfp-loader-wrapper{position:absolute;width:100%;height:100%;top:0;left:0;z-index:99999;}.atfp-loader-container{width:100%;height:100%;}.atfp-loader-skeleton{--skbg:hsl(227deg, 13%, 50%, 0.2);display:grid;gap:20px;width:100%;height:100%;background:#ffffff;padding:15px;border-radius:8px;box-shadow:0 4px 12px rgba(0, 0, 0, 0.1);transition:transform 0.3s ease;transform:scale(1.02);}.atfp-loader-shimmer{display:flex;aspect-ratio:2/1;width:100%;height:100%;background:var(--skbg);border-radius:4px;overflow:hidden;position:relative;}.atfp-loader-shimmer::before{content:"";position:absolute;width:100%;height:100%;background-image:linear-gradient(-90deg,transparent 8%,rgba(255,255,255,0.28) 18%,transparent 33%);background-size:200%;animation:shimerAnimate 1.5s ease-in-out infinite;}@keyframes shimerAnimate{0%{background-position:100% 0;}100%{background-position:-100% 0;}}</style>'
|
||||
|
||||
return '<div class="atfp-loader-container">' + container + '<div class="atfp-loader-skeleton"><span class="atfp-loader-shimmer"></span></div></div>';
|
||||
}
|
||||
|
||||
loader.className = 'atfp-loader-wrapper'; // Add the atfp class to the loader
|
||||
loader.innerHTML = loaderContainer();
|
||||
|
||||
this.loader = loader;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
window.addEventListener('load', () => {
|
||||
const atfpCreateBlockObj = new atfpCreateNewBlock();
|
||||
|
||||
atfpCreateBlockObj.copyBtnInitialize();
|
||||
atfpCreateBlockObj.noticeInitialize();
|
||||
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
let newBlock = '';
|
||||
|
||||
if (urlParams.has('atfp_new_block') && '' !== urlParams.get('atfp_new_block').trim()) {
|
||||
newBlock = urlParams.get('atfp_new_block');
|
||||
atfpCreateBlockObj.addBlockInitialize(newBlock);
|
||||
}
|
||||
});
|
||||
})();
|
||||
@@ -0,0 +1,34 @@
|
||||
jQuery(document).ready(function(){
|
||||
const atfpSubsubsubList = jQuery('.atfp_subsubsub');
|
||||
const atfpBulkTranslateBtn = jQuery('.atfpp-bulk-translate-btn');
|
||||
|
||||
if(atfpSubsubsubList.length){
|
||||
const $defaultSubsubsub = jQuery('ul.subsubsub:not(.atfp_subsubsub_list)');
|
||||
|
||||
if($defaultSubsubsub.length){
|
||||
$defaultSubsubsub.after(atfpSubsubsubList);
|
||||
atfpSubsubsubList.show();
|
||||
}
|
||||
}
|
||||
|
||||
if(atfpBulkTranslateBtn.length){
|
||||
const $defaultFilter = jQuery('.actions:not(.bulkactions)');
|
||||
const $bulkAction=jQuery('.actions.bulkactions');
|
||||
|
||||
if($defaultFilter.length){
|
||||
$defaultFilter.each(function(){
|
||||
const clone=atfpBulkTranslateBtn.clone(true);
|
||||
jQuery(this).append(clone);
|
||||
clone.show();
|
||||
});
|
||||
|
||||
atfpBulkTranslateBtn.remove();
|
||||
}else if($bulkAction.length){
|
||||
$bulkAction.each(function(){
|
||||
const clone=atfpBulkTranslateBtn.clone(true);
|
||||
jQuery(this).after(clone);
|
||||
clone.show();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,221 @@
|
||||
class BlockFilterSorter {
|
||||
constructor() {
|
||||
this.tableBody = document.querySelector('.atfp-custom-data-table-table tbody');
|
||||
this.filters = document.querySelectorAll('.atfp-custom-data-table-filters .atfp-filter-tab');
|
||||
this.atfpDataTableObj = null;
|
||||
this.saveButtonEnabled = false;
|
||||
this.saveButtonText = false;
|
||||
this.saveButtonClass = false;
|
||||
this.saveButtonAction = false;
|
||||
this.saveButtonNonce = false;
|
||||
this.displayAjaxNotice=false;
|
||||
this.ajaxUrl = false;
|
||||
|
||||
if (window.atfpCustomTableDataObject) {
|
||||
if (atfpCustomTableDataObject.save_button_enabled && '' !== atfpCustomTableDataObject.save_button_enabled) {
|
||||
this.saveButtonEnabled = atfpCustomTableDataObject.save_button_enabled;
|
||||
}
|
||||
if (atfpCustomTableDataObject.save_button_text && '' !== atfpCustomTableDataObject.save_button_text) {
|
||||
this.saveButtonText = atfpCustomTableDataObject.save_button_text;
|
||||
}
|
||||
if (atfpCustomTableDataObject.save_button_class && '' !== atfpCustomTableDataObject.save_button_class) {
|
||||
this.saveButtonClass = atfpCustomTableDataObject.save_button_class;
|
||||
}
|
||||
if (atfpCustomTableDataObject.save_button_handler && '' !== atfpCustomTableDataObject.save_button_handler) {
|
||||
this.saveButtonAction = atfpCustomTableDataObject.save_button_handler;
|
||||
}
|
||||
if (atfpCustomTableDataObject.save_button_nonce && '' !== atfpCustomTableDataObject.save_button_nonce) {
|
||||
this.saveButtonNonce = atfpCustomTableDataObject.save_button_nonce;
|
||||
}
|
||||
if (atfpCustomTableDataObject.admin_url && '' !== atfpCustomTableDataObject.admin_url) {
|
||||
this.ajaxUrl = atfpCustomTableDataObject.admin_url;
|
||||
}
|
||||
|
||||
const inputFields = document.querySelectorAll('#atfp-custom-datatable tbody input[name="atfp_fields_status"]');
|
||||
inputFields.forEach(input => {
|
||||
input.addEventListener('change', this.updateStatusHandler.bind(this));
|
||||
});
|
||||
}
|
||||
|
||||
if (this.tableBody) {
|
||||
this.atfpDataTable();
|
||||
|
||||
this.filters.forEach(filter => {
|
||||
filter.addEventListener('input', this.datatableFilterHandler.bind(this));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
atfpDataTable() {
|
||||
if (this.tableBody) {
|
||||
this.atfpDataTableObj = new DataTable('#atfp-custom-datatable', {
|
||||
pageLength: 25,
|
||||
infoCallback: function (settings, start, end, total, max) {
|
||||
return `Showing ${start} to ${end} of ${max} records`;
|
||||
}
|
||||
});
|
||||
|
||||
this.atfpDataTableObj.on('draw.dt', function (e) {
|
||||
const rows = jQuery(this).find('tbody tr');
|
||||
|
||||
if (rows.length.length === 0) {
|
||||
this.atfpDataTableObj.empty();
|
||||
}
|
||||
|
||||
const length = e.dt.page.info().length;
|
||||
const page = e.dt.page.info().page;
|
||||
|
||||
rows.each(function (index, row) {
|
||||
const emptyCell = row.querySelector('td.dt-empty');
|
||||
if (!emptyCell) {
|
||||
row.children[0].textContent = (page * length) + index + 1;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
const tableWrp = document.getElementById('atfp-custom-datatable_wrapper');
|
||||
const selectWrapper = document.querySelector('.atfp-custom-data-table-filters');
|
||||
selectWrapper.remove();
|
||||
tableWrp.prepend(selectWrapper);
|
||||
|
||||
if (this.saveButtonEnabled && '' !== this.saveButtonText && 'false' !== this.saveButtonText) {
|
||||
const saveButton = this.appendSaveButton();
|
||||
const lastRow = tableWrp.querySelector('.dt-layout-row:last-child');
|
||||
lastRow.before(saveButton);
|
||||
|
||||
jQuery(`.${this.saveButtonClass}`).on('click', this.saveButtonHandler.bind(this));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
datatableFilterHandler(e) {
|
||||
if (this.atfpDataTableObj) {
|
||||
let value = e.target.value;
|
||||
let wrapper = e.target.closest('.atfp-filter-tab');
|
||||
let column = parseInt(wrapper.dataset.column);
|
||||
let defaultValue = wrapper.dataset.default;
|
||||
value = value === defaultValue ? false : value;
|
||||
this.atfpDataTableObj.column(column).search(value ? new RegExp('^' + value, 'i') : '', false, false, false).draw();
|
||||
}
|
||||
}
|
||||
|
||||
updateStatusHandler(e) {
|
||||
const table = jQuery('#atfp-custom-datatable').DataTable();
|
||||
|
||||
if (!table) return; // DataTable not initialized
|
||||
|
||||
const $tr = jQuery(e.target).closest('tr');
|
||||
if (!$tr.length) return; // no row found
|
||||
|
||||
const dtRow = table.row($tr);
|
||||
if (!dtRow.node()) return; // row doesn’t exist in DataTable
|
||||
|
||||
const checked = e.target.checked;
|
||||
const status = checked ? 'Supported' : 'Unsupported';
|
||||
|
||||
// Make sure cell exists
|
||||
const cell = dtRow.cell(dtRow.index(), 3);
|
||||
if (!cell) return;
|
||||
|
||||
// Update via DataTables API
|
||||
cell.data(status);
|
||||
}
|
||||
|
||||
saveButtonHandler(e) {
|
||||
e.preventDefault();
|
||||
const saveBtns = jQuery(`.${this.saveButtonClass}`);
|
||||
|
||||
if (saveBtns.hasClass('saving')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.saveButtonAction || '' === this.saveButtonAction || !this.saveButtonNonce || '' === this.saveButtonNonce || !this.ajaxUrl || '' === this.ajaxUrl) {
|
||||
return;
|
||||
}
|
||||
|
||||
const selectedCheckbox = [];
|
||||
const tdNodes = this.atfpDataTableObj.column(4).nodes();
|
||||
|
||||
if (tdNodes.length > 0) {
|
||||
Array.from(tdNodes).forEach(tdNode => {
|
||||
const checkbox = tdNode.querySelector('input[type="checkbox"]');
|
||||
if (checkbox && checkbox.checked) {
|
||||
selectedCheckbox.push(checkbox.value);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (selectedCheckbox.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const apiSendData = {
|
||||
action: this.saveButtonAction,
|
||||
atfp_nonce: this.saveButtonNonce,
|
||||
save_custom_fields_data: JSON.stringify(selectedCheckbox)
|
||||
};
|
||||
|
||||
saveBtns.addClass('saving').html('<span class="saving-text">Saving<span class="dot" style="--i:0"></span><span class="dot" style="--i:1"></span><span class="dot" style="--i:2"></span></span>', true);
|
||||
|
||||
fetch(this.ajaxUrl, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
'Accept': 'application/json',
|
||||
},
|
||||
body: new URLSearchParams(apiSendData)
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
saveBtns.removeClass('saving').html(this.saveButtonText, true);
|
||||
|
||||
if (data.success) {
|
||||
if (data.data.message) {
|
||||
this.appendMessageNotice(data.data.message, 'success');
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.log(error);
|
||||
if (error.data.message) {
|
||||
this.appendMessageNotice(data.data.message, 'error');
|
||||
}
|
||||
saveBtns.removeClass('saving').html(this.saveButtonText, true);
|
||||
console.error(error);
|
||||
});
|
||||
}
|
||||
|
||||
appendMessageNotice(message, type) {
|
||||
|
||||
if(this.displayAjaxNotice){
|
||||
jQuery('#atfp-custom-fields-message-notice').remove();
|
||||
clearTimeout(this.displayAjaxNotice);
|
||||
}
|
||||
|
||||
this.displayAjaxNotice=setTimeout(() => {
|
||||
this.displayAjaxNotice=false;
|
||||
jQuery('#atfp-custom-fields-message-notice').remove();
|
||||
}, 10000);
|
||||
|
||||
let messageNotice = jQuery('<div id="atfp-custom-fields-message-notice"><p>' + message + '</p></div>');
|
||||
messageNotice.addClass('is-dismissible notice notice-' + type);
|
||||
jQuery('.atfpp-dashboard-wrapper').before(messageNotice);
|
||||
}
|
||||
|
||||
appendSaveButton() {
|
||||
|
||||
if (!this.saveButtonText || '' === this.saveButtonText || 'false' === this.saveButtonText || !this.saveButtonEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
const saveButton = document.createElement('button');
|
||||
saveButton.className = 'button button-primary ' + this.saveButtonClass;
|
||||
saveButton.textContent = this.saveButtonText;
|
||||
return saveButton;
|
||||
}
|
||||
}
|
||||
|
||||
// Call the class after window load
|
||||
window.addEventListener('load', () => {
|
||||
new BlockFilterSorter();
|
||||
});
|
||||
@@ -0,0 +1,126 @@
|
||||
const { __, sprintf } = wp.i18n;
|
||||
|
||||
const atfpElementorConfirmBox = {
|
||||
init: function() {
|
||||
this.pageTitleEvent=false;
|
||||
if(window.atfpElementorConfirmBoxData){
|
||||
this.createConfirmBox();
|
||||
}
|
||||
},
|
||||
|
||||
createConfirmBox: function() {
|
||||
const sourceLangName=window.atfpElementorConfirmBoxData.sourceLangName;
|
||||
const targetLangName=window.atfpElementorConfirmBoxData.targetLangName;
|
||||
const confirmBox = jQuery(`<div class="atfp-elementor-translate-confirm-box modal-container" style="display:flex">
|
||||
<div class="modal-content">
|
||||
<p>
|
||||
${sprintf(
|
||||
__("The original page in %s was built with Elementor. Its content has already been copied into this new %s version. You can now translate it with Elementor to keep the same design, or edit it with the Gutenberg editor.", "autopoly-ai-translation-for-polylang-pro"),
|
||||
sourceLangName,
|
||||
targetLangName
|
||||
)}
|
||||
</p>
|
||||
<div>
|
||||
<button data-value="yes">
|
||||
${__("Translate with Elementor", "autopoly-ai-translation-for-polylang-pro")}
|
||||
</button>
|
||||
<button data-value="no">
|
||||
${__("Edit with Gutenberg", "autopoly-ai-translation-for-polylang-pro")}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`);
|
||||
|
||||
confirmBox.appendTo(jQuery('body'));
|
||||
|
||||
confirmBox.find('button[data-value="yes"]').on('click', (e)=>{this.confirmTranslation(e)});
|
||||
confirmBox.find('button[data-value="no"]').on('click', (e)=>{e.preventDefault();this.closeConfirmBox();});
|
||||
},
|
||||
|
||||
closeConfirmBox: function() {
|
||||
this.setPageTitle();
|
||||
const confirmBox = jQuery('.atfp-elementor-translate-confirm-box.modal-container');
|
||||
confirmBox.remove();
|
||||
},
|
||||
|
||||
confirmTranslation: function(e) {
|
||||
this.setPageTitle();
|
||||
e.preventDefault();
|
||||
const postId=window.atfpElementorConfirmBoxData.postId;
|
||||
const targetLangSlug=window.atfpElementorConfirmBoxData.targetLangSlug;
|
||||
|
||||
if(postId && targetLangSlug) {
|
||||
let oldData=localStorage.getItem('atfpElementorConfirmBox');
|
||||
let data={[postId+'_'+targetLangSlug]: true};
|
||||
|
||||
if(oldData && 'string' === typeof oldData && '' !== oldData) {
|
||||
oldData=JSON.parse(oldData);
|
||||
data={...oldData, ...data};
|
||||
}
|
||||
|
||||
localStorage.setItem('atfpElementorConfirmBox', JSON.stringify(data));
|
||||
|
||||
const elementorButton=document.getElementById('elementor-editor-button');
|
||||
const elementorEditModeButton=document.getElementById('elementor-edit-mode-button');
|
||||
|
||||
if(elementorEditModeButton) {
|
||||
elementorEditModeButton.click();
|
||||
}else if(elementorButton) {
|
||||
elementorButton.click();
|
||||
}
|
||||
|
||||
this.closeConfirmBox();
|
||||
}
|
||||
},
|
||||
|
||||
setPageTitle: function() {
|
||||
|
||||
if(window.atfpElementorConfirmBoxData.editorType !== 'classic') {
|
||||
return;
|
||||
}
|
||||
|
||||
if(this.pageTitleEvent) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.pageTitleEvent=true;
|
||||
|
||||
const elementorButtons=document.querySelectorAll('#elementor-editor-button, #elementor-edit-mode-button');
|
||||
|
||||
elementorButtons.forEach(button=>{
|
||||
button.addEventListener('click', (e)=>{
|
||||
e.preventDefault();
|
||||
|
||||
if(window.wp && window.elementorAdmin && window.elementorAdmin.getDefaultElements){
|
||||
const defaultElements=window.elementorAdmin.getDefaultElements();
|
||||
|
||||
if(defaultElements) {
|
||||
$goToEditLink=defaultElements.$goToEditLink;
|
||||
|
||||
if($goToEditLink) {
|
||||
var $wpTitle = jQuery('#title');
|
||||
|
||||
if (!$wpTitle.val()) {
|
||||
$wpTitle.val('Elementor #' + jQuery('#post_ID').val());
|
||||
}
|
||||
|
||||
if (wp.autosave) {
|
||||
wp.autosave.server.triggerSave();
|
||||
}
|
||||
|
||||
jQuery(document).on('heartbeat-tick.autosave', function () {
|
||||
window.elementorCommon.elements.$window.off('beforeunload.edit-post');
|
||||
location.href = $goToEditLink.attr('href');
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
jQuery(document).ready(function($) {
|
||||
atfpElementorConfirmBox.init();
|
||||
});
|
||||
@@ -0,0 +1,333 @@
|
||||
const { parse } = wp.blocks;
|
||||
const { select, subscribe } = wp.data;
|
||||
|
||||
class blockDataReterive {
|
||||
constructor() {
|
||||
this.blockLists = [];
|
||||
this.customBlockTranslateData = {};
|
||||
this.customBlocksData = [];
|
||||
this.loaderContainer = null;
|
||||
this.init();
|
||||
}
|
||||
|
||||
init = () => {
|
||||
this.fetchCustomBlocks();
|
||||
|
||||
// Create full-page overlay and append to <body>
|
||||
this.loaderContainer = document.createElement('div');
|
||||
this.loaderContainer.className = 'atfp-overlay';
|
||||
this.loaderContainer.setAttribute('role', 'status');
|
||||
this.loaderContainer.setAttribute('aria-live', 'polite');
|
||||
this.loaderContainer.innerHTML = this.getOverlayTemplate(); // see section 2
|
||||
document.body.appendChild(this.loaderContainer);
|
||||
document.body.classList.add('atfp-overlay-open');
|
||||
}
|
||||
|
||||
getBlocks = (blocks) => {
|
||||
const innerBlocks = (block) => {
|
||||
const innerBlock = block.innerBlocks;
|
||||
if (innerBlock.length > 0) {
|
||||
innerBlock.forEach(innerBlock => {
|
||||
this.customBlocksData.push(innerBlock);
|
||||
innerBlocks(innerBlock);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const blockLists = blocks;
|
||||
|
||||
blockLists.forEach(block => {
|
||||
innerBlocks(block);
|
||||
});
|
||||
|
||||
|
||||
this.customBlocksData = [...this.customBlocksData, ...blockLists];
|
||||
|
||||
this.getBlockData();
|
||||
}
|
||||
|
||||
fetchCustomBlocks = () => {
|
||||
/**
|
||||
* Prepare data to send in API request.
|
||||
*/
|
||||
const apiSendData = {
|
||||
atfp_nonce: atfp_block_update_object.ajax_nonce,
|
||||
action: atfp_block_update_object.action_get_content
|
||||
};
|
||||
const apiUrl = atfp_block_update_object.ajax_url;
|
||||
|
||||
fetch(apiUrl, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
},
|
||||
body: new URLSearchParams(apiSendData)
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.message === 'No custom blocks found.') {
|
||||
this.loaderContainer && this.loaderContainer.remove();
|
||||
return;
|
||||
}
|
||||
|
||||
const customBlocks = parse(data.data.block_data);
|
||||
|
||||
this.getBlocks(customBlocks);
|
||||
|
||||
// Save new block translate data
|
||||
this.saveBlockData();
|
||||
})
|
||||
.catch(error => {
|
||||
this.loaderContainer && this.loaderContainer.remove();
|
||||
console.error('Error fetching block rules:', error);
|
||||
});
|
||||
}
|
||||
|
||||
saveBlockData = () => {
|
||||
if (Object.keys(this.customBlockTranslateData).length < 1) {
|
||||
this.loaderContainer && this.loaderContainer.remove();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Prepare data to send in API request & update latest translate block data.
|
||||
*/
|
||||
const apiSendData = {
|
||||
atfp_nonce: atfp_block_update_object.ajax_nonce,
|
||||
action: atfp_block_update_object.action_update_content,
|
||||
save_block_data: JSON.stringify(this.customBlockTranslateData)
|
||||
};
|
||||
|
||||
const apiUrl = atfp_block_update_object.ajax_url;
|
||||
|
||||
fetch(apiUrl, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
},
|
||||
body: new URLSearchParams(apiSendData)
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
this.setOverlayState('success');
|
||||
this.teardownOverlay();
|
||||
if (data.success && data.data.message) {
|
||||
console.log(data.data.message);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
this.setOverlayState('error');
|
||||
this.teardownOverlay();
|
||||
console.error('Error fetching block rules:', error);
|
||||
});
|
||||
}
|
||||
|
||||
nestedAttrValue = (idsArr) => {
|
||||
const convertToArrays = (obj) => {
|
||||
// Check if obj is an object
|
||||
if (typeof obj !== 'object' || obj === null) {
|
||||
return obj;
|
||||
}
|
||||
|
||||
// Process each key-value pair in the object
|
||||
for (let key in obj) {
|
||||
if (obj.hasOwnProperty(key)) {
|
||||
// If the current value is an object and has the key 'atfp_array_key_replace'
|
||||
if (typeof obj[key] === 'object' && obj[key] !== null && obj[key].hasOwnProperty('atfp_array_key_replace')) {
|
||||
// Replace the value with 'true' directly in the array
|
||||
obj[key] = Object.values(obj[key]);
|
||||
obj[key] = convertToArrays(obj[key]);
|
||||
} else {
|
||||
// Recursively call convertToArrays for nested objects or arrays
|
||||
obj[key] = convertToArrays(obj[key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
const deepMerge = (target, source) => {
|
||||
|
||||
for (const key in source) {
|
||||
if (source[key] instanceof Object && key in target) {
|
||||
Object.assign(source[key], deepMerge(target[key], source[key]));
|
||||
}
|
||||
}
|
||||
Object.assign(target || {}, source);
|
||||
return target;
|
||||
};
|
||||
|
||||
let currentElement = {};
|
||||
let tempObj = currentElement;
|
||||
let lastKey = idsArr[idsArr.length - 1];
|
||||
idsArr.slice(0, -1).forEach((key) => {
|
||||
tempObj[key] = tempObj[key] || {};
|
||||
tempObj = tempObj[key];
|
||||
});
|
||||
tempObj[lastKey] = true;
|
||||
|
||||
const obj = convertToArrays(currentElement);
|
||||
deepMerge(this.customBlockTranslateData, obj);
|
||||
}
|
||||
|
||||
filterAttr = (idsArray, value) => {
|
||||
if (null === value || undefined === value) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Object.getPrototypeOf(value) === Array.prototype) {
|
||||
this.filterBlockArrayAttr(idsArray, value);
|
||||
} else if (Object.getPrototypeOf(value) === Object.prototype) {
|
||||
this.filterBlockObjectAttr(idsArray, value);
|
||||
} else if (typeof value === 'string' && /Make This Content Available for Translation/i.test(value)) {
|
||||
this.nestedAttrValue(idsArray, value);
|
||||
} else if (value instanceof wp.richText.RichTextData && /Make This Content Available for Translation/i.test(value.originalHTML)) {
|
||||
this.nestedAttrValue(idsArray, value.originalHTML);
|
||||
}
|
||||
}
|
||||
|
||||
filterBlockArrayAttr = (idsArr, blockData) => {
|
||||
const newIdArr = new Array(...idsArr);
|
||||
newIdArr.push('atfp_array_key_replace');
|
||||
blockData.forEach((value, key) => {
|
||||
if ((typeof value === 'string' && /Make This Content Available for Translation/i.test(value)) || (![null, undefined].includes(value) && [Array.prototype, Object.prototype].includes(Object.getPrototypeOf(value)))) {
|
||||
this.filterAttr(newIdArr, value)
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
filterBlockObjectAttr = (idsArr, blockData) => {
|
||||
Object.keys(blockData).forEach(key => {
|
||||
const newIdArr = new Array(...idsArr);
|
||||
const value = blockData[key];
|
||||
if (value !== null && value !== undefined) {
|
||||
if ((typeof value === 'string' && /Make This Content Available for Translation/i.test(value)) || [Array.prototype, Object.prototype].includes(Object.getPrototypeOf(value))) {
|
||||
newIdArr.push(key);
|
||||
this.filterAttr(newIdArr, blockData[key]);
|
||||
};
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
filterBlockAttribute = (blockData) => {
|
||||
Object.keys(blockData).map(clientId => {
|
||||
const blockName = Object.keys(blockData[clientId])[0];
|
||||
const attributes = blockData[clientId][blockName];
|
||||
Object.keys(attributes).forEach(keytwo => {
|
||||
const value = attributes[keytwo];
|
||||
const idsArray = new Array(blockName, "attributes", keytwo);
|
||||
this.filterAttr(idsArray, value);
|
||||
});
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
getBlockData = () => {
|
||||
if (typeof this.customBlocksData !== 'object' || Object.keys(this.customBlocksData).length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const blockData = this.customBlocksData;
|
||||
const blockAttributes = {};
|
||||
Object.values(blockData).forEach(block => {
|
||||
if (Object.values(block.attributes).length > 0) {
|
||||
blockAttributes[block.clientId] = {};
|
||||
blockAttributes[block.clientId][block.name] = block.attributes;
|
||||
}
|
||||
});
|
||||
|
||||
if (Object.values(blockAttributes).length > 0) {
|
||||
this.filterBlockAttribute(blockAttributes);
|
||||
}
|
||||
}
|
||||
|
||||
setOverlayState = (state /* 'loading' | 'success' | 'error' */) => {
|
||||
if (!this.loaderContainer) return;
|
||||
const panel = this.loaderContainer.querySelector('.atfp-overlay .atfp-box');
|
||||
if (panel) panel.setAttribute('data-state', state);
|
||||
};
|
||||
|
||||
teardownOverlay = (delayMs = 3000) => {
|
||||
if (!this.loaderContainer) return;
|
||||
setTimeout(() => {
|
||||
this.loaderContainer.classList.add('atfp-overlay--closing');
|
||||
setTimeout(() => {
|
||||
this.loaderContainer.remove();
|
||||
this.loaderContainer = null;
|
||||
document.body.classList.remove('atfp-overlay-open');
|
||||
}, 300);
|
||||
}, delayMs);
|
||||
};
|
||||
|
||||
getOverlayTemplate = () => {
|
||||
return `
|
||||
<div class="atfp-overlay" role="status" aria-live="polite">
|
||||
<div class="atfp-backdrop"></div>
|
||||
<div class="atfp-box" data-state="loading">
|
||||
<div class="atfp-row">
|
||||
<span class="atfp-spinner" aria-hidden="true"></span>
|
||||
<span class="atfp-icon atfp-icon--ok" aria-hidden="true">✓</span>
|
||||
<span class="atfp-icon atfp-icon--err" aria-hidden="true">!</span>
|
||||
|
||||
<div class="atfp-text">
|
||||
<div class="atfp-title" data-label="loading">Saving block content</div>
|
||||
<div class="atfp-title" data-label="success">Supported block content has been updated</div>
|
||||
<div class="atfp-title" data-label="error">Update failed</div>
|
||||
|
||||
<div class="atfp-desc" data-label="loading">
|
||||
Please don’t close or refresh this window until the update is complete.
|
||||
</div>
|
||||
<div class="atfp-desc" data-label="success">
|
||||
Supported block content has been updated. You may continue.
|
||||
</div>
|
||||
<div class="atfp-desc" data-label="error">
|
||||
Something went wrong. You can retry without closing this window.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="atfp-bar"><span></span></div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const debounce = (func, delay) => {
|
||||
let timeoutId;
|
||||
return function (...args) {
|
||||
clearTimeout(timeoutId);
|
||||
timeoutId = setTimeout(() => func.apply(this, args), delay);
|
||||
};
|
||||
};
|
||||
|
||||
let isBlockContentUpdating = false;
|
||||
const saveBlockContent = debounce(() => {
|
||||
new blockDataReterive();
|
||||
isBlockContentUpdating = false;
|
||||
}, 300);
|
||||
|
||||
if (select && select('core/editor') && subscribe) {
|
||||
subscribe(() => {
|
||||
const {
|
||||
isCurrentPostPublished,
|
||||
isSavingPost,
|
||||
isPublishingPost,
|
||||
isAutosavingPost,
|
||||
} = select('core/editor');
|
||||
|
||||
const isAutoSaving = isAutosavingPost();
|
||||
const isPublishing = isPublishingPost();
|
||||
const isSaving = isSavingPost();
|
||||
const postPublished = isCurrentPostPublished();
|
||||
|
||||
if ((isPublishing || (postPublished && isSaving)) && !isAutoSaving && !isBlockContentUpdating) {
|
||||
isBlockContentUpdating = true;
|
||||
saveBlockContent();
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||