PluginProbe ʕ •ᴥ•ʔ
Nested Pages / trunk
Nested Pages vtrunk
3.2.14 3.1.8 3.1.9 3.2.0 3.2.1 3.2.10 3.2.11 3.2.12 3.2.13 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 trunk 1.0 1.1 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.2.1 1.3.0 1.3.1 1.3.10 1.3.11 1.3.12 1.3.13 1.3.14 1.3.15 1.3.2 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.6.1 1.6.2 1.6.3 1.6.3.1 1.6.3.2 1.6.4 1.6.5 1.6.5.1 1.6.5.2 1.6.6 1.6.7 1.6.8 1.7.0 1.7.1 2.0.1 2.0.2 2.0.3 2.0.4 3.0.1 3.0.10 3.0.11 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.10 3.1.11 3.1.12 3.1.13 3.1.14 3.1.15 3.1.16 3.1.17 3.1.18 3.1.19 3.1.2 3.1.20 3.1.21 3.1.22 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7
wp-nested-pages / assets / js / lib / nestedpages.wpml.js
wp-nested-pages / assets / js / lib Last commit date
jquery.mjs.nestedSortable.js 4 years ago jquery.ui.touch-punch.min.js 11 years ago nestedpages-factory.js 3 years ago nestedpages.bulk-actions.js 4 years ago nestedpages.check-all.js 9 years ago nestedpages.clone.js 3 years ago nestedpages.confirm-delete.js 8 years ago nestedpages.dropdowns.js 8 years ago nestedpages.formatter.js 3 years ago nestedpages.hidden-item-count.js 9 years ago nestedpages.manual-sync.js 9 years ago nestedpages.menu-links.js 3 years ago nestedpages.menu-search.js 1 year ago nestedpages.menu-toggle.js 8 years ago nestedpages.modals.js 8 years ago nestedpages.move-post.js 8 years ago nestedpages.nesting.js 3 years ago nestedpages.new-post.js 6 years ago nestedpages.page-toggle.js 4 years ago nestedpages.post-search.js 9 years ago nestedpages.quickedit-link.js 8 years ago nestedpages.quickedit-post.js 3 years ago nestedpages.settings-admin-customization.js 6 years ago nestedpages.settings-reset.js 6 years ago nestedpages.settings.js 3 years ago nestedpages.sync-menu-setting.js 8 years ago nestedpages.tabs.js 6 years ago nestedpages.trash-with-children.js 6 years ago nestedpages.trash.js 8 years ago nestedpages.userprefs-reset.js 7 years ago nestedpages.wpml.js 8 years ago
nestedpages.wpml.js
126 lines
1 var NestedPages = NestedPages || {};
2
3 /**
4 * WPML functionality
5 * @package Nested Pages
6 * @author Kyle Phillips - https://github.com/kylephillips/wp-nested-pages
7 */
8 NestedPages.Wpml = function()
9 {
10 var plugin = this;
11 var $ = jQuery;
12
13 plugin.button = null; // The quick edit button with all the data-attributes for the post
14 plugin.postData = null; // Object containing post data
15 plugin.modal = null; // The modal element
16 plugin.parent_li = null; // The post's nested pages list element
17 plugin.formatter = new NestedPages.Formatter;
18
19 plugin.selectors = {
20 translationsBtn : 'data-nestedpages-translations',
21 modal : 'data-np-wpml-translations-modal',
22 title : 'data-wmpl-translation-title',
23 table : 'data-np-wpml-translations-modal-table'
24 }
25
26 plugin.bindEvents = function()
27 {
28 if ( !nestedpages.wpml ) return;
29 $(document).on('click', '[' + plugin.selectors.translationsBtn + ']', function(e){
30 e.preventDefault();
31 plugin.createTranslationsModal($(this));
32 });
33 }
34
35 /**
36 * Create the translations modal
37 */
38 plugin.createTranslationsModal = function(button)
39 {
40 plugin.parent_li = $(button).parents('.action-buttons').closest(NestedPages.selectors.row).parent('li');
41 plugin.button = $(plugin.parent_li).find(NestedPages.selectors.quickEditOpen);
42 plugin.postData = {
43 id : $(plugin.button).attr('data-id'),
44 title : $(plugin.button).attr('data-title'),
45 slug : $(plugin.button).attr('data-slug')
46 }
47 plugin.modal = $('[' + plugin.selectors.modal + ']').clone();
48
49 if ( $(plugin.parent_li).children('ol').length > 0 ){
50 var child_ol = $(plugin.parent_li).children('ol');
51 $(plugin.modal).insertBefore(child_ol);
52 } else {
53 $(plugin.modal).appendTo(plugin.parent_li);
54 }
55 $(plugin.modal).find('[' + plugin.selectors.title + ']').text(plugin.postData.title);
56 plugin.formatter.showQuickEdit();
57 $(plugin.modal).show();
58 plugin.getTranslationData();
59 }
60
61 /**
62 * Get the Translation Data for the Post
63 */
64 plugin.getTranslationData = function()
65 {
66 $.ajax({
67 url: NestedPages.jsData.ajaxurl,
68 type: 'post',
69 datatype: 'json',
70 data : {
71 action : NestedPages.formActions.wpmlTranslations,
72 post_id : plugin.postData.id,
73 nonce : NestedPages.jsData.nonce
74 },
75 success: function(data){
76 console.log(data);
77 console.log(plugin.postData.id);
78 if ( data.status === 'success' ){
79 plugin.populateModal(data.translations);
80 } else {
81 $(plugin.modal).find(NestedPages.selectors.quickEditErrorDiv).text(data.message).show();
82 plugin.toggleLoading(false);
83 }
84 }
85 });
86 }
87
88 /**
89 * Open the Modal
90 */
91 plugin.populateModal = function(translations)
92 {
93 var html = '<tbody>';
94 $.each(translations, function(i, v){
95 var translation = translations[i];
96 html += '<tr>';
97 html += '<td><img src="' + translation.country_flag_url + '" alt="' + translation.translated_name + '" /> ' + translation.translated_name + '</td>';
98 html += '<td>';
99 if ( translation.has_translation && translation.edit_link ){
100 html += '<a href="' + translation.edit_link + '">' + translation.translation.post_title + ' (' + nestedpages.edit + ')</a>';
101 } else {
102 html += '<a href="' + translation.add_link + '" class="np-btn">+ ' + nestedpages.add_translation + '</a>';
103 }
104 html += '</td>';
105 html += '</tr>';
106 });
107 html += '</tbody>';
108 $(plugin.modal).find('[' + plugin.selectors.table + ']').html(html);
109 plugin.toggleLoading(false);
110 }
111
112 /**
113 * Toggle the Loading State
114 */
115 plugin.toggleLoading = function(loading)
116 {
117 if ( loading ){
118 $(plugin.modal).addClass('loading');
119 return;
120 }
121 $(plugin.modal).removeClass('loading');
122 }
123
124
125 return plugin.bindEvents();
126 }