Diligent web site
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

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