Diligent web site
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

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