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 15KB

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