Repository navigation
Expand file tree
/
Copy pathscript.js
More file actions
155 lines (138 loc) · 4.76 KB
/
Copy pathscript.js
File metadata and controls
155 lines (138 loc) · 4.76 KB
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
(function($) {
$(document).ready(function(){
// putting lines by the pre blocks
$("pre").each(function(){
var pre = $(this).text().split("\n");
var lines = new Array(pre.length+1);
for(var i = 0; i < pre.length; i++) {
var wrap = Math.floor(pre[i].split("").length / 70)
if (pre[i]==""&&i==pre.length-1) {
lines.splice(i, 1);
} else {
lines[i] = i+1;
for(var j = 0; j < wrap; j++) {
lines[i] += "\n";
}
}
}
$(this).before("<pre class='lines'>" + lines.join("\n") + "</pre>");
});
var headings = [];
var collectHeaders = function(){
headings.push({"top":$(this).offset().top - 15,"text":$(this).text()});
}
if($(".markdown-body h1").length > 1)
$(".markdown-body h1").each(collectHeaders)
else if($(".markdown-body h2").length > 1)
$(".markdown-body h2").each(collectHeaders)
else if($(".markdown-body h3").length > 1)
$(".markdown-body h3").each(collectHeaders)
$(window).scroll(function(){
if(headings.length==0) return true;
var scrolltop = $(window).scrollTop() || 0;
if(headings[0] && scrolltop < headings[0].top) {
$(".current-section").css({"opacity":0,"visibility":"hidden"});
return false;
}
$(".current-section").css({"opacity":1,"visibility":"visible"});
for(var i in headings) {
if(scrolltop >= headings[i].top) {
$(".current-section .name").text(headings[i].text);
}
}
});
$(".current-section a").click(function(){
$(window).scrollTop(0);
return false;
});
(function() {
$(function() {
return $("#invitationForm").on("submit", function(e) {
var serialized, xhr;
e.preventDefault();
$("#invitationFormSuccess").hide();
$("#invitationFormFail").hide();
serialized = $("#invitationForm").serialize();
$("#invitationForm").find("input").prop("disabled", "disabled");
xhr = $.post("https://ancient-bayou-8275.herokuapp.com/invitations", serialized);
xhr.done(function() {
return $("#invitationFormSuccess").show();
});
xhr.fail(function() {
return $("#invitationFormFail").show();
});
return xhr.always(function() {
return $("#invitationForm").find("input").prop("disabled", "");
});
});
});
}).call(this);
$("#invitationFormSuccess").hide();
$("#invitationFormFail").hide();
if ($(window).width() > 805) {
// $(window).resize(function() {
// if ($(this).width() > 768) {
// console.log($(this).width());
if ($('.main-header').length > 0) {
var mainbottom = $('.main-header').offset().top + $('.main-header').height();
$(window).on('scroll', function() {
console.log('scolling');
var stopWindow = Math.round($(window).scrollTop()) + $('.menu-area').outerHeight();
conditionNavbar(stopWindow, mainbottom);
});
}
// } else {
// $(window).on('scroll', function() {});
}
// });
//Check Navbar Show
if ($('.main-header').length > 0) {
var mainbottom = $('.main-header').offset().top + $('.main-header').height();
var stopWindow = Math.round($(window).scrollTop()) + $('.menu-area').outerHeight();
conditionNavbar(stopWindow, mainbottom);
}
//animate jump to anchor
// $('.link-inpage').click(function(e) {
// var target = this.hash, $target = $(target);
// $('html, body').stop().animate({
// 'scrollTop': $target.offset().top - ($('.menu-area').outerHeight() - 1)
// }, 1500, 'easeInOutExpo', function() {
// //window.location.hash = target;
// });
// return false;
// });
//Animate jump to #top
$('.back-to-top').click(function() {
$('html, body').stop().animate({
'scrollTop': 0
}, 1500, 'easeInOutExpo', function() {
});
return false;
});
//Condition Navbar
function conditionNavbar(stopWindow, mainbottom) {
if (stopWindow > mainbottom)
$('.menu-area').addClass('nav-fixed');
else
$('.menu-area').removeClass('nav-fixed nav-white-bg');
// if ((stopWindow) > $('.menu-area').outerHeight())
// $('.menu-area').addClass('nav-white-bg');
}
if (window.location.hash) {
// $('.link-inpage[href="' + window.location.hash + '"]').first().trigger('click');
$('.segment').hide();
$('.segment_'+window.location.hash.substr(1)).show()
} else {
$('.segment').hide();
$('.segment_home').show();
$('.link-inpage').parent().removeClass('active')
$('.link-inpage[href="#home"').parent().addClass('active')
}
$('.link-inpage').click(function(e) {
$('.link-inpage').parent().removeClass('active')
$(this).parent().addClass('active')
$('.segment').hide();
$('.segment_'+$(this).attr('href').substr(1)).show()
});
});
})(jQuery);