-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.html
146 lines (131 loc) · 6.55 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<!DOCTYPE html>
<html>
<head>
<title>FitIt Demo and Docs</title>
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.4/styles/monokai.min.css">
<style>
body {
padding: 2em;
font-family: Helvetica, sans;
}
pre code,
.hljs {
padding: 2em;
margin: 2em 0;
}
.demo {
padding: 0;
margin: 2em 0;
position: relative;
background: #ddd;
}
.demo:before {
content: "DEMO";
color: #ccc;
position: absolute;
top: .25em;
left: .25em;
font-family: impact, slab-serif;
font-size: 1em;
}
.async-demo {
background-color: #f9f9f9;
padding: 2em;
}
.async-demo__btn {
background: hsl(200, 100%, 50%);
padding: .5em;
border-radius: 0;
border: 1px solid hsl(200, 80%, 50%);
color: hsl(200, 100%, 90%);
font-size: 2em;
}
</style>
<script src="dist/fitit.js"></script>
<script>
fitIt('[src*="youtube.com"], [src*="player.vimeo.com"]');
</script>
</head>
<body>
<p>#fitIt
A dependancy free, utra-slim tool for fluid width video (and other) embeds.</p>
<p>##Usage</p>
<pre><code class="lang-javascript"> fitIt(<selector>)
</code></pre>
<p>All elements that match the <code>selector</code> will be made responsive and full width within it's container...</p>
<pre><code class="lang-javascript"> fitIt('[src*="youtube.com"]');
</code></pre>
<figure class="async-demo demo">
<iframe width="560" height="315" src="//www.youtube.com/embed/MG9-y2t2ZLI" frameborder="0" allowfullscreen></iframe>
</figure>
<hr>
<p>Including any asynchronously loaded nodes</p>
<pre><code class="lang-javascript"> fitIt('[src*="youtube.com"]');
document.querySelector('.async-demo__btn').addEventListener('click', function (clickEvt) {
var container = clickEvt.target.parentElement,
i = document.createElement('iframe');
i.src = '//www.youtube.com/embed/ImlzsxHbTRQ';
container.appendChild(i);
container.removeChild(clickEvt.target);
});
</code></pre>
<figure class="async-demo demo">
<button class="async-demo__btn">Load Video</button>
</figure>
<hr>
<p>Multiple selectors can be used...</p>
<pre><code class="lang-javascript"> fitIt('[src*="youtube.com"], [src*="player.vimeo.com"]');
</code></pre>
<figure class="async-demo demo">
<iframe src="//player.vimeo.com/video/1084537" width="500" height="281" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
</figure>
<hr>
<p>Even multiple calls.</p>
<pre><code class="lang-javascript"> fitIt('[src*="youtube.com"]');
fitIt('object embed');
</code></pre>
<figure class="async-demo demo">
<object id="flashObj" width="480" height="270" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,47,0"><param name="movie" value="http://c.brightcove.com/services/viewer/federated_f9?isVid=1&isUI=1" /><param name="bgcolor" value="#FFFFFF" /><param name="flashVars" value="videoId=3867093869001&linkBaseURL=https%3A%2F%2Fwww.lds.org%2Fmedia-library%2Fvideo%2F2014-10-003-fashion-faith%3Fcategory%3Dsocial-media-sharable-videos%26lang%3Deng&playerID=710849472001&playerKey=AQ~~,AAAApYNoccE~,xDmRWfqDlPhbhwoOkZ1F_TSoe20nAtRQ&domain=embed&dynamicStreaming=true" /><param name="base" value="http://admin.brightcove.com" /><param name="seamlesstabbing" value="false" /><param name="allowFullScreen" value="true" /><param name="swLiveConnect" value="true" /><param name="allowScriptAccess" value="always" /><embed src="http://c.brightcove.com/services/viewer/federated_f9?isVid=1&isUI=1" bgcolor="#FFFFFF" flashVars="videoId=3867093869001&linkBaseURL=https%3A%2F%2Fwww.lds.org%2Fmedia-library%2Fvideo%2F2014-10-003-fashion-faith%3Fcategory%3Dsocial-media-sharable-videos%26lang%3Deng&playerID=710849472001&playerKey=AQ~~,AAAApYNoccE~,xDmRWfqDlPhbhwoOkZ1F_TSoe20nAtRQ&domain=embed&dynamicStreaming=true" base="http://admin.brightcove.com" name="flashObj" width="480" height="270" seamlesstabbing="false" type="application/x-shockwave-flash" allowFullScreen="true" allowScriptAccess="always" swLiveConnect="true" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></embed></object>
</figure>
<hr>
<p>Before the element...</p>
<pre><code class="lang-html"> <script>
fitIt('[src*="youtube.com"], [src*="player.vimeo.com"]');
</script>
<iframe width="560" height="315" src="//www.youtube.com/embed/MG9-y2t2ZLI" frameborder="0" allowfullscreen></iframe>
</code></pre>
<hr>
<p>or after it...</p>
<pre><code class="lang-html"> <object data="" type="">
<embed src="" type=""></embed>
</object>
<script>
fitIt('object embed');
</script>
</code></pre>
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.4/highlight.min.js"></script>
<script>
hljs.configure({
languages: ['js','html']
});
hljs.initHighlightingOnLoad();
</script>
<script>
[].slice.call(document.querySelectorAll('.async-demo__btn')).forEach(function (btn) {
btn.addEventListener('click', function (clickEvt) {
var container = clickEvt.target.parentElement,
i = document.createElement('iframe');
i.src = '//www.youtube.com/embed/ImlzsxHbTRQ';
container.appendChild(i);
container.removeChild(clickEvt.target);
});
})
</script>
<script>
fitIt('embed');
</script>
<script type='text/javascript' id="__bs_script__">//<![CDATA[
document.write("<script async src='//HOST:3000/browser-sync/browser-sync-client.1.7.0.js'><\/script>".replace(/HOST/g, location.hostname).replace(/PORT/g, location.port));
//]]></script>
</body>
</html>