-
Notifications
You must be signed in to change notification settings - Fork 0
/
wp-category-permalink.js
79 lines (72 loc) · 2.86 KB
/
wp-category-permalink.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
(function($) {
'use strict';
$.fn.sCategoryPermalink = function(options) {
var me = this;
this.find('.selectit').append(
'<span style="display: none; font-size: 11px; font-weight: normal !important; margin-left: 5px; top: -2px; position: relative;" class="taxa-value-selector">' +
'<span class="dashicons dashicons-heart" style="font-size: 18px; margin-top: 4px; line-height: inherit; color: rgba(255, 0, 0, 0.65);">' +
'</span>Permalink</span>')
.mouseenter(function() {
$(this).find('.taxa-value-selector').show();
})
.mouseleave(function() {
$(this).find('.taxa-value-selector').hide();
})
.change(function () {
if ($(this).prop('checked'))
return;
if ($(this).css('fontWeight') == 'bold') {
$('.permalink-taxa', me).val('');
$(this).css('fontWeight', 'normal');
}
});
this.find('.taxa-value-selector').click(function (event) {
event.preventDefault();
console.debug(event);
if ($(this).css('fontWeight') == 'bold') {
$('.permalink-taxa', me).val('');
$(this).css('fontWeight', 'normal');
}
me.find('.selectit').css('fontWeight', '');
$(this).parents('.selectit').css('fontWeight', 'bold');
$(this).parents('.selectit').find('input').prop('checked', true);
var val = $(this).prev().attr('value');
$('.permalink-taxa', me).val(val);
});
var taxonomy = $(this).data('taxonomy');
$(this).append('<input type="hidden" name="permalinkTaxa[' + taxonomy + ']" class="permalink-taxa" />');
if (options.current && options.current[taxonomy])
{
$(this).find('input[value="' + options.current[taxonomy] + '"]').prop('checked', true).parent('label').css('fontWeight', 'bold')
$('.permalink-taxa', me).val(options.current[taxonomy]);
}
return this;
};
}(jQuery));
jQuery(function($) {
'use strict';
$('.posts .scategory_permalink_name').each(function () {
var $this = $(this);
var category = $this.text().trim();
var categoryWithHtml = $this.html().trim();
if ( !category )
return;
else
{
var taxonomy = $this.attr('data-taxonomy');
if (taxonomy == 'category') {
taxonomy = 'categories';
}
var column = $this.parents('tr').children('.posts .column-' + taxonomy);
var content = column.html();
if (content)
{
content = content.replace('>'+category+'<', '><b>' + categoryWithHtml + '</b><');
column.html(content);
}
else {
console.debug('WP Category Permalink could not find a column named' + '.posts .column-' + taxonomy);
}
}
});
});