Diligent web site
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

custom.js 14KB

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