first commit
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
jQuery(function ($) {
|
||||
"use strict";
|
||||
|
||||
var dialog = $('.js-wpml-translation-basket-dialog');
|
||||
|
||||
var openDialog = function (result) {
|
||||
/** @namespace result.call_to_action */
|
||||
/** @namespace result.ts_batch_link */
|
||||
|
||||
var hasAdditionalContent = typeof result.call_to_action !== 'undefined' || typeof result.ts_batch_link !== 'undefined';
|
||||
|
||||
var options = {
|
||||
dialogClass: 'wpml-dialog otgs-ui-dialog',
|
||||
width: 600,
|
||||
title: dialog.data('title'),
|
||||
modal: true,
|
||||
closeOnEscape: false,
|
||||
resizable: false,
|
||||
draggable: false,
|
||||
open: function () {
|
||||
var dialogContent = dialog.find('.js-dialog-content');
|
||||
|
||||
var callToAction = dialogContent.find('.js-call-to-action');
|
||||
|
||||
var batchLink = dialogContent.find('.js-batch-link');
|
||||
var batchLinkAnchor = batchLink.find('a');
|
||||
|
||||
if (callToAction && typeof result.call_to_action !== 'undefined') {
|
||||
callToAction.text(result.call_to_action);
|
||||
hasAdditionalContent = true;
|
||||
}
|
||||
if (batchLinkAnchor && typeof result.ts_batch_link !== 'undefined') {
|
||||
batchLinkAnchor.attr('href', result.ts_batch_link.href);
|
||||
batchLinkAnchor.text(result.ts_batch_link.text);
|
||||
$(batchLinkAnchor).on('click', function () {
|
||||
dialog.dialog('close');
|
||||
});
|
||||
|
||||
batchLink.show();
|
||||
hasAdditionalContent = true;
|
||||
}
|
||||
dialog.show();
|
||||
repositionDialog();
|
||||
}
|
||||
};
|
||||
|
||||
if (hasAdditionalContent) {
|
||||
dialog.dialog(options);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
var repositionDialog = function() {
|
||||
if (dialog.hasClass("ui-dialog-content") && dialog.dialog('isOpen')) {
|
||||
var winH = $(window).height() - 180;
|
||||
$(".otgs-ui-dialog .ui-dialog-content").css({
|
||||
"max-height": winH
|
||||
});
|
||||
$(".otgs-ui-dialog").css({
|
||||
"max-width": "95%"
|
||||
});
|
||||
dialog.dialog("option", "position", {
|
||||
my: "center",
|
||||
at: "center",
|
||||
of: window
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
$(window).resize(repositionDialog);
|
||||
|
||||
var form = $('#translation-jobs-translators-form');
|
||||
|
||||
form.on('wpml-tm-basket-submitted', function(event, response) {
|
||||
if (response.result) {
|
||||
openDialog(response.result);
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,24 @@
|
||||
jQuery(function () {
|
||||
"use strict";
|
||||
|
||||
var dialog = jQuery('.wpml-tm-invalid-fields-dialog');
|
||||
|
||||
jQuery('.wpml-tm-invalid-fields-open-dialog').click(function () {
|
||||
var fields = jQuery(this).data('fields');
|
||||
dialog.dialog({
|
||||
dialogClass: 'wpml-dialog otgs-ui-dialog',
|
||||
width : 'auto',
|
||||
title : jQuery(this).data('page-title'),
|
||||
modal: true,
|
||||
open: function () {
|
||||
dialog.html('');
|
||||
dialog.append('<ul>');
|
||||
jQuery.each(fields, function(index, value){
|
||||
var field = JSON.parse(value);
|
||||
dialog.append('<li><strong>' + field.title + '</strong>: ' + field.content + '</li>');
|
||||
});
|
||||
dialog.append( '</ul>' );
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user