Skip to content

Commit 77a7a65

Browse files
authored
Merge pull request #3 from awesomemotive/try/composer
Update SDK
2 parents da9f696 + df470c9 commit 77a7a65

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+28781
-29560
lines changed

.editorconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[*]
2+
charset = utf-8
3+
end_of_line = lf
4+
insert_final_newline = true
5+
trim_trailing_whitespace = true
6+
indent_style = tab

assets/build/css/style-edd-sl-sdk.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/build/index.asset.php

Lines changed: 0 additions & 1 deletion
This file was deleted.

assets/build/js/edd-sl-sdk.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/css/style.scss

Lines changed: 0 additions & 11 deletions
This file was deleted.

assets/js/index.js

Lines changed: 0 additions & 85 deletions
This file was deleted.

assets/js/utils/spinners.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

assets/src/css/_toggle.scss

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
.edd-sl-sdk__data-control {
2+
position: relative;
3+
display: flex;
4+
gap: 5px;
5+
overflow: visible;
6+
align-items: center;
7+
8+
input {
9+
position: relative;
10+
margin: 0;
11+
padding: 0;
12+
width: 42px;
13+
min-width: 42px;
14+
height: 24px;
15+
background-color: #ccc;
16+
transition: background 0.2s ease;
17+
border-radius: 34px;
18+
box-shadow: none;
19+
border: none;
20+
}
21+
22+
label,
23+
.label {
24+
margin-bottom: 0 !important;
25+
}
26+
27+
input:before {
28+
position: absolute;
29+
content: "" !important;
30+
height: 18px !important;
31+
width: 18px !important;
32+
left: 3px;
33+
bottom: 3px;
34+
background-color: white !important;
35+
transition: 0.1s transform ease;
36+
border-radius: 50%;
37+
z-index: 99;
38+
}
39+
40+
@media only screen and (max-width: 782px) {
41+
input:checked:before {
42+
margin: -.1875rem 0 0 -.25rem;
43+
}
44+
}
45+
46+
input:checked {
47+
background-color: var( --wp-admin-theme-color, #007cba );
48+
}
49+
50+
input:active,
51+
input:focus {
52+
outline: 0;
53+
box-shadow: 0 0 0 1px #fff, 0 0 0 3px #7e8993;
54+
}
55+
56+
input:checked:active,
57+
input:checked:focus {
58+
box-shadow: 0 0 0 1px #fff, 0 0 0 3px var( --wp-admin-theme-color, #007cba );
59+
}
60+
61+
input:checked:before {
62+
transform: translateX(22px);
63+
}
64+
65+
input[type="radio"]:checked:before {
66+
margin: 0;
67+
transform: translateX(18px);
68+
}
69+
70+
input:disabled {
71+
opacity: 0.5;
72+
}
73+
}

assets/src/css/style.scss

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
@use "toggle";
2+
3+
.edd-sdk__notice__overlay {
4+
position: fixed;
5+
top: 0;
6+
bottom: 0;
7+
width: 100%;
8+
z-index: 1000;
9+
background: rgba(0, 0, 0, 0.5);
10+
align-items: center;
11+
justify-content: center;
12+
display: none;
13+
14+
.auto-fold & {
15+
margin-left: 160px;
16+
width: calc(100% - 160px);
17+
}
18+
19+
.folded & {
20+
margin-left: 36px;
21+
width: calc(100% - 36px);
22+
}
23+
24+
@media only screen and (max-width: 960px) {
25+
margin-left: 36px !important;
26+
width: calc(100% - 36px) !important;
27+
}
28+
29+
@media only screen and (max-width: 782px) {
30+
margin-left: 0 !important;
31+
width: 100% !important;
32+
}
33+
}
34+
35+
.edd-sdk-notice--overlay {
36+
padding: 2em;
37+
background: white;
38+
border-radius: 4px;
39+
border: 1px solid #ddd;
40+
position: relative;
41+
display: flex;
42+
flex-direction: column;
43+
gap: 1.5em;
44+
max-width: 500px;
45+
46+
button.edd-sdk__notice--dismiss {
47+
position: absolute;
48+
color: #555;
49+
text-decoration: none;
50+
font-size: 2em;
51+
top: 0.5em;
52+
right: 0.5em;
53+
line-height: 1;
54+
padding: 4px;
55+
56+
&:before {
57+
font-family: dashicons;
58+
font-weight: normal;
59+
content: "\f335";
60+
}
61+
}
62+
63+
.inline-notice {
64+
margin: 1em 0 0;
65+
}
66+
67+
@media only screen and (max-width: 782px) {
68+
max-width: 100%;
69+
}
70+
}
71+
72+
.edd-sl-sdk__license-control {
73+
display: flex;
74+
gap: 4px;
75+
margin-top: 1em;
76+
77+
button {
78+
margin: 0 !important;
79+
}
80+
81+
@media only screen and (max-width: 600px) {
82+
flex-wrap: wrap;
83+
84+
input {
85+
width: 100%;
86+
}
87+
}
88+
}
89+
90+
.edd-sl-sdk-license-response {
91+
margin-top: 5px;
92+
93+
&__valid {
94+
color: #008a20;
95+
}
96+
97+
&__invalid {
98+
color: #d63638;
99+
}
100+
}
101+
102+
.edd-sl-sdk__license-status-message {
103+
font-style: italic;
104+
}
105+
106+
.edd-sl-sdk-licensing__actions {
107+
display: flex;
108+
gap: 4px;
109+
}

assets/src/js/data.js

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
( function ( document ) {
2+
'use strict';
3+
4+
// Helper function for selecting elements
5+
const $ = ( selector ) => document.querySelector( selector );
6+
const $$ = ( selector ) => document.querySelectorAll( selector );
7+
8+
// Handle data tracking checkbox changes
9+
document.addEventListener( 'change', function ( e ) {
10+
if ( ! e.target.matches( 'input[id^="edd_sl_sdk_allow_data"]' ) ) {
11+
return;
12+
}
13+
14+
const checkbox = e.target;
15+
const slug = checkbox.getAttribute( 'data-slug' );
16+
const itemId = checkbox.id.match( /\[(\d+)\]/ )?.[1];
17+
18+
if ( ! itemId ) {
19+
return;
20+
}
21+
22+
// Get security attributes from the checkbox
23+
const timestamp = checkbox.getAttribute( 'data-timestamp' );
24+
const token = checkbox.getAttribute( 'data-token' );
25+
const nonce = checkbox.getAttribute( 'data-nonce' );
26+
27+
if ( ! timestamp || ! token || ! nonce ) {
28+
console.warn( 'Missing security attributes on data tracking checkbox' );
29+
return;
30+
}
31+
32+
// Remove previous notices
33+
$$( '.edd-sl-sdk__data + .notice' ).forEach( ( el ) => el.remove() );
34+
35+
// Disable checkbox during request
36+
checkbox.setAttribute( 'disabled', 'true' );
37+
38+
const data = {
39+
action: 'edd_sl_sdk_update_tracking_' + slug,
40+
token: token,
41+
timestamp: timestamp,
42+
nonce: nonce,
43+
item_id: itemId,
44+
allow_tracking: checkbox.checked ? '1' : '0',
45+
46+
};
47+
48+
// AJAX request
49+
fetch( ajaxurl, {
50+
method: 'POST',
51+
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
52+
body: new URLSearchParams( data ),
53+
} )
54+
.then( ( response ) => response.json() )
55+
.then( ( res ) => {
56+
if ( res.success ) {
57+
if ( res.data.message ) {
58+
$( '.edd-sl-sdk__data' ).insertAdjacentHTML(
59+
'afterend',
60+
`<div class="notice inline-notice notice-success">${ res.data.message }</div>`
61+
);
62+
}
63+
} else {
64+
$( '.edd-sl-sdk__data' ).insertAdjacentHTML(
65+
'afterend',
66+
`<div class="notice inline-notice notice-warning">${ res.data.message }</div>`
67+
);
68+
// Revert checkbox state on error
69+
checkbox.checked = ! checkbox.checked;
70+
}
71+
checkbox.removeAttribute( 'disabled' );
72+
} )
73+
.catch( ( error ) => {
74+
console.error( 'Error updating tracking preference:', error );
75+
$( '.edd-sl-sdk__data' ).insertAdjacentHTML(
76+
'afterend',
77+
`<div class="notice inline-notice notice-error"><p>${ edd_sdk_notice.error }</p></div>`
78+
);
79+
// Revert checkbox state on error
80+
checkbox.checked = ! checkbox.checked;
81+
checkbox.removeAttribute( 'disabled' );
82+
} );
83+
} );
84+
} )( document );

0 commit comments

Comments
 (0)