1/* 2Title: Main Javascript 3Author: 3 Crown Creative 4*/ 5 6jQuery(document).ready(function() { 7 8 /* make all external links open in a new window */ 9 var a = new RegExp('/' + window.location.host + '/'); 10 var b = new RegExp("mailto:"); 11 jQuery('a').each(function() { 12 if (!a.test(this.href) && !b.test(this.href) && !jQuery(this).hasClass('popup') ) { 13 jQuery(this).addClass('external').attr('target', "_blank"); 14 } 15 }); 16 17 /* popup windows */ 18 jQuery('.popup').click(function(event) { 19 //this.removeAttr('target'); 20 var width = 665, 21 height = 780, 22 left = (jQuery(window).width() - width) / 2, 23 top = (jQuery(window).height() - height) / 2, 24 url = this.href, 25 opts = 'status=1' + 26 ',width=' + width + 27 ',height=' + height + 28 ',top=' + top + 29 ',left=' + left; 30 31 window.open(url, 'mywindow', opts); 32 33 return false; 34 }); 35 36 /* ajaxify the comment form */ 37 var commentform=jQuery('#commentform'); // find the comment form 38 commentform.prepend('<div id="comment-status" ></div>'); // add info panel before the form to provide feedback or errors 39 var statusdiv=jQuery('#comment-status'); // define the infopanel 40 41 commentform.submit(function(){ 42 var formdata=commentform.serialize(); // Serialize and store form data in a variable 43 statusdiv.html('<p>Processing...</p>'); // Add a status message 44 var formurl=commentform.attr('action'); // Extract action URL from commentform 45 var request = jQuery.ajax({ //Post Form with data 46 type: 'POST', 47 url: formurl, 48 data: commentform.serialize(), 49 error: function(XMLHttpRequest, textStatus, errorThrown){ 50 statusdiv.html('<p class="ajax-error" >You might have left one of the fields blank, or be posting too quickly</p>'); 51 }, 52 success: function(data){ 53 var commenttext = jQuery('#comment').val(); 54 var authorName = jQuery('#author').val(); 55 jQuery('<ol class="commentlist"><li class="comment"><strong>'+authorName+'</strong> says:<br><em>Your comment is awaiting moderation.</em><p><code>'+commenttext+'</code></li></ol>').insertBefore(respond); 56 statusdiv.html('<p class="ajax-success" >Thanks for your comment. We appreciate your response.</p>'); 57 commentform.find('textarea[name=comment]').val(''); 58 } 59 }); 60 return false; 61 }); 62 63 64 /* ajaxify the giveaway comment form */ 65 var giveawayform=jQuery('#giveawayForm'); // find the giveaway comment form 66 giveawayform.prepend('<div id="comment-status" ></div>'); // add info panel before the form to provide feedback or errors 67 var giveawayStatusdiv=jQuery('#comment-status'); // define the infopanel 68 69 giveawayform.submit(function(){ 70 var formdata=giveawayform.serialize(); 71 giveawayStatusdiv.html('<p>Processing...</p>'); 72 var formurl=giveawayform.attr('action'); 73 jQuery.ajax({ 74 type: 'post', 75 url: formurl, 76 data: formdata, 77 error: function(XMLHttpRequest, textStatus, errorThrown){ 78 giveawayStatusdiv.html('<p class="ajax-error" >Hmmm. Either you have not entered all the fields, or you have already entered the contest today.</p>'); 79 }, 80 success: function(data, textStatus){ 81 giveawayStatusdiv.html('<p class="ajax-success" >You have been entered in our getaway! Thank you and good luck!</p>'); 82 giveawayform.find('input[name=author]').val(''); 83 giveawayform.find('input[name=email]').val(''); 84 } 85 }); 86 return false; 87 }); 88 89 /* set the home page blocks to equal heights */ 90 $(function(){ $('#homeGroup0').equalHeights(); }); 91 $(function(){ $('#homeGroup3').equalHeights(); }); 92 93 $("a.fancybox").fancybox({ 94 'hideOnContentClick': true 95 }); 96 97}); 98 99//---------------------------------------------------------------------- 100// FUNCTION: set columns to equal heights on home page "blocks" 101//---------------------------------------------------------------------- 102$.fn.equalHeights = function(px) { 103 $(this).each(function(){ 104 var currentTallest = 0; 105 $(this).find('.fixedFeature').each(function(i){ 106 if ($(this).height() > currentTallest) { currentTallest = $(this).height(); } 107 }); 108 // for ie6, set height since min-height isn't supported 109 if ($.browser.msie && $.browser.version == 6.0) { 110 $(this).find('.fixedFeature').css({'height': currentTallest}); 111 } 112 $(this).find('.fixedFeature').css({'min-height': currentTallest}); 113 }); 114 return this; 115}; 116 117 118 119 120//---------------------------------------------------------------------- 121// FUNCTION: Open a new window 122//---------------------------------------------------------------------- 123function targetBlank (url) { 124 blankWin = window.open(url,'_blank','menubar=yes,toolbar=yes,location=yes,directories=yes,fullscreen=no,titlebar=yes,hotkeys=yes,status=yes,scrollbars=yes,resizable=yes'); 125} 126function popupWindow (url) { 127 popupWin = window.open(url,'popup','resizable=yes,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,fullscreen=no,dependent=no,width=550,height=550,status'); 128}
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.