Commit a1aa3011
a1aa3011144aMerged
Justin Dorfman <[email protected]> · 10 years ago · 3 files · +3 added
Description
New revisions
Details
- Commit
- a1aa3011144a
- Parent
- 520f7069f7a0
public/2015/temp/jquery-sri-demo-2.htmladdedView file
1+
<!DOCTYPE html>2+
<html lang="en">3+
<head>4+
<meta charset="UTF-8">5+
<title>Modal</title>6+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/jquery.ui/1.11.4/jquery-ui.min.css" integrity="sha384-UojmfO2c7ldhtzt0/YTNpjAu7TcwOHO4//eR4gYTPIw24QDZVOzu1JNngy0J3yk8" crossorigin="anonymous">7+
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha256-3dkvEK0WLHRJ7/Csr0BZjAWxERc5WH7bdeUya2aXxdU= sha512-+L4yy6FRcDGbXJ9mPG8MT/3UCDzwR9gPeyFNMCtInsol++5m3bk2bXWKdZjvybmohrAsn3Ua5x8gfLnbE1YkOg==" crossorigin="anonymous">8+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/hint.css/2.0.0/hint.min.css" integrity="sha384-nFq7KsffjWjXn9mLj5zQt379N2PdqFZzVE2XiefrYXeSdCJ/DenEeiEX6mjk768N" crossorigin="anonymous">9+
10+
<style>11+
.sri-modal {12+
padding: 0;13+
border: none;14+
background: #fff;15+
border-radius: 0;16+
}17+
18+
.sri-modal .ui-dialog-titlebar {19+
padding: 0;20+
border: none;21+
background: #fff;22+
color: #000;23+
cursor: auto;24+
}25+
26+
.sri-modal .ui-dialog-title {27+
padding-top: 20px;28+
text-align: center;29+
font-family: "klavika-web", "Helvetica Neue", Helvetica, Arial, Geneva, sans-serif;30+
font-weight: 400;31+
width: 100%;32+
}33+
34+
.sri-modal .ui-dialog-titlebar-close {35+
background: none;36+
border: none;37+
right: 28px;38+
}39+
40+
.sri-modal .ui-icon-closethick {41+
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAclBMVEUAAADMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMxg1ZvWAAAAJXRSTlMAAQIDBAUGCQsNDhQWGSg4g4uUoKOoq62vsLW8wMrO2tzk5ujxm/5xbwAAAGxJREFUGBmNwVcWgkAQRcFHg4FgzjomZu7+t+hpRv6p0iS7byPJTs+5BluIjewML5O7A3F1AdJMrgpkqVVWBVxqNVriNhrZDRdrZXYl62sNjkBaB6Cv5PaQOpUB3iZXHFInqXx8FvozDQpN8gNoXAtiMhPWmQAAAABJRU5ErkJggg==) 0 0;42+
}43+
44+
.sri-modal .ui-widget-content {45+
padding: 30px 0 0 0;46+
}47+
48+
.sri-modal .ui-widget-content a {49+
color: #b24926;50+
}51+
52+
.sri-modal-link {53+
width: 810px;54+
word-wrap: break-word;55+
word-break: break-all;56+
display: inline-block;57+
background-color: #f8fbfb;58+
padding: 0 10px;59+
position: relative;60+
}61+
62+
.sri-modal-link code {63+
width: 765px;64+
display: inline-block;65+
white-space: pre-line;66+
background-color: transparent;67+
padding: 0;68+
font-size: 13px;69+
line-height: 16px;70+
}71+
72+
.sri-modal-copy-btn {73+
background-color: #1c6db3;74+
color: #fff;75+
border: none;76+
font-size: 1rem;77+
width: 35px;78+
height: 35px;79+
cursor: pointer;80+
position: absolute;81+
top: 5px;82+
}83+
84+
.sri-modal-info {85+
padding: 15px;86+
font: 15px/22px "Helvetica Neue", HelveticaNeue, Helvetica, Arial, sans-serif;87+
}88+
89+
code {90+
font-family: "source-code-pro", Consolas, monospace ;91+
word-spacing: 0;92+
padding: 0 3px;93+
background-color: #e6e6e6;94+
border-radius: 3px;95+
white-space: pre-wrap;96+
word-wrap: break-word;97+
}98+
99+
#sri-modal-template {100+
display: none;101+
}102+
</style>103+
</head>104+
105+
<body>106+
<a class="open-sri-modal" href="https://code.jquery.com/jquery-2.2.0.min.js"107+
data-hash="sha256-ihAoc6M/JPfrIiIeayPE9xjin4UWjsx2mjW/rtmxLM4=">Show modal</a>108+
109+
<!-- Modal template -->110+
<div id="sri-modal-template" title="jQuery Code Integration">111+
<div class="sri-modal-link">112+
<code><script src="{{link}}"113+
integrity="{{hash}}"114+
crossorigin="anonymous"></script></code>115+
116+
<button class="sri-modal-copy-btn hint--top hint-rounded hint--always"117+
data-clipboard-text='<script src="{{link}}" integrity="{{hash}}" crossorigin="anonymous"></script>'>118+
<i class="fa fa-copy"></i>119+
</button>120+
</div>121+
122+
<div class="sri-modal-info">123+
The <code>integrity</code> and <code>crossorigin</code> attributes are used for124+
<a href="https://www.w3.org/TR/SRI/" target="_blank">Subresource Integrity (SRI) checking</a>.125+
This allows browsers to ensure that resources hosted on third-party servers have126+
not been tampered with. Use of SRI is recommended as a best-practice, whenever127+
libraries are loaded from a third-party source. Read more at <a href="https://www.srihash.org/" target="_blank">srihash.org</a>128+
</div>129+
</div>130+
131+
<!-- jQuery and clipboard.js -->132+
<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>133+
<script src="https://cdn.jsdelivr.net/jquery.ui/1.11.4/jquery-ui.min.js" integrity="sha384-YWP9O4NjmcGo4oEJFXvvYSEzuHIvey+LbXkBNJ1Kd0yfugEZN9NCQNpRYBVC1RvA" crossorigin="anonymous"></script>134+
<script src="https://cdn.jsdelivr.net/clipboard.js/1.5.5/clipboard.min.js" integrity="sha384-EUVyZHL1sLfH3sG2kGvM6DauK0gevJs+n/C1v/xIffAuEzCDbnH1HJjjC3kLz/yR" crossorigin="anonymous"></script>135+
136+
<script>137+
// Store modal templates138+
var modalTemplate = $( "#sri-modal-template" )[ 0 ].outerHTML,139+
clipboard;140+
141+
// Show modal on click142+
$( "body" ).on( "click", ".open-sri-modal", function( event ) {143+
if ( !event.ctrlKey && !event.metaKey ) {144+
$( replace( modalTemplate, {145+
link: $( this ).attr( "href" ),146+
hash: $( this ).attr( "data-hash" )147+
} ) ).removeAttr( "id" ).appendTo( "body" ).dialog( {148+
modal: true,149+
resizable: false,150+
width: 830,151+
dialogClass: "sri-modal",152+
draggable: false,153+
close: function() {154+
$( this ).remove();155+
}156+
} );157+
158+
return false;159+
}160+
} );161+
162+
// Helper functions163+
function replace ( string, values ) {164+
$.each( values, function( key, value ) {165+
string = string.replace( new RegExp( "\\{\\{" + key + "}}", "g" ), value );166+
} );167+
168+
return string;169+
}170+
171+
clipboard = new Clipboard( "[data-clipboard-text]" );172+
173+
clipboard.on( "success", function( e ) {174+
$( e.trigger )175+
.blur()176+
.attr( "data-hint", "Copied!" )177+
.on( "mouseout", function() {178+
$( this ).removeAttr( "data-hint" );179+
} );180+
} );181+
182+
clipboard.on( "error", function( e ) {183+
$( e.trigger )184+
.blur()185+
.attr( "data-hint", "Press Ctrl+C to copy!" )186+
.on( "mouseout", function() {187+
$( this ).removeAttr( "data-hint" );188+
} );189+
} );190+
</script>191+
</body>192+
</html>public/2015/temp/jquery-sri-demo-2a.htmladdedView file
Loading diff…
public/2015/temp/jquery-sri-demo.htmladdedView file
Loading diff…