Skip to content

Commit

Permalink
maint(Cleanup): Autoformat with prettier.
Browse files Browse the repository at this point in the history
  • Loading branch information
thet committed Feb 13, 2023
1 parent f7a9bd3 commit 389b884
Show file tree
Hide file tree
Showing 16 changed files with 187 additions and 191 deletions.
17 changes: 7 additions & 10 deletions src/core/i18n-wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,29 @@ import I18N from "./i18n";
// delay the initialization of the translate catalog
// until after the dom is available
let _translation_domains = {
"plone": null,
"widgets": null,
plone: null,
widgets: null,
};

const translate = function(domain, msgid, keywords) {
if(_translation_domains[domain] === null) {
const translate = function (domain, msgid, keywords) {
if (_translation_domains[domain] === null) {
var i18n = new I18N();
i18n.loadCatalog(domain);
_translation_domains[domain] = i18n.MessageFactory(domain);
}
return _translation_domains[domain](msgid, keywords);
};

const translate_widgets = function(msgid, keywords) {
const translate_widgets = function (msgid, keywords) {
return translate("widgets", msgid, keywords);
};

const translate_plone = function(msgid, keywords) {
const translate_plone = function (msgid, keywords) {
return translate("plone", msgid, keywords);
};

// backwards compatibilty: "widgets" domain is default factory
export default translate_widgets;

// explicit export of translation domain factories
export {
translate_widgets,
translate_plone,
}
export { translate_widgets, translate_plone };
34 changes: 16 additions & 18 deletions src/pat/controlpanels/registry--implementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,31 +33,29 @@ export default class ConfigRegistry {
.click();
});
/* ajax retrieval of paging */
$("#recordsContainer").on(
"click",
".pagination a, .listingBar a",
function (e) {
e.preventDefault();
var $el = $(this);
utils.loading.show();
$("#recordsTable").load(
$el.attr("href") + " #recordsTable > *",
function () {
self.loadModals();
utils.loading.hide();
}
);
}
);
$("#recordsContainer").on("click", ".pagination a, .listingBar a", function (e) {
e.preventDefault();
var $el = $(this);
utils.loading.show();
$("#recordsTable").load(
$el.attr("href") + " #recordsTable > *",
function () {
self.loadModals();
utils.loading.hide();
}
);
});

/* ajax form submission */
$("#recordsContainer").on("submit", "#searchrow form", function (e) {
e.preventDefault();
var $el = $(this);
utils.loading.show();
$("#recordsTable").load(
$("body").attr("data-base-url")
+ "?" + $el.serialize() + " #recordsTable > *",
$("body").attr("data-base-url") +
"?" +
$el.serialize() +
" #recordsTable > *",
function () {
self.loadModals();
utils.loading.hide();
Expand Down
132 changes: 65 additions & 67 deletions src/pat/controlpanels/schemaeditor--implementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ export default class SchemaEditor {
init_add_field(fieldset_id) {
if (fieldset_id) {
var $add_field = $("a#add-field", this.el);
var $fieldset = $("#form fieldset#fieldset-"+fieldset_id, this.el);
if ($fieldset.data('can-add-fields') === false){
$add_field.addClass('disabled');
var $fieldset = $("#form fieldset#fieldset-" + fieldset_id, this.el);
if ($fieldset.data("can-add-fields") === false) {
$add_field.addClass("disabled");
} else {
var href = $add_field.attr("href").split("?")[0]; // get base href without any previously set ``fieldset_id``.
$add_field.attr("href", href + "?fieldset_id=" + fieldset_id);
$add_field.removeClass('disabled');
$add_field.removeClass("disabled");
}
}
}
Expand Down Expand Up @@ -236,72 +236,70 @@ $.fn.plone_schemaeditor_html5_sortable = function (

var self = this;
// Make tab and legend elements droppable. we drop on legend when form tabbing is disabled
$("#form fieldset legend")
.each(function (i) {
var $fieldset = $("#form fieldset#fieldset-"+i, self.el);
if ($fieldset.data('can-add-fields') === true){
$(this).attr("droppable", "true")
$("#form fieldset legend").each(function (i) {
var $fieldset = $("#form fieldset#fieldset-" + i, self.el);
if ($fieldset.data("can-add-fields") === true) {
$(this).attr("droppable", "true");
}
$(this).attr("data-fieldset_drag_id", i);
});
$("#form .autotoc-nav > a").each(function (i) {
// Plone 5 / mockup
var $fieldset = $("#form fieldset#fieldset-" + i, self.el);
if ($fieldset.data("can-add-fields") === true) {
$(this).attr("droppable", "true");
this.ondrop = function (e) {
// apply change fieldset when we drop a field on a tab or a legend
e.preventDefault();
var src = e.dataTransfer.getData("Text"),
node = $("[data-drag_id=" + src + "]");
var orig_fieldset = node.parents("fieldset");
var orig_fieldset_id = orig_fieldset.attr("id").split("-")[1];
var target_fieldset_id = $(this).attr("data-fieldset_drag_id");
if (orig_fieldset_id != target_fieldset_id) {
var target_fieldset = $("#fieldset-" + target_fieldset_id),
tab_height = $(this).height(),
tab_width = $(this).width(),
tab_position = $(this).position();
node.animate(
{
top: tab_position.top - node.position().top,
left: tab_position.left - node.position().left,
width: "50%",
opacity: "0",
},
1000,
function () {
node.appendTo(target_fieldset);
node.css("left", "");
node.css("top", "");
node.css("width", "");
node.css("opacity", "");
}
);
changefieldset_callback.apply(node, [target_fieldset_id]);
}
$(this).css("border", "");
};
this.ondragover = function (e) {
// style when we drag over tab or legend
e.preventDefault();
var draggable = e.dataTransfer.getData("draggable");
if (draggable) {
$(this).css("border", "3px dotted red");
$("#drop-marker").hide();
}
return false;
};
this.ondragleave = function (e) {
// remove style when we leave tab or legend
e.preventDefault();
$(this).css("border", "");
$("#drop-marker").show();
};
}
$(this).attr("data-fieldset_drag_id", i);
});
$("#form .autotoc-nav > a")
.each(function (i) {
// Plone 5 / mockup
var $fieldset = $("#form fieldset#fieldset-"+i, self.el);
if ($fieldset.data('can-add-fields') === true){
$(this).attr("droppable", "true");
this.ondrop = function (e) {
// apply change fieldset when we drop a field on a tab or a legend
e.preventDefault();
var src = e.dataTransfer.getData("Text"),
node = $("[data-drag_id=" + src + "]");
var orig_fieldset = node.parents("fieldset");
var orig_fieldset_id = orig_fieldset.attr("id").split("-")[1];
var target_fieldset_id = $(this).attr("data-fieldset_drag_id");
if (orig_fieldset_id != target_fieldset_id) {
var target_fieldset = $("#fieldset-" + target_fieldset_id),
tab_height = $(this).height(),
tab_width = $(this).width(),
tab_position = $(this).position();
node.animate(
{
top: tab_position.top - node.position().top,
left: tab_position.left - node.position().left,
width: "50%",
opacity: "0",
},
1000,
function () {
node.appendTo(target_fieldset);
node.css("left", "");
node.css("top", "");
node.css("width", "");
node.css("opacity", "");
}
);
changefieldset_callback.apply(node, [target_fieldset_id]);
}
$(this).css("border", "");
};
this.ondragover = function (e) {
// style when we drag over tab or legend
e.preventDefault();
var draggable = e.dataTransfer.getData("draggable");
if (draggable) {
$(this).css("border", "3px dotted red");
$("#drop-marker").hide();
}
return false;
};
this.ondragleave = function (e) {
// remove style when we leave tab or legend
e.preventDefault();
$(this).css("border", "");
$("#drop-marker").show();
};
}
$(this).attr("data-fieldset_drag_id", i);
});

$('<span class="draghandle">&#x28FF;</span>')
.css("cursor", "ns-resize")
Expand Down
21 changes: 12 additions & 9 deletions src/pat/modal/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -472,18 +472,21 @@ export default Base.extend({
self.emit("before-events-setup");

// Wire up events
self.$modal[0].querySelectorAll(
`.modal-header > .modal-close,
self.$modal[0]
.querySelectorAll(
`.modal-header > .modal-close,
.modal-footer > .pattern-modal-buttons > .modal-close,
.modal-footer [name="form.buttons.Cancel" i]`
).forEach((el) => {
$(el).off("click").on("click", (e) => {
e.stopPropagation();
e.preventDefault();
$(e.target).trigger("destroy.plone-modal.patterns");
)
.forEach((el) => {
$(el)
.off("click")
.on("click", (e) => {
e.stopPropagation();
e.preventDefault();
$(e.target).trigger("destroy.plone-modal.patterns");
});
});
});


// form
if (options.form) {
Expand Down
49 changes: 27 additions & 22 deletions src/pat/recurrence/recurrence.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,11 @@ function widgetSaveToRfc5545(form, icaldata, conf, tz, start_date) {
human +=
" " +
format(
new Date(date_parts[0], date_parts[1]-1, date_parts[2]),
new Date(
date_parts[0],
date_parts[1] - 1,
date_parts[2]
),
conf.localization.longDateFormat,
conf
);
Expand All @@ -247,14 +251,16 @@ function widgetSaveToRfc5545(form, icaldata, conf, tz, start_date) {
let tmp_dates = [];
let tmp_human = [];
// make sure our additional RDATE dates have the same start time
const rdate_time = start_date ? `T${start_date.getHours()}:${start_date.getMinutes()}:00` : "T00:00:00";
const rdate_time = start_date
? `T${start_date.getHours()}:${start_date.getMinutes()}:00`
: "T00:00:00";

for (let rdate of icaldata.RDATE) {
if (rdate !== "") {
// RDATE values are "YYYY-MM-DD"
// by adding "T000000" the recurrence sequence generator of
// plone.event.recurrence adds the current start time correctly
rdate += (rdate.length === 10) ? "T000000" : "";
rdate += rdate.length === 10 ? "T000000" : "";
rdate += tz ? "Z" : "";
tmp_dates.push(rdate);

Expand Down Expand Up @@ -394,7 +400,6 @@ function widgetLoadFromRfc5545(form, conf, icaldata, force) {
var freq, interval, byday, bymonth, bymonthday, count, until;
var day, month, year, weekday;


if (icaldata.RRULE === undefined) {
unsupportedFeatures.push(conf.localization.noRule);
if (!force) {
Expand Down Expand Up @@ -645,7 +650,7 @@ const RecurrenceInput = function (conf, textarea) {

// initalize parsed icaldata
if (textarea.value) {
textarea["ical"] = parseIcal(textarea.value)
textarea["ical"] = parseIcal(textarea.value);
} else {
textarea["ical"] = {
RRULE: "",
Expand Down Expand Up @@ -738,7 +743,7 @@ const RecurrenceInput = function (conf, textarea) {
$(`<div class="d-flex justify-content-between occurrence rdate">
<span class="rdate">
${format(
new Date(date_parts[0], date_parts[1]-1, date_parts[2]),
new Date(date_parts[0], date_parts[1] - 1, date_parts[2]),
conf.localization.longDateFormat,
conf
)},
Expand Down Expand Up @@ -971,14 +976,11 @@ const RecurrenceInput = function (conf, textarea) {
);

// Now when we have a start date, we can also do an ajax call to calculate occurrences:
var rfc5545 = textarea.value || widgetSaveToRfc5545(form, textarea["ical"], conf, false).result;
var rfc5545 =
textarea.value ||
widgetSaveToRfc5545(form, textarea["ical"], conf, false).result;

loadOccurrences(
startdate,
rfc5545,
0,
false
);
loadOccurrences(startdate, rfc5545, 0, false);

// Show the add and refresh buttons:
form.find("div.rioccurrencesactions").show();
Expand All @@ -992,18 +994,19 @@ const RecurrenceInput = function (conf, textarea) {
}

function recurrenceOn(form) {
var RFC5545 = widgetSaveToRfc5545(form, textarea["ical"], conf, false, findStartDate());
var RFC5545 = widgetSaveToRfc5545(
form,
textarea["ical"],
conf,
false,
findStartDate()
);
var label = self.display.find("label[class=ridisplay]");
label.text(conf.localization.displayActivate + " " + RFC5545.description);
$textarea.val(RFC5545.result).trigger("change");
var startdate = findStartDate();
if (startdate !== null) {
loadOccurrences(
startdate,
RFC5545.result,
0,
true
);
loadOccurrences(startdate, RFC5545.result, 0, true);
}
self.display.find('a[name="riedit"]').text(conf.localization.edit_rules);
self.display.find('a[name="ridelete"]').show();
Expand Down Expand Up @@ -1141,7 +1144,8 @@ const RecurrenceInput = function (conf, textarea) {
if (checkFields(form)) {
loadOccurrences(
startDate,
widgetSaveToRfc5545(self.$modalForm, textarea["ical"], conf, false).result,
widgetSaveToRfc5545(self.$modalForm, textarea["ical"], conf, false)
.result,
0,
false
);
Expand All @@ -1166,7 +1170,8 @@ const RecurrenceInput = function (conf, textarea) {

// Update the selected dates section
self.$modalForm
.find(`
.find(
`
input:radio,
input:checkbox,
.riweeklyweekday > input,
Expand Down
Loading

0 comments on commit 389b884

Please sign in to comment.