Site for my Call of Duty: Mobile clan. http://codm.ataraxy.tk
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

319 lines
8.7 KiB

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