-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainScript.js
64 lines (61 loc) · 2.33 KB
/
mainScript.js
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
ko.bindingHandlers.audioControl = {
init: function (element, valueAccessor) {
var audioEl = $(element).parent().siblings('audio')[0];
if (valueAccessor() == "play") $(element).click(function () {
$('.pauseButton').trigger("click");
audioEl.play();
$(element).siblings().show();
$(element).hide();
});
if (valueAccessor() == "pause") $(element).click(function () {
audioEl.pause();
$(element).siblings().show();
$(element).hide();
});
if (valueAccessor() == "barArea") {
setInterval(function () {
var end = parseFloat(audioEl.duration);
var howMuchSoFar = parseFloat(audioEl.currentTime);
var fraction = howMuchSoFar / end;
var percent = (fraction * parseFloat(100)) + "%";
$(element).children().css("width", percent);
}, 100);
$(element).click(function (event) {
var end = parseFloat(audioEl.duration);
var barAreaWidth = parseFloat($(element).width());
var barFromEdge = parseFloat($(element).offset().left);
var mouseInBar = parseFloat(event.pageX) - barFromEdge;
var barFraction = mouseInBar / barAreaWidth;
var newTime = barFraction * end;
audioEl.currentTime = newTime;
});
}
}
}
var accordionItem = 0;
ko.bindingHandlers.setHrefToGrandparentSibling = {
init: function (element, valueAccessor) {
collapsingEl = $(element).parent().parent().siblings();
accordionItem++;
collapsingEl.attr("ID", accordionItem);
$(element).attr("href", "#" + accordionItem);
}
}
$(document).ready(function () {
ko.applyBindings();
function SetFontSize(){
if ($(window).width() > 600) {
$('h1').css({ 'font-size': '96px' });
} else if ($(window).width() <= 600 && $(window).width() > 500) {
$('h1').css({ 'font-size': '80px' });
} else if ($(window).width() <= 500 && $(window).width() > 450) {
$('h1').css({ 'font-size': '64px' });
} else {
$('h1').css({ 'font-size': '48px' });
}
}
SetFontSize();
$(window).resize(function () {
SetFontSize();
})
});