PluginProbe
Polylang / 1.5.2
Polylang v1.5.2
3.8.9 3.8.8 3.8.7 3.8.6 3.8.5 3.8.4 3.8.3 2.7 2.7.0.1 2.7.1 2.7.2 2.7.3 2.7.4 2.8 2.8.1 2.8.2 2.8.3 2.8.4 2.9 2.9.1 2.9.2 3.0 3.0.1 3.0.2 3.0.3 All 233 releases
polylang / js / term.js

term.js in Polylang 1.5.2, at js/term.js

88 lines 2.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 // quick edit
2 if ('undefined' != typeof(inlineEditTax)) {
3 (function($) {
4 var $wp_inline_edit = inlineEditTax.edit;
5
6 inlineEditTax.edit = function( id ) {
7 $wp_inline_edit.apply( this, arguments );
8 var $term_id = 0;
9 if ( typeof( id ) == 'object' )
10 $term_id = parseInt( this.getId( id ) );
11
12 if ( $term_id > 0 ) {
13 var $edit_row = $('#edit-' + $term_id);
14 var $select = $edit_row.find(':input[name="inline_lang_choice"]');
15 $select.find('option:selected').removeProp('selected');
16 var lang = $('#lang_' + $term_id).html();
17 $("input[name='old_lang']").val(lang);
18 $select.find('option[value="'+lang+'"]').prop('selected', true);
19 }
20 }
21 })(jQuery);
22 }
23
24 jQuery(document).ready(function($) {
25 // translations autocomplete input box
26 function init_translations() {
27 $('.tr_lang').each(function(){
28 var tr_lang = $(this).attr('id').substring(8);
29 var td = $(this).parent().siblings('.pll-edit-column');
30
31 $(this).autocomplete({
32 minLength: 0,
33
34 source: ajaxurl + '?action=pll_terms_not_translated&term_language=' + $('#term_lang_choice').val() +
35 '&term_id=' + $("input[name='tag_ID']").val() + '&taxonomy=' + $("input[name='taxonomy']").val() +
36 '&translation_language=' + tr_lang + '&post_type=' + typenow + '&_pll_nonce=' + $('#_pll_nonce').val(),
37
38 select: function(event, ui) {
39 $('#htr_lang_'+tr_lang).val(ui.item.id);
40 td.html(ui.item.link);
41 },
42 });
43
44 // when the input box is emptied
45 $(this).blur(function() {
46 if (!$(this).val()) {
47 $('#htr_lang_'+tr_lang).val(0);
48 td.html(td.siblings('.hidden').children().clone());
49 }
50 });
51 });
52 }
53
54 init_translations();
55
56 // ajax for changing the term's language
57 $('#term_lang_choice').change(function() {
58 var data = {
59 action: 'term_lang_choice',
60 lang: $(this).val(),
61 term_id: $("input[name='tag_ID']").val(),
62 taxonomy: $("input[name='taxonomy']").val(),
63 post_type: typenow,
64 _pll_nonce: $('#_pll_nonce').val()
65 }
66
67 $.post(ajaxurl, data, function(response) {
68 var res = wpAjax.parseAjaxResponse(response, 'ajax-response');
69 $.each(res.responses, function() {
70 switch (this.what) {
71 case 'translations': // translations fields
72 $("#term-translations").html(this.data);
73 init_translations();
74 break;
75 case 'parent': // parent dropdown list for hierarchical taxonomies
76 $('#parent').replaceWith(this.data);
77 break;
78 case 'tag_cloud': // popular items
79 $('.tagcloud').replaceWith(this.data);
80 break;
81 default:
82 break;
83 }
84 });
85 });
86 });
87 });
88