1/* 2 Any site-specific scripts you might have. 3 Note that <html> innately gets a class of "no-js". 4 This is to allow you to react to non-JS users. 5 Recommend removing that and adding "js" as one of the first things your script does. 6 Note that if you are using Modernizr, it already does this for you. :-) 7*/ 8 9 10jQuery(function($) { 11 var root = $('#logo').find('a').attr('href'), 12 template_dir = '/wp-content/themes/jobs.world.edu/'; 13 14 /*------------------------------------------------------------------------ 15 Fixes for Internet Explorer 16 ------------------------------------------------------------------------*/ 17 18 if ($.browser.msie) { 19 20 //Fix up placeholders 21 $('input:text[placeholder]').placeholderLabel(); 22 23 // This website is only applying fixes for IE7 and above. 24 if($.browser.version <= 8) { 25 26 //Fix Z-index issues 27 var zIndexNumber = 1000;// Put your target element(s) in the selector below! 28 $(".field").each(function() { 29 $(this).css('zIndex', zIndexNumber); 30 zIndexNumber -= 10; 31 }); 32 33 } 34 } 35 /*------------------------------------------------------------------------ 36 Taxonomy Tabs 37 ------------------------------------------------------------------------*/ 38 39 (function() { 40 41 //Tabs 42 $('.tabs').delegate('a', 'click', function(){ 43 var $self = $(this), 44 $related_tab = $($self.attr('href')) 45 $('.tab').hide(); 46 $('.tabs').find('a').removeClass('active'); 47 $related_tab.show().find('.top-level').hide().fadeIn(); 48 $self.addClass('active'); 49 return false; 50 }); 51 52 //Drop Downs 53 $('.tab') 54 .delegate('.top-level', 'click', function(){ 55 var $self = $(this), 56 $options = $(this).find('.taxonomy'); 57 if($self.hasClass('active')) { 58 $options.slideUp(); 59 } else { 60 $options.slideDown(); 61 } 62 $self.toggleClass('active'); 63 return false; 64 }) 65 .delegate('a', 'click', function(event){ 66 event.stopPropagation(); 67 }); 68 })(); 69 70 /*------------------------------------------------------------------------ 71 Main Pagination and Filtering 72 ------------------------------------------------------------------------*/ 73 74 (function() { 75 if(!$('.nav-next').find('a').length) return; 76 var $next = $('.nav-next').find('a'), 77 $pagination = $next.closest('#pagination'), 78 $url = $next.attr('href'), 79 $jobs = $('#jobs, #resumes'), 80 $filter = $('.filter'), 81 $more = $('<button />'), 82 $page_title = $('.pagetitle'); 83 84 //Filtering 85 $filter.submit(function(){ 86 $jobs.fadeTo('fast', 0.75); 87 $.get($(this).attr('action'), $(this).serialize(), function(data, textStatus) { 88 89 var $data = $(innerShiv(data,false)), 90 $results = $data.find('#jobs, resumes').html(); 91 $jobs.html($results); 92 $jobs.fadeTo('fast', 1); 93 94 //update the next button 95 if(!$data.find('.nav-next').find('a').length) { 96 $more.hide(); 97 } else { 98 $url = $data.find('.nav-next').find('a').attr('href'); 99 $more.html('View more results').show(); 100 } 101 102 //Display the "remove filter option 103 if($data.find('.remove-filters').length > 0) { 104 $page_title.find('.remove-filters').remove(); 105 $remove_filters = $data.find('.remove-filters'); 106 $remove_filters.appendTo('.pagetitle'); 107 } else { 108 $page_title.find('.remove-filters').remove(); 109 } 110 }); 111 return false; 112 }); 113 114 $filter.delegate('input', 'click', function(){ 115 $filter.trigger('submit'); 116 }); 117 118 //Pagination; 119 $more.addClass('more') 120 .html('Load more results') 121 .appendTo($pagination); 122 123 $pagination.find('a').hide(); 124 $pagination.delegate('.more', 'click', function() { 125 $jobs.fadeTo('fast', 0.75); 126 $more.html('Loading...'); 127 $.get($url, function(data){ 128 var $data = $(innerShiv(data,false)), 129 $results = $data.find('#jobs, #resumes').html(); 130 $jobs.html($jobs.html() + $results); 131 $jobs.fadeTo('fast', 1); 132 133 //update the next button 134 if(!$data.find('.nav-next').find('a').length) { 135 $more.hide(); 136 } else { 137 $url = $data.find('.nav-next').find('a').attr('href'); 138 $more.html('Load more results').show(); 139 } 140 141 }); 142 return false; 143 }) 144 })();
145 146 147 /*------------------------------------------------------------------------ 148 Job Detail Page 149 ------------------------------------------------------------------------*/ 150 (function() { 151 152 if(!$('.with-aside').length) return; 153 $('.block').equalHeights(); 154 155 if(!$('.apply').length) return; 156 $('.apply').fancybox(); 157 158 function apply_form($form) { 159 var $apply_form = $('#apply_form'), 160 loader = $('<img />'); 161 loader 162 .attr('src', root + template_dir + 'images/ajax-loader.gif') 163 .addClass('loader'); 164 165 $form.validate({ 166 errorElement: "strong", 167 errorPlacement: function(error, element) { 168 error.appendTo(element.parent().children('label')); 169 }, 170 submitHandler: function(form) { 171 $apply_form.append(loader); 172 $('.main_form, h2', $apply_form).fadeTo(100, 0.5); 173 var options = { 174 success: showResponse 175 }; 176 $(form).ajaxSubmit(options); 177 return false; 178 } 179 }); 180 } 181 // post-submit callback 182 function showResponse(responseText, statusText, xhr, $form) { 183 var $data = $(innerShiv(responseText,false)); 184 if($data.find('#apply_form_result.success').length > 0) { 185 $('#apply_form').html($data.find('#apply_form_result')); 186 187 //Close the fancybox 188 window.setTimeout(function(){$.fancybox.close();}, 2000); 189 190 } else { 191 $('#apply_form').html($data.find('#apply_form').html()); 192 } 193 //Re-bind the validation
194 apply_form($('#apply_form .main_form')); 195 $.fancybox.resize(); 196 } 197 198 //Init on load 199 apply_form($('#apply_form .main_form')); 200 201 })(); 202 203 204 205 /*------------------------------------------------------------------------ 206 Submit Job 207 ------------------------------------------------------------------------*/ 208 209 (function() { 210 if(!$('#submit_form').length) return; 211 validate($('#submit_form')); 212 213 var $company_details = $('#company-details'), 214 $your_name = $('#your_name'); 215 216 217 if($('#admin-org-select').val() != "") { 218 $company_details.fadeOut(); 219 $your_name.addClass('invalid').removeClass('required').removeClass('error'); 220 } 221 222 //Organisation selection for admin 223 $('#admin-org-select').live('change', function(){ 224 if($(this).val() != "") { 225 $company_details.fadeOut(); 226 $your_name.addClass('invalid').removeClass('required').removeClass('error'); 227 228 } else { 229 $company_details.fadeIn(); 230 $your_name.removeClass('invalid').addClass('required'); 231 } 232 }); 233 234 //Organisation selection for user 235 $('.org').find('input').live('click', function(){ 236 if($(this).is(":checked")) { 237 $company_details.fadeOut(); 238 $your_name.addClass('invalid').removeClass('required').removeClass('error'); 239 240 } else { 241 $company_details.fadeIn(); 242 $your_name.removeClass('invalid').addClass('required'); 243 } 244 }); 245 246 //Apply online selection 247 $('#apply-online').live('click', function(){ 248 var $apply_online_settings = $('#apply-online-settings'); 249 if($(this).is(":checked")) { 250 $apply_online_settings.fadeIn(); 251 252 } else { 253 $apply_online_settings.fadeOut(); 254 } 255 }); 256 257 //Attachments 258 $('#attachment-field-2').hide(); 259 $('#add-attachment').live('click', function(){ 260 $('#attachment-field-2').slideDown(); 261 $(this).fadeOut(); 262 return false; 263 }); 264 265 })(); 266 267 /*------------------------------------------------------------------------ 268 Preview Job 269 ------------------------------------------------------------------------*/ 270 271 (function() { 272 if(!$('#preview_form').length) return; 273 274 //Full Preview Link 275 $('.preview-link').fancybox({ 276 width:1020, 277 height: 800 278 }); 279 280 $('.pack').each(function() { 281 var $pack = $(this); 282 283 $pack.find('header, section').live('click', function(e){ 284 var $self = $(this).parent(); 285 var $radio = $self.find('input'); 286 if($radio.is(':checked')) { 287 $radio.removeAttr('checked'); 288 $self.removeClass('active'); 289 } else { 290 $radio.attr('checked', 'checked'); 291 $self.addClass('active'); 292 } 293 }); 294 295 }); 296 })(); 297 298 /*------------------------------------------------------------------------ 299 Related Jobs Pagination 300 ------------------------------------------------------------------------*/ 301 302 (function() { 303 if(!$('.widget-articles').find('.pagination').length) return; 304 var $pagination = $('.widget-articles').find('.pagination'), 305 $next = $pagination.find('.next'), 306 $url = $next.attr('href'), 307 $jobs = $('.related-articles'), 308 $more = $('<button />'); 309 310 //Pagination; 311 $more.addClass('more') 312 .html('Load more sugggestions...') 313 .appendTo($pagination); 314 315 $pagination.find('a').hide(); 316 $pagination.delegate('.more', 'click', function() { 317 $jobs.fadeTo('fast', 0.75); 318 $more.html('Loading...'); 319 $.get($url, function(data){ 320 var $data = $(innerShiv(data,false)), 321 $results = $data.find('.related-articles').html(); 322 $jobs.html($jobs.html() + $results); 323 $jobs.fadeTo('fast', 1); 324 325 //update the next button 326 if(!$data.find('.next').find('a').length) { 327 $more.hide(); 328 } else { 329 $url = $data.find('.next').find('a').attr('href'); 330 $more.html('Load more sugggestions...').show(); 331 } 332 333 }); 334 return false; 335 }) 336 })(); 337 338 339 /*------------------------------------------------------------------------ 340 Global form validation & select element styling 341 ------------------------------------------------------------------------*/ 342 343 (function() {
344 if(jQuery().validate) { 345 validate($('.content').find('form').not('.account_form')); 346 } 347 if(jQuery().tzSelect) { 348 $('select').tzSelect(); 349 } 350 351 })(); 352 353 function validate($form) { 354 $form.validate({ 355 errorElement: "strong", 356 errorPlacement: function(error, element) { 357 error.insertBefore(element); 358 error.parent().find('label').addClass('error'); 359 }, 360 success: function(label){ 361 label.parent().find('label').removeClass('error'); 362 label.removeClass('error').remove(); 363 } 364 }); 365 //Hack for date and email field validation 366 $('.text.date:not(".required"), .text.email:not(".required")').change(function(){ 367 if($(this).val() == '') { 368 $(this).parent().find('label').removeClass('error'); 369 } 370 }); 371 } 372 373 374 var W3CDOM = (document.createElement && document.getElementsByTagName); 375 function initFileUploads() { 376 if (!W3CDOM) return; 377 var fakeFileUpload = document.createElement('div'); 378 fakeFileUpload.className = 'fakefile'; 379 fakeFileUpload.appendChild(document.createElement('input')); 380 var image = document.createElement('img'); 381 image.src = root + template_dir + 'images/upload.png'; 382 fakeFileUpload.appendChild(image); 383 var x = document.getElementsByTagName('input'); 384 for (var i=0;i<x.length;i++) { 385 if (x[i].type != 'file') continue; 386 if (x[i].parentNode.className != 'fileinputs') continue; 387 //x[i].className = 'file '; 388 var clone = fakeFileUpload.cloneNode(true); 389 x[i].parentNode.appendChild(clone); 390 x[i].relatedElement = clone.getElementsByTagName('input')[0]; 391 x[i].onchange = x[i].onmouseout = function () { 392 this.relatedElement.value = this.value; 393 } 394 } 395 } 396 initFileUploads(); 397 398}); 399 400 401// Equal Heights 402jQuery.fn.equalHeights = function(options) { 403 var config = { 404 target: this, 405 source: this, 406 offset: 0 407 }; 408 409 if(options) $.extend(config, options); 410 411 var h = 0; 412 413 config.source.each(function(){ 414 if($(this).height() > h){ 415 h = $(this).height(); 416 } 417 }); 418 419 return config.target.height(h + config.offset); 420}; 421 422// http://jdbartlett.github.com/innershiv | WTFPL License 423window.innerShiv = (function() { 424 var d, r; 425 426 return function(h, u) { 427 if (!d) { 428 d = document.createElement('div'); 429 r = document.createDocumentFragment(); 430 /*@cc_on d.style.display = 'none';@*/ 431 } 432 433 var e = d.cloneNode(true); 434 /*@cc_on document.body.appendChild(e);@*/ 435 e.innerHTML = h.replace(/^\s\s*/, '').replace(/\s\s*$/, ''); 436 /*@cc_on document.body.removeChild(e);@*/ 437 438 if (u === false) return e.childNodes; 439 440 var f = r.cloneNode(true), i = e.childNodes.length; 441 while (i--) f.appendChild(e.firstChild); 442 443 return f; 444 } 445}()); 446 447/** 448 * Placeholder label 449 * https://github.com/AbleTech/jquery.placeholder-label 450 * 451 * Copyright (c) 2010 Able Technology Consulting Limited 452 * http://www.abletech.co.nz/ 453 */ 454(function($) {
455 $.placeholderLabel = { 456 placeholder_class: null, 457 add_placeholder: function(){ 458 if($(this).val() == $(this).attr('placeholder')){ 459 $(this).val('').removeClass($.placeholderLabel.placeholder_class); 460 } 461 }, 462 remove_placeholder: function(){ 463 if($(this).val() == ''){ 464 $(this).val($(this).attr('placeholder')).addClass($.placeholderLabel.placeholder_class); 465 } 466 }, 467 disable_placeholder_fields: function(){ 468 $(this).find("input[placeholder]").each(function(){ 469 if($(this).val() == $(this).attr('placeholder')){ 470 $(this).val(''); 471 } 472 }); 473 474 return true; 475 } 476 }; 477 478 $.fn.placeholderLabel = function(options) { 479 // detect modern browsers 480 var dummy = document.createElement('input'); 481 if(dummy.placeholder != undefined){ 482 return this; 483 } 484 485 var config = { 486 placeholder_class : 'placeholder' 487 }; 488 489 if(options) $.extend(config, options); 490 491 $.placeholderLabel.placeholder_class = config.placeholder_class; 492 493 this.each(function() { 494 var input = $(this); 495
496 input.focus($.placeholderLabel.add_placeholder); 497 input.blur($.placeholderLabel.remove_placeholder); 498 499 input.triggerHandler('focus'); 500 input.triggerHandler('blur'); 501 502 $(this.form).submit($.placeholderLabel.disable_placeholder_fields); 503 }); 504 505 return this; 506 } 507})(jQuery); 508 509 510 511 512 513 514 515 516 517 518
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.