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

Site Tour: Fix CORS error in accessing tour stylesheet #1694

Merged
merged 4 commits into from Sep 25, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 9 additions & 6 deletions assets/js/tour.js
Expand Up @@ -99,13 +99,16 @@ jQuery( document ).ready(
window.loadTour = function() {
var color1 = '';
var color2 = '';
var sheet = {};
var styleElement = document.createElement( 'style' );
var n;
var style;
document.head.appendChild( styleElement );
for ( n in window.tour ) {
color1 = window.tour[ n ][ 0 ].color + '00';
color2 = window.tour[ n ][ 0 ].color + 'a0';
sheet = document.styleSheets[ 0 ];
sheet.insertRule( '@keyframes animation-' + n + ' {' +
style = styleElement.sheet;
trymebytes marked this conversation as resolved.
Show resolved Hide resolved

style.insertRule( '@keyframes animation-' + n + ' {' +
'0% {' +
'box-shadow: 0 0 0 0 ' + color2 + ';' +
'}' +
Expand All @@ -116,14 +119,14 @@ jQuery( document ).ready(
'box-shadow: 0 0 0 0 ' + color1 + ';' +
'}' +
'}',
sheet.cssRules.length );
style.cssRules.length );

sheet.insertRule( '.tour-' + n + '{' +
style.insertRule( '.tour-' + n + '{' +
'box-shadow: 0 0 0 ' + color2 + ';' +
'background: ' + color1 + ';' +
'-webkit-animation: animation-' + n + ' 2s infinite;' +
'animation: animation-' + n + ' 2s infinite; }',
sheet.cssRules.length );
style.cssRules.length );
addPulse( jQuery( window.tour[ n ][ 1 ].selector ), window.tour[ n ][ 1 ], n, 1 );
}
};
Expand Down