|
1 jQuery(document).ready(function () { |
|
2 jQuery( '.switch-have-key' ).click( function() { |
|
3 var no_key = jQuery( this ).parents().find('div.no-key'); |
|
4 var have_key = jQuery( this ).parents().find('div.have-key'); |
|
5 |
|
6 no_key.addClass( 'hidden' ); |
|
7 have_key.removeClass( 'hidden' ); |
|
8 |
|
9 return false; |
|
10 }); |
|
11 jQuery( 'p.need-key a' ).click( function(){ |
|
12 document.akismet_activate.submit(); |
|
13 }); |
|
14 jQuery('.akismet-status').each(function () { |
|
15 var thisId = jQuery(this).attr('commentid'); |
|
16 jQuery(this).prependTo('#comment-' + thisId + ' .column-comment div:first-child'); |
|
17 }); |
|
18 jQuery('.akismet-user-comment-count').each(function () { |
|
19 var thisId = jQuery(this).attr('commentid'); |
|
20 jQuery(this).insertAfter('#comment-' + thisId + ' .author strong:first').show(); |
|
21 }); |
|
22 jQuery('#the-comment-list tr.comment .column-author a[title ^= "http://"]').each(function () { |
|
23 var thisTitle = jQuery(this).attr('title'); |
|
24 thisCommentId = jQuery(this).parents('tr:first').attr('id').split("-"); |
|
25 |
|
26 jQuery(this).attr("id", "author_comment_url_"+ thisCommentId[1]); |
|
27 |
|
28 if (thisTitle) { |
|
29 jQuery(this).after(' <a href="#" class="remove_url" commentid="'+ thisCommentId[1] +'" title="Remove this URL">x</a>'); |
|
30 } |
|
31 }); |
|
32 jQuery('.remove_url').live('click', function () { |
|
33 var thisId = jQuery(this).attr('commentid'); |
|
34 var data = { |
|
35 action: 'comment_author_deurl', |
|
36 _wpnonce: WPAkismet.comment_author_url_nonce, |
|
37 id: thisId |
|
38 }; |
|
39 jQuery.ajax({ |
|
40 url: ajaxurl, |
|
41 type: 'POST', |
|
42 data: data, |
|
43 beforeSend: function () { |
|
44 // Removes "x" link |
|
45 jQuery("a[commentid='"+ thisId +"']").hide(); |
|
46 // Show temp status |
|
47 jQuery("#author_comment_url_"+ thisId).html('<span>Removing...</span>'); |
|
48 }, |
|
49 success: function (response) { |
|
50 if (response) { |
|
51 // Show status/undo link |
|
52 jQuery("#author_comment_url_"+ thisId).attr('cid', thisId).addClass('akismet_undo_link_removal').html('<span>URL removed (</span>undo<span>)</span>'); |
|
53 } |
|
54 } |
|
55 }); |
|
56 |
|
57 return false; |
|
58 }); |
|
59 jQuery('.akismet_undo_link_removal').live('click', function () { |
|
60 var thisId = jQuery(this).attr('cid'); |
|
61 var thisUrl = jQuery(this).attr('href').replace("http://www.", "").replace("http://", ""); |
|
62 var data = { |
|
63 action: 'comment_author_reurl', |
|
64 _wpnonce: WPAkismet.comment_author_url_nonce, |
|
65 id: thisId, |
|
66 url: thisUrl |
|
67 }; |
|
68 jQuery.ajax({ |
|
69 url: ajaxurl, |
|
70 type: 'POST', |
|
71 data: data, |
|
72 beforeSend: function () { |
|
73 // Show temp status |
|
74 jQuery("#author_comment_url_"+ thisId).html('<span>Re-adding…</span>'); |
|
75 }, |
|
76 success: function (response) { |
|
77 if (response) { |
|
78 // Add "x" link |
|
79 jQuery("a[commentid='"+ thisId +"']").show(); |
|
80 // Show link |
|
81 jQuery("#author_comment_url_"+ thisId).removeClass('akismet_undo_link_removal').html(thisUrl); |
|
82 } |
|
83 } |
|
84 }); |
|
85 |
|
86 return false; |
|
87 }); |
|
88 jQuery('a[id^="author_comment_url"]').mouseover(function () { |
|
89 var wpcomProtocol = ( 'https:' === location.protocol ) ? 'https://' : 'http://'; |
|
90 // Need to determine size of author column |
|
91 var thisParentWidth = jQuery(this).parent().width(); |
|
92 // It changes based on if there is a gravatar present |
|
93 thisParentWidth = (jQuery(this).parent().find('.grav-hijack').length) ? thisParentWidth - 42 + 'px' : thisParentWidth + 'px'; |
|
94 if (jQuery(this).find('.mShot').length == 0 && !jQuery(this).hasClass('akismet_undo_link_removal')) { |
|
95 var thisId = jQuery(this).attr('id').replace('author_comment_url_', ''); |
|
96 jQuery('.widefat td').css('overflow', 'visible'); |
|
97 jQuery(this).css('position', 'relative'); |
|
98 var thisHref = jQuery.URLEncode(jQuery(this).attr('href')); |
|
99 jQuery(this).append('<div class="mShot mshot-container" style="left: '+thisParentWidth+'"><div class="mshot-arrow"></div><img src="'+wpcomProtocol+'s0.wordpress.com/mshots/v1/'+thisHref+'?w=450" width="450" class="mshot-image_'+thisId+'" style="margin: 0;" /></div>'); |
|
100 setTimeout(function () { |
|
101 jQuery('.mshot-image_'+thisId).attr('src', wpcomProtocol+'s0.wordpress.com/mshots/v1/'+thisHref+'?w=450&r=2'); |
|
102 }, 6000); |
|
103 setTimeout(function () { |
|
104 jQuery('.mshot-image_'+thisId).attr('src', wpcomProtocol+'s0.wordpress.com/mshots/v1/'+thisHref+'?w=450&r=3'); |
|
105 }, 12000); |
|
106 } else { |
|
107 jQuery(this).find('.mShot').css('left', thisParentWidth).show(); |
|
108 } |
|
109 }).mouseout(function () { |
|
110 jQuery(this).find('.mShot').hide(); |
|
111 }); |
|
112 }); |
|
113 // URL encode plugin |
|
114 jQuery.extend({URLEncode:function(c){var o='';var x=0;c=c.toString();var r=/(^[a-zA-Z0-9_.]*)/; |
|
115 while(x<c.length){var m=r.exec(c.substr(x)); |
|
116 if(m!=null && m.length>1 && m[1]!=''){o+=m[1];x+=m[1].length; |
|
117 }else{if(c[x]==' ')o+='+';else{var d=c.charCodeAt(x);var h=d.toString(16); |
|
118 o+='%'+(h.length<2?'0':'')+h.toUpperCase();}x++;}}return o;} |
|
119 }); |
|
120 // Preload mshot images after everything else has loaded |
|
121 jQuery(window).load(function() { |
|
122 var wpcomProtocol = ( 'https:' === location.protocol ) ? 'https://' : 'http://'; |
|
123 jQuery('a[id^="author_comment_url"]').each(function () { |
|
124 jQuery.get(wpcomProtocol+'s0.wordpress.com/mshots/v1/'+jQuery.URLEncode(jQuery(this).attr('href'))+'?w=450'); |
|
125 }); |
|
126 }); |