5
|
1 |
jQuery( function ( $ ) { |
|
2 |
$( 'a.activate-option' ).click( function(){ |
|
3 |
var link = $( this ); |
|
4 |
if ( link.hasClass( 'clicked' ) ) { |
|
5 |
link.removeClass( 'clicked' ); |
|
6 |
} |
|
7 |
else { |
|
8 |
link.addClass( 'clicked' ); |
|
9 |
} |
|
10 |
$( '.toggle-have-key' ).slideToggle( 'slow', function() {}); |
|
11 |
return false; |
|
12 |
}); |
|
13 |
$('.akismet-status').each(function () { |
|
14 |
var thisId = $(this).attr('commentid'); |
|
15 |
$(this).prependTo('#comment-' + thisId + ' .column-comment'); |
|
16 |
}); |
|
17 |
$('.akismet-user-comment-count').each(function () { |
|
18 |
var thisId = $(this).attr('commentid'); |
|
19 |
$(this).insertAfter('#comment-' + thisId + ' .author strong:first').show(); |
|
20 |
}); |
|
21 |
$('#the-comment-list').find('tr.comment, tr[id ^= "comment-"]').find('.column-author a[title]').each(function () { |
|
22 |
// Comment author URLs are the only URL with a title attribute in the author column. |
|
23 |
var thisTitle = $(this).attr('title'); |
|
24 |
|
|
25 |
var thisCommentId = $(this).parents('tr:first').attr('id').split("-"); |
|
26 |
|
|
27 |
$(this).attr("id", "author_comment_url_"+ thisCommentId[1]); |
|
28 |
|
|
29 |
if (thisTitle) { |
|
30 |
$(this).after( |
|
31 |
$( '<a href="#" class="remove_url">x</a>' ) |
|
32 |
.attr( 'commentid', thisCommentId[1] ) |
|
33 |
.attr( 'title', WPAkismet.strings['Remove this URL'] ) |
|
34 |
); |
|
35 |
} |
|
36 |
}); |
|
37 |
$('.remove_url').live('click', function () { |
|
38 |
var thisId = $(this).attr('commentid'); |
|
39 |
var data = { |
|
40 |
action: 'comment_author_deurl', |
|
41 |
_wpnonce: WPAkismet.comment_author_url_nonce, |
|
42 |
id: thisId |
|
43 |
}; |
|
44 |
$.ajax({ |
|
45 |
url: ajaxurl, |
|
46 |
type: 'POST', |
|
47 |
data: data, |
|
48 |
beforeSend: function () { |
|
49 |
// Removes "x" link |
|
50 |
$("a[commentid='"+ thisId +"']").hide(); |
|
51 |
// Show temp status |
|
52 |
$("#author_comment_url_"+ thisId).html( $( '<span/>' ).text( WPAkismet.strings['Removing...'] ) ); |
|
53 |
}, |
|
54 |
success: function (response) { |
|
55 |
if (response) { |
|
56 |
// Show status/undo link |
|
57 |
$("#author_comment_url_"+ thisId) |
|
58 |
.attr('cid', thisId) |
|
59 |
.addClass('akismet_undo_link_removal') |
|
60 |
.html( |
|
61 |
$( '<span/>' ).text( WPAkismet.strings['URL removed'] ) |
|
62 |
) |
|
63 |
.append( ' ' ) |
|
64 |
.append( |
|
65 |
$( '<span/>' ) |
|
66 |
.text( WPAkismet.strings['(undo)'] ) |
|
67 |
.addClass( 'akismet-span-link' ) |
|
68 |
); |
|
69 |
} |
|
70 |
} |
|
71 |
}); |
|
72 |
|
|
73 |
return false; |
|
74 |
}); |
|
75 |
$('.akismet_undo_link_removal').live('click', function () { |
|
76 |
var thisId = $(this).attr('cid'); |
|
77 |
var thisUrl = $(this).attr('href'); |
|
78 |
var data = { |
|
79 |
action: 'comment_author_reurl', |
|
80 |
_wpnonce: WPAkismet.comment_author_url_nonce, |
|
81 |
id: thisId, |
|
82 |
url: thisUrl |
|
83 |
}; |
|
84 |
$.ajax({ |
|
85 |
url: ajaxurl, |
|
86 |
type: 'POST', |
|
87 |
data: data, |
|
88 |
beforeSend: function () { |
|
89 |
// Show temp status |
|
90 |
$("#author_comment_url_"+ thisId).html( $( '<span/>' ).text( WPAkismet.strings['Re-adding...'] ) ); |
|
91 |
}, |
|
92 |
success: function (response) { |
|
93 |
if (response) { |
|
94 |
// Add "x" link |
|
95 |
$("a[commentid='"+ thisId +"']").show(); |
|
96 |
// Show link. Core strips leading http://, so let's do that too. |
|
97 |
$("#author_comment_url_"+ thisId).removeClass('akismet_undo_link_removal').text( thisUrl.replace( /^http:\/\/(www\.)?/ig, '' ) ); |
|
98 |
} |
|
99 |
} |
|
100 |
}); |
|
101 |
|
|
102 |
return false; |
|
103 |
}); |
|
104 |
$('a[id^="author_comment_url"], tr.pingback td.column-author a:first-of-type').mouseover(function () { |
|
105 |
var wpcomProtocol = ( 'https:' === location.protocol ) ? 'https://' : 'http://'; |
|
106 |
// Need to determine size of author column |
|
107 |
var thisParentWidth = $(this).parent().width(); |
|
108 |
// It changes based on if there is a gravatar present |
|
109 |
thisParentWidth = ($(this).parent().find('.grav-hijack').length) ? thisParentWidth - 42 + 'px' : thisParentWidth + 'px'; |
|
110 |
if ($(this).find('.mShot').length == 0 && !$(this).hasClass('akismet_undo_link_removal')) { |
|
111 |
var self = $( this ); |
|
112 |
$('.widefat td').css('overflow', 'visible'); |
|
113 |
$(this).css('position', 'relative'); |
|
114 |
var thisHref = $.URLEncode( $(this).attr('href') ); |
|
115 |
$(this).append('<div class="mShot mshot-container" style="left: '+thisParentWidth+'"><div class="mshot-arrow"></div><img src="//s0.wordpress.com/mshots/v1/'+thisHref+'?w=450" width="450" class="mshot-image" style="margin: 0;" /></div>'); |
|
116 |
setTimeout(function () { |
|
117 |
self.find( '.mshot-image' ).attr('src', '//s0.wordpress.com/mshots/v1/'+thisHref+'?w=450&r=2'); |
|
118 |
}, 6000); |
|
119 |
setTimeout(function () { |
|
120 |
self.find( '.mshot-image' ).attr('src', '//s0.wordpress.com/mshots/v1/'+thisHref+'?w=450&r=3'); |
|
121 |
}, 12000); |
|
122 |
} else { |
|
123 |
$(this).find('.mShot').css('left', thisParentWidth).show(); |
|
124 |
} |
|
125 |
}).mouseout(function () { |
|
126 |
$(this).find('.mShot').hide(); |
|
127 |
}); |
|
128 |
$('.checkforspam:not(.button-disabled)').click( function(e) { |
|
129 |
$('.checkforspam:not(.button-disabled)').addClass('button-disabled'); |
|
130 |
$('.checkforspam-spinner').addClass( 'spinner' ); |
|
131 |
akismet_check_for_spam(0, 100); |
|
132 |
e.preventDefault(); |
|
133 |
}); |
|
134 |
|
|
135 |
function akismet_check_for_spam(offset, limit) { |
|
136 |
$.post( |
|
137 |
ajaxurl, |
|
138 |
{ |
|
139 |
'action': 'akismet_recheck_queue', |
|
140 |
'offset': offset, |
|
141 |
'limit': limit |
|
142 |
}, |
|
143 |
function(result) { |
|
144 |
if (result.processed < limit) { |
|
145 |
window.location.reload(); |
|
146 |
} |
|
147 |
else { |
|
148 |
akismet_check_for_spam(offset + limit, limit); |
|
149 |
} |
|
150 |
} |
|
151 |
); |
|
152 |
} |
|
153 |
}); |
|
154 |
// URL encode plugin |
|
155 |
jQuery.extend({URLEncode:function(c){var o='';var x=0;c=c.toString();var r=/(^[a-zA-Z0-9_.]*)/; |
|
156 |
while(x<c.length){var m=r.exec(c.substr(x)); |
|
157 |
if(m!=null && m.length>1 && m[1]!=''){o+=m[1];x+=m[1].length; |
|
158 |
}else{if(c[x]==' ')o+='+';else{var d=c.charCodeAt(x);var h=d.toString(16); |
|
159 |
o+='%'+(h.length<2?'0':'')+h.toUpperCase();}x++;}}return o;} |
|
160 |
}); |