PluginProbe
Polylang / 2.3.6
Polylang v2.3.6
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 / nav-menu.js

nav-menu.js in Polylang 2.3.6, at js/nav-menu.js

69 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 jQuery( document ).ready(function( $ ) {
2 $( '#update-nav-menu' ).bind( 'click', function( e ) {
3 if ( e.target && e.target.className && -1 != e.target.className.indexOf( 'item-edit' ) ) {
4 $( "input[value='#pll_switcher'][type=text]" ).parent().parent().parent().each(function(){
5 var item = $( this ).attr( 'id' ).substring( 19 );
6 $( this ).children( 'p:not( .field-move )' ).remove(); // remove default fields we don't need
7
8 h = $( '<input>' ).attr({
9 type: 'hidden',
10 id: 'edit-menu-item-title-' + item,
11 name: 'menu-item-title[' + item + ']',
12 value: pll_data.title
13 });
14 $( this ).append( h );
15
16 h = $( '<input>' ).attr({
17 type: 'hidden',
18 id: 'edit-menu-item-url-' + item,
19 name: 'menu-item-url[' + item + ']',
20 value: '#pll_switcher'
21 });
22 $( this ).append( h );
23
24 // a hidden field which exits only if our jQuery code has been executed
25 h = $( '<input>' ).attr({
26 type: 'hidden',
27 id: 'edit-menu-item-pll-detect-' + item,
28 name: 'menu-item-pll-detect[' + item + ']',
29 value: 1
30 });
31 $( this ).append( h );
32
33 ids = Array( 'hide_if_no_translation', 'hide_current', 'force_home', 'show_flags', 'show_names', 'dropdown' ); // reverse order
34
35 // add the fields
36 for ( var i = 0; i < ids.length; i++ ) {
37 p = $( '<p>' ).attr( 'class', 'description' );
38 $( this ).prepend( p );
39 label = $( '<label>' ).attr( 'for', 'edit-menu-item-' + ids[ i ] + '-' + item ).text( ' ' + pll_data.strings[ ids[ i ] ] );
40 p.append( label );
41 cb = $( '<input>' ).attr({
42 type: 'checkbox',
43 id: 'edit-menu-item-' + ids[ i ] + '-' + item,
44 name: 'menu-item-' + ids[ i ] + '[' + item + ']',
45 value: 1
46 });
47 if ( ( typeof( pll_data.val[ item ] ) != 'undefined' && pll_data.val[ item ][ ids[ i ] ] == 1 ) || ( typeof( pll_data.val[ item ] ) == 'undefined' && ids[ i ] == 'show_names' ) ) { // show_names as default value
48 cb.prop( 'checked', true );
49 }
50 label.prepend( cb );
51 }
52 });
53
54 // disallow unchecking both show names and show flags
55 $( '.menu-item-data-object-id' ).each(function() {
56 var id = $( this ).val();
57 var options = ['names-', 'flags-'];
58 $.each( options, function( i, v ) {
59 $( '#edit-menu-item-show_' + v + id ).change(function() {
60 if ( 'checked' != $( this ).attr( 'checked' ) ) {
61 $( '#edit-menu-item-show_' + options[ 1 - i ] + id ).prop( 'checked', true );
62 }
63 });
64 });
65 });
66 }
67 });
68 });
69