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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601
  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. function scrollToID(url, id, speed) {
  31. if(url!==null)
  32. {
  33. window.location.href = url;
  34. }
  35. var offSet = 50;
  36. var obj = jQuery(id).offset();
  37. var targetOffset = 0;
  38. if(jQuery(id).length)
  39. {
  40. targetOffset = jQuery(id).offset().top - offSet;
  41. }
  42. jQuery('html,body').animate({ scrollTop: targetOffset }, speed);
  43. }
  44. //homepage
  45. var headerIsActive = false;
  46. $('.service-link').on('click', function()
  47. {
  48. $('#industriesMenu').css('displa', 'none');
  49. $('#servicesMenu').toggle('active');
  50. if(headerIsActive)
  51. {
  52. $('#header').removeClass('active_dropdown');
  53. }
  54. else
  55. {
  56. $('#header').addClass('active_dropdown');
  57. }
  58. });
  59. $('.industries-link').on('click', function()
  60. {
  61. $('#servicesMenu').css('display', 'none');
  62. $('#industriesMenu').toggle('active');
  63. if(headerIsActive)
  64. {
  65. $('#header').removeClass('active_dropdown');
  66. }
  67. else
  68. {
  69. $('#header').addClass('active_dropdown');
  70. }
  71. });
  72. //homepage end
  73. //career
  74. var expand = false;
  75. $('.position').on('click', function(ev) {
  76. //ev.preventDefault();
  77. $(this).find(".chev").toggleClass('chevron--down chevron--up');
  78. $(this).closest(".position-cont").find(".collapse").toggleClass("show");
  79. $(this).toggleClass("active"); //css({"background-color": "#993c95", "color": "white"});
  80. expand= !expand;
  81. });
  82. $('.chev').on('click', function(ev) {
  83. //ev.preventDefault();
  84. $(this).toggleClass('chevron--down chevron--up');
  85. $(this).closest(".position-cont").find(".collapse").toggleClass("show");
  86. $(this).closest(".position").toggleClass("active"); //css({"background-color": "#993c95", "color": "white"});
  87. expand= !expand;
  88. });
  89. //end career
  90. //apply
  91. // $(".resume-cont").click(function()
  92. // {
  93. // $(".resume-file").click();
  94. // });
  95. if( $("#positions").length)
  96. {
  97. $("#positions").selectize({
  98. create: true,
  99. sortField: {
  100. field: 'text',
  101. direction: 'asc'
  102. },
  103. });
  104. }
  105. var resume = "";
  106. $("input:file").change(function (event){
  107. var fileName = $(this).val();
  108. var reader = new FileReader();
  109. reader.onload = function(e)
  110. {
  111. resume = e.target.result;
  112. }
  113. reader.readAsDataURL(this.files[0]);
  114. var fileExtensionAt = fileName.lastIndexOf(".") + 1;
  115. console.log(fileName.substring(fileExtension, fileName.length));
  116. var fileExtension = fileName.substring(fileExtensionAt, fileName.length);
  117. if(fileName!="" && fileExtension == "doc" || fileExtension == "docx" || fileExtension == "pdf")
  118. {
  119. var from = fileName.lastIndexOf("\\") + 1;
  120. var to = fileName.length ;
  121. fileName = fileName.substring(from, to);
  122. }
  123. else{
  124. fileName="Choose file";
  125. }
  126. $(".resume-file-cont label").html(fileName);
  127. });
  128. $(".btn-delete-file").click(function(e)
  129. {
  130. e.preventDefault();
  131. $(".resume-file-cont label").html("Choose file");
  132. });
  133. var btn_apply = $("#apply-submit");
  134. var apply_form = $("#apply-form");
  135. apply_form.bind('submit', function(ev) {
  136. ev.preventDefault();
  137. var resume_file = document.getElementById("resume-file").files[0];
  138. console.log(resume.toString());
  139. var data = new FormData(document.getElementById("apply-form"));
  140. data.append("resume", "'" + resume + "'");
  141. data.append("resume-file", resume_file);
  142. $.ajax({
  143. url: "job_apply.php?call=upload",
  144. method: "POST",
  145. data: data,
  146. contentType: false,
  147. cache: false,
  148. processData:false,
  149. success : function(data) {
  150. console.log(data)
  151. $(".apply-msg").addClass("active");
  152. },
  153. error: function(error)
  154. {
  155. console.log(console.error);
  156. }
  157. });
  158. });
  159. //apply end
  160. //contact form
  161. var form = document.getElementById("contact-form");
  162. var button = jQuery("#contact-form #submit");
  163. var status = jQuery(".log");
  164. function success(data)
  165. {
  166. form.append(xhr.response);
  167. }
  168. function error()
  169. {
  170. form.append(xhr.response);
  171. }
  172. button.on("submit", function(ev)
  173. {
  174. var data = new FormData(form);
  175. ajax(form.method, form.action, data, success, error);
  176. });
  177. function ajax(method, url, data, success, error) {
  178. var xhr = new XMLHttpRequest();
  179. xhr.open(method, url);
  180. xhr.setRequestHeader("Accept", "application/json");
  181. xhr.onreadystatechange = function() {
  182. if (xhr.readyState !== XMLHttpRequest.DONE) return;
  183. if (xhr.status === 200) {
  184. success();
  185. } else {
  186. error();
  187. }
  188. };
  189. xhr.send(data);
  190. }
  191. //end contact form
  192. // $('#contact-wrap').waypoint(function() {
  193. // animate();
  194. // });
  195. //nikola
  196. $('.clear_storage').on('click', function(e){
  197. window.localStorage.clear();
  198. });
  199. var get_id = localStorage.getItem('pg_id');
  200. var setupUrl = false;
  201. // check page id, then scroll to its div
  202. if(get_id)
  203. {
  204. scrollToID(null, get_id, 300);
  205. }
  206. jQuery(document).ready(function()
  207. {
  208. var loc = window.location;
  209. if(!get_id && loc.pathname.substring(loc.pathname.lastIndexOf('/') + 1, loc.pathname.length) == 'index.html' && !setupUrl)
  210. {
  211. var sectionType = window.location.hash;
  212. console.log(sectionType.substr(sectionType.indexOf('=') + 1, sectionType.length ) );
  213. var id = sectionType.substr(sectionType.indexOf('=') + 1, sectionType.length );
  214. id+="-section";
  215. if(id != "" && id != null)
  216. {
  217. //console.log(loc.pathname);
  218. console.log(id);
  219. var nav_link = "#navigation ."+ id +" > a";
  220. console.log(item);
  221. var item = $(nav_link);
  222. console.log(item);
  223. item.trigger('click');
  224. //localStorage.setItem('pg_id', id);
  225. //scrollToID('index.html', "#"+id, 300);
  226. setupUrl =true;;
  227. }
  228. }
  229. });
  230. $("#back-to-top").on('click', function()
  231. {
  232. $(window).scrollTop(0);
  233. $(this).removeClass('active');
  234. });
  235. // click event to scroll to div
  236. //section link in nav which refer to section on homepage
  237. $('.home_link').on('click', function(e){
  238. e.preventDefault();
  239. var id = '#'+$(this).data('id');
  240. localStorage.setItem('pg_id', id);
  241. var url = $(this).attr("href");
  242. scrollToID(url, id, 300);
  243. });
  244. //Link from our partners section on homepage which refer to section on portfolio page
  245. $('.partners_link').on('click', function(e){
  246. e.preventDefault();
  247. var id = '#'+$(this).data('id');
  248. localStorage.setItem('pg_id', id);
  249. var url = $(this).attr("href");
  250. scrollToID(url, id, 300);
  251. });
  252. var siteUrl = window.location.hash;
  253. window.addEventListener('scroll', function(e) {
  254. if($( document ).width() <= 768)
  255. {
  256. $("#back-to-top").addClass("active");
  257. }
  258. if($( document ).scrollTop() == 0)
  259. {
  260. $("#back-to-top").removeClass("active");
  261. }
  262. var loc = window.location;
  263. if(loc.pathname.substring(loc.pathname.lastIndexOf('/') + 1, loc.pathname.length) == 'index.html')
  264. {
  265. var newUrl = "";
  266. if( isOnScreen( $( '#intro-section' ) ) ) { /* Pass element id/class you want to check */
  267. $("nav li.active").removeClass("active").find('.nav-active-mark').remove();
  268. $("nav li.intro-section").addClass("active").append('<span class="nav-active-mark"></span>');
  269. //newUrl = siteUrl.substring(0, siteUrl.indexOf("/"));
  270. parent.location.hash = "?section=intro";
  271. }
  272. if( isOnScreen( $( '#about-section' ) ) ) { /* Pass element id/class you want to check */
  273. $("nav li.active").removeClass("active").find('.nav-active-mark').remove();
  274. $("nav li.about-section").addClass("active").append('<span class="nav-active-mark"></span>');
  275. //newUrl = siteUrl.substring(0, siteUrl.lastIndexOf("/") -1) + "about-wrap";
  276. parent.location.hash = "?section=about";
  277. //console.log(siteUrl.substring(0, siteUrl.lastIndexOf("/")));
  278. }
  279. if( isOnScreen( $( '#our_partners-section' ) ) ) { /* Pass element id/class you want to check */
  280. $("nav li.active").removeClass("active").find('.nav-active-mark').remove();
  281. $("nav li.our_partners-section").addClass("active").append('<span class="nav-active-mark"></span>');
  282. //newUrl = siteUrl.substring(0, siteUrl.lastIndexOf("/") -1) + "our_partners-wrap";
  283. parent.location.hash = "?section=our_partners";
  284. }
  285. if( isOnScreen( $( '#services-section' ) ) ) { /* Pass element id/class you want to check */
  286. $("nav li.active").removeClass("active").find('.nav-active-mark').remove();
  287. $("nav li.services-section").addClass("active").append('<span class="nav-active-mark"></span>');
  288. //newUrl = siteUrl.substring(0, siteUrl.lastIndexOf("/") -1) + "services";
  289. parent.location.hash = "?section=services";
  290. }
  291. if( isOnScreen( $( '#teams-wrap' ) ) ) { /* Pass element id/class you want to check */
  292. $("nav li.active").removeClass("active").find('.nav-active-mark').remove();
  293. $("nav li.teams-wrap").addClass("active").append('<span class="nav-active-mark"></span>');
  294. newUrl = siteUrl.substring(0, siteUrl.lastIndexOf("/") -1) + "teams-wrap";
  295. parent.location.hash = "?section=teams"
  296. }
  297. if( isOnScreen( $( '#contact-section' ) ) ) { /* Pass element id/class you want to check */
  298. $("nav li.active").removeClass("active").find('.nav-active-mark').remove();
  299. $("nav li.contact-section").addClass("active").append('<span class="nav-active-mark"></span>');
  300. //newUrl = siteUrl.substring(0, siteUrl.lastIndexOf("/") -1) + "contact-wrap";
  301. parent.location.hash = "?section=contact"
  302. }
  303. //history.pushState({}, null, newUrl);
  304. }
  305. });
  306. //nikola
  307. /*========== Disables ==========*/
  308. if( /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent) ) {
  309. $('#animate_css_file, #wow_js_file').remove();
  310. } else {
  311. /*========== WOW Animations ==========*/
  312. var wow = new WOW(
  313. {
  314. animateClass: 'animated',
  315. offset: 100
  316. }
  317. );
  318. wow.init();
  319. }
  320. /*========== Logo Retina ==========*/
  321. if( window.devicePixelRatio > 1 ) {
  322. var logoWidth = $('#logo img').width();
  323. var logoHeight = $('#logo img').height();
  324. $('#logo img').attr("src", "images/logo@2x.png");
  325. $('#logo img').css({ 'width': logoWidth , 'height': logoHeight });
  326. }
  327. /*========== Team Item Hover ==========*/
  328. $('.team-item').each(function(){
  329. var memberImage = $(this).find('.member-face').attr('style');
  330. var current = $(this).find('.change-color');
  331. $(this).find('.hex-in2.outer-hex').first().hover(function(){
  332. $(this).find('.member-face').css('background','#000');
  333. $(current).css('background-color','#f3b202');
  334. $(this).find('.socials').show();
  335. },function(){
  336. $(this).find('.socials').hide();
  337. $(this).find('.member-face').attr('style', memberImage);
  338. $(current).css('background-color','#000');
  339. });
  340. });
  341. /*========== Gallery Item Hover ==========*/
  342. $('.gallery-item').hover(function(){
  343. $(this).find('.gallery-info').stop(true,true).animate({ "top": "0" } );
  344. },function(){
  345. $(this).find('.gallery-info').stop(true,true).animate({ "top": "-999" } );
  346. });
  347. /*========== Pie Chart ==========*/
  348. $('.days').waypoint(function() {
  349. $('.chart').easyPieChart({
  350. easing: 'easeOutBounce',
  351. barColor: '#f3b202',
  352. trackColor: '#595959',
  353. lineWidth: '18',
  354. lineCap: 'butt',
  355. size: '160',
  356. scaleColor: false,
  357. onStep: function(from, to, percent) {
  358. $(this.el).find('.percent').text(Math.round(percent));
  359. }
  360. });
  361. });
  362. /*========== Smooth Scroll ==========*/
  363. $('a[href*=#]:not([href=#])').click(function() {
  364. $("li.active").removeClass("active").find('.nav-active-mark').remove();
  365. $(this).parent().addClass('active').end().append('<span class="nav-active-mark"></span>');
  366. if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
  367. var target = $(this.hash);
  368. target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
  369. if (target.length) {
  370. $('html,body').animate({
  371. scrollTop: target.offset().top - 53
  372. }, 1000);
  373. return false;
  374. }
  375. }
  376. });
  377. /*========== Graph Bars Animate ==========*/
  378. $('.days').waypoint(function() {
  379. $('.graph ul li.bar').each(function() {
  380. var curBarHeight = $(this).data('bar-height');
  381. $(this).animate({ height: curBarHeight }, 2000, "easeInOutBack");
  382. });
  383. });
  384. /*========== Intro Note Box Tooltip ==========*/
  385. /*$('.note-1').hover(function(){
  386. $(this).find('.note-tooltip').fadeIn();
  387. },function(){
  388. $(this).find('.note-tooltip').fadeOut();
  389. });
  390. */
  391. /*========== PrettyPhoto ==========*/
  392. $("a[data-rel^='prettyPhoto']").prettyPhoto({theme:'dark_rounded', hook: 'data-rel'});
  393. /*========== Flickr ==========*/
  394. var flickrImageSrc = [ ];
  395. var flickrLink = [ ];
  396. $('.flickr_badge_image').each(function(i){
  397. flickrImageSrc[i] = $(this).find('img').attr('src');
  398. flickrLink[i] = $(this).find('a').attr('href');
  399. });
  400. $('.flickr-item').each(function(i){
  401. $(this).find('.hex-area').css('background-image', 'url(' + flickrImageSrc[i] + ')');
  402. $(this).find('.flickr-link').attr('href', flickrLink[i] );
  403. });
  404. /*========== Window Resize ==========*/
  405. var windowWidth = $(window).width();
  406. var numberOfHexagon = windowWidth / 106;
  407. var offsetBackground = ((numberOfHexagon - 14) * 106 ) /2;
  408. $('#hexagon-overlay').css('background-position', offsetBackground + 'px' + ' ' + 'top');
  409. $(window).resize(function() {
  410. var currentWindowWidth = $(window).width();
  411. if(currentWindowWidth <= 940) return;
  412. $('#hexagon-overlay').css('background-position', - ( ( (windowWidth - currentWindowWidth)/2 ) - offsetBackground ) + 'px' + ' ' + 'top');
  413. });
  414. /*========== Mobile Menu ==========*/
  415. $('.mobile-nav-toggle').on('click',function(){
  416. if($(this).attr('class') == 'mobile-nav-toggle deactive') {
  417. $('#mobile-navigation').fadeIn();
  418. $(this).removeClass('deactive');
  419. } else {
  420. $('#mobile-navigation').fadeOut();
  421. $(this).addClass('deactive');
  422. }
  423. });
  424. $("#mobile-navigation li a").on("click", function(){
  425. $('#mobile-navigation').fadeOut();
  426. $(".mobile-nav-toggle").addClass('deactive');
  427. });
  428. $(window).resize(function(){
  429. var w = $(window).width();
  430. if(w > 767) {
  431. $('#mobile-navigation').fadeOut();
  432. $(".mobile-nav-toggle").addClass('deactive');
  433. }
  434. });
  435. /*========== Contact Form Validation ==========*/
  436. function isValidEmailAddress(emailAddress) {
  437. 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);
  438. return pattern.test(emailAddress);
  439. }
  440. // $('.contact-form form').submit(function() {
  441. // var hasError = false;
  442. // var comment = $('#message-txt').val();
  443. // if ($.trim(comment) == '') {
  444. // $('#message-txt').addClass('error');
  445. // $('#message-txt').focus();
  446. // hasError = true;
  447. // }
  448. // else {
  449. // $('#message-txt').removeClass('error');
  450. // }
  451. // var subject = $('#subject-txt').val();
  452. // if ($.trim(subject) == '') {
  453. // $('#subject-txt').addClass('error');
  454. // $('#subject-txt').focus();
  455. // hasError = true;
  456. // }
  457. // else {
  458. // $('#subject-txt').removeClass('error');
  459. // }
  460. // var emailVal = $('#email-txt').val();
  461. // if ($.trim(emailVal) == '' || !isValidEmailAddress(emailVal)) {
  462. // $('#email-txt').addClass('error');
  463. // $('#email-txt').focus();
  464. // hasError = true;
  465. // }
  466. // else {
  467. // $('#email-txt').removeClass('error');
  468. // }
  469. // var name = $('#name-txt').val();
  470. // if ($.trim(name) == '') {
  471. // $('#name-txt').addClass('error');
  472. // $('#name-txt').focus();
  473. // hasError = true;
  474. // }
  475. // else {
  476. // $('#name-txt').removeClass('error');
  477. // }
  478. // if (!hasError) {
  479. // $('#submit').fadeOut('normal', function(){
  480. // $('.loading').css({
  481. // display: "block"
  482. // });
  483. // });
  484. // // $.post($('.contact-form form').attr('action'), $('.contact-form form').serialize(), function(data){
  485. // // $('.log').html(data);
  486. // // $('.loading').remove();
  487. // // $('.contact-form form').slideUp('slow');
  488. // // });
  489. // }
  490. // return false;
  491. // });
  492. /*========== FlexSlider ==========*/
  493. $('.flexslider').flexslider({
  494. animation: "fade",
  495. animationLoop: false,
  496. directionNav: false,
  497. slideshow: false
  498. });
  499. }); // end jquery init
  500. })(jQuery);