-
Notifications
You must be signed in to change notification settings - Fork 12k
Move CSS in a separate file to be CSP-compliant #6048
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 @@ | ||
.content { | ||
max-width: 640px; | ||
margin: auto; | ||
padding: 1rem; | ||
} | ||
|
||
.note { | ||
font-family: sans-serif; | ||
color: #5050a0; | ||
line-height: 1.4; | ||
margin-bottom: 1rem; | ||
padding: 1rem; | ||
} | ||
|
||
code { | ||
background-color: #f5f5ff; | ||
border: 1px solid #d0d0fa; | ||
border-radius: 4px; | ||
padding: 0.05rem 0.25rem; | ||
} |
This file contains hidden or 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,27 @@ | ||
<!DOCTYPE html> | ||
<html lang="en-US"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=Edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<meta http-equiv="Content-Security-Policy" content="default-src 'self'"> | ||
<title>Scriptable > Bubble | Chart.js sample</title> | ||
<link rel="stylesheet" type="text/css" href="../../dist/Chart.min.css"> | ||
<link rel="stylesheet" type="text/css" href="./content-security-policy.css"> | ||
simonbrunel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<script src="../../dist/Chart.min.js"></script> | ||
<script src="../utils.js"></script> | ||
<script src="content-security-policy.js"></script> | ||
</head> | ||
<body> | ||
<div class="content"> | ||
<div class="note"> | ||
In order to support a strict content security policy (<code>default-src 'self'</code>), | ||
this page manually loads <code>Chart.min.css</code> and turns off the automatic style | ||
injection by setting <code>Chart.platform.disableCSSInjection = true;</code>. | ||
</div> | ||
<div class="wrapper"> | ||
benmccann marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<canvas id="chart-0"></canvas> | ||
</div> | ||
</div> | ||
</body> | ||
</html> |
This file contains hidden or 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,54 @@ | ||
var utils = Samples.utils; | ||
|
||
// CSP: disable automatic style injection | ||
Chart.platform.disableCSSInjection = true; | ||
|
||
utils.srand(110); | ||
|
||
function generateData() { | ||
var DATA_COUNT = 16; | ||
var MIN_XY = -150; | ||
var MAX_XY = 100; | ||
var data = []; | ||
var i; | ||
|
||
for (i = 0; i < DATA_COUNT; ++i) { | ||
data.push({ | ||
x: utils.rand(MIN_XY, MAX_XY), | ||
y: utils.rand(MIN_XY, MAX_XY), | ||
v: utils.rand(0, 1000) | ||
}); | ||
} | ||
|
||
return data; | ||
} | ||
|
||
window.addEventListener('load', function() { | ||
new Chart('chart-0', { | ||
type: 'bubble', | ||
data: { | ||
datasets: [{ | ||
backgroundColor: utils.color(0), | ||
data: generateData() | ||
}, { | ||
backgroundColor: utils.color(1), | ||
data: generateData() | ||
}] | ||
}, | ||
options: { | ||
aspectRatio: 1, | ||
legend: false, | ||
tooltip: false, | ||
elements: { | ||
point: { | ||
radius: function(context) { | ||
var value = context.dataset.data[context.dataIndex]; | ||
var size = context.chart.width; | ||
var base = Math.abs(value.v) / 1000; | ||
return (size / 24) * base; | ||
} | ||
} | ||
} | ||
} | ||
}); | ||
}); |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
|
@@ -21,7 +21,7 @@ git remote add auth-origin https://[email protected]/$TRAVIS_REPO_SL | |
git config --global user.email "$GITHUB_AUTH_EMAIL" | ||
git config --global user.name "Chart.js" | ||
git checkout --detach --quiet | ||
git add -f dist/*.js bower.json | ||
git add -f dist/*.css dist/*.js bower.json | ||
git commit -m "Release $VERSION" | ||
git tag -a "v$VERSION" -m "Version $VERSION" | ||
git push -q auth-origin refs/tags/v$VERSION 2>/dev/null | ||
|
This file contains hidden or 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 @@ | ||
/* | ||
* DOM element rendering detection | ||
* https://davidwalsh.name/detect-node-insertion | ||
*/ | ||
@keyframes chartjs-render-animation { | ||
from { opacity: 0.99; } | ||
to { opacity: 1; } | ||
} | ||
|
||
.chartjs-render-monitor { | ||
animation: chartjs-render-animation 0.001s; | ||
} | ||
|
||
/* | ||
* DOM element resizing detection | ||
* https://github.com/marcj/css-element-queries | ||
*/ | ||
.chartjs-size-monitor, | ||
.chartjs-size-monitor-expand, | ||
.chartjs-size-monitor-shrink { | ||
position: absolute; | ||
left: 0; | ||
top: 0; | ||
right: 0; | ||
bottom: 0; | ||
overflow: hidden; | ||
pointer-events: none; | ||
visibility: hidden; | ||
z-index: -1; | ||
} | ||
|
||
.chartjs-size-monitor-expand > div { | ||
position: absolute; | ||
width: 1000000px; | ||
height: 1000000px; | ||
left: 0; | ||
top: 0; | ||
} | ||
|
||
.chartjs-size-monitor-shrink > div { | ||
position: absolute; | ||
width: 200%; | ||
height: 200%; | ||
left: 0; | ||
top: 0; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.