-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnon-latin.js
34 lines (30 loc) · 912 Bytes
/
non-latin.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
jQuery(document).ready(function($){
// GD bbPress Attachments
$('[id^="d4p-bbp-attachment_"]:not(:has("img"))').each(function(){
var $this = $(this);
var parameter = {
id: $(this).attr('id').replace(/d4p-bbp-attachment_/,''),
action: 'filename_for_download'
};
$.get(nlf.ajaxurl, parameter,function(title){
$this.find('a:first').text(title).attr('title',title);
});
});
// replace download link
var attachments = [];
$('a[href^="' + nlf.upload_baseurl + '"]').each(function(){
attachments.push($(this).attr('href'));
});
if(attachments.length > 0){
var post_vars = {
'action': 'non_latin_attachments_get_download_url',
'attachments': attachments
};
$.post(nlf.ajaxurl, post_vars, function(result){
for (var i = result.length - 1; i >= 0; i--) {
var obj = result[i];
$('a[href="' + obj.guid + '"]').attr('download', obj.title);
}
}, 'json');
}
});