-
Notifications
You must be signed in to change notification settings - Fork 171
adding sri modal to codeorigin #391
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
Changes from 1 commit
2d6cd06
aec1567
37a4ecd
50680d7
b084449
ed6cd93
0d5db46
3570ee7
2b99d13
e4f0003
d30709b
0a77507
5656dc2
eb0c755
3df694f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,54 @@ | ||
<?php | ||
|
||
// attach custom header and footer tags | ||
function header_append() { | ||
echo ' | ||
<link rel="stylesheet" href="' . get_template_directory_uri() . '/css/font-awesome.css" /> | ||
<link rel="stylesheet" href="' . get_template_directory_uri() . '/css/hint.2.0.0.min.css" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use jQuery UI. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @scottgonzalez to be clear, use jQuery UI There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah. It's already being loaded. |
||
<link rel="stylesheet" href="' . get_template_directory_uri() . '/css/jquery-ui.1.11.4.min.css" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are you adding a local copy of a jQuery UI theme instead of using the CDN? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was an oversight, I believe I was using the cdn at one point. I'll fix it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
<link rel="stylesheet" href="' . get_template_directory_uri() . '/css/modal.css" /> | ||
'; | ||
} | ||
|
||
function footer_append() { | ||
echo ' | ||
<script src="https://code.jquery.com/jquery-2.2.0.min.js" integrity="sha384-K+ctZQ+LL8q6tP7I94W+qzQsfRV2a+AfHIi9k8z8l9ggpc8X+Ytst4yBo/hH+8Fk" crossorigin="anonymous"></script> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. jQuery is already loaded. |
||
<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.min.js" integrity="sha384-YWP9O4NjmcGo4oEJFXvvYSEzuHIvey+LbXkBNJ1Kd0yfugEZN9NCQNpRYBVC1RvA" crossorigin="anonymous"></script> | ||
<script src="' . get_template_directory_uri() . '/js/clipboard.1.5.5.min.js"></script> | ||
<script src="' . get_template_directory_uri() . '/js/modal.js"></script> | ||
'; | ||
} | ||
|
||
?> | ||
|
||
<?php get_header(); ?> | ||
|
||
<?php the_post(); ?> | ||
|
||
<div id="sri-modal-template" title="jQuery Code Integration"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This title isn't great since not everything is about jQuery. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm thinking just "Code Integration", unless someone has a better suggestion. |
||
<div class="sri-modal-link"> | ||
<code> | ||
<script | ||
<span>src="{{link}}"</span> | ||
<span>integrity="{{hash}}"</span> | ||
<span>crossorigin="anonymous"></script></span> | ||
</code> | ||
|
||
<button class="sri-modal-copy-btn hint--top hint-rounded hint--always" | ||
data-clipboard-text='<script src="{{link}}" integrity="{{hash}}" crossorigin="anonymous"></script>'> | ||
<i class="sri-modal-icon-copy icon-copy"></i> | ||
</button> | ||
</div> | ||
|
||
<div class="sri-modal-info"> | ||
The <code>integrity</code> and <code>crossorigin</code> attributes are used for | ||
<a href="https://www.w3.org/TR/SRI/" target="_blank">Subresource Integrity (SRI) checking</a>. | ||
This allows browsers to ensure that resources hosted on third-party servers have | ||
not been tampered with. Use of SRI is recommended as a best-practice, whenever | ||
libraries are loaded from a third-party source. Read more at <a href="https://www.srihash.org/" target="_blank">srihash.org</a> | ||
</div> | ||
</div> | ||
|
||
<div class="content-full twelve columns"> | ||
<div id="content"> | ||
<?php if ( !count( get_post_meta( $post->ID, "hide_title" ) ) ) : ?> | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
/* | ||
* Added for SRI Modal | ||
*/ | ||
.sri-modal { | ||
padding: 0; | ||
border: none; | ||
background: #fff; | ||
border-radius: 0; | ||
} | ||
|
||
.sri-modal .ui-dialog-titlebar { | ||
padding: 0; | ||
border: none; | ||
background: #fff; | ||
color: #000; | ||
cursor: auto; | ||
} | ||
|
||
.sri-modal .ui-dialog-title { | ||
padding-top: 20px; | ||
text-align: center; | ||
font-family: "klavika-web", "Helvetica Neue", Helvetica, Arial, Geneva, sans-serif; | ||
font-weight: 400; | ||
width: 100%; | ||
} | ||
|
||
.sri-modal .ui-dialog-titlebar-close { | ||
background: none; | ||
border: none; | ||
right: 28px; | ||
} | ||
|
||
.sri-modal .ui-icon-closethick { | ||
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAclBMVEUAAADMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMxg1ZvWAAAAJXRSTlMAAQIDBAUGCQsNDhQWGSg4g4uUoKOoq62vsLW8wMrO2tzk5ujxm/5xbwAAAGxJREFUGBmNwVcWgkAQRcFHg4FgzjomZu7+t+hpRv6p0iS7byPJTs+5BluIjewML5O7A3F1AdJMrgpkqVVWBVxqNVriNhrZDRdrZXYl62sNjkBaB6Cv5PaQOpUB3iZXHFInqXx8FvozDQpN8gNoXAtiMhPWmQAAAABJRU5ErkJggg==) 0 0; | ||
} | ||
|
||
.sri-modal .ui-widget-content { | ||
padding: 30px 0 0 0; | ||
} | ||
|
||
.sri-modal .ui-widget-content a { | ||
color: #b24926; | ||
} | ||
|
||
.sri-modal-link { | ||
width: 810px; | ||
word-wrap: break-word; | ||
word-break: break-all; | ||
display: inline-block; | ||
background-color: #f8fbfb; | ||
padding: 0 10px; | ||
position: relative; | ||
} | ||
|
||
.sri-modal-link code { | ||
width: 765px; | ||
display: inline-block; | ||
white-space: pre-line; | ||
background-color: transparent; | ||
padding: 0; | ||
font-size: 13px; | ||
line-height: 16px; | ||
} | ||
|
||
.sri-modal-copy-btn { | ||
background-color: #1c6db3; | ||
border: none; | ||
font-size: 1rem; | ||
width: 35px; | ||
height: 35px; | ||
cursor: pointer; | ||
position: absolute; | ||
top: 5px; | ||
} | ||
|
||
.sri-modal-copy-btn > i { | ||
color: #fff; | ||
} | ||
|
||
.sri-modal-info { | ||
padding: 15px; | ||
font: 15px/22px "Helvetica Neue", HelveticaNeue, Helvetica, Arial, sans-serif; | ||
} | ||
|
||
code { | ||
font-family: "source-code-pro", Consolas, monospace ; | ||
word-spacing: 0; | ||
padding: 0 3px; | ||
background-color: #e6e6e6; | ||
border-radius: 3px; | ||
white-space: pre-wrap; | ||
word-wrap: break-word; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems like this file contains a fair amount of code in order to not follow the existing design. cc @jquery/content There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Too right, removing. |
||
|
||
code span { | ||
word-wrap: normal; | ||
white-space: nowrap; | ||
} | ||
|
||
#sri-modal-template { | ||
display: none; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,7 +36,12 @@ | |
</div> | ||
</footer> | ||
|
||
<?php wp_footer(); ?> | ||
<?php | ||
wp_footer(); | ||
|
||
if ( function_exists( 'footer_append' ) ) | ||
footer_append(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just leaving myself a note to come back to this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wasn't sure about this approach, so I'd be interested in your feedback and possible alternative. It does allow other themes to follow suit, but feels a little hacky at the same time. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure what problem you were having enqueueing these files, but replacing the function definitions in wp_enqueue_style('jquery-ui', 'https://code.jquery.com/ui/1.11.4/themes/ui-lightness/jquery-ui.css');
wp_enqueue_style('sri-modal', get_template_directory_uri() . '/css/sri-modal.css');
wp_enqueue_script('jquery-ui', 'https://code.jquery.com/ui/1.11.4/jquery-ui.min.js');
wp_enqueue_script('clipboard', get_template_directory_uri() . '/js/clipboard.1.5.5.min.js');
wp_enqueue_script('sri-modal', get_template_directory_uri() . '/js/sri-modal.js'); There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, yes that works. Apologies, I must have had a type or something in my tests. |
||
?> | ||
|
||
</body> | ||
</html> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Font Awesome is already loaded on the page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw it in the themes/jquery/css directory, but not included. I'l drop this out.