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

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