Diligent web site
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

custom.js 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  1. "use strict";
  2. function isOnScreen(elem) {
  3. // if the element doesn't exist, abort
  4. if( elem.length == 0 ) {
  5. return;
  6. }
  7. var $window = jQuery(window)
  8. var viewport_top = $window.scrollTop()
  9. var viewport_height = $window.height()
  10. var viewport_bottom = viewport_top + viewport_height
  11. var $elem = jQuery(elem)
  12. var top = $elem.offset().top
  13. var height = $elem.height()
  14. var bottom = top + height
  15. return (top >= viewport_top && top < viewport_bottom) ||
  16. (bottom > viewport_top && bottom <= viewport_bottom) ||
  17. (height > viewport_height && top <= viewport_top && bottom >= viewport_bottom)
  18. }
  19. // start custom scripts
  20. (function($) {
  21. jQuery(document).ready(function($){
  22. /*========== Swicher ==========*/
  23. /*========== Progress bar ==========*/
  24. function animate() {
  25. $(".progress-bar").each(function(){
  26. var progressValue = $(this).attr('data-value');
  27. $(this).animate({width: progressValue +'%'}, 6000);
  28. });
  29. }
  30. //contact form
  31. var form = document.getElementById("contact-form");
  32. var button = $("#contact-form #submit");
  33. var status = $(".log");
  34. function success(data){
  35. //form.reset();
  36. //form.css('display', 'block!important');
  37. //button.style = "display: none ";
  38. form.append(xhr.response);
  39. }
  40. function error() {
  41. //status.addClass("error").text("Oops! There was a problem.");
  42. form.append(xhr.response);
  43. }
  44. button.on("submit", function(ev) {
  45. //ev.preventDefault();
  46. //button.style = "display: none ";
  47. var data = new FormData(form);
  48. ajax(form.method, form.action, data, success, error);
  49. // $.ajax({
  50. // url: "https://formspree.io/xnqgkykr",
  51. // method: "POST",
  52. // dataType: "json",
  53. // data: data
  54. // }).then((response) => { success(); });
  55. });
  56. function ajax(method, url, data, success, error) {
  57. var xhr = new XMLHttpRequest();
  58. xhr.open(method, url);
  59. xhr.setRequestHeader("Accept", "application/json");
  60. xhr.onreadystatechange = function() {
  61. if (xhr.readyState !== XMLHttpRequest.DONE) return;
  62. if (xhr.status === 200) {
  63. success();
  64. } else {
  65. error();
  66. }
  67. };
  68. xhr.send(data);
  69. }
  70. //end contact form
  71. // $('#contact-wrap').waypoint(function() {
  72. // animate();
  73. // });
  74. //nikola
  75. $('.clear_storage').on('click', function(e){
  76. window.localStorage.clear();
  77. });
  78. var get_id = localStorage.getItem('pg_id');
  79. // check page id, then scroll to its div
  80. if(get_id)
  81. scrollToID(null, get_id, 300);
  82. // click event to scroll to div
  83. //section link in nav which refer to section on homepage
  84. $('.home_link').on('click', function(e){
  85. e.preventDefault();
  86. var id = '#'+$(this).data('id');
  87. localStorage.setItem('pg_id', id);
  88. var url = $(this).attr("href");
  89. scrollToID(url, id, 300);
  90. });
  91. //Link from our partners section on homepage which refer to section on portfolio page
  92. $('.partners_link').on('click', function(e){
  93. e.preventDefault();
  94. var id = '#'+$(this).data('id');
  95. localStorage.setItem('pg_id', id);
  96. var url = $(this).attr("href");
  97. scrollToID(url, id, 300);
  98. });
  99. function scrollToID(url, id, speed) {
  100. if(url!==null)
  101. {
  102. window.location.href = url;
  103. }
  104. var offSet = 50;
  105. var obj = $(id).offset();
  106. var targetOffset = $(id).offset().top - offSet;
  107. $('html,body').animate({ scrollTop: targetOffset }, speed);
  108. }
  109. window.addEventListener('scroll', function(e) {
  110. var loc = window.location;
  111. if(loc.pathname.substring(loc.pathname.lastIndexOf('/') + 1, loc.pathname.length)=='index.html')
  112. {
  113. if( isOnScreen( $( '#intro-wrap' ) ) ) { /* Pass element id/class you want to check */
  114. $("nav li.active").removeClass("active").find('.nav-active-mark').remove();
  115. $("nav li.intro-wrap").addClass("active").append('<span class="nav-active-mark"></span>');
  116. }
  117. if( isOnScreen( $( '#about-wrap' ) ) ) { /* Pass element id/class you want to check */
  118. $("nav li.active").removeClass("active").find('.nav-active-mark').remove();
  119. $("nav li.about-wrap").addClass("active").append('<span class="nav-active-mark"></span>');
  120. }
  121. if( isOnScreen( $( '#our_partners-wrap' ) ) ) { /* Pass element id/class you want to check */
  122. $("nav li.active").removeClass("active").find('.nav-active-mark').remove();
  123. $("nav li.our_partners-wrap").addClass("active").append('<span class="nav-active-mark"></span>');
  124. }
  125. if( isOnScreen( $( '#services-wrap' ) ) ) { /* Pass element id/class you want to check */
  126. $("nav li.active").removeClass("active").find('.nav-active-mark').remove();
  127. $("nav li.services-wrap").addClass("active").append('<span class="nav-active-mark"></span>');
  128. }
  129. if( isOnScreen( $( '#contact-wrap' ) ) ) { /* Pass element id/class you want to check */
  130. $("nav li.active").removeClass("active").find('.nav-active-mark').remove();
  131. $("nav li.contact-wrap").addClass("active").append('<span class="nav-active-mark"></span>');
  132. }
  133. if( isOnScreen( $( '#teams-wrap' ) ) ) { /* Pass element id/class you want to check */
  134. $("nav li.active").removeClass("active").find('.nav-active-mark').remove();
  135. $("nav li.teams-wrap").addClass("active").append('<span class="nav-active-mark"></span>');
  136. }
  137. }
  138. });
  139. //nikola
  140. /*========== Disables ==========*/
  141. if( /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent) ) {
  142. $('#animate_css_file, #wow_js_file').remove();
  143. } else {
  144. /*========== WOW Animations ==========*/
  145. var wow = new WOW(
  146. {
  147. animateClass: 'animated',
  148. offset: 100
  149. }
  150. );
  151. wow.init();
  152. }
  153. /*========== Logo Retina ==========*/
  154. if( window.devicePixelRatio > 1 ) {
  155. var logoWidth = $('#logo img').width();
  156. var logoHeight = $('#logo img').height();
  157. $('#logo img').attr("src", "images/logo@2x.png");
  158. $('#logo img').css({ 'width': logoWidth , 'height': logoHeight });
  159. }
  160. /*========== Team Item Hover ==========*/
  161. $('.team-item').each(function(){
  162. var memberImage = $(this).find('.member-face').attr('style');
  163. var current = $(this).find('.change-color');
  164. $(this).find('.hex-in2.outer-hex').first().hover(function(){
  165. $(this).find('.member-face').css('background','#000');
  166. $(current).css('background-color','#f3b202');
  167. $(this).find('.socials').show();
  168. },function(){
  169. $(this).find('.socials').hide();
  170. $(this).find('.member-face').attr('style', memberImage);
  171. $(current).css('background-color','#000');
  172. });
  173. });
  174. /*========== Gallery Item Hover ==========*/
  175. $('.gallery-item').hover(function(){
  176. $(this).find('.gallery-info').stop(true,true).animate({ "top": "0" } );
  177. },function(){
  178. $(this).find('.gallery-info').stop(true,true).animate({ "top": "-999" } );
  179. });
  180. /*========== FlexSlider ==========*/
  181. $('.flexslider').flexslider({
  182. animation: "fade",
  183. animationLoop: false,
  184. directionNav: false,
  185. slideshow: false
  186. });
  187. /*========== Pie Chart ==========*/
  188. $('.days').waypoint(function() {
  189. $('.chart').easyPieChart({
  190. easing: 'easeOutBounce',
  191. barColor: '#f3b202',
  192. trackColor: '#595959',
  193. lineWidth: '18',
  194. lineCap: 'butt',
  195. size: '160',
  196. scaleColor: false,
  197. onStep: function(from, to, percent) {
  198. $(this.el).find('.percent').text(Math.round(percent));
  199. }
  200. });
  201. });
  202. /*========== Smooth Scroll ==========*/
  203. $('a[href*=#]:not([href=#])').click(function() {
  204. $("li.active").removeClass("active").find('.nav-active-mark').remove();
  205. $(this).parent().addClass('active').end().append('<span class="nav-active-mark"></span>');
  206. if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
  207. var target = $(this.hash);
  208. target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
  209. if (target.length) {
  210. $('html,body').animate({
  211. scrollTop: target.offset().top - 53
  212. }, 1000);
  213. return false;
  214. }
  215. }
  216. });
  217. /*========== Graph Bars Animate ==========*/
  218. $('.days').waypoint(function() {
  219. $('.graph ul li.bar').each(function() {
  220. var curBarHeight = $(this).data('bar-height');
  221. $(this).animate({ height: curBarHeight }, 2000, "easeInOutBack");
  222. });
  223. });
  224. /*========== Intro Note Box Tooltip ==========*/
  225. /*$('.note-1').hover(function(){
  226. $(this).find('.note-tooltip').fadeIn();
  227. },function(){
  228. $(this).find('.note-tooltip').fadeOut();
  229. });
  230. */
  231. /*========== PrettyPhoto ==========*/
  232. $("a[data-rel^='prettyPhoto']").prettyPhoto({theme:'dark_rounded', hook: 'data-rel'});
  233. /*========== Flickr ==========*/
  234. var flickrImageSrc = [ ];
  235. var flickrLink = [ ];
  236. $('.flickr_badge_image').each(function(i){
  237. flickrImageSrc[i] = $(this).find('img').attr('src');
  238. flickrLink[i] = $(this).find('a').attr('href');
  239. });
  240. $('.flickr-item').each(function(i){
  241. $(this).find('.hex-area').css('background-image', 'url(' + flickrImageSrc[i] + ')');
  242. $(this).find('.flickr-link').attr('href', flickrLink[i] );
  243. });
  244. /*========== Window Resize ==========*/
  245. var windowWidth = $(window).width();
  246. var numberOfHexagon = windowWidth / 106;
  247. var offsetBackground = ((numberOfHexagon - 14) * 106 ) /2;
  248. $('#hexagon-overlay').css('background-position', offsetBackground + 'px' + ' ' + 'top');
  249. $(window).resize(function() {
  250. var currentWindowWidth = $(window).width();
  251. if(currentWindowWidth <= 940) return;
  252. $('#hexagon-overlay').css('background-position', - ( ( (windowWidth - currentWindowWidth)/2 ) - offsetBackground ) + 'px' + ' ' + 'top');
  253. });
  254. /*========== Mobile Menu ==========*/
  255. $('.mobile-nav-toggle').on('click',function(){
  256. if($(this).attr('class') == 'mobile-nav-toggle deactive') {
  257. $('#mobile-navigation').fadeIn();
  258. $(this).removeClass('deactive');
  259. } else {
  260. $('#mobile-navigation').fadeOut();
  261. $(this).addClass('deactive');
  262. }
  263. });
  264. $("#mobile-navigation li a").on("click", function(){
  265. $('#mobile-navigation').fadeOut();
  266. $(".mobile-nav-toggle").addClass('deactive');
  267. });
  268. $(window).resize(function(){
  269. var w = $(window).width();
  270. if(w > 767) {
  271. $('#mobile-navigation').fadeOut();
  272. $(".mobile-nav-toggle").addClass('deactive');
  273. }
  274. });
  275. /*========== Contact Form Validation ==========*/
  276. function isValidEmailAddress(emailAddress) {
  277. var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
  278. return pattern.test(emailAddress);
  279. }
  280. // $('.contact-form form').submit(function() {
  281. // var hasError = false;
  282. // var comment = $('#message-txt').val();
  283. // if ($.trim(comment) == '') {
  284. // $('#message-txt').addClass('error');
  285. // $('#message-txt').focus();
  286. // hasError = true;
  287. // }
  288. // else {
  289. // $('#message-txt').removeClass('error');
  290. // }
  291. // var subject = $('#subject-txt').val();
  292. // if ($.trim(subject) == '') {
  293. // $('#subject-txt').addClass('error');
  294. // $('#subject-txt').focus();
  295. // hasError = true;
  296. // }
  297. // else {
  298. // $('#subject-txt').removeClass('error');
  299. // }
  300. // var emailVal = $('#email-txt').val();
  301. // if ($.trim(emailVal) == '' || !isValidEmailAddress(emailVal)) {
  302. // $('#email-txt').addClass('error');
  303. // $('#email-txt').focus();
  304. // hasError = true;
  305. // }
  306. // else {
  307. // $('#email-txt').removeClass('error');
  308. // }
  309. // var name = $('#name-txt').val();
  310. // if ($.trim(name) == '') {
  311. // $('#name-txt').addClass('error');
  312. // $('#name-txt').focus();
  313. // hasError = true;
  314. // }
  315. // else {
  316. // $('#name-txt').removeClass('error');
  317. // }
  318. // if (!hasError) {
  319. // $('#submit').fadeOut('normal', function(){
  320. // $('.loading').css({
  321. // display: "block"
  322. // });
  323. // });
  324. // // $.post($('.contact-form form').attr('action'), $('.contact-form form').serialize(), function(data){
  325. // // $('.log').html(data);
  326. // // $('.loading').remove();
  327. // // $('.contact-form form').slideUp('slow');
  328. // // });
  329. // }
  330. // return false;
  331. // });
  332. }); // end jquery init
  333. })(jQuery);