-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmedia-links.html
260 lines (221 loc) · 11.9 KB
/
media-links.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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
<!--
Runtime:include this blurb at the bottom of your story.
Wrap words you want to appear as a popup with
<span class="media-link"></span>
possible attributes:
Basic Options:
data-type="" - type of media.
data-url="" - url of image, document, etc.
data-vid="" - id of video to pull in
data-width="" - width of graphic, document, etc.
data-time="" - time video should start on - only works for YT right now.
data-caption="" - caption that should appear under the element, usually for photos or graphics
Advanced Options:
data-href="" - destination to link to, if an image
-->
<script type="text/javascript" src="http://s3.documentcloud.org/notes/loader.js"></script>
<script src="http://s3.documentcloud.org/viewer/loader.js"></script>
<style type="text/css">
.media-link {color:#111; border-bottom: 1px dotted #111; padding:2px 5px 2px 21px; -webkit-transition: background-color .1s linear; -moz-transition: background-color .1s linear; -o-transition: background-color .1s linear; -ms-transition: background-color .1s linear; transition: background-color .1s linear; }
.media-link[data-type=graphic] {background: #fff url('http://www.latimes.com/media/graphic/2012-08/72045156.png') 0 -48px no-repeat;}
.media-link[data-type=video-brightcove],
.media-link[data-type=video-youtube],
.media-link[data-type=video-vimeo],
.media-link[data-type=video-ndn] {background: #fff url('http://www.latimes.com/media/graphic/2012-08/72045156.png') 0px -70px no-repeat;}
.media-link[data-type=document] {background: #fff url('http://www.latimes.com/media/graphic/2012-08/72045156.png') 0 -24px no-repeat;}
.media-link[data-type=audio] {background: #fff url('http://www.latimes.com/media/graphic/2012-08/72045156.png') 0 -90px no-repeat;}
.media-link[data-type=photo] {background: #fff url('http://www.latimes.com/media/graphic/2012-08/72045156.png') 0 -1px no-repeat;}
.media-link[data-type]:hover {background-color:#D2DDEA; cursor:pointer;}
/* Document Cloud styles */
.DC-note { border:0px; -webkit-box-shadow:0px 0px 0px #fff; box-shadow:0px 0px 0px 0px #fff; margin-top:0;}
.DC-note .DC-note-title { text-align:left; font-size: 24px; line-height:30px; font-family:"Georgia", "Times New Roman", Times, serif;}
.DC-note .DC-note-excerpt-wrap { border: 2px solid #999; }
/* Dialog Box Styles */
.ui-dialog.ui-widget { }
.ui-dialog .ui-dialog-content { }
.ui-widget-overlay {background:#fff url(''); opacity: .70; filter:Alpha(Opacity=70); position:absolute; top:0; left:0;}
div.ui-dialog.ui-widget.video-player div.ui-dialog-titlebar {display:none;}
div.ui-dialog.ui-widget.video-player .ui-dialog-content {padding:5px 15px 15px 15px;}
.ui-widget-content h3 {text-align:left; font-size:20px;}
.ui-widget-content p.description {text-align:left; margin-bottom:10px;}
.ui-widget-content p.close {margin-bottom:10px; font-family:'Arial', 'Helvetica', sans-serif; text-align:right; position:relative; }
p.close img {display:inline; position: relative; top: 3px;}
p.close a {font-weight:bold; color:#999;}
#video-holder{ width:1010px; display:none; top:0; left:0; background-color:#fff; z-index:10001; -webkit-box-shadow:2px 3px 6px #333; box-shadow:2px 3px 6px #333; border:1px solid #696969; border-radius:4px; -moz-border-radius:4px; -webkit-border-radius:4px;}
#video-holder p.close a {color:#999; }
#widget-overlay {height:100%; width:100%; position:fixed; top:0; left:0; background:#fff url(''); opacity: .70; filter:Alpha(Opacity=70); display:none; z-index:10000;}
</style>
<div id="video-holder" class="ui-dialog ui-widget video-player"></div>
<div id="widget-overlay"></div>
<script type="text/javascript">
/*
* Media Links
* Multimedia embeds for stories.
* Author: Armand Emamdjomeh
* Version: 1.0
*/
function mediaLink(type, url, wide, vid, link, timecode, caption){
// make sure the width is an integer
var wide = parseInt(wide),
winWidth = jQuery(window).width();
// if the width is larget than the window width, then adjust it to something smaller
if (wide >= winWidth) {
wide = winWidth - 50;
}
// we need to calculate height for video embeds
if(type === "video-youtube" || type === "video-vimeo" || type === "video-brightcove" || type === "video-vimeo") {
var height = Math.floor(wide * 9 / 16);
}
// close button in the popup
var embedString = '<div class="ui-dialog-content ui-widget-content"><p class="close"><a>CLOSE <img src="http://www.latimes.com/includes/projects/population/images/close_18px.png" /></a></p>';
var vignette_box = jQuery('#video-holder');
var overlay = jQuery('#widget-overlay');
// ok, here's our big switch statement to determine what gets displayed for each content type
switch (type) {
case "graphic":
case "photo":
if(link !== ""){
embedStringConstruct = ['<a href="', link, '"><img src="', url, '" /></a>'];
if (caption !== ""){
embedStringConstruct.push['<p>', caption, '</p>']
}
embedString += embedStringConstruct.join('');
}
else {
embedStringConstruct = ['<img src="', url, '" />'];
if (caption !== ""){
embedStringConstruct.push['<p>', caption, '</p>']
}
embedString += embedStringConstruct.join('');
}
break;
case "document":
var ids = dcEmbedParse(url);
var docID = ids[0];
var noteID = ids[1];
embedString += '<div class="DC-note-container" id="DC-note-'+ noteID + '"></div>';
embedString += '<p style="text-align:left; font-weight:bold; padding-left:10px;">Click image to view the full document.</p>'
docUrl = "http://www.documentcloud.org/documents/" + docID + "/annotations/" + noteID + ".js";
break;
case "document-full":
embedString += '<div style="height:600px;" id="'+ url + '"></div>';
break;
case "video-brightcove":
var linkBaseURL = document.URL;
embedStringConstruct = ["<object id='myExperience207503375' class='BrightcoveExperience'><param name='bgcolor' value='#FFFFFF' /><param name='wmode' value='transparent' /><param name='autoStart' value='false' /><param name='sectionName' value ='/' /><param name='contentItemType' value ='embed' /><param name='omnitureServer' value='latimes.com' /><param name='omnitureAcct' value='tribglobal' /><param name='width' value='", wide, "' /><param name='height' value='", height, "' /><param name='playerID' value='782523707001' /><param name='playerKey' value='AQ~~,AAAAtkVbcwk~,5Rx45u37p7At4uUFYYBfI0whp8ObLWHD' /><param name='adServerURL' value='http://ad.doubleclick.net/pfadx/trb.latimes/hp' /><param name='additionalAdTargetingParams' value=';player=bc;pos=pre;vc=News;clip=71433116;sz=3x3;tile=13;ord=3083020945' /><param name='externalAds' value='true' /><param name='linkBaseURL' value='", linkBaseURL, "' /><param name='isVid' value='true' /><param name='isUI' value='true' /><param name='dynamicStreaming' value='true' /><param name='showNoContentMessage' value='true' /><param name='@videoPlayer' value='ref:", vid, "' /></object>"];
embedString += embedStringConstruct.join('');
break;
case "video-youtube":
if (timecode !== ""){
var embedStringConstruct = ['<iframe width="', wide, '" height="', height, '" src="http://www.youtube.com/embed/', vid, '?rel=0&autoplay=1#t=', timecode, '" frameborder="0" allowfullscreen></iframe>'];
embedString += embedStringConstruct.join('');
} else {
var embedStringConstruct = ['<iframe width="', wide, '" height="', height, '" src="http://www.youtube.com/embed/', vid, '?rel=0&autoplay=1" frameborder="0" allowfullscreen></iframe>'];
embedString += embedStringConstruct.join('');
}
break;
case "video-vimeo":
embedStringConstruct = ["<iframe src='http://player.vimeo.com/video/", vid, "?autoplay=1' width='", wide, "' height='", height, "' frameborder='0' webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>"];
embedString += embedStringConstruct.join('');
break;
case "video-ndn":
embedStringConstruct = ["<iframe src='http://embed.newsinc.com/Single/iframe.html?WID=2&VID=", vid, "&freewheel=91002&sitesection=latimes&height=", height, "&width=", width, "' height=551 width=980 frameborder=no scrolling=no noresize marginwidth=0px marginheight=0px></iframe>"];
embedString += embedStringConstruct.join('');
break;
case "audio":
embedStringConstruct = ['<iframe width="100%" height="100" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%', vid, '"></iframe>'];
embedString += embedStringConstruct.join('');
break;
}
embedString += '</div>';
var popUpWidth = wide + 30;
jQuery(vignette_box).html(embedString);
var dialogRight = (jQuery(window).width()-popUpWidth)/2;
var dialogTop = (jQuery(window).height()-551)/2;
vignette_box.css({
"display":"block",
"position":"fixed",
"width": popUpWidth,
"top": dialogTop,
"left": dialogRight
});
var docWidth = jQuery(document).width();
var docHeight = jQuery(document).height();
overlay.css({
"width": docWidth,
"height": docHeight,
"display": "block"
});
if(type === 'video-brightcove') {
brightcove.createExperiences();
} else if (type === 'document') {
dc.embed.loadNote(docUrl, {afterLoad: function(){jQuery('.DC-note-contents a').attr('target', '_blank')}});
} else if (type === 'document-full') {
DV.load('http://www.documentcloud.org/documents/' + url + '.js', {
container : '#' + url
});
}
// Binding keystrokes
document.onkeydown = function(evt) {
if(window.event){
evt = window.event;
}
switch(evt.keyCode){
// escape key
case 27:
jQuery('p.close').click();
break;
}
}
// bind close action
jQuery('#widget-overlay, .close').bind('click', function(e){
e.preventDefault();
vignette_box.css({
"display":"none"
});
overlay.css({
"display":"none"
});
brightcove.removeExperience(vid);
jQuery(vignette_box).html('');
embed_code = "";
// UnBinding keystrokes
document.onkeydown = function(evt) {
if(window.event){
evt = window.event;
}
switch(evt.keyCode){
// escape key
case 27:
break;
}
}
});
return false;
}
jQuery(document).ready(function(){
jQuery('.media-link').bind('click', function(){
$this = jQuery(this);
var type = $this.attr('data-type');
var url = $this.attr('data-url') || "";
var wide = $this.attr('data-width') || "650";
var vid = $this.attr('data-vid') || "";
var link = $this.attr('data-href') || "";
var timecode = $this.attr('data-time') || "";
var caption = $this.attr('data-caption') || "";
mediaLink(type, url, wide, vid, link, timecode, caption);
});
});
var dcEmbedParse = function (url) {
// https://www.documentcloud.org/documents/396423-san-bernardino-bankruptcty-report.html#document/p5/a63666
if (!url) {
return false;
}
var parts = /(\d+)[-\w]+.html#document\/p\d+\/a(\d+)/.exec(url);
var docID = parts[1];
var noteID = parts[2];
return [docID, noteID];
}
function loadDocEmbed(url, embedString){
}
</script>