Advertisement
Heberth

theme-scripts.js

Apr 30th, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.93 KB | None | 0 0
  1. Query(document).ready(function($) {
  2.  
  3. /* Single Job Apply Validate */
  4.  
  5. $('#apply_form .main_form').validate({
  6. rules: {
  7. // simple rule, converted to {required:true}
  8. name: "required",
  9. // compound rule
  10. your_email: {
  11. required: true,
  12. email: true
  13. }
  14. }
  15. }
  16. );
  17.  
  18. /* Register Form Validate */
  19.  
  20. $('#login-form').validate({
  21. rules: {
  22. // simple rule, converted to {required:true}
  23. name: "required",
  24. // compound rule
  25. user_email: {
  26. required: true,
  27. email: true
  28. }
  29. }
  30. });
  31.  
  32.  
  33. /* Load more sponsored results */
  34.  
  35. $(document.body).on('click', 'a.more_sponsored_results', function(){
  36. var link = $(this);
  37. var source = $(this).attr('source');
  38. var tax = '';
  39. var term = '';
  40.  
  41. $(link).fadeOut('fast');
  42.  
  43. if ($(link).is('.front_page')) {
  44. load = 'more_front_results';
  45. } else if ($(link).is('.filter')) {
  46. if ( $(link).attr('tax') && $(link).attr('tax').length > 0 ) {
  47. tax = $(link).attr('tax');
  48. term = $(link).attr('term');
  49. }
  50. load = 'more_filter_results';
  51. } else if ($(link).is('.search_page')) {
  52. load = 'search';
  53. } else {
  54. load = '';
  55. }
  56.  
  57. var callback = $(this).attr("callback");
  58.  
  59. var data = {
  60. // get more sponsored results
  61. action: callback,
  62. security: jobroller_params.get_sponsored_results_nonce,
  63. page: $(link).attr('rel'),
  64. load: load,
  65. tax: tax,
  66. term: term
  67. };
  68.  
  69. $.post( jobroller_params.ajax_url, data, function(response) {
  70.  
  71. if ( ! response ) {
  72. $('.more_sponsored_results').replaceWith('<span>'+jobroller_params.no_more_results+'</span>');
  73. return;
  74. }
  75.  
  76. $('ol.sponsored_results[source="' + source + '"]').append(response);
  77. var current = parseInt($(link).attr('rel'));
  78. $(link).attr('rel', (current + 1)).fadeIn();
  79.  
  80. $('html, body').animate({
  81. scrollTop: $("li#more-" + current).offset().top
  82. }, 500);
  83.  
  84. });
  85.  
  86. return false;
  87.  
  88. });
  89.  
  90. /* Search Geo Location */
  91. function clientside_geo_lookup() {
  92.  
  93. var address_string = $('#near').val();
  94. if (address_string) {
  95.  
  96. var geo = new google.maps.Geocoder();
  97. geo.geocode({'address' : address_string}, function(results, status){
  98.  
  99. latitude = results[0].geometry.location.lat();
  100. longitude = results[0].geometry.location.lng();
  101. north_east_lat = results[0].geometry.bounds.getNorthEast().lat();
  102. south_west_lat = results[0].geometry.bounds.getSouthWest().lat();
  103. north_east_lng = results[0].geometry.bounds.getNorthEast().lng();
  104. south_west_lng = results[0].geometry.bounds.getSouthWest().lng();
  105.  
  106. full_address = results[0]['formatted_address'];
  107.  
  108. $('input#field_longitude').val( longitude );
  109. $('input#field_latitude').val( latitude );
  110. $('input#field_full_address').val( full_address );
  111. $('input#field_north_east_lat').val( north_east_lat );
  112. $('input#field_south_west_lat').val( south_west_lat );
  113. $('input#field_north_east_lng').val( north_east_lng );
  114. $('input#field_south_west_lng').val( south_west_lng );
  115.  
  116. });
  117. }
  118. $('#searchform').unbind('submit');
  119. setTimeout("jQuery('#searchform').submit();", 100);
  120. return false;
  121. }
  122. $('#searchform').bind('submit', function() {
  123. return clientside_geo_lookup();
  124. });
  125.  
  126. /* Placeholder fallback */
  127. $('[placeholder]').not("input[class*='tag-input-']").defaultValue();
  128.  
  129. /* Tag input */
  130. $('.tag-input-commas').tag( {separator: ','} );
  131.  
  132. /* Apply for job slider */
  133. $('#share_form, #apply_form:not(.open)').hide();
  134.  
  135. if ( $('#apply_form').is('.open') ) {
  136. $('a.apply_online').addClass('active');
  137. }
  138.  
  139. $('a.apply_online').click(function(){
  140. $('#job_map').slideUp();
  141. $('#share_form').slideUp();
  142. $('#apply_form').slideToggle();
  143. $('a.share').removeClass('active');
  144. $(this).toggleClass('active');
  145. return false;
  146. });
  147.  
  148. $('a.share').click(function(){
  149. $('#job_map').slideUp();
  150. $('#apply_form').slideUp();
  151. $('#share_form').slideToggle();
  152. $('a.apply_online').removeClass('active');
  153. $(this).toggleClass('active');
  154. return false;
  155. });
  156.  
  157. // Show single job apply and print section
  158. $('ul.section_footer').show();
  159.  
  160. // add jquery lazy load for images
  161. $('img:not(.load)').lazyload({
  162. effect:'fadeIn',
  163. placeholder: jobroller_params.lazyload_placeholder
  164. });
  165.  
  166. $('textarea.grow').autogrow();
  167.  
  168. // qTips
  169. $('h1.resume-title span, .resume_header img').qtip({
  170. content: {
  171. text: $('.user_prefs_wrap')
  172. },
  173. position: {
  174. corner: {
  175. tooltip: 'bottomMiddle',
  176. target: 'topMiddle'
  177. },
  178. adjust: {
  179. y: 8
  180. }
  181. },
  182. style: {
  183. width: 300,
  184. border: {
  185. width: 0,
  186. radius: 5
  187. },
  188. padding: 12,
  189. textAlign: 'left',
  190. tip: true,
  191. name: 'light'
  192. }
  193. });
  194. $('ol.resumes li').qtip({
  195. position: {
  196. corner: {
  197. tooltip: 'bottomMiddle',
  198. target: 'topMiddle'
  199. },
  200. adjust: {
  201. y: 14
  202. }
  203. },
  204. style: {
  205. width: 300,
  206. border: {
  207. width: 0,
  208. radius: 5
  209. },
  210. padding: 12,
  211. textAlign: 'left',
  212. tip: true,
  213. name: 'light'
  214. }
  215. });
  216.  
  217. function check_pass_strength () {
  218.  
  219. var pass = jQuery('#pass1').val();
  220. var pass3 = jQuery('#pass2').val();
  221. var user = jQuery('#user_login').val();
  222.  
  223. jQuery('#pass-strength-result').removeClass('short bad good strong');
  224. if ( ! pass ) {
  225. jQuery('#pass-strength-result').html( jobroller_params.si_empty );
  226. return;
  227. }
  228.  
  229. var strength = passwordStrength(pass, user, pass2);
  230.  
  231. if ( 2 == strength )
  232. jQuery('#pass-strength-result').addClass('bad').html( jobroller_params.si_bad );
  233. else if ( 3 == strength )
  234. jQuery('#pass-strength-result').addClass('good').html( jobroller_params.si_good );
  235. else if ( 4 == strength )
  236. jQuery('#pass-strength-result').addClass('strong').html( jobroller_params.si_strong );
  237. else if ( 5 == strength )
  238. jQuery('#pass-strength-result').addClass('short').html( jobroller_params.si_mismatch );
  239. else
  240. jQuery('#pass-strength-result').addClass('short').html( jobroller_params.si_short );
  241.  
  242. }
  243.  
  244. jQuery('#pass1, #pass2').val('').keyup( check_pass_strength );
  245.  
  246. try{convertEntities(jobroller_params);}catch(e){};
  247. });
  248.  
  249. /* Footables for smaller screens */
  250. $('.footable').footable();
  251.  
  252. /* Gateways */
  253.  
  254. $('form.gateway').addClass('custom');
  255.  
  256. var button_text = $('.section_content .row form button').text();
  257.  
  258. $('.section_content .row form button').parents('form').addClass('main_form');
  259. $('.section_content .row form button').replaceWith('<input type="submit" class="submit" value="' + button_text.trim() + '">');
  260.  
  261. /* Tabs */
  262.  
  263. var url = window.location.hash;
  264. var hash = url.substring( url.indexOf("#") + 1 );
  265.  
  266. if ( hash ) {
  267.  
  268. if ( undefined !== $('a[href="#'+hash+'"]').html() ) {
  269.  
  270. $('a[href="#'+hash+'"]').trigger('click');
  271.  
  272. $('html,body').animate( {scrollTop: $('a[href=#'+hash+']').offset().top-100} );
  273. }
  274.  
  275. }
  276.  
  277. /* Functions */
  278.  
  279. /* Load sponsored results on the background - async */
  280. function load_async_sponsored_results () {
  281.  
  282. $('div.async_sponsored_results').each( function() {
  283.  
  284. var link = $(this);
  285. var load = 'front_results';
  286. var tax = '';
  287. var term = '';
  288.  
  289. // front page sponsored results
  290. if ($(link).length > 0) {
  291. if ( $(link).attr('tax') && $(link).attr('tax').length > 0 ) {
  292. load = 'filter_results';
  293. tax = $(link).attr('tax');
  294. term = $(link).attr('term');
  295. }
  296. } else
  297. return;
  298.  
  299. var callback = $(this).attr("callback");
  300.  
  301. var data = {
  302. action: callback,
  303. security: jobroller_params.get_sponsored_results_nonce,
  304. load: load,
  305. tax: tax,
  306. term: term
  307. };
  308.  
  309. $.post( jobroller_params.ajax_url, data, function(response) {
  310.  
  311. $(link).html(response);
  312. $(link).fadeIn();
  313.  
  314. });
  315.  
  316. });
  317. }
  318.  
  319. /* Init sponsored results async load */
  320. load_async_sponsored_results();
  321. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement