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

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