first commit

This commit is contained in:
2023-09-12 21:41:04 +02:00
commit 3361a7f053
13284 changed files with 2116755 additions and 0 deletions

View File

@@ -0,0 +1 @@
.icl-st-inline{border:1px solid #ddd;padding:1px;clear:both;display:none}.icl-st-table{width:100%}.wpml-st-col-string{width:30%}.wpml-st-col-string .icl-st-original{word-break:break-all}.wpml-st-col-string .spinner{float:left;margin:0 3px}.icl-st-tablenav{height:auto}.icl-st-bulk-actions input.button,.icl-st-bulk-actions .wpml_select2-container{margin:3px 1px}.icl-st-per-page{margin-top:2px}.icl-st-per-page select{font-size:12px;min-height:0}.colthree{width:48%;float:left;padding-right:8px}.colthree h4{margin-bottom:0}.meta_comment{font-style:italic;color:#777}p.sub{color:#444444;font-size:12px;margin:0 0 5px 0}div.postbox div.inside{margin:10px;position:relative}#icl_show_source_top{position:fixed;margin-left:-10px}.icl_string_track_source pre{height:100%;background-color:#fefefe;border:1px solid #eee}.icl_string_track_source ol{line-height:10px}.icl_string_track_source ol li{font-size:10px;margin:0;list-style-position:inside;padding:0;line-height:5px}.icl_string_track_source.icl_string_track_filename{position:fixed;font-size:10px;margin:-25px 0 0 -5px;color:#fff;background-color:#222222}.icl_string_track_url{font-size:10px;height:16px;overflow:hidden;white-space:nowrap}#colorPickerDiv{background-color:#000;color:#fff;border:1px solid #000}#icl_st_option_writes ul.icl_st_option_writes{margin-left:20px}.icl_st_admin_string{padding:2px;float:left;margin-bottom:5px}.icl_st_numeric{background-color:#d5e8f9;border:1px solid #9bc8f0}.icl_st_string{background-color:#f3ece2;border:1px solid #c4a26f}span.icl_st_numeric,span.icl_st_string{padding:2px;border-radius:4px}.icl_stow_head{float:left}#icl_st_options_write_success{padding:4px}tr.st_requires_update td{background-color:#fef7f1}tr.st_requires_update>td:first-child{border-left:4px solid #d54e21}tr.st_requires_update .update-message{font-size:13px;font-weight:normal;padding:6px 12px;margin:0 31px 8px 10px;background-color:rgba(247,247,247,0.03)}tr.st_requires_update .update-message:before{color:#d54e21;display:inline-block;font:normal 20px/1 'dashicons';-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;vertical-align:top;content:'\f463';margin:0 -2px 0 8px}@media aural{tr.st_requires_update .update-message:before{speak:none}}.wpml-st-col-domain,.wpml-st-col-name{width:15%;word-break:break-all}.wpml-cdl-summary{margin-top:30px}.wpml-cdl-table{margin-bottom:40px}.wpml-cdl-table .num{text-align:right}.wpml-cdl-table,.wpml-cdl-info{width:90%;max-width:500px;margin-left:5%}label[for="wpml-cdl-set-default"]{display:block;margin-top:5px}.wpml-st-exclude-contexts .wpml-st-excluded-info{font-weight:bold}.wpml-st-exclude-contexts-box .contexts p{float:left;width:50%}.wpml-st-exclude-contexts-box .wpml-st-filter-and-select-all-box{border-bottom:1px solid #e5e5e5}.wpml-st-cancel-button{margin-right:20px}.wpml_plugin_table_filters>li{display:inline-block}.wpml-st-mo-translation{background-color:#f6f647;margin-bottom:5px;display:inline-block}.wpml-mo-scan-message{margin-top:24px;margin-bottom:24px;padding:16px}.wpml-mo-scan-message>*:first-child{margin-top:0}.wpml-mo-scan-message h2,.wpml-mo-scan-message h3{font-weight:500;margin:0.7em 0 0.5em}#icl_st_send_strings h3{font-size:17px;line-height:1.4em;margin:10px 0}#icl_st_send_strings .st-translate-strings-table{min-width:250px}#icl_st_send_strings .st-translate-strings-table h4{margin-top:0;font-size:1.3em;font-weight:bold;color:#32373c}#icl_st_send_strings .st-translate-strings-table tr td:first-of-type{width:20px;padding-right:0}#icl_st_send_strings .st-translate-strings-table label{font-size:14px;line-height:1.3em}#icl_st_send_strings .st-translate-strings-table img{position:relative;top:2px}#icl_st_send_strings #icl_send_strings{margin:50px 0 30px 10px;display:block}#icl_st_send_strings #icl_send_strings .otgs-ico-basket{color:#fff;top:-2px;position:relative;margin-right:5px}#icl_st_send_strings #icl_send_strings:disabled .otgs-ico-basket{color:#66c6e4}.wpml-strings-widgets #dashboard-widgets .postbox .handlediv{float:left}.wpml-strings-widgets #dashboard-widgets .postbox .handlediv svg{-webkit-transform:rotate(90deg);transform:rotate(90deg);display:inline-block;margin:17px 0 0 15px}.wpml-strings-widgets #dashboard-widgets .postbox h3.hndle{padding:14px;margin-bottom:0;border:none}.wpml-strings-widgets #dashboard-widgets .postbox.closed .handlediv svg{-webkit-transform:none;transform:none}.wpml-strings-widgets #dashboard-widgets .postbox .inside{margin-bottom:10px}.wpml-strings-widgets #dashboard-widgets .postbox p:last-child{margin-bottom:0}.wpml-string-translation-filter{line-height:220%}.wpml-string-translation-filter select,.wpml-string-translation-filter input.button{margin:3px 1px;vertical-align:middle}

View File

@@ -0,0 +1 @@
.icl_st_admin_string,span.icl_st_numeric,span.icl_st_string{padding:2px;-moz-border-radius:4px}.colthree,.icl_stow_head{float:left}.icl-st-inline{border:1px solid #ddd;padding:1px;clear:both;display:none}.icl-st-table{width:100%}.icl-st-table textarea{font-size:10px;padding:1px;margin:0;line-height:normal}.colthree{width:48%;padding-right:8px}.colthree h4{margin-bottom:0}.meta_comment{font-style:italic;color:#777}p.sub{color:#444;font-family:Verdana;font-size:12px;margin:0 0 5px 0}div.postbox div.inside{margin:10px;position:relative}#icl_show_source_top{position:fixed;margin-left:-10px}.icl_string_track_source pre{height:100%;font-family:Arial;background-color:#fefefe;border:1px solid #eee}.icl_string_track_source ol{line-height:10px}.icl_string_track_source ol li{font-size:10px;margin:0;list-style-position:inside;padding:0;line-height:5px}.icl_string_track_source .icl_string_track_filename{position:fixed;font-size:10px;margin:-25px 0 0 -5px;color:#fff;background-color:#222}.icl_string_track_url{font-size:10px;height:16px;overflow:hidden;white-space:nowrap}#colorPickerDiv{background-color:#000;color:#fff;border:1px solid #000}#icl_st_option_writes ul.icl_st_option_writes{margin-left:20px}.icl_st_admin_string{float:left;margin-bottom:5px}.icl_st_numeric{background-color:#d5e8f9;border:1px solid #9bc8f0}.icl_st_string{background-color:#f3ece2;border:1px solid #c4a26f}#icl_st_options_write_success{padding:4px}a.icl_stow_toggler{text-decoration:none}#icl_st_ow_export_close,#icl_st_ow_export_out{display:none}#icl_st_ow_export_out textarea{width:100%;height:200px;font-size:10px}

View File

@@ -0,0 +1 @@
.wpml-section-content a{text-decoration:none}.wpml-st-localization .spinner{float:left}.wpml-st-localization button{float:left}.wpml-st-localization .wpml-section-content .state-selector li{display:inline;padding-right:5px}.wpml-st-localization .wpml-section-content .state-selector li.active{font-weight:bold}.wpml-st-localization .wpml-section-content .state-selector li:hover{cursor:pointer}.wpml-st-localization .wpml-section-content .other-options-save{float:right}.wpml-st-localization .wpml-section-content li a:hover,.wpml-st-localization .wpml-section-content a:active{color:#21759b}.wpml-st-localization .wpml-section-content li a.wpml_st_pop_download:hover,.wpml-st-localization .wpml-section-content li a.wpml_st_pop_download:active{color:inherit}.wpml-st-localization .wpml-section-content .wpml-col-center{text-align:center}.wpml-st-localization .wpml-section-content .otgs-ico-translated::before{font-size:20px;color:#008000}.wpml-st-localization .wpml-section-content .otgs-ico-needs-update::before{font-size:20px;color:#FFB900}.wpml-st-localization li{height:30px;padding-bottom:10px}.wpml-st-localization li a{color:#555;text-decoration:underline}.wpml-st-localization .wpml-translated li{color:#008000;font-weight:bold;text-align:center}.wpml-st-localization .wpml-needs-update li{color:#FFB900;font-weight:bold;text-align:center;display:block;min-height:20px}.wpml-st-localization .wpml-needs-update li a{color:inherit}.wpml-scan-results{height:200px;display:none;clear:both;overflow:scroll;margin:30px 0 0 0;padding:20px;max-width:900px;border-bottom:1px solid #ededed;background:#fff}

View File

@@ -0,0 +1 @@
#wp-admin-bar-WPML_PACKAGE_LANG .ab-item img{width:18px !important;height:12px !important}.wpml-package-popup{display:none;position:fixed;z-index:9002;width:200px;padding:10px;background-color:#32373c;color:rgba(240,245,250,0.7)}.wpml-package-popup h2{margin-top:0;color:rgba(240,245,250,0.7)}.wpml-package-popup .wpml-simple-lang-selector{margin:10px 0 7px}.wpml-package-popup .wpml-simple-lang-selector .wpml_select2-choice{background-color:#fff}

Binary file not shown.

After

Width:  |  Height:  |  Size: 673 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 256 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 803 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 721 B

View File

@@ -0,0 +1,232 @@
jQuery(function () {
WPML_String_Translation.AutoRegisterStrings.init(jQuery('.wpml-st-auto-register-strings'));
});
var WPML_String_Translation = WPML_String_Translation || {};
WPML_String_Translation.AutoRegisterStrings = {
init: function(box) {
this.form = box.find('form');
this.box = box;
this.checkBox = this.box.find('.js-auto-register-enabled');
this.description = this.box.find('.js-auto-register-description');
this.intervalMilliseconds = 1000;
this.runningCountdown = this.description.data('running-countdown');
this.dialog = this.form.parent();
this.updateDescription();
this.update_excluded_preview();
this.create_dialog();
this.form.find('input[name = "select_all"]').on('click', {'form': this.form}, this.select_all);
this.form.find('input[name = "search"]').on('keyup', {'form': this.form}, this.filter);
this.form.find('.contexts input:checkbox').on('change', {'form': this.form}, this.toggle_context);
this.checkBox.on('change', this.checkBoxChanged.bind( this ) );
},
create_dialog: function () {
var that = this;
this.dialog.dialog({
autoOpen: false,
width: 1150,
height: 600,
modal: true,
buttons: [
{
class: 'wpml-st-cancel-button',
text: 'Cancel',
click: function() {
jQuery( this ).dialog( 'close' );
}
},
{
text: 'Apply',
class: 'button-primary js-wpml-st-apply-button',
click: function() {
that.save(true);
}
}
]
});
this.box.find('.js-wpml-autoregister-edit-contexts').on( 'click', {'dialog' : this.dialog}, function(event) {
event.preventDefault();
event.data.dialog.dialog( 'open' );
});
},
save: function(fromDialog) {
var that = this;
var apply_button;
if (fromDialog) {
apply_button = this.dialog.parent().find('.js-wpml-st-apply-button');
apply_button.prop('disabled', true);
}
var data = {
action: 'wpml_st_exclude_contexts',
wpml_st_auto_reg_excluded_contexts: this.get_excluded_contexts(),
auto_register_enabled: this.isEnabled(),
nonce: this.form.data('nonce')
};
jQuery.ajax({
url: ajaxurl,
type: 'POST',
data: data,
dataType: 'json',
success: function (response) {
if (response.success) {
that.update_excluded_preview();
if (fromDialog) {
that.dialog.dialog('close');
}
} else {
that.display_error_msg('Error: ' + response.data);
}
if (fromDialog) {
apply_button.prop('disabled', false);
}
}
});
this.updateDescription();
},
update_excluded_preview: function() {
var container = this.box.find('.wpml-st-excluded-info');
var excluded = this.get_excluded_contexts();
var included = this.get_included_contexts();
if (excluded.length == 0) {
var text = container.data('all-included');
container.html(text);
} else if(included.length == 0) {
var text = container.data('all-excluded');
container.html(text);
} else {
var limit = 4;
var elements = included.length > excluded.length ? excluded : included;
var text = included.length > excluded.length ? container.data('excluded-preview') : container.data('included-preview');
text += ' ' + elements.slice(0, limit).join(', ');
if (elements.length > limit) {
text += ' ' + container.data('preview-suffix');
}
container.html(text);
}
},
get_excluded_contexts: function () {
var excluded = [];
this.form.find('.contexts input:checkbox').not(':checked').each(function() {
excluded.push(jQuery(this).val());
});
return excluded;
},
get_included_contexts: function () {
var included = [];
this.form.find('.contexts input:checkbox:checked').each(function() {
included.push(jQuery(this).val());
});
return included;
},
display_error_msg: function (msg) {
alert(msg);
},
toggle_context: function(event) {
if (jQuery(this).is(':checked')) {
if (event.data.form.find('.contexts input:checkbox:not(:checked)').length == 0) {
event.data.form.find('input[name = "select_all"]').prop( 'checked', true );
}
} else {
event.data.form.find('input[name = "select_all"]').prop( 'checked', false );
}
},
select_all: function(event) {
if (jQuery(this).is(':checked')) {
event.data.form.find('.contexts input').prop( 'checked', true );
} else {
event.data.form.find('.contexts input').prop( 'checked', false );
}
},
filter: function(event) {
var text = jQuery(this).val().toLowerCase();
if (text.length < 2) {
event.data.form.find('.contexts p').show();
return;
}
event.data.form.find('.contexts p span').each(function () {
if (jQuery(this).text().toLowerCase().search(text) != -1) {
jQuery(this).parents('p').show();
} else {
jQuery(this).parents('p').hide();
}
})
},
checkBoxChanged: function() {
this.save(false);
this.box.find('.wpml-st-excluded-info-wrapper').slideToggle();
},
isEnabled: function() {
return this.checkBox.is(':checked')
},
updateDescription: function() {
const that = this;
clearInterval(this.interval);
if ( this.isEnabled() ) {
this.initCountDown();
const rawString = this.description.data('enabled-string');
this.refreshCountDownInDescription(rawString);
this.interval = setInterval( function(rawString) {
that.refreshCountDownInDescription(rawString);
}, this.intervalMilliseconds, rawString);
} else {
this.description.html(this.description.data('disabled-string'));
}
},
initCountDown: function() {
if (this.runningCountdown > 0) {
this.secondsToEnd = this.runningCountdown;
this.runningCountdown = 0;
} else {
this.secondsToEnd = this.description.data('reset-countdown');
}
},
refreshCountDownInDescription: function(rawString) {
const date = new Date(null);
date.setSeconds(this.secondsToEnd);
const description = rawString.replace('%s', date.toISOString().substr(11, 8));
this.description.html(description);
this.secondsToEnd = this.secondsToEnd - (this.intervalMilliseconds / 1000);
if (this.secondsToEnd < 1) {
this.checkBox.click();
}
}
}

View File

@@ -0,0 +1,204 @@
/*jshint devel:true */
/*global jQuery, ajaxurl */
var WPML_String_Translation = WPML_String_Translation || {};
WPML_String_Translation.ChangeDomainLanguage = function () {
"use strict";
var privateData = {};
var init = function () {
jQuery(function () {
privateData.summary_div = jQuery('#wpml-change-domain-language-dialog').find('.js-summary');
privateData.lang_select = jQuery(privateData.summary_div).find('select');
privateData.apply_button = jQuery('#wpml-change-domain-language-dialog-apply-button');
privateData.table_body = privateData.summary_div.find('table').find('tbody');
privateData.domain_select = jQuery('#wpml-domain-select');
privateData.check_all = jQuery(privateData.summary_div).find('.js-all-check');
privateData.lang_area = jQuery(privateData.summary_div).find('.js-lang-select-area');
setupDialog();
jQuery('#wpml-language-of-domains-link').on('click', showDialog);
privateData.domain_select.on('change', showSummary);
privateData.apply_button.prop('disabled', true).addClass('button-primary');
privateData.check_all.on('click', checkAllClick);
privateData.lang_select.on('change', changeLanguage);
jQuery(privateData.summary_div).find('.js-default').on('click', enableApplyButton);
});
};
var setupDialog = function () {
privateData.change_lang_dialog = jQuery('#wpml-change-domain-language-dialog');
privateData.change_lang_dialog.dialog({
autoOpen: false,
resizable: false,
modal: true,
minWidth: 600,
closeText: privateData.change_lang_dialog.data('cancel-text'),
closeOnEscape: true,
buttons: [
{
id: 'wpml-change-domain-language-dialog-apply-button',
text: privateData.change_lang_dialog.data('button-text'),
click: applyChanges
}
],
close: function () {
var languageSelector = jQuery('.js-simple-lang-selector-flags');
if (languageSelector) {
languageSelector.wpml_select2("close");
}
}
});
privateData.apply_button = jQuery('#wpml-change-domain-language-dialog-apply-button');
privateData.spinner = privateData.change_lang_dialog.find('.spinner');
privateData.spinner.css( 'float', 'none' ).detach().insertBefore( privateData.apply_button );
enableApplyButton();
};
var showDialog = function () {
privateData.change_lang_dialog.dialog('open');
};
var showSummary = function () {
var domainLang;
var languages;
var domain = jQuery(this).val();
if (domain) {
languages = jQuery(this).find('option:selected').data('langs');
buildTable(languages);
domainLang = jQuery(this).find('option:selected').data('domain_lang');
jQuery(privateData.lang_select).wpml_select2('val', domainLang);
privateData.summary_div.show();
} else {
privateData.summary_div.hide();
}
};
var buildTable = function (data) {
var i;
var tr;
jQuery(privateData.summary_div).find('.js-lang').off('click');
privateData.table_body.empty();
for (i = 0; i < data.length; i++) {
tr = '';
if (i % 2) {
tr += '<tr class="alternate">';
} else {
tr += '<tr>';
}
tr += '<td>';
tr += '<input class="js-lang" type="checkbox" value="' + data[i].language + '" />';
tr += '</td>';
tr += '<td>';
tr += data[i].display_name;
tr += '</td>';
tr += '<td class="num">';
tr += data[i].count;
tr += '</td>';
tr += '</tr>';
privateData.table_body.append(tr);
}
jQuery(privateData.summary_div).find('.js-lang').on('click', langClick);
if (1 === data.length) {
privateData.check_all.hide();
} else {
privateData.check_all.show();
}
};
var applyChanges = function () {
var data;
var languages;
privateData.apply_button.prop('disabled', true);
privateData.spinner.addClass( 'is-active' );
languages = [];
privateData.summary_div.find('.js-lang:checked').each(function () {
var itemSourceLanguage = jQuery(this).val();
languages.push(itemSourceLanguage);
});
data = {
action: 'wpml_change_string_lang_of_domain',
wpnonce: jQuery('#wpml_change_string_domain_language_nonce').val(),
domain: privateData.domain_select.val(),
langs: languages,
use_default: 0 < privateData.summary_div.find('.js-default:checked').length,
language: privateData.lang_select.val()
};
jQuery.ajax({
url: ajaxurl,
type: 'post',
data: data,
dataType: 'json',
success: function (response) {
if (response.success) {
window.location.reload(true);
}
if (response.error) {
privateData.spinner.removeClass( 'is-active' );
alert(response.error);
privateData.apply_button.prop('disabled', false);
}
}
});
};
var checkAllClick = function () {
var selected = jQuery(this).prop('checked');
jQuery(privateData.summary_div).find('.js-lang').prop('checked', selected);
enableApplyButton();
};
var langClick = function () {
var allLanguagesChecked = jQuery(privateData.summary_div).find('.js-lang').length === jQuery(privateData.summary_div).find('.js-lang:checked').length;
jQuery(privateData.summary_div).find('.js-all-check').prop('checked', allLanguagesChecked);
enableApplyButton();
};
var changeLanguage = function () {
enableApplyButton();
};
var enableApplyButton = function () {
var lang = privateData.lang_select.val();
if (lang && jQuery(privateData.summary_div).find('.js-lang:checked').length) {
privateData.apply_button.prop('disabled', false);
privateData.lang_area.show();
} else if (jQuery(privateData.summary_div).find('.js-lang:checked').length) {
privateData.apply_button.prop('disabled', true);
privateData.lang_area.show();
} else {
privateData.apply_button.prop('disabled', true);
privateData.lang_area.hide();
}
};
init();
};
WPML_String_Translation.change_domain_language = new WPML_String_Translation.ChangeDomainLanguage();

View File

@@ -0,0 +1,64 @@
/*jshint devel:true */
/*global jQuery, ajaxurl, get_checked_cbs */
var WPML_String_Translation = WPML_String_Translation || {};
WPML_String_Translation.ChangeLanguage = function () {
"use strict";
var privateData = {};
var init = function () {
jQuery(function () {
privateData.language_select = jQuery('#icl_st_change_lang_selected');
privateData.language_select.on('change', applyChanges);
privateData.spinner = jQuery('.icl-st-change-spinner');
privateData.spinner.detach().insertAfter(privateData.language_select);
});
};
var applyChanges = function () {
var checkBoxValue;
var data;
var i;
var checkboxes;
var strings;
privateData.spinner.addClass('is-active');
strings = [];
checkboxes = get_checked_cbs();
for (i = 0; i < checkboxes.length; i++) {
checkBoxValue = jQuery(checkboxes[i]).val();
strings.push(checkBoxValue);
}
data = {
action: 'wpml_change_string_lang',
wpnonce: jQuery('#wpml_change_string_language_nonce').val(),
strings: strings,
language: privateData.language_select.val()
};
jQuery.ajax({
url: ajaxurl,
type: 'post',
data: data,
dataType: 'json',
success: function (response) {
if (response.success) {
window.location.reload(true);
}
if (response.error) {
privateData.spinner.removeClass( 'is-active' );
alert(response.error);
privateData.apply_button.prop('disabled', false);
}
}
});
};
init();
};
WPML_String_Translation.change_language = new WPML_String_Translation.ChangeLanguage();

View File

@@ -0,0 +1,58 @@
/*globals jQuery, ajaxurl, wpml_st_disable_notices_strings */
function wpml_st_hide_strings_scan_notices(element, callback) {
"use strict";
var buttonNo = wpml_st_disable_notices_strings.no;
var buttonYes = wpml_st_disable_notices_strings.yes;
var dialog = jQuery('<div title="' + wpml_st_disable_notices_strings.title + '"><p>' + wpml_st_disable_notices_strings.message + '</p></div>');
dialog.css('display', 'none');
dialog.dialog({
resizable: false,
height: "auto",
width: "auto",
modal: true,
buttons: {
buttonNo: {
text: buttonNo,
click: function () {
if (typeof callback === 'function') {
callback();
}
dialog.dialog("close");
}
},
buttonYes: {
text: buttonYes,
class: 'button-primary',
click: function () {
jQuery.ajax({
url: ajaxurl,
type: 'POST',
data: {
action: 'hide_strings_scan_notices'
},
dataType: 'json',
complete: function () {
if (typeof callback === 'function') {
callback();
}
dialog.dialog("close");
}
});
}
}
},
open: function () {
jQuery('#jquery-ui-style-css').prop('disabled', true);
jQuery('.ui-widget-overlay.ui-front').css('z-index', '10001');
jQuery('.ui-dialog').css('z-index', '10002');
},
close: function () {
jQuery('#jquery-ui-style-css').prop('disabled', false);
}
});
}

View File

@@ -0,0 +1,411 @@
jQuery(function () {
var filterSearch = jQuery("#icl_st_filter_search");
jQuery('.wpml-colorpicker').wpColorPicker();
jQuery('select[name="icl_st_filter_status"]').change(icl_st_filter_status);
jQuery('select[name="icl_st_filter_context"]').change(icl_st_filter_context);
jQuery('select[name="icl-st-filter-translation-priority"]').change(icl_st_filter_translation_priority);
jQuery('#icl_st_filter_search_sb').click(icl_st_filter_search);
if (filterSearch.length) {
updateControls();
filterSearch.keyup(function (event) {
if (event.keyCode === 13) {
icl_st_filter_search();
}
updateControls();
});
}
jQuery('#icl_st_filter_search_remove').click(icl_st_filter_search_remove);
jQuery('#icl_st_delete_selected').click(icl_st_delete_selected);
jQuery('#icl_st_po_translations').click(function(){
var po_language = jQuery('#icl_st_po_language');
po_language.prop('disabled', !jQuery(this).prop('checked'));
if(jQuery(this).prop('checked')){
po_language.fadeIn();
}else{
po_language.fadeOut();
}
});
var iclTMLanguages = jQuery('#icl_tm_languages');
iclTMLanguages.find(':checkbox').click(icl_st_update_languages);
jQuery('.icl_st_row_cb, .check-column :checkbox').click(icl_st_update_checked_elements);
iclTMLanguages.find('select').change(icl_st_change_service);
jQuery('#icl_st_po_form').submit(icl_validate_po_upload);
jQuery('#icl_st_send_strings').submit(icl_st_send_strings);
jQuery('#icl_st_translate_to_all').click(icl_st_select_all);
jQuery('.handlediv').click(function () {
jQuery(this).parent().toggleClass('closed');
});
jQuery('#icl_st_track_strings').submit(iclSaveForm);
var iclSTOptionWriteForm = jQuery('#icl_st_option_write_form');
iclSTOptionWriteForm.submit(icl_st_admin_options_form_submit);
iclSTOptionWriteForm.submit(iclSaveForm);
// Picker align
jQuery(".pick-show").click(function () {
var set = jQuery(this).offset();
jQuery("#colorPickerDiv").css({"top":set.top-180,"left":set.left, "z-index":99});
});
jQuery('input[name="wpml_st_theme_localization_type_wpml_td"]').on('click', function () {
var checked = jQuery(this).prop('checked');
jQuery('input[name="wpml_st_theme_localization_type_wpml_td"]').prop('checked', checked);
});
jQuery(document).on('click', '.wpml_st_pop_download', icl_st_pop_download);
var ICLSTMoreOptions = jQuery('#icl_st_more_options');
ICLSTMoreOptions.submit(iclSaveForm);
ICLSTMoreOptions.submit(
function () {
var iclSTTUser = jQuery('#icl_st_tusers');
if (!iclSTTUser.find('label input:checked').length) {
jQuery('#icl_st_tusers_list').html('-');
} else {
jQuery('#icl_st_tusers_list').html(iclSTTUser.find('label input:checked').next().map(
function () {
return jQuery(this).html();
}).get().join(', '))
}
}
);
function updateControls() {
jQuery('#icl_st_filter_search_em').prop('disabled', filterSearch[0].value === '');
jQuery('#search_translation').prop('disabled', filterSearch[0].value === '');
}
});
function icl_st_filter_status(){
var qs = jQuery(this).val() != '' ? '&status=' + WPML_core.sanitize(jQuery(this).val()) : '';
location.href = WPML_core.sanitize(location.href).replace(/#(.*)$/,'').replace(/&paged=([0-9]+)/,'').replace(/&updated=true/,'').replace(/&status=([0-9a-z-]+)/g,'') + qs;
}
function icl_st_filter_context(){
var qs = jQuery(this).val() != '' ? '&context=' + encodeURIComponent(jQuery(this).val()) : '';
location.href= WPML_core.sanitize(location.href).replace(/#(.*)$/,'').replace(/&paged=([0-9]+)/,'').replace(/&updated=true/,'').replace(/&context=(.*)/g,'') + qs;
}
function icl_st_filter_translation_priority(){
var qs = jQuery(this).val() != '' ? '&translation-priority=' + encodeURIComponent(jQuery(this).val()) : '';
location.href= WPML_core.sanitize(location.href).replace(/#(.*)$/,'').replace(/&paged=([0-9]+)/,'').replace(/&updated=true/,'').replace(/&translation-priority=(.*)/g,'') + qs;
}
function icl_st_filter_search(){
var context = jQuery('select[name="icl_st_filter_context"]').val(),
search_text = jQuery('#icl_st_filter_search').val(),
exact_match = jQuery('#icl_st_filter_search_em').prop('checked'),
search_translation = jQuery('#search_translation').prop('checked'),
query_string = search_text !== '' ? '&search=' + encodeURIComponent(search_text) : '',
url = WPML_core.sanitize(location.href);
query_string = query_string.replace(/&em=1/g,'');
if (icl_st_getUrlParameter('show_results') === 'all') {
search_translation = false;
}
if(exact_match){
query_string += '&em=1';
}
if (search_translation) {
query_string += '&search_translation=1';
}
url = url.replace(/#(.*)$/,'')
.replace(/&paged=([0-9]+)/,'')
.replace(/&updated=true/,'')
.replace(/&search=(.*)/g,'') + query_string;
if ('' === context) {
url = url.replace(/&context=(.*)/g,'');
}
location.href = WPML_core.sanitize(url);
}
function icl_st_getUrlParameter(name) {
name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
var results = regex.exec( WPML_core.sanitize(location.search) );
return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
}
function icl_st_filter_search_remove(){
location.href = WPML_core.sanitize(location.href).replace(/#(.*)$/,'').replace(/&search=(.*)/g,'').replace(/&em=1/g,'');
}
function icl_st_delete_selected() {
var postVars;
var delids;
var proceed;
var confirmMessage;
var errorMessage;
var checkedRows = jQuery('.icl_st_row_cb:checked');
if (checkedRows.length) {
confirmMessage = jQuery(this).data('confirm');
errorMessage = jQuery(this).data('error');
proceed = confirm(confirmMessage);
if (proceed) {
delids = [];
checkedRows.each(function () {
var item = WPML_core.sanitize(jQuery(this).val());
delids.push(item);
jQuery(this).trigger('click');
});
if (delids) {
postVars = 'icl_ajx_action=icl_st_delete_strings&value=' + delids.join(',') + '&_icl_nonce=' + jQuery('#_icl_nonce_dstr').val();
jQuery.post(icl_ajx_url, postVars, function () {
var i = 0;
for (; i < delids.length; i++) {
jQuery('.icl_st_row_cb[value="' + delids[i] + '"]').parent().parent().fadeOut('fast', function () {
jQuery(this).remove();
});
}
}).success(function (msg) {
if ('1' !== msg) {
alert(errorMessage);
}
}).error(function () {
alert(errorMessage);
});
}
}
}
return false;
}
function icl_st_send_strings(){
var checkedRows = jQuery('.icl_st_row_cb:checked');
if(!checkedRows.length){
return false;
}
var sendids = [];
checkedRows.each(function(){
sendids.push(jQuery(this).val());
});
if(!sendids.length){
return false;
}
jQuery('#icl_st_send_strings').find('input[name="strings"]').val(sendids.join(','));
return true;
}
function icl_st_update_languages() {
if (!jQuery('#icl_tm_languages').find('input[type=checkbox]:checked:not(:disabled)').length) {
jQuery('#icl_send_strings').prop('disabled', true);
} else if (jQuery('.icl_st_row_cb:checked, .check-column input:checked').length && jQuery('.js-lang-not-active:checked').length === 0) {
jQuery('#icl_send_strings').prop('disabled', false);
}
var self = jQuery(this);
var lang = self.attr('name').replace(/translate_to\[(.+)]/, '$1');
if (self.prop('checked') && jQuery('#icl_st_service_' + lang).val() === 'icanlocalize') {
icl_st_show_estimated_cost(lang);
} else {
icl_st_hide_estimated_cost(lang);
}
icl_st_update_select_all_status();
}
function icl_st_select_all() {
var self = jQuery(this);
jQuery('#icl_tm_languages').find('input[type=checkbox]').prop('checked', self.prop('checked'));
icl_st_update_languages();
}
function icl_st_update_select_all_status() {
const uncheckedCount = jQuery('#icl_tm_languages input[type=checkbox]:not(:checked)').length;
jQuery('#icl_st_translate_to_all').prop('checked', uncheckedCount === 0);
}
function show_package_incomplete_notice(hide) {
var notice = jQuery('#wpml-st-package-incomplete');
if (hide) {
notice.hide();
} else {
notice.show();
}
}
function get_checked_cbs() {
var package_counts = {};
var context_select_options = jQuery('select[name="icl_st_filter_context"]').find('option') || [];
jQuery.each(context_select_options, function (i, option) {
option = jQuery(option);
package_counts[option.val()] = option.data('unfiltered-count');
});
var st_table = jQuery('#icl_string_translations');
var package_cbs = st_table.find('.icl_st_row_package:checked') || [];
var affected_package_counts = {};
jQuery.each(package_cbs, function (i, cb) {
var domain = jQuery(jQuery(cb).closest('tr')).find('.wpml-st-col-domain').text();
affected_package_counts[domain] = affected_package_counts.hasOwnProperty(domain) ? affected_package_counts[domain] : package_counts[domain];
affected_package_counts[domain] = affected_package_counts[domain] - 1;
jQuery(cb).data('package-domain', domain);
});
var checked_cbs = st_table.find('.icl_st_row_cb:checked');
checked_cbs = checked_cbs.length > 0 ? checked_cbs : [];
var incomplete_packages = false;
var domain;
for(domain in affected_package_counts){
if(affected_package_counts.hasOwnProperty(domain) && affected_package_counts[domain] > 0){
incomplete_packages = true;
}
}
show_package_incomplete_notice( !incomplete_packages || checked_cbs.length === 0);
return incomplete_packages ? [] : checked_cbs;
}
function icl_st_update_checked_elements() {
if (jQuery(this).closest('th, td').hasClass('manage-column')) {
jQuery('.icl_st_row_cb').prop('checked', jQuery(this).prop('checked'));
}
var selectedStringsCount = get_checked_cbs().length;
jQuery('#icl_st_change_lang_selected').wpml_select2().prop('disabled', selectedStringsCount === 0);
jQuery('#icl-st-change-translation-priority-selected').wpml_select2().prop('disabled', selectedStringsCount === 0);
jQuery('.js-change-translation-priority .wpml_select2-choice, .js-simple-lang-selector-flags .wpml_select2-choice').attr('disabled', selectedStringsCount === 0)
.addClass('button button-secondary');
if (!jQuery('.icl_st_row_cb:checked').length) {
jQuery('#icl_st_delete_selected, #icl_send_strings').prop('disabled', true);
WPML_String_Translation.translation_basket.clear_message();
} else {
jQuery('#icl_st_delete_selected').prop('disabled', false);
var iclTROpt = jQuery('#icl-tr-opt');
if (!iclTROpt.length || iclTROpt.find('input:checked').length) {
if (WPML_String_Translation.translation_basket.maybe_enable_button()) {
WPML_String_Translation.translation_basket.show_target_languages();
}
}
}
jQuery('.icl_st_estimate_wrap:visible').each(function () {
var lang = jQuery(this).attr('id').replace(/icl_st_estimate_(.+)_wrap/, '$1');
icl_st_show_estimated_cost(lang);
});
if (jQuery(this).hasClass('icl_st_row_cb')) {
set_bulk_selects(jQuery('.icl_st_row_cb:not(:checked)').length === 0);
}
}
function set_bulk_selects(bulk_cb_checked) {
jQuery('.check-column input').prop('checked', bulk_cb_checked);
}
function icl_validate_po_upload(){
var cont = jQuery(this).contents();
cont.find('.icl_error_text').hide();
if(!jQuery('#icl_po_file').val()){
cont.find('#icl_st_err_po').fadeIn();
return false;
}
if(!cont.find('select[name="icl_st_i_context"]').val() && !cont.find('input[name="icl_st_i_context_new"]').val()){
cont.find('#icl_st_err_domain').fadeIn();
return false;
}
}
var icl_show_in_source_scroll_once = false;
jQuery(document).delegate('#icl_show_source_wrap', 'mouseover', function(){
if(icl_show_in_source_scroll_once){
icl_show_in_source(0, icl_show_in_source_scroll_once);
icl_show_in_source_scroll_once = false;
}
});
function icl_show_in_source(tabfile, line){
if(icl_show_in_source_scroll_once){
if(line > 40){
line = line - 10;
location.href= WPML_core.sanitize(location.protocol+'//'+location.host+location.pathname+location.search+'#icl_source_line_'+tabfile+'_'+line);
}
}else{
jQuery('.icl_string_track_source').fadeOut(
function(){
jQuery('#icl_string_track_source_'+tabfile).fadeIn(
function(){
if(line > 40){
line = line - 10;
location.href= WPML_core.sanitize(location.protocol+'//'+location.host+location.pathname+location.search+'#icl_source_line_'+tabfile+'_'+line);
}
}
);
}
);
}
return false;
}
function iclResizeIframe() {
var frame = jQuery('#icl_string_track_frame_wrap').find('iframe');
var tbAjaxContent = jQuery('#TB_ajaxContent');
frame.attr('height', tbAjaxContent.height() - 20);
frame.attr('width', tbAjaxContent.width());
}
function icl_st_admin_options_form_submit(){
if(jQuery('input:checkbox.icl_st_has_translations:not(:checked)').length){
iclHaltSave = !confirm(jQuery('#icl_st_options_write_confirm').html());
}
iclSaveForm_success_cb.push(function(){
jQuery('#icl_st_options_write_success').fadeIn();
});
}
function icl_st_pop_download(){
var file = jQuery(this).data('file');
var domain = jQuery(this).data('domain');
location.href = WPML_core.sanitize( ajaxurl + "?action=icl_st_pop_download&file=" + file + "&domain=" + domain );
return false;
}
function icl_st_selected_word_count() {
var word_count = 0;
jQuery('.icl_st_row_cb:checked').each(function () {
var string_id = WPML_core.sanitize(jQuery(this).val());
word_count += parseInt(jQuery('#icl_st_wc_' + string_id).val())
});
return word_count;
}
function icl_st_show_estimated_cost(lang){
var estimate = icl_st_selected_word_count() * jQuery('#icl_st_max_rate_'+lang).html();
jQuery('#icl_st_estimate_'+lang).html(Math.round(estimate*100)/100);
jQuery('#icl_st_estimate_'+lang+'_wrap').show();
}
function icl_st_hide_estimated_cost(lang){
jQuery('#icl_st_estimate_'+lang+'_wrap').hide();
}
function icl_st_change_service(){
var lang = jQuery(this).attr('name').replace(/service\[(.+)]/ , '$1');
if(jQuery(this).val()=='icanlocalize'){
if(jQuery('#icl_st_translate_to_'+lang).prop('checked')){
icl_st_show_estimated_cost(lang);
}
}else{
icl_st_hide_estimated_cost(lang);
}
}

View File

@@ -0,0 +1,26 @@
/*jshint devel:true */
/*global jQuery */
var WPML_String_Translation = WPML_String_Translation || {};
WPML_String_Translation.Settings = function () {
"use strict";
var self = this;
self.updateTrackStringWarning = function (event) {
var warning = jQuery('.js-track-strings-note');
if (jQuery(this).prop('checked')) {
warning.fadeIn();
} else {
warning.fadeOut();
}
};
jQuery(function () {
jQuery('#track_strings').on('click', self.updateTrackStringWarning);
});
};
WPML_String_Translation.settings = new WPML_String_Translation.Settings();

View File

@@ -0,0 +1,71 @@
/*jshint devel:true */
/*global jQuery, ajaxurl, get_checked_cbs */
var WPML_String_Translation = WPML_String_Translation || {};
WPML_String_Translation.ChangeTranslationPriority = function () {
"use strict";
var privateData = {};
var init = function () {
jQuery(function () {
privateData.translation_priority_select = jQuery('#icl-st-change-translation-priority-selected');
privateData.translation_priority_select.on('change', applyChanges);
privateData.spinner = jQuery('.icl-st-change-spinner');
privateData.spinner.detach().insertAfter(privateData.translation_priority_select);
initializeSelect2();
});
};
var applyChanges = function () {
var checkBoxValue;
var data;
var i;
var checkboxes;
var strings;
privateData.spinner.addClass('is-active');
strings = [];
checkboxes = get_checked_cbs();
for (i = 0; i < checkboxes.length; i++) {
checkBoxValue = jQuery(checkboxes[i]).val();
strings.push(checkBoxValue);
}
data = {
action: 'wpml_change_string_translation_priority',
wpnonce: jQuery('#wpml_change_string_translation_priority_nonce').val(),
strings: strings,
priority: privateData.translation_priority_select.val()
};
jQuery.ajax({
url: ajaxurl,
type: 'post',
data: data,
dataType: 'json',
success: function (response) {
if (response.success) {
window.location.reload(true);
}
}
});
};
var initializeSelect2 = function () {
privateData.translation_priority_select.wpml_select2({
width: 'auto',
dropdownCss: {'z-index': parseInt(jQuery('.ui-dialog').css('z-index'), 10) + 100},
dropdownAutoWidth: true
});
jQuery('.js-change-translation-priority .wpml_select2-choice').addClass('button button-secondary').attr('disabled', 'true');
};
init();
};
WPML_String_Translation.change_translation_priority = new WPML_String_Translation.ChangeTranslationPriority();

View File

@@ -0,0 +1,26 @@
jQuery(function () {
jQuery('#wpml_add_strings').submit(function () {
var strings = [];
jQuery('.js-wpml-btn-cancel, .js-wpml-btn-add-strings').attr('disabled', 'disabled');
jQuery('.spinner').addClass('is-active');
jQuery('.icl_st_row_cb:checked').each(function () {
var st_fields_wrapper = jQuery(this).parent().next();
var fields_to_disable = 'input[name="icl_strings[]"], input[name="icl_translations[]"], input[name="icl_fuzzy[]"], input[name="icl_name[]"], input[name="icl_context[]"]';
var string = {
original: st_fields_wrapper.find( 'input[name="icl_strings[]"]' ).val(),
translation: st_fields_wrapper.find( 'input[name="icl_translations[]"]' ).val(),
fuzzy: st_fields_wrapper.find( 'input[name="icl_fuzzy[]"]' ).val(),
name: st_fields_wrapper.find( 'input[name="icl_name[]"]' ).val(),
context: st_fields_wrapper.find( 'input[name="icl_context[]"]' ).val()
};
strings.push( string );
jQuery( this ).attr( 'disabled', 'disabled' );
st_fields_wrapper.find( fields_to_disable ).attr( 'disabled', 'disabled' );
});
jQuery( '#strings_json' ).val( JSON.stringify( strings ) );
});
});

View File

@@ -0,0 +1,378 @@
/* globals ajaxurl, wpml_groups_to_scan, wpml_active_plugins_themes */
var WPML_ST = WPML_ST || {};
jQuery(function($) {
'use strict';
WPML_ST.ThemePluginFilter = function(scanningSection){
this.scanningSection = scanningSection;
};
WPML_ST.ThemePluginFilter.prototype = {
attachEvents: function() {
this.scanningSection.section.on( 'click', '.state-selector li', {instance: this}, function (event){
event.preventDefault();
event.data.instance.toggleItems( event.data.instance.scanningSection, $(this) );
});
this.scanningSection.section.on( 'click', 'thead input:checkbox, tfoot input:checkbox', {instance: this}, function (event){
event.data.instance.toggleCheckboxes( event.data.instance.scanningSection.section, $(this) );
});
this.scanningSection.section.on( 'change', 'input:checkbox', {instance: this}, function(event) {
var checked = event.data.instance.scanningSection.section.find( '.item input:checkbox:checked' );
var disableScanButton = ! Boolean( checked.length );
$(event.data.instance.scanningSection.scanButton).prop('disabled', disableScanButton );
});
this.scanningSection.section.on( 'click', '.item input:checkbox', {instance: this}, function(event) {
var check_all_items = event.data.instance.scanningSection.section.find( 'thead input:checkbox, tfoot input:checkbox' );
var all_items = event.data.instance.scanningSection.section.find( '.item input:checkbox' );
var all_items_checked = event.data.instance.scanningSection.section.find( '.item input:checkbox:checked' );
check_all_items.prop( 'checked', all_items.length === all_items_checked.length );
});
},
toggleItems: function (data, triggerElement) {
var status = triggerElement.data('status') ? triggerElement.data('status') : '';
$(data.section).find('ul li').removeClass('active');
triggerElement.addClass('active');
data.section.data('active-selector', status);
if ('active' === status) {
$(data.section).find('table tr.item').hide();
$(data.section).find('table .active').show();
} else if ('inactive' === status) {
$(data.section).find('table tr.item').show();
$(data.section).find('table .active').hide();
} else if ('all' === status) {
$(data.section).find('table tr.item').show();
}
},
toggleCheckboxes: function (e, trigger) {
$(this.scanningSection.section).find('input:checkbox').prop('checked', trigger.prop('checked') );
}
};
WPML_ST.ScanningSections = function() {
this.theme = {
type: 'theme',
section: $('.wpml_theme_localization'),
scanButton: '#wpml_theme_localization_scan'
};
this.plugin = {
type: 'plugin',
section: $('.wpml_plugin_localization'),
scanButton: '#wpml_plugin_localization_scan'
};
};
WPML_ST.ScanningCounter = function() {
this.filesChunkCount = 0;
this.filesChunkCounter = 0;
this.totalStrings = 0;
this.scannedFiles = [];
};
WPML_ST.ScanningCounter.prototype = {
reset: function() {
this.filesChunkCount = 0;
this.filesChunkCounter = 0;
this.totalStrings = 0;
this.scannedFiles = [];
}
};
WPML_ST.StringsScanning = function(isFirstSection, counter) {
this.numberOfFilesPerChunk = 50;
this.scannedFiles = [];
this.totalStrings = 0;
this.filesChunkCount = 0;
this.filesChunkCounter = 0;
this.triggerElement = {};
this.ajaxScanDirFiles = {};
this.elements = {};
this.scanSuccessfulMessage = '';
this.filesProcessedMessage = '';
this.spinner = '.wpml-scanning-progress .spinner';
this.progressMsg = '.wpml-scanning-progress-msg';
this.statsSection = '.wpml-scanning-results';
this.scanningProgressDialog = '.wpml-scanning-progress';
this.dialogCloseSelector = '.ui-dialog-titlebar-close';
this.isFirstSection = isFirstSection;
this.counter = counter;
};
WPML_ST.StringsScanning.prototype = {
init: function() {
$( this.progressMsg ).hide();
},
attachEvents: function( sectionData ) {
sectionData.section.on( 'click', sectionData.scanButton, {instance: this}, function(event){
var instance = event.data.instance;
event.preventDefault();
instance.triggerElement = $( this );
instance.elements = sectionData;
instance.scan(sectionData);
});
},
scan: function( sectionData ) {
var selectedItems = sectionData.section.find('table').find('input:checkbox:checked[data-component-name]');
var itemsCount = 0;
var that = this;
var type = sectionData.type;
this.elements = sectionData;
this.triggerElement.prop('disabled', true);
$( this.spinner ).addClass('is-active');
$( this.progressMsg ).show();
$( this.statsSection ).empty();
$( this.scanningProgressDialog ).dialog({
width: 350,
maxHeight: 300,
modal: true,
open: function() {
$(that.dialogCloseSelector).hide();
},
closeOnEscape: false
});
if (selectedItems.length) {
selectedItems.toArray().forEach(function(element) {
this.ajaxScanDirFiles = {};
if ($('input[name="use_theme_plugin_domain"]').prop('checked')) {
this.ajaxScanDirFiles.auto_text_domain = 1;
}
type = sectionData.type;
if ( -1 !== $( element ).data( 'component-name' ).search( 'mu-::-' ) ) {
type = 'mu-plugin';
}
this.ajaxScanDirFiles[ type ] = $(element).val();
this.ajaxScanDirFiles.action = $( sectionData.section ).attr('data-scan_folder-action');
this.ajaxScanDirFiles.nonce = $( sectionData.section ).attr('data-scan_folder-nonce');
this.scanDirAjax( sectionData.type, $(element).val() );
itemsCount++;
}, this);
}
},
scanDirAjax: function( section_type, section_value ) {
$.ajax({
type: 'POST',
url: ajaxurl,
section_type: section_type,
section_value: section_value,
instance: this,
data: this.ajaxScanDirFiles,
success: this.scanDirSuccess
});
},
updateHashAjax: function() {
$.ajax({
type: 'POST',
url: ajaxurl,
data: {
'action': $( this.elements.section ).attr('data-update_hash-action'),
'nonce': $( this.elements.section ).attr('data-update_hash-nonce'),
'files': this.counter.scannedFiles
},
success: $.proxy(this.refreshScreen, this)
});
},
scanFilesAjax: function(ajax_files_chunk, files_chunks, index) {
if ( index === files_chunks.length - 1 ) {
ajax_files_chunk.scan_mo_files = 1;
}
ajax_files_chunk.files = files_chunks[index];
$.ajax({
type: 'POST',
url: ajaxurl,
data: ajax_files_chunk,
context: this,
success: $.proxy(this.scanFilesSuccess, this)
}).done(function() {
this.scanFilesAjaxDone(files_chunks, ajax_files_chunk, index);
});
},
scanFilesAjaxDone: function(files_chunks, ajax_files_chunk, index) {
if (index < files_chunks.length - 1) {
this.scanFilesAjax(ajax_files_chunk, files_chunks, index + 1);
}
},
scanFilesSuccess: function( result ) {
var scanned_files_obj = result.data;
this.counter.scannedFiles = this.counter.scannedFiles.concat(scanned_files_obj.files_processed);
this.counter.totalStrings = this.counter.totalStrings + scanned_files_obj.strings_found;
this.scanSuccessfulMessage = scanned_files_obj.scan_successful_message;
this.filesProcessedMessage = scanned_files_obj.files_processed_message;
this.counter.filesChunkCounter++;
$(this.statsSection).html(this.renderStringsCounter());
$(this.statsSection).show();
if ( this.counter.filesChunkCounter === this.counter.filesChunkCount ) {
this.updateHashAjax();
}
},
scanDirSuccess: function( dirFilesResult ) {
var ajaxFilesChunk = {},
dirFiles = dirFilesResult.data.files,
filesChunks = [],
index = 0;
ajaxFilesChunk.action = $( this.instance.elements.section ).attr('data-scan_files-action');
ajaxFilesChunk.nonce = $( this.instance.elements.section ).attr('data-scan_files-nonce');
ajaxFilesChunk[this.section_type] = this.section_value;
while ( 0 < dirFiles.length ) {
filesChunks.push( dirFiles.splice(0, this.instance.numberOfFilesPerChunk) );
}
this.instance.counter.filesChunkCount = this.instance.counter.filesChunkCount + filesChunks.length;
if ( filesChunks.length > 0 ) {
this.instance.scanFilesAjax(ajaxFilesChunk, filesChunks, index);
} else if ( this.instance.counter.filesChunkCounter === this.instance.counter.filesChunkCount ) {
this.instance.restoreUI();
$(this.instance.statsSection).html( dirFilesResult.data.no_files_message );
$(this.instance.statsSection).show();
}
},
refreshScreen: function() {
this.elements.section.load(location + ' #wpml-' + this.elements.type + '-content', $.proxy( this.afterScreenReload, this ) );
},
afterScreenReload: function() {
$(this.statsSection).html(this.renderScanningResults());
$(this.statsSection).show();
var currentFilterSelector = this.elements.section.data( 'active-selector' );
this.elements.section.find( 'ul [data-status="' + currentFilterSelector + '"]' ).trigger( 'click' );
this.restoreUI();
},
renderScanningResults: function() {
var text = '';
text = text + this.scanSuccessfulMessage.replace('%s', this.counter.totalStrings) + '<br />';
if ( this.filesProcessedMessage ) {
text = text + this.filesProcessedMessage + '<br /><br />';
if ( this.counter.scannedFiles ) {
$.each(this.counter.scannedFiles, function (index, element) {
text = text + element + '<br />';
});
}
}
return text;
},
renderStringsCounter: function () {
return 'WPML' + this.scanSuccessfulMessage.replace('%s', this.counter.totalStrings).split('WPML')[1];
},
restoreUI: function() {
$(this.spinner).removeClass('is-active');
this.triggerElement.prop('disabled', false);
$( this.progressMsg ).hide();
this.allowClosingDialog();
this.counter.reset();
},
allowClosingDialog: function() {
$(this.dialogCloseSelector).show();
$(this.scanningProgressDialog).dialog('option', 'closeOnEscape', true);
$(this.scanningProgressDialog).closest('.ui-dialog').focus();
}
};
WPML_ST.AutoScan = function( groups, scanningSections ) {
this.groups = groups;
this.scanningSections = scanningSections;
};
WPML_ST.AutoScan.prototype = {
init: function() {
if ( this.shouldRunAutoScan() ) {
for (var group in this.groups) {
if (this.groups.hasOwnProperty(group)) {
this.selectItems( this.scanningSections[group].scanButton, this.groups[group] );
this.scan( this.scanningSections[group].scanButton );
}
}
}
},
selectItems: function( scanButton, group ) {
group.forEach(function(item){
$( 'input[value="' + item + '"]' ).prop( 'checked', true );
});
},
scan: function (scanButton) {
$(scanButton).click();
},
shouldRunAutoScan: function () {
return '' !== this.groups[0] && (-1 !== location.href.search('action=scan_from_notice') || -1 !== location.href.search('action=scan_active_items'))
}
};
$(function () {
var scanningSections = new WPML_ST.ScanningSections();
var auto_scan_type = wpml_active_plugins_themes;
var sections_count = 0;
var counter = new WPML_ST.ScanningCounter();
if (-1 !== location.href.search('action=scan_from_notice')) {
auto_scan_type = wpml_groups_to_scan;
}
for (var section in scanningSections) {
if (scanningSections.hasOwnProperty(section)) {
var isFirstSection = 0 === sections_count;
var scanSection = new WPML_ST.StringsScanning(isFirstSection, counter);
var themePluginFilter = new WPML_ST.ThemePluginFilter(scanningSections[section]);
scanSection.init();
scanSection.attachEvents(scanningSections[section]);
themePluginFilter.attachEvents();
}
sections_count++;
}
var autoScan = new WPML_ST.AutoScan( auto_scan_type, scanningSections );
autoScan.init();
});
});

View File

@@ -0,0 +1,29 @@
jQuery(function () {
jQuery('.js-wpml-st-troubleshooting-action').click(function () {
var self = jQuery(this);
var nonce = self.data('nonce');
var reload = self.data('reload');
self.prop('disabled', true);
self.after(icl_ajxloaderimg);
jQuery.ajax({
type: "post",
url : ajaxurl,
data : {
action: self.data('action'),
nonce: nonce
},
success: function() {
if (reload) {
window.location.reload(true);
} else {
alert(self.data('success-message'));
}
},
complete: function() {
self.prop('disabled', false);
self.next().fadeOut();
}
});
});
});

View File

@@ -0,0 +1,42 @@
/*jshint devel:true */
/*global jQuery */
var WPML_String_Translation = WPML_String_Translation || {};
WPML_String_Translation.CustomTypeSlugUI = function () {
var init = function () {
jQuery(function () {
jQuery('.js-translate-slug-original').on('change', change_original_lang);
jQuery('.js-toggle-slugs-table').on('click', toggle_slugs_table);
});
};
var change_original_lang = function () {
var new_lang = jQuery(this).val();
jQuery(this).closest('.js-custom-type-slugs').find('input').each( function() {
var input_lang = jQuery(this).data('lang');
if (input_lang == new_lang) {
jQuery(this).closest('tr').hide();
} else {
jQuery(this).closest('tr').show();
}
})
};
var toggle_slugs_table = function(e) {
e.preventDefault();
var toggle = jQuery(e.currentTarget);
var slugsTable = toggle.closest('.icl_slug_translation_choice').find('.js-custom-type-slugs');
slugsTable.fadeToggle(400, function() {
var arrow = toggle.find('span');
arrow.toggleClass('otgs-ico-caret-up', slugsTable.is(':visible'));
arrow.toggleClass('otgs-ico-caret-down', ! slugsTable.is(':visible'));
});
};
init();
};
WPML_String_Translation.custom_post_ui = new WPML_String_Translation.CustomTypeSlugUI();

View File

@@ -0,0 +1,23 @@
(function ($, window) {
"use strict";
$(function () {
$('.wpml_plugin_table_filters').find('a').each(function (i, element) {
$(element).on('click', function (e) {
e.preventDefault();
var element = $(this),
filter = element.attr('href').replace('#', '');
$("#wpml_strings_in_plugins > tbody > tr").filter(function () {
var tr = $(this),
display = '';
if (filter && 'all' !== filter && filter !== tr.data('plugin-status')) {
display = 'none';
}
tr.css('display', display);
});
});
});
});
})(jQuery, window);

View File

@@ -0,0 +1,103 @@
/*jshint devel:true */
/*global jQuery */
var WPML_String_Translation = WPML_String_Translation || {};
WPML_String_Translation.TranslationBasket = function () {
"use strict";
var self = this;
var private_data = {};
var init = function () {
jQuery(function () {
private_data.button = jQuery('#icl_send_strings');
});
};
self.maybe_enable_button = function () {
if ( self.is_not_active_lang_selected() ) {
private_data.button.prop('disabled', true);
jQuery('.js-translation-message').html(private_data.button.data('lang-not-active-message')).show();
} else if ( self.is_more_than_on_lang_selected() ) {
private_data.button.prop('disabled', true);
jQuery('.js-translation-message').html(private_data.button.data('more-than-one-lang-message')).show();
} else if ( self.basket_has_strings_in_different_lang() ) {
private_data.button.prop('disabled', true);
jQuery('.js-translation-message').html(private_data.button.data('translation-basket-lang-message')).show();
} else {
private_data.button.prop('disabled', false);
self.clear_message();
}
return !private_data.button.prop('disabled');
};
self.basket_has_strings_in_different_lang = function () {
var different = false;
var basket_lang = jQuery('input[name="icl-basket-language"]').val();
if (basket_lang) {
var checked = jQuery('.icl_st_row_cb:checked:first');
var lang = checked.data('language');
different = basket_lang !== lang;
}
return different;
};
self.is_not_active_lang_selected = function () {
return jQuery('.js-lang-not-active:checked').length;
};
self.is_more_than_on_lang_selected = function () {
var checked = jQuery('.icl_st_row_cb:checked');
var OK = true;
if (checked.length > 1) {
var langs = [];
jQuery(checked).each( function () {
var lang = jQuery(this).data('language');
if ( langs.indexOf(lang) === -1) {
langs.push(lang);
}
});
if (langs.length > 1) {
OK = false;
}
}
return !OK;
};
self.show_target_languages = function () {
if (!self.is_more_than_on_lang_selected()) {
var checked = jQuery('.icl_st_row_cb:checked:first');
var lang = checked.data('language');
jQuery('#icl_tm_languages').find('input').each(function() {
var show = lang === jQuery(this).data('language');
jQuery(this).closest('tr').toggle(!show);
jQuery(this).attr('disabled', show);
});
jQuery('input[name="icl-tr-from"]').val(lang);
}
};
self.clear_message = function () {
jQuery('.js-translation-message').html('').hide();
};
init();
};
WPML_String_Translation.translation_basket = new WPML_String_Translation.TranslationBasket();