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

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