Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

script.js 8.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. jQuery(function ($) {
  2. "use strict";
  3. /* ========================================================================= */
  4. /* Page Preloader
  5. /* ========================================================================= */
  6. // Preloader js
  7. $(window).on('load', function () {
  8. $('#preloader').fadeOut(700);
  9. });
  10. //animation scroll js
  11. var html_body = $('html, body');
  12. $('nav a, .page-scroll').on('click', function () { //use page-scroll class in any HTML tag for scrolling
  13. if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
  14. var target = $(this.hash);
  15. target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
  16. if (target.length) {
  17. html_body.animate({
  18. scrollTop: target.offset().top - 50
  19. }, 1500, "easeInOutExpo");
  20. return false;
  21. }
  22. }
  23. });
  24. //easeInOutExpo Declaration
  25. jQuery.extend(jQuery.easing, {
  26. easeInOutExpo: function (x, t, b, c, d) {
  27. if (t == 0) return b;
  28. if (t == d) return b + c;
  29. if ((t /= d / 2) < 1) return c / 2 * Math.pow(2, 10 * (t - 1)) + b;
  30. return c / 2 * (-Math.pow(2, -10 * --t) + 2) + b;
  31. }
  32. });
  33. /* ========================================================================= */
  34. /* Post image slider
  35. /* ========================================================================= */
  36. $("#post-thumb, #gallery-post").slick({
  37. infinite: true,
  38. arrows: false,
  39. autoplay: true,
  40. autoplaySpeed: 4000
  41. });
  42. $("#features").slick({
  43. infinite: true,
  44. arrows: false,
  45. autoplay: true,
  46. autoplaySpeed: 4000
  47. });
  48. /* ========================================================================= */
  49. /* Magnific popup
  50. /* ========================================================================= */
  51. $('.image-popup').magnificPopup({
  52. type: 'image',
  53. removalDelay: 160, //delay removal by X to allow out-animation
  54. callbacks: {
  55. beforeOpen: function () {
  56. // just a hack that adds mfp-anim class to markup
  57. this.st.image.markup = this.st.image.markup.replace('mfp-figure', 'mfp-figure mfp-with-anim');
  58. this.st.mainClass = this.st.el.attr('data-effect');
  59. }
  60. },
  61. closeOnContentClick: true,
  62. midClick: true,
  63. fixedContentPos: false,
  64. fixedBgPos: true
  65. });
  66. /* ========================================================================= */
  67. /* Portfolio Filtering Hook
  68. /* ========================================================================= */
  69. var mixer = mixitup('.portfolio-items-wrapper');
  70. /* ========================================================================= */
  71. /* Testimonial Carousel
  72. /* ========================================================================= */
  73. //Init the carousel
  74. $("#testimonials").slick({
  75. infinite: true,
  76. arrows: false,
  77. autoplay: true,
  78. autoplaySpeed: 4000
  79. });
  80. /* ========================================================================= */
  81. /* Contact Form Validating
  82. /* ========================================================================= */
  83. $('#contact-submit').click(function (e) {
  84. //stop the form from being submitted
  85. e.preventDefault();
  86. /* declare the variables, var error is the variable that we use on the end
  87. to determine if there was an error or not */
  88. var error = false;
  89. var name = $('#name').val();
  90. var email = $('#email').val();
  91. var subject = $('#subject').val();
  92. var message = $('#message').val();
  93. /* in the next section we do the checking by using VARIABLE.length
  94. where VARIABLE is the variable we are checking (like name, email),
  95. length is a JavaScript function to get the number of characters.
  96. And as you can see if the num of characters is 0 we set the error
  97. variable to true and show the name_error div with the fadeIn effect.
  98. if it's not 0 then we fadeOut the div( that's if the div is shown and
  99. the error is fixed it fadesOut.
  100. The only difference from these checks is the email checking, we have
  101. email.indexOf('@') which checks if there is @ in the email input field.
  102. This JavaScript function will return -1 if no occurrence have been found.*/
  103. if (name.length == 0) {
  104. var error = true;
  105. $('#name').css("border-color", "#D8000C");
  106. } else {
  107. $('#name').css("border-color", "#666");
  108. }
  109. if (email.length == 0 || email.indexOf('@') == '-1') {
  110. var error = true;
  111. $('#email').css("border-color", "#D8000C");
  112. } else {
  113. $('#email').css("border-color", "#666");
  114. }
  115. if (subject.length == 0) {
  116. var error = true;
  117. $('#subject').css("border-color", "#D8000C");
  118. } else {
  119. $('#subject').css("border-color", "#666");
  120. }
  121. if (message.length == 0) {
  122. var error = true;
  123. $('#message').css("border-color", "#D8000C");
  124. } else {
  125. $('#message').css("border-color", "#666");
  126. }
  127. //now when the validation is done we check if the error variable is false (no errors)
  128. if (error == false) {
  129. //disable the submit button to avoid spamming
  130. //and change the button text to Sending...
  131. $('#contact-submit').attr({
  132. 'disabled': 'false',
  133. 'value': 'Sending...'
  134. });
  135. /* using the jquery's post(ajax) function and a lifesaver
  136. function serialize() which gets all the data from the form
  137. we submit it to send_email.php */
  138. $.post("sendmail.php", $("#contact-form").serialize(), function (result) {
  139. //and after the ajax request ends we check the text returned
  140. if (result == 'sent') {
  141. //if the mail is sent remove the submit paragraph
  142. $('#cf-submit').remove();
  143. //and show the mail success div with fadeIn
  144. $('#mail-success').fadeIn(500);
  145. } else {
  146. //show the mail failed div
  147. $('#mail-fail').fadeIn(500);
  148. //re enable the submit button by removing attribute disabled and change the text back to Send The Message
  149. $('#contact-submit').removeAttr('disabled').attr('value', 'Send The Message');
  150. }
  151. });
  152. }
  153. });
  154. });
  155. // End Jquery Function
  156. /* ========================================================================= */
  157. /* Animated section
  158. /* ========================================================================= */
  159. var wow = new WOW({
  160. offset: 100, // distance to the element when triggering the animation (default is 0)
  161. mobile: false // trigger animations on mobile devices (default is true)
  162. });
  163. wow.init();
  164. /* ========================================================================= */
  165. /* Google Map Customization
  166. /* ========================================================================= */
  167. function initialize() {
  168. var latitude = $('#map-canvas').attr('data-latitude');
  169. var longitude = $('#map-canvas').attr('data-longitude');
  170. var myLatLng = new google.maps.LatLng(latitude, longitude);
  171. var roadAtlasStyles = [{
  172. "featureType": "landscape",
  173. "elementType": "geometry.fill",
  174. "stylers": [{
  175. "color": "#2F3238"
  176. }]
  177. }, {
  178. "elementType": "labels.text.fill",
  179. "stylers": [{
  180. "color": "#FFFFFF"
  181. }]
  182. }, {
  183. "elementType": "labels.text.stroke",
  184. "stylers": [{
  185. "visibility": "off"
  186. }]
  187. }, {
  188. "featureType": "road",
  189. "elementType": "geometry.fill",
  190. "stylers": [{
  191. "color": "#50525f"
  192. }]
  193. }, {
  194. "featureType": "road",
  195. "elementType": "geometry.stroke",
  196. "stylers": [{
  197. "visibility": "on"
  198. }, {
  199. "color": "#808080"
  200. }]
  201. }, {
  202. "featureType": "poi",
  203. "elementType": "labels",
  204. "stylers": [{
  205. "visibility": "off"
  206. }]
  207. }, {
  208. "featureType": "transit",
  209. "elementType": "labels.icon",
  210. "stylers": [{
  211. "visibility": "off"
  212. }]
  213. }, {
  214. "featureType": "poi",
  215. "elementType": "geometry",
  216. "stylers": [{
  217. "color": "#808080"
  218. }]
  219. }, {
  220. "featureType": "water",
  221. "elementType": "geometry.fill",
  222. "stylers": [{
  223. "color": "#3071a7"
  224. }, {
  225. "saturation": -65
  226. }]
  227. }, {
  228. "featureType": "road",
  229. "elementType": "labels.icon",
  230. "stylers": [{
  231. "visibility": "off"
  232. }]
  233. }, {
  234. "featureType": "landscape",
  235. "elementType": "geometry.stroke",
  236. "stylers": [{
  237. "color": "#bbbbbb"
  238. }]
  239. }];
  240. var mapOptions = {
  241. zoom: 14,
  242. center: myLatLng,
  243. disableDefaultUI: true,
  244. scrollwheel: false,
  245. navigationControl: false,
  246. mapTypeControl: false,
  247. scaleControl: false,
  248. draggable: false,
  249. mapTypeControlOptions: {
  250. mapTypeIds: [google.maps.MapTypeId.ROADMAP, 'roadatlas']
  251. }
  252. };
  253. var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
  254. var marker = new google.maps.Marker({
  255. position: myLatLng,
  256. map: map,
  257. title: '',
  258. });
  259. google.maps.event.addListener(marker, 'click', function () {
  260. infowindow.open(map, marker);
  261. });
  262. var styledMapOptions = {
  263. name: 'US Road Atlas'
  264. };
  265. var usRoadMapType = new google.maps.StyledMapType(
  266. roadAtlasStyles, styledMapOptions);
  267. map.mapTypes.set('roadatlas', usRoadMapType);
  268. map.setMapTypeId('roadatlas');
  269. }
  270. google.maps.event.addDomListener(window, "load", initialize);