PluginProbe
Polylang / 2.5
Polylang v2.5
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
← All changes | js/term.js +134 -174 2.82.5 View file →
@@ -1,34 +1,27 @@
1 -/**
2 - * @package Polylang
3 - */
4 -
5 1 // quick edit
6 2 (function( $ ) {
7 - $( document ).bind(
8 - 'DOMNodeInserted',
9 - function( e ) {
10 - var t = $( e.target );
3 + $( document ).bind( 'DOMNodeInserted', function( e ) {
4 + var t = $( e.target );
11 5
12 - // WP inserts the quick edit from
13 - if ( 'inline-edit' == t.attr( 'id' ) ) {
14 - var term_id = t.prev().attr( 'id' ).replace( "tag-", "" );
6 + // WP inserts the quick edit from
7 + if ( 'inline-edit' == t.attr( 'id' ) ) {
8 + var term_id = t.prev().attr( 'id' ).replace( "tag-", "" );
15 9
16 - if ( term_id > 0 ) {
17 - // language dropdown
18 - var select = t.find( ':input[name="inline_lang_choice"]' );
19 - var lang = $( '#lang_' + term_id ).html();
20 - select.val( lang ); // populates the dropdown
10 + if ( term_id > 0 ) {
11 + // language dropdown
12 + var select = t.find( ':input[name="inline_lang_choice"]' );
13 + var lang = $( '#lang_' + term_id ).html();
14 + select.val( lang ); // populates the dropdown
21 15
22 - // disable the language dropdown for default categories
23 - var default_cat = $( '#default_cat_' + term_id ).html();
24 - if ( term_id == default_cat ) {
25 - select.prop( 'disabled', true );
26 - }
16 + // disable the language dropdown for default categories
17 + var default_cat = $( '#default_cat_' + term_id ).html();
18 + if ( term_id == default_cat ) {
19 + select.prop( 'disabled', true );
27 20 }
28 21 }
29 22 }
30 - );
23 + });
31 24 })( jQuery );
32 25
33 26
34 27 // update rows of translated terms when adding / deleting a translation or when the language is modified in quick edit
@@ -33,175 +26,142 @@
33 26
34 27 // update rows of translated terms when adding / deleting a translation or when the language is modified in quick edit
35 28 // acts on ajaxSuccess event
36 29 (function( $ ) {
37 - $( document ).ajaxSuccess(
38 - function( event, xhr, settings ) {
39 - function update_rows( term_id ) {
40 - // collect old translations
41 - var translations = new Array();
42 - $( '.translation_' + term_id ).each(
43 - function() {
44 - translations.push( $( this ).parent().parent().attr( 'id' ).substring( 4 ) );
45 - }
46 - );
30 + $( document ).ajaxSuccess(function( event, xhr, settings ) {
31 + function update_rows( term_id ) {
32 + // collect old translations
33 + var translations = new Array;
34 + $( '.translation_' + term_id ).each(function() {
35 + translations.push( $( this ).parent().parent().attr( 'id' ).substring( 4 ) );
36 + });
47 37
48 - var data = {
49 - action: 'pll_update_term_rows',
50 - term_id: term_id,
51 - translations: translations.join( ',' ),
52 - taxonomy: $( "input[name='taxonomy']" ).val(),
53 - post_type: $( "input[name='post_type']" ).val(),
54 - screen: $( "input[name='screen']" ).val(),
55 - _pll_nonce: $( '#_pll_nonce' ).val()
56 - };
38 + var data = {
39 + action: 'pll_update_term_rows',
40 + term_id: term_id,
41 + translations: translations.join( ',' ),
42 + taxonomy: $( "input[name='taxonomy']" ).val(),
43 + post_type: $( "input[name='post_type']" ).val(),
44 + screen: $( "input[name='screen']" ).val(),
45 + _pll_nonce: $( '#_pll_nonce' ).val()
46 + }
57 47
58 - // get the modified rows in ajax and update them
59 - $.post(
60 - ajaxurl,
61 - data,
62 - function( response ) {
63 - if ( response ) {
64 - var res = wpAjax.parseAjaxResponse( response, 'ajax-response' );
65 - $.each(
66 - res.responses,
67 - function() {
68 - if ( 'row' == this.what ) {
69 - $( "#tag-" + this.supplemental.term_id ).replaceWith( this.data );
70 - }
71 - }
72 - );
48 + // get the modified rows in ajax and update them
49 + $.post( ajaxurl, data, function( response ) {
50 + if ( response ) {
51 + var res = wpAjax.parseAjaxResponse( response, 'ajax-response' );
52 + $.each( res.responses, function() {
53 + if ( 'row' == this.what ) {
54 + $( "#tag-" + this.supplemental.term_id ).replaceWith( this.data );
73 55 }
74 - }
75 - );
76 - }
56 + });
57 + }
58 + });
59 + }
77 60
78 - var data = wpAjax.unserialize( settings.data ); // what were the data sent by the ajax request?
79 - if ( 'undefined' != typeof( data['action'] ) ) {
80 - switch ( data['action'] ) {
81 - // when adding a term, the new term_id is in the ajax response
82 - case 'add-tag':
83 - res = wpAjax.parseAjaxResponse( xhr.responseXML, 'ajax-response' );
84 - $.each(
85 - res.responses,
86 - function() {
87 - if ( 'term' == this.what ) {
88 - update_rows( this.supplemental.term_id );
89 - }
90 - }
91 - );
61 + var data = wpAjax.unserialize( settings.data ); // what were the data sent by the ajax request?
62 + if ( 'undefined' != typeof( data['action'] ) ) {
63 + switch ( data['action'] ) {
64 + // when adding a term, the new term_id is in the ajax response
65 + case 'add-tag':
66 + res = wpAjax.parseAjaxResponse( xhr.responseXML, 'ajax-response' );
67 + $.each( res.responses, function() {
68 + if ( 'term' == this.what ) {
69 + update_rows( this.supplemental.term_id );
70 + }
71 + });
92 72
93 - // and also reset translations hidden input fields
94 - $( '.htr_lang' ).val( 0 );
95 - break;
73 + // and also reset translations hidden input fields
74 + $( '.htr_lang' ).val( 0 );
75 + break;
96 76
97 - // when deleting a term
98 - case 'delete-tag':
99 - update_rows( data['tag_ID'] );
100 - break;
77 + // when deleting a term
78 + case 'delete-tag':
79 + update_rows( data['tag_ID'] );
80 + break;
101 81
102 - // in case the language is modified in quick edit and breaks translations
103 - case 'inline-save-tax':
104 - update_rows( data['tax_ID'] );
105 - break;
106 - }
82 + // in case the language is modified in quick edit and breaks translations
83 + case 'inline-save-tax':
84 + update_rows( data['tax_ID'] );
85 + break;
107 86 }
108 87 }
109 - );
88 + });
110 89 })( jQuery );
111 90
112 -jQuery( document ).ready(
113 - function( $ ) {
114 - // translations autocomplete input box
115 - function init_translations() {
116 - $( '.tr_lang' ).each(
117 - function(){
118 - var tr_lang = $( this ).attr( 'id' ).substring( 8 );
119 - var td = $( this ).parent().parent().siblings( '.pll-edit-column' );
91 +jQuery( document ).ready(function( $ ) {
92 + // translations autocomplete input box
93 + function init_translations() {
94 + $( '.tr_lang' ).each(function(){
95 + var tr_lang = $( this ).attr( 'id' ).substring( 8 );
96 + var td = $( this ).parent().parent().siblings( '.pll-edit-column' );
120 97
121 - $( this ).autocomplete(
122 - {
123 - minLength: 0,
124 - source: ajaxurl + '?action=pll_terms_not_translated' +
125 - '&term_language=' + $( '#term_lang_choice' ).val() +
126 - '&term_id=' + $( "input[name='tag_ID']" ).val() +
127 - '&taxonomy=' + $( "input[name='taxonomy']" ).val() +
128 - '&translation_language=' + tr_lang +
129 - '&post_type=' + typenow +
130 - '&_pll_nonce=' + $( '#_pll_nonce' ).val(),
131 - select: function( event, ui ) {
132 - $( '#htr_lang_' + tr_lang ).val( ui.item.id );
133 - // ui.item.link is built and come from server side and is well escaped when necessary
134 - td.html( ui.item.link ); // phpcs:ignore WordPressVIPMinimum.JS.HTMLExecutingFunctions.html
135 - },
136 - }
137 - );
98 + $( this ).autocomplete({
99 + minLength: 0,
138 100
139 - // when the input box is emptied
140 - $( this ).blur(
141 - function() {
142 - if ( ! $( this ).val() ) {
143 - $( '#htr_lang_' + tr_lang ).val( 0 );
144 - // Value is retrieved from HTML already generated server side
145 - td.html( td.siblings( '.hidden' ).children().clone() ); // phpcs:ignore WordPressVIPMinimum.JS.HTMLExecutingFunctions.html
146 - }
147 - }
148 - );
101 + source: ajaxurl + '?action=pll_terms_not_translated' +
102 + '&term_language=' + $( '#term_lang_choice' ).val() +
103 + '&term_id=' + $( "input[name='tag_ID']" ).val() +
104 + '&taxonomy=' + $( "input[name='taxonomy']" ).val() +
105 + '&translation_language=' + tr_lang +
106 + '&post_type=' + typenow +
107 + '&_pll_nonce=' + $( '#_pll_nonce' ).val(),
108 +
109 + select: function( event, ui ) {
110 + $( '#htr_lang_' + tr_lang ).val( ui.item.id );
111 + td.html( ui.item.link );
112 + },
113 + });
114 +
115 + // when the input box is emptied
116 + $( this ).blur(function() {
117 + if ( ! $( this ).val() ) {
118 + $( '#htr_lang_' + tr_lang ).val( 0 );
119 + td.html( td.siblings( '.hidden' ).children().clone() );
149 120 }
150 - );
151 - }
121 + });
122 + });
123 + }
152 124
153 - init_translations();
125 + init_translations();
154 126
155 - // ajax for changing the term's language
156 - $( '#term_lang_choice' ).change(
157 - function() {
158 - var value = $( this ).val();
159 - var lang = $( this ).children( 'option[value="' + value + '"]' ).attr( 'lang' );
160 - var dir = $( '.pll-translation-column > span[lang="' + lang + '"]' ).attr( 'dir' );
127 + // ajax for changing the term's language
128 + $( '#term_lang_choice' ).change(function() {
129 + var value = $( this ).val();
130 + var lang = $( this ).children( 'option[value="' + value + '"]' ).attr( 'lang' );
131 + var dir = $( '.pll-translation-column > span[lang="' + lang + '"]' ).attr( 'dir' );
161 132
162 - var data = {
163 - action: 'term_lang_choice',
164 - lang: value,
165 - from_tag: $( "input[name='from_tag']" ).val(),
166 - term_id: $( "input[name='tag_ID']" ).val(),
167 - taxonomy: $( "input[name='taxonomy']" ).val(),
168 - post_type: typenow,
169 - _pll_nonce: $( '#_pll_nonce' ).val()
170 - };
133 + var data = {
134 + action: 'term_lang_choice',
135 + lang: value,
136 + from_tag: $( "input[name='from_tag']" ).val(),
137 + term_id: $( "input[name='tag_ID']" ).val(),
138 + taxonomy: $( "input[name='taxonomy']" ).val(),
139 + post_type: typenow,
140 + _pll_nonce: $( '#_pll_nonce' ).val()
141 + }
171 142
172 - $.post(
173 - ajaxurl,
174 - data,
175 - function( response ) {
176 - var res = wpAjax.parseAjaxResponse( response, 'ajax-response' );
177 - $.each(
178 - res.responses,
179 - function() {
180 - switch ( this.what ) {
181 - case 'translations': // translations fields
182 - // Data is built and come from server side and is well escaped when necessary
183 - $( "#term-translations" ).html( this.data ); // phpcs:ignore WordPressVIPMinimum.JS.HTMLExecutingFunctions.html
184 - init_translations();
185 - break;
186 - case 'parent': // parent dropdown list for hierarchical taxonomies
187 - $( '#parent' ).replaceWith( this.data );
188 - break;
189 - case 'tag_cloud': // popular items
190 - $( '.tagcloud' ).replaceWith( this.data );
191 - break;
192 - case 'flag': // flag in front of the select dropdown
193 - // Data is built and come from server side and is well escaped when necessary
194 - $( '.pll-select-flag' ).html( this.data ); // phpcs:ignore WordPressVIPMinimum.JS.HTMLExecutingFunctions.html
195 - break;
196 - }
197 - }
198 - );
143 + $.post( ajaxurl, data, function( response ) {
144 + var res = wpAjax.parseAjaxResponse( response, 'ajax-response' );
145 + $.each( res.responses, function() {
146 + switch ( this.what ) {
147 + case 'translations': // translations fields
148 + $( "#term-translations" ).html( this.data );
149 + init_translations();
150 + break;
151 + case 'parent': // parent dropdown list for hierarchical taxonomies
152 + $( '#parent' ).replaceWith( this.data );
153 + break;
154 + case 'tag_cloud': // popular items
155 + $( '.tagcloud' ).replaceWith( this.data );
156 + break;
157 + case 'flag': // flag in front of the select dropdown
158 + $( '.pll-select-flag' ).html( this.data );
159 + break;
160 + }
161 + });
199 162
200 - // Modifies the text direction
201 - $( 'body' ).removeClass( 'pll-dir-rtl' ).removeClass( 'pll-dir-ltr' ).addClass( 'pll-dir-' + dir );
202 - }
203 - );
204 - }
205 - );
206 - }
207 -);
163 + // Modifies the text direction
164 + $( 'body' ).removeClass( 'pll-dir-rtl' ).removeClass( 'pll-dir-ltr' ).addClass( 'pll-dir-' + dir );
165 + });
166 + });
167 +});