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

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