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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518 | 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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450 | +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+
-
-
+
+
+
-
-
-
+
+
-
-
+
+
+
+
+
-
-
-
-
-
+
+
+
+
-
-
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
-
-
-
+
+
+
-
-
+
-
-
-
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
+
+
+
+
-
-
-
-
-
-
+
+
-
-
-
+
-
-
+
-
-
-
+
-
-
-
-
+
-
-
-
-
+
-
-
-
+
-
-
+
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+
-
-
-
-
-
+
+
-
-
-
-
-
+
+
+
+
+
+
+
-
+
-
-
+
+
+
-
-
-
+
+
+
+
+
-
-
-
-
+
+
+
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
-
-
+
-
-
-
-
+
+
+
-
-
-
-
+
+
+
+
+
-
-
-
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
+
+
-
-
-
-
+
-
-
+
-
-
+
+
-
-
-
+
-
-
-
-
-
-
-
+
-
-
-
-
+
+
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
+
+
+
+
-
-
-
+
+
+
+
-
-
-
+
+
-
-
+
-
-
-
-
+
+
+
+
-
-
-
+
+
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
-
-
-
-
+
+
+
+
+
+
+
+
+
-
-
-
+
-
-
-
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
+
-
-
+
+
+
+
-
-
+
+
-
-
+
+
-
-
-
-
-
+
-
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
-
-
-
+
+
-
-
-
+
+
+
+
+
+
-
-
-
+
+
+
+
-
-
-
-
-
-
-
-
+
-
-
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
-
-
+
+
+
+
-
-
-
-
-
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
-
-
-
-
+
-
-
-
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
-
+
+
+
+
+
+
-
-
-
-
+
+
+
-
-
-
-
-
-
-
-
+
-
-
-
-
+
-
-
-
-
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+
-
-
-
+
+
+
-
-
-
-
-
+
+
+
+
-
-
-
-
-
+
+
+
+
+
-
+
|
document.addEventListener('DOMContentLoaded', function() {
var yelp_hash_highlight = function () {
if (location.hash != '') {
var sect = document.querySelector(location.hash);
if (sect != null) {
sect.classList.add('yelp-hash-highlight');
window.setTimeout(function () {
sect.classList.remove('yelp-hash-highlight');
}, 500);
}
}
}
window.addEventListener('hashchange', yelp_hash_highlight, false);
yelp_hash_highlight();
}, false);
var __yelp_generate_id_counter__ = 0;
function yelp_generate_id () {
var ret = 'yelp--' + (++__yelp_generate_id_counter__).toString();
if ($('#' + ret).length != 0)
if (document.getElementById(ret) != null)
return yelp_generate_id();
else
return ret;
};
$(document).ready (function () {
var highlight_hash = function () {
if (location.hash != '') {
var sect = $(location.hash);
sect.css('background-color', '#fffacc');
window.setTimeout(function () {
sect.css({
function yelp_ui_expander_init (expander) {
var yelpdata = null;
var innerdiv = null;
var region = null;
var contents = null;
var title = null;
var title_e = null;
var title_c = null;
var titlespan = null;
var issect = false;
'-webkit-transition': 'background-color 2s linear',
'-moz-transition': 'background-color 2s linear',
'transition': 'background-color 2s linear',
'background-color': 'rgba(1, 1, 1, 0)'
for (var i = 0; i < expander.children.length; i++) {
});
}, 200);
var child = expander.children[i];
if (child.classList.contains('yelp-data-ui-expander')) {
yelpdata = child;
}
};
$(window).bind('hashchange', highlight_hash);
highlight_hash();
else if (child.classList.contains('inner')) {
innerdiv = child;
});
}
}
if (innerdiv == null) {
return;
}
$.fn.yelp_ui_expander_toggle = function (onlyopen, callback) {
var expander = $(this);
var region = expander.children('.inner').children('.region');
var yelpdata = expander.children('div.yelp-data-ui-expander');
var compfunc = function () {
for (var i = 0; i < innerdiv.children.length; i++) {
var child = innerdiv.children[i];
if (child.classList.contains('region')) {
region = child;
if (expander.is('div.figure')) { expander.yelp_auto_resize(); }
if (callback) { callback(); }
}
else if (child.classList.contains('title')) {
return true;
};
var title = expander.children('.inner').children('.title');
if (title.length == 0)
title = expander.children('.inner').children('.hgroup');
var title = title.find('span.title:first');
if (expander.is('.ui-expander-e')) {
if (!onlyopen) {
title = child;
}
else if (child.classList.contains('hgroup')) {
title = child;
issect = true;
}
}
if (region == null || title == null) {
return;
expander.removeClass('ui-expander-e').addClass('ui-expander-c');
region.attr('aria-expanded', 'false').slideUp('fast', compfunc);
title.html(yelpdata.children('div.yelp-title-collapsed').html());
}
}
if (!region.hasAttribute('id')) {
region.setAttribute('id', yelp_generate_id());
}
else {
expander.removeClass('ui-expander-c').addClass('ui-expander-e');
title.setAttribute('aria-controls', region.getAttribute('id'));
region.attr('aria-expanded', 'true').slideDown('fast', compfunc);
title.html(yelpdata.children('div.yelp-title-expanded').html());
}
};
$(document).ready(function () {
$('.ui-expander').each(function () {
var expander = $(this);
var yelpdata = expander.children('div.yelp-data-ui-expander');
var region = expander.children('.inner').children('.region');
var title = expander.children('.inner').children('.title');
var issect = false;
if (title.length == 0) {
if (yelpdata != null) {
for (var i = 0; i < yelpdata.children.length; i++) {
var child = yelpdata.children[i];
if (child.classList.contains('yelp-title-expanded')) {
title_e = child;
}
else if (child.classList.contains('yelp-title-collapsed')) {
title = expander.children('.inner').children('.hgroup');
issect = true;
}
if (title.length == 0) {
return;
}
title_c = child;
}
}
}
titlespan = title.querySelector('span.title');
if (titlespan == null) {
return;
}
if (region.attr('id') == '')
region.attr('id', yelp_generate_id());
title.attr('role', 'button').attr('aria-controls', region.attr('id'));
var titlespan = title.find('span.title:first');
var title_e = yelpdata.children('div.yelp-title-expanded');
var title_c = yelpdata.children('div.yelp-title-collapsed');
if (title_e.length == 0)
if (title_e == null) {
var node = document.createElement('div');
node.className = 'yelp-title-expanded';
node.innerHTML = titlespan.innerHTML;
yelpdata.appendChild(node);
title_e = node;
yelpdata.append($('<div class="yelp-title-expanded"></div>').html(titlespan.html()));
if (title_c.length == 0)
yelpdata.append($('<div class="yelp-title-collapsed"></div>').html(titlespan.html()));
}
if (title_c == null) {
var node = document.createElement('div');
node.className = 'yelp-title-collapsed';
if (yelpdata.attr('data-yelp-expanded') == 'false') {
expander.addClass('ui-expander-c');
region.attr('aria-expanded', 'false').hide();
if (title_c.length != 0)
titlespan.html(title_c.html());
} else {
node.innerHTML = titlespan.innerHTML;
yelpdata.appendChild(node);
expander.addClass('ui-expander-e');
region.attr('aria-expanded', 'true');
if (title_e.length != 0)
title_c = node;
titlespan.html(title_e.html());
}
}
title.click(function () {
expander.yelp_ui_expander_toggle(false);
});
});
});
$(document).ready(function () {
var expand_hash = function () {
var ui_expander_zoom_region = function (event) {
if (location.hash != '') {
var target = $(location.hash);
var parents = target.parents('div.ui-expander');
if (target.is('div.ui-expander'))
if (yelpdata.getAttribute('data-yelp-expanded') != 'false') {
parents = parents.andSelf();
parents.each(function () {
$(this).yelp_ui_expander_toggle(true, function () {
ui_expander_toggle();
window.scrollTo(0, $(target).offset().top);
});
event.preventDefault();
});
}
};
$(window).bind('hashchange', expand_hash);
expand_hash();
}
if (expander.nodeName == 'section' || expander.nodeName == 'SECTION') {
for (var i = 0; i < region.children.length; i++) {
var child = region.children[i];
if (child.classList.contains('contents')) {
contents = child;
break;
}
}
contents.addEventListener('click', ui_expander_zoom_region, true);
});
}
yelp_color_text_light = '#2e3436';
yelp_color_gray_background = '#f3f3f0';
yelp_color_gray_border = '#babdb6';
yelp_paint_zoom = function (zoom, zoomed) {
var ctxt = zoom.children('canvas')[0].getContext('2d');
ctxt.strokeStyle = ctxt.fillStyle = yelp_color_text_light;
ctxt.clearRect(0, 0, 10, 10);
ctxt.strokeRect(0.5, 0.5, 9, 9);
if (zoomed) {
ctxt.fillRect(1, 1, 9, 4);
ctxt.fillRect(5, 5, 4, 4);
zoom.attr('title', zoom.attr('data-zoom-out-title'));
}
else {
ctxt.fillRect(1, 5, 4, 4);
zoom.attr('title', zoom.attr('data-zoom-in-title'));
region.addEventListener('click', ui_expander_zoom_region, true);
}
}
$.fn.yelp_auto_resize = function () {
var fig = $(this);
if (fig.is('img'))
fig = fig.parents('div.figure').eq(0);
var ui_expander_toggle = function () {
if (yelpdata.getAttribute('data-yelp-expanded') == 'false') {
yelpdata.setAttribute('data-yelp-expanded', 'true');
expander.classList.remove('ui-expander-e');
expander.classList.add('ui-expander-c');
region.setAttribute('aria-expanded', 'false');
if (title_c != null)
titlespan.innerHTML = title_c.innerHTML;
}
else {
yelpdata.setAttribute('data-yelp-expanded', 'false');
expander.classList.remove('ui-expander-c');
expander.classList.add('ui-expander-e');
region.setAttribute('aria-expanded', 'true');
if (title_e != null)
titlespan.innerHTML = title_e.innerHTML;
if (fig.data('yelp-zoom-timeout') != undefined) {
clearInterval(fig.data('yelp-zoom-timeout'));
fig.removeData('yelp-zoom-timeout');
}
}
var imgs = fig.find('img');
for (var i = 0; i < imgs.length; i++) {
var img = $(imgs[i]);
if (img.data('yelp-load-bound') == true)
img.unbind('load', fig.yelp_auto_resize);
};
expander.yelp_ui_expander_toggle = ui_expander_toggle;
if (!imgs[i].complete) {
img.data('yelp-load-bound', true);
img.bind('load', fig.yelp_auto_resize);
return false;
}
title.addEventListener('click', ui_expander_toggle, false);
ui_expander_toggle();
}
document.addEventListener('DOMContentLoaded', function() {
var matches = document.querySelectorAll('.ui-expander');
for (var i = 0; i < matches.length; i++) {
yelp_ui_expander_init(matches[i]);
}
$(window).unbind('resize', yelp_resize_imgs);
var yelp_hash_ui_expand = function () {
var zoom = fig.children('div.inner').children('a.zoom');
if (fig.find('div.contents:first').is(':hidden')) {
if (location.hash != '') {
var sect = document.querySelector(location.hash);
if (sect != null) {
zoom.hide();
return;
}
for (var cur = sect; cur instanceof Element; cur = cur.parentNode) {
if (cur.classList.contains('ui-expander')) {
if (cur.classList.contains('ui-expander-c')) {
cur.yelp_ui_expander_toggle();
}
for (var i = 0; i < imgs.length; i++) {
var img = $(imgs[i]);
if (img.data('yelp-original-width') == undefined) {
var iwidth = parseInt(img.attr('width'));
}
}
sect.scrollIntoView();
if (!iwidth)
iwidth = img[0].width;
img.data('yelp-original-width', iwidth);
var iheight = parseInt(img.attr('height'));
if (!iheight)
iheight = img[0].height * (iwidth / img[0].width);
img.data('yelp-original-height', iheight);
}
}
if (img.data('yelp-original-width') > img.parent().width()) {
if (img.data('yelp-zoomed') != true) {
img[0].width = img.parent().width();
img[0].height = (parseInt(img.data('yelp-original-height')) *
img.width() / parseInt(img.data('yelp-original-width')));
}
zoom.show();
}
else {
img[0].width = img.data('yelp-original-width');
img[0].height = img.data('yelp-original-height');
zoom.hide();
}
}
}
};
window.addEventListener('hashchange', yelp_hash_ui_expand, false);
yelp_hash_ui_expand();
}, false);
yelp_color_text_light = 'rgb(75,75,73)';
yelp_color_gray_background = 'rgb(244,244,244)';
yelp_color_gray_border = '#c0bfbc';
function yelp_figure_init (figure) {
var zoom = figure.querySelector('a.figure-zoom');
var figure_resize = function () {
var zoomed = zoom.classList.contains('figure-zoomed');
var imgs = figure.querySelectorAll('img');
for (var i = 0; i < imgs.length; i++) {
var img = imgs[i];
var mediaDiv = null;
for (var cur = img; cur instanceof Element; cur = cur.parentNode) {
if ((cur.nodeName == 'div' || cur.nodeName == 'DIV') &&
cur.classList.contains('media')) {
mediaDiv = cur;
break;
}
}
/* The image scaling above can cause the window to resize if it causes
* scrollbars to disappear or reapper. Unbind the resize handler before
* scaling the image. Don't rebind immediately, because we'll still get
if (mediaDiv == null)
* that resize event in an idle. Rebind on the callback instead.
*/
var reresize = function () {
continue;
$(window).unbind('resize', reresize);
$(window).bind('resize', yelp_resize_imgs);
}
$(window).bind('resize', reresize);
return false;
};
yelp_resize_imgs = function () {
$('div.figure img').parents('div.figure').each(function () {
var div = $(this);
if (div.data('yelp-zoom-timeout') == undefined)
div.data('yelp-zoom-timeout', setTimeout(function () { div.yelp_auto_resize() }, 1));
if (!img.hasAttribute('data-yelp-original-width')) {
var iwidth = null;
if (img.hasAttribute('width'))
iwidth = parseInt(img.getAttribute('width'));
});
return false;
else
};
$(document).ready(function () {
$('div.figure img').parents('div.figure').each(function () {
var fig = $(this);
iwidth = img.width;
img.setAttribute('data-yelp-original-width', iwidth);
var iheight = null;
var zoom = fig.children('div.inner').children('a.zoom');
zoom.append($('<canvas width="10" height="10"/>'));
yelp_paint_zoom(zoom, false);
zoom.data('yelp-zoomed', false);
if (img.hasAttribute('height'))
iheight = parseInt(img.getAttribute('height'));
else
iheight = img.height * (iwidth / img.width);
img.setAttribute('data-yelp-original-height', iheight);
zoom.click(function () {
var zoomed = !zoom.data('yelp-zoomed');
zoom.data('yelp-zoomed', zoomed);
zoom.parent().find('img').each(function () {
var zimg = $(this);
zimg.data('yelp-zoomed', zoomed);
}
var owidth = img.width;
var oheight = img.height;
if (zoomed) {
zimg[0].width = zimg.data('yelp-original-width');
zimg[0].height = zimg.data('yelp-original-height');
} else {
zimg[0].width = zimg.parent().width();
zimg[0].height = (parseInt(zimg.data('yelp-original-height')) *
zimg.width() / parseInt(zimg.data('yelp-original-width')));
}
yelp_paint_zoom(zoom, zoomed);
img.width = parseInt(img.getAttribute('data-yelp-original-width'));
img.height = parseInt(img.getAttribute('data-yelp-original-height'));
var mediaw = mediaDiv.offsetWidth;
img.width = owidth;
img.height = oheight;
if (parseInt(img.getAttribute('data-yelp-original-width')) <= mediaw) {
img.width = parseInt(img.getAttribute('data-yelp-original-width'));
img.height = parseInt(img.getAttribute('data-yelp-original-height'));
zoom.style.display = 'none';
}
else if (zoomed) {
});
return false;
});
});
yelp_resize_imgs();
img.width = parseInt(img.getAttribute('data-yelp-original-width'));
img.height = parseInt(img.getAttribute('data-yelp-original-height'));
$(window).bind('resize', yelp_resize_imgs);
});
function yelp_init_video (element) {
var video = $(element);
zoom.style.display = 'block';
video.removeAttr('controls');
}
var controls = $('<div class="media-controls media-controls-' + element.nodeName + '"></div>');
var playControl = $('<button class="media-play"></button>').attr({
else {
img.width = mediaw;
'data-play-label': video.attr('data-play-label'),
'data-pause-label': video.attr('data-pause-label'),
'value': video.attr('data-play-label')
img.height = (parseInt(img.getAttribute('data-yelp-original-height')) *
});
var playCanvas = $('<canvas width="20" height="20"></canvas>');
playControl.append(playCanvas);
var rangeCanvas = $('<canvas width="104" height="20"></canvas>');
var rangeCanvasCtxt = rangeCanvas[0].getContext('2d');
rangeCanvasCtxt.strokeStyle = yelp_color_gray_border;
rangeCanvasCtxt.strokeWidth = 1;
img.width /
rangeCanvasCtxt.strokeRect(0.5, 0.5, 103, 19);
var currentSpan = $('<span class="media-current">0:00</span>');
var durationSpan = $('<span class="media-duration">-:--</span>');
controls.append(playControl,
parseInt(img.getAttribute('data-yelp-original-width')));
zoom.style.display = 'block';
$('<div class="media-range"></div>').append(rangeCanvas),
$('<div class="media-time"></div>').append(currentSpan, durationSpan));
video.after(controls);
}
var playCanvasCtxt = playCanvas[0].getContext('2d');
var paintPlayButton = function () {
playCanvasCtxt.fillStyle = yelp_color_gray_background;
playCanvasCtxt.clearRect(0, 0, 20, 20);
playCanvasCtxt.beginPath();
playCanvasCtxt.moveTo(5, 5); playCanvasCtxt.lineTo(5, 15);
playCanvasCtxt.lineTo(15, 10); playCanvasCtxt.lineTo(5, 5);
playCanvasCtxt.fill();
}
var paintPauseButton = function () {
}
}
figure.yelp_figure_resize = figure_resize;
figure.yelp_figure_resize();
zoom.onclick = function (e) {
var zoomed = zoom.classList.contains('figure-zoomed');
if (zoomed)
zoom.classList.remove('figure-zoomed');
else
zoom.classList.add('figure-zoomed');
figure.yelp_figure_resize();
return false;
};
}
window.addEventListener('load', function() {
playCanvasCtxt.fillStyle = yelp_color_gray_background;
playCanvasCtxt.clearRect(0, 0, 20, 20);
playCanvasCtxt.beginPath();
playCanvasCtxt.moveTo(5, 5); playCanvasCtxt.lineTo(9, 5);
playCanvasCtxt.lineTo(9, 15); playCanvasCtxt.lineTo(5, 15);
playCanvasCtxt.lineTo(5, 5); playCanvasCtxt.fill();
playCanvasCtxt.beginPath();
playCanvasCtxt.moveTo(11, 5); playCanvasCtxt.lineTo(15, 5);
playCanvasCtxt.lineTo(15, 15); playCanvasCtxt.lineTo(11, 15);
var figures = document.querySelectorAll('div.figure');
for (var i = 0; i < figures.length; i++) {
if (figures[i].querySelector('img') != null)
yelp_figure_init(figures[i]);
playCanvasCtxt.lineTo(11, 5); playCanvasCtxt.fill();
}
paintPlayButton();
var timeout = null;
var yelp_figures_resize = function () {
if (timeout != null)
return;
var video_el = video[0];
var mediaChange = function () {
if (video_el.ended)
timeout = window.setTimeout(function () {
for (var i = 0; i < figures.length; i++) {
video_el.pause()
if (video_el.paused) {
if (figures[i].querySelector('img') != null)
playControl.attr('value', playControl.attr('data-play-label'));
paintPlayButton();
}
else {
figures[i].yelp_figure_resize();
}
window.clearTimeout(timeout);
timeout = null;
playControl.attr('value', playControl.attr('data-pause-label'));
paintPauseButton();
}
}, 100);
};
window.addEventListener('resize', yelp_figures_resize, false);
}, false);
function yelp_media_init (media) {
media.removeAttribute('controls');
if (media.parentNode.classList.contains('links-tile-img')) {
return;
}
video_el.addEventListener('play', mediaChange, false);
video_el.addEventListener('pause', mediaChange, false);
video_el.addEventListener('ended', mediaChange, false);
var playClick = function () {
if (video_el.paused || video_el.ended)
video_el.play();
media.addEventListener('click', function () {
if (media.paused)
media.play();
else
video_el.pause();
};
playControl.click(playClick);
media.pause();
}, false);
var controls = null;
for (var cur = media.nextSibling; cur instanceof Element; cur = cur.nextSibling) {
if (cur.classList.contains('media-controls')) {
controls = cur;
break;
}
var ttmlDiv = video.parent().children('div.media-ttml');
var ttmlNodes = ttmlDiv.find('.media-ttml-node');
}
var timeUpdate = function () {
var pct = (element.currentTime / element.duration) * 100;
rangeCanvasCtxt.fillStyle = yelp_color_gray_border;
rangeCanvasCtxt.clearRect(2, 2, 100, 16);
rangeCanvasCtxt.fillRect(2, 2, pct, 16);
var mins = parseInt(element.currentTime / 60);
if (controls == null) {
media.setAttribute('controls', 'controls');
return;
var secs = parseInt(element.currentTime - (60 * mins))
currentSpan.text(mins + (secs < 10 ? ':0' : ':') + secs);
ttmlNodes.each(function () {
var ttml = this;
if (element.currentTime >= parseFloat(ttml.getAttribute('data-ttml-begin')) &&
(!ttml.hasAttribute('data-ttml-end') ||
element.currentTime < parseFloat(ttml.getAttribute('data-ttml-end')) )) {
if (ttml.tagName == 'span')
ttml.style.display = 'inline';
else
ttml.style.display = 'block';
}
else {
ttml.style.display = 'none';
}
}
var playbutton = controls.querySelector('button.media-play');
playbutton.addEventListener('click', function () {
if (media.paused || media.ended)
media.play();
else
media.pause();
}, false);
var mediachange = function () {
if (media.ended)
media.pause()
if (media.paused) {
playbutton.setAttribute('value', playbutton.getAttribute('data-play-label'));
playbutton.classList.remove('media-play-playing');
}
else {
playbutton.setAttribute('value', playbutton.getAttribute('data-pause-label'));
playbutton.classList.add('media-play-playing');
}
});
};
element.addEventListener('timeupdate', timeUpdate, false);
var durationUpdate = function () {
if (!isNaN(element.duration)) {
mins = parseInt(element.duration / 60);
secs = parseInt(element.duration - (60 * mins));
durationSpan.text(mins + (secs < 10 ? ':0' : ':') + secs);
}
}
};
element.addEventListener('durationchange', durationUpdate, false);
media.addEventListener('play', mediachange, false);
media.addEventListener('pause', mediachange, false);
media.addEventListener('ended', mediachange, false);
var mediarange = controls.querySelector('input.media-range');
rangeCanvas.click(function (event) {
var pct = event.clientX - Math.floor(rangeCanvas.offset().left);
mediarange.addEventListener('input', function () {
var pct = this.value;
if (pct < 0)
pct = 0;
if (pct > 100)
pct = 100;
element.currentTime = (pct / 100.0) * element.duration;
});
media.currentTime = (pct / 100.0) * media.duration;
}, false);
};
$(document).ready(function () {
$('video, audio').each(function () { yelp_init_video(this) });;
});
var curspan = controls.querySelector('span.media-current');
$(document).ready( function () { jQuery.syntax({root: '', blockLayout: 'yelp',
theme: false, linkify: false}); });
$(document).ready(function () {
$('input.facet').change(function () {
var control = $(this);
var content = control.closest('div.body,div.sect');
var durspan = controls.querySelector('span.media-duration');
var durationUpdate = function () {
if (!isNaN(media.duration)) {
mins = parseInt(media.duration / 60);
secs = parseInt(media.duration - (60 * mins));
durspan.textContent = (mins + (secs < 10 ? ':0' : ':') + secs);
content.find('.facet-link').each(function () {
var link = $(this);
var facets = link.parents('div.body,div.sect').children('div.region').children('div.contents').children('div.facets').children('div.facet');
var visible = true;
for (var i = 0; i < facets.length; i++) {
var facet = facets.slice(i, i + 1);
var facetvis = false;
var inputs = facet.find('input.facet:checked');
for (var j = 0; j < inputs.length; j++) {
var input = inputs.slice(j, j + 1);
var inputvis = false;
var key = input.attr('data-facet-key');
var values = input.attr('data-facet-values').split(' ');
for (var k = 0; k < values.length; k++) {
if (link.is('*[data-facet-' + key + ' ~= "' + values[k] + '"]')) {
inputvis = true;
break;
}
}
}
};
if (inputvis) {
facetvis = true;
break;
}
media.addEventListener('durationchange', durationUpdate, false);
}
if (!facetvis) {
visible = false;
var ttmlDiv = null;
var ttmlNodes = null;
for (var i = 0; i < media.parentNode.children.length; i++) {
var child = media.parentNode.children[i];
if (child.classList.contains('media-ttml'))
ttmlDiv = child;
break;
}
}
}
if (ttmlDiv != null) {
ttmlNodes = ttmlDiv.querySelectorAll('.media-ttml-node');
}
if (!visible)
link.hide('fast');
else
link.show('fast');
});
});
});
$(document).ready(function () {
var timeUpdate = function () {
$('a.gloss-term').each(function () {
if ($(this).attr('href') == '#') {
var pct = (media.currentTime / media.duration) * 100;
mediarange.value = pct;
var mins = parseInt(media.currentTime / 60);
var secs = parseInt(media.currentTime - (60 * mins))
curspan.textContent = (mins + (secs < 10 ? ':0' : ':') + secs);
if (ttmlNodes != null) {
$(this).click(function () { return false; });
}
var showtip = function () {
var desc = $(this).children('span.gloss-desc');
if (desc.is(':visible'))
return;
for (var i = 0; i < ttmlNodes.length; i++) {
var ttml = ttmlNodes[i];
if (media.currentTime >= parseFloat(ttml.getAttribute('data-ttml-begin')) &&
(!ttml.hasAttribute('data-ttml-end') ||
media.currentTime < parseFloat(ttml.getAttribute('data-ttml-end')) )) {
if (ttml.tagName == 'span' || ttml.tagName == 'SPAN')
ttml.style.display = 'inline';
else
var top = $(this).offset().top + $(this).height() + 1;
var left = $(this).offset().left;
var cnt = $(this).closest('div.contents');
var diff = cnt.offset().left + cnt.width() - desc.width() - 4;
if (left > diff)
left = diff;
ttml.style.display = 'block';
}
else {
ttml.style.display = 'none';
desc.css({'top': top + 'px', 'left': left + 'px'}).fadeIn('slow');
};
}
}
}
};
var hidetip = function () {
if ($(this).is(':focus'))
return;
$(this).children('span.gloss-desc').fadeOut('fast');
};
media.addEventListener('timeupdate', timeUpdate, false);
};
$(this).hover(showtip, hidetip);
$(this).focus(showtip);
$(this).blur(hidetip);
});
});
$(document).ready(function () {
document.addEventListener('DOMContentLoaded', function() {
var matches = document.querySelectorAll('video, audio');
for (var i = 0; i < matches.length; i++) {
yelp_media_init(matches[i]);
}
}, false);
$('div.mouseovers').each(function () {
var contdiv = $(this);
var width = 0;
var height = 0;
contdiv.find('img').each(function () {
if ($(this).attr('data-yelp-match') == '')
$(this).show();
});
contdiv.next('ul').find('a').each(function () {
var mlink = $(this);
document.addEventListener('DOMContentLoaded', function() {
var tiles = document.querySelectorAll('div.links-tile');
for (var i = 0; i < tiles.length; i++) {
mlink.hover(
function () {
if (contdiv.is(':visible')) {
var offset = contdiv.offset();
mlink.find('img').css({left: offset.left, top: offset.top, zIndex: 10});
mlink.find('img').fadeIn('fast');
(function (tile) {
if (!tile.parentNode.classList.contains('links-tiles') &&
(tile.nextElementSibling &&
tile.nextElementSibling.classList.contains('links-tile')) &&
!(tile.previousElementSibling &&
tile.previousElementSibling.classList.contains('links-tile'))) {
var tilesdiv = document.createElement('div');
tilesdiv.className = 'links-tiles';
}
},
function () {
mlink.find('img').fadeOut('fast');
tile.parentNode.insertBefore(tilesdiv, tile);
var cur = tile;
while (cur && cur.classList.contains('links-tile')) {
var curcur = cur;
cur = cur.nextElementSibling;
tilesdiv.appendChild(curcur);
}
);
});
});
$('div.links-ui-hover').each(function () {
for (j = 0; j < 2; j++) {
var paddiv = document.createElement('div');
paddiv.className = 'links-tile';
var contdiv = $(this);
var width = 0;
var height = 0;
contdiv.next('ul').find('a').each(function () {
var mlink = $(this);
mlink.hover(
function () {
if (contdiv.is(':visible')) {
tilesdiv.appendChild(paddiv);
var offset = contdiv.offset();
mlink.find('img').parent('span').css({left: offset.left, top: offset.top, zIndex: 10});
mlink.find('img').parent('span').show();
}
}
},
function () {
mlink.find('img').parent('span').hide();
}
}
);
});
});
$('a.ui-overlay').each(function () {
$(this).click(function () {
var overlay = $(this).parent('div').children('div.ui-overlay');
var inner = overlay.children('div.inner');
var close = inner.children('a.ui-overlay-close');
var media = inner.find('audio, video');
})(tiles[i]);
}
});
document.addEventListener('DOMContentLoaded', function() {
var overlays = document.querySelectorAll('a.ui-overlay');
for (var i = 0; i < overlays.length; i++) {
(function (ovlink) {
var overlay = ovlink.parentNode.querySelector('div.ui-overlay');
var ui_overlay_show = function (ev) {
overlay.style.display = 'block';
overlay.classList.add('ui-overlay-show');
var screen = document.querySelector('div.ui-overlay-screen');
if (screen == null) {
screen = document.createElement('div');
screen.className = 'ui-overlay-screen';
document.body.appendChild(screen);
}
var inner = overlay.querySelector('div.inner');
var close = inner.querySelector('a.ui-overlay-close');
var media = inner.querySelectorAll('audio, video');
var screen = $('div.ui-screen');
if (screen.length == 0) {
screen = $('<div class="ui-screen"></div>');
$('body').append(screen);
}
var hideoverlay = function () {
if (media.length > 0)
media[0].pause();
var overlay_play_func = function () {
for (var j = 0; j < media.length; j++) {
media[j].play();
$(document).unbind('keydown.yelp-ui-overlay');
close.unbind('click');
screen.unbind('click');
screen.fadeOut('slow');
overlay.unbind('click');
overlay.slideUp('fast');
return false;
};
screen.click(hideoverlay);
close.click(hideoverlay);
$(document).bind('keydown.yelp-ui-overlay', function (event) {
if (event.which == 27) {
hideoverlay();
}
});
overlay.click(function (event) {
var target = event.target;
}
};
var overlay_play_timeout = window.setTimeout(overlay_play_func, 1000);
var ui_overlay_funcs = {};
ui_overlay_funcs['hide'] = function () {
overlay.style.display = 'none';
document.body.removeChild(screen);
document.removeEventListener('keydown', ui_overlay_funcs['keydown'], false);
for (var j = 0; j < media.length; j++) {
media[j].pause();
}
window.clearTimeout(overlay_play_timeout);
};
ui_overlay_funcs['hideclick'] = function (uiev) {
ui_overlay_funcs['hide']();
uiev.preventDefault();
do {
if (target == inner[0]) {
break;
}
};
} while (target = target.parentNode);
if (target != inner[0]) {
hideoverlay();
ui_overlay_funcs['keydown'] = function (uiev) {
if (uiev.keyCode == 27) {
ui_overlay_funcs['hide']();
return false;
}
});
screen.fadeIn('slow');
overlay.slideDown('fast', function () {
}
};
screen.addEventListener('click', ui_overlay_funcs['hideclick'], false);
close.addEventListener('click', ui_overlay_funcs['hideclick'], false);
if (media.length > 0)
media[0].play();
});
return false;
});
document.addEventListener('keydown', ui_overlay_funcs['keydown'], false);
ev.preventDefault();
};
ovlink.addEventListener('click', ui_overlay_show, false);
})(overlays[i]);
});
}
}); |