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

script.js 8.4KB

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