1 |
/* |
/* |
2 |
CrudeDoc Java Script |
CrudeDoc Java Script |
3 |
Copyright (c) 2015 Christian Schoenebeck. All rights reserved. |
Copyright (c) 2015 - 2017 Christian Schoenebeck. All rights reserved. |
4 |
http://www.crudebyte.com |
http://www.crudebyte.com |
5 |
*/ |
*/ |
6 |
|
|
7 |
|
var g_isTouch = false; |
8 |
|
|
9 |
function crdWindowHeight() { |
function crdWindowHeight() { |
10 |
return window.innerHeight || |
return window.innerHeight || |
11 |
document.documentElement.clientHeight || |
document.documentElement.clientHeight || |
16 |
$('html, body').animate({ |
$('html, body').animate({ |
17 |
scrollTop: $( "#" + $(e).attr("section") ).offset().top - 68 |
scrollTop: $( "#" + $(e).attr("section") ).offset().top - 68 |
18 |
}, 300); |
}, 300); |
19 |
|
var obj = $( "#" + $(e).attr("section") ); |
20 |
|
$(obj).fadeIn(100).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(120).fadeOut(100).fadeIn(120); |
21 |
|
} |
22 |
|
|
23 |
|
function crdScrollToHash(h) { |
24 |
|
if (typeof h === 'undefined') { |
25 |
|
h = location.hash; |
26 |
|
if (!h || h.length < 2) return; |
27 |
|
} |
28 |
|
$('html, body').animate({ |
29 |
|
scrollTop: $( h ).offset().top - 68 |
30 |
|
}, 300); |
31 |
|
$(h).fadeIn(100).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(120).fadeOut(100).fadeIn(120); |
32 |
} |
} |
33 |
|
|
34 |
function crdOnScroll() { |
function crdOnScroll() { |
61 |
} |
} |
62 |
|
|
63 |
function crdDetectFeatures() { |
function crdDetectFeatures() { |
64 |
|
if ('ontouchstart' in document.documentElement) { |
65 |
|
g_isTouch = true; |
66 |
|
document.documentElement.className += ' touch'; |
67 |
|
} else { |
68 |
|
g_isTouch = false; |
69 |
|
document.documentElement.className += ' no-touch'; |
70 |
|
} |
71 |
if ($.support["transform"]) { |
if ($.support["transform"]) { |
72 |
$("body").addClass("hasTransform"); |
$("body").addClass("hasTransform"); |
73 |
} |
} |
74 |
|
var iOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream; |
75 |
|
if (iOS) { |
76 |
|
$("body").addClass("iOS"); |
77 |
|
} |
78 |
} |
} |
79 |
|
|
80 |
$(function() { |
$(function() { |
81 |
crdDetectFeatures(); |
crdDetectFeatures(); |
82 |
$(document).tooltip(); |
$(document).tooltip(); |
83 |
|
if (g_isTouch) { |
84 |
|
$("header a[title]" ).tooltip({ |
85 |
|
disabled: true |
86 |
|
}); |
87 |
|
} |
88 |
$("article img[caption]").each(function() { |
$("article img[caption]").each(function() { |
89 |
$(this).after( |
$(this).after( |
90 |
"<div class='imgcptn'>" + |
"<div class='imgcptn'>" + |
100 |
$(window).resize(function() { |
$(window).resize(function() { |
101 |
crdOnWindowResize(); |
crdOnWindowResize(); |
102 |
}); |
}); |
103 |
|
if ("onhashchange" in window) { |
104 |
|
window.onhashchange = function() { |
105 |
|
crdScrollToHash(); |
106 |
|
}; |
107 |
|
} |
108 |
|
$("article a[href]").each(function() { |
109 |
|
var href = $(this).attr("href"); |
110 |
|
if (href && href.length > 1 && href.charAt(0) == '#') { |
111 |
|
$(this).click(function(e) { |
112 |
|
var anch = $(this).attr("href"); |
113 |
|
crdScrollToHash(anch); |
114 |
|
}); |
115 |
|
} |
116 |
|
}); |
117 |
}); |
}); |
118 |
|
|
119 |
$(document).ready(function() { |
$(document).ready(function() { |
120 |
crdOnWindowResize(); |
crdOnWindowResize(); |
121 |
|
crdScrollToHash(); |
122 |
}); |
}); |
123 |
|
|
124 |
var _crdScrollTimeout; |
var _crdScrollTimeout; |