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