mirror of
https://github.com/pretix/pretix.git
synced 2026-05-05 15:14:04 +00:00
Reorganize main.js in control module
This commit is contained in:
@@ -665,33 +665,8 @@ var form_handlers = function (el) {
|
|||||||
questions_init_photos(el);
|
questions_init_photos(el);
|
||||||
};
|
};
|
||||||
|
|
||||||
$(function () {
|
function setup_basics(el) {
|
||||||
"use strict";
|
el.find("#sumtoggle").find("button").click(function () {
|
||||||
|
|
||||||
$("body").removeClass("nojs");
|
|
||||||
lightbox.init();
|
|
||||||
|
|
||||||
$(document).on("click", ".variations .variations-select-all", function (e) {
|
|
||||||
$(this).parent().parent().find("input[type=checkbox]").prop("checked", true).change();
|
|
||||||
e.stopPropagation();
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
$(document).on("click", ".variations .variations-select-none", function (e) {
|
|
||||||
$(this).parent().parent().find("input[type=checkbox]").prop("checked", false).change();
|
|
||||||
e.stopPropagation();
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
if ($(".items-on-quota").length) {
|
|
||||||
$(".items-on-quota .panel").each(function () {
|
|
||||||
var $panel = $(this);
|
|
||||||
$panel.toggleClass("panel-success", $panel.find("input:checked").length > 0);
|
|
||||||
$(this).find("input").change(function () {
|
|
||||||
$panel.toggleClass("panel-success", $panel.find("input:checked").length > 0);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
$("#sumtoggle").find("button").click(function () {
|
|
||||||
$(".table-product-overview .sum-gross").toggle($(this).attr("data-target") === ".sum-gross");
|
$(".table-product-overview .sum-gross").toggle($(this).attr("data-target") === ".sum-gross");
|
||||||
$(".table-product-overview .sum-net").toggle($(this).attr("data-target") === ".sum-net");
|
$(".table-product-overview .sum-net").toggle($(this).attr("data-target") === ".sum-net");
|
||||||
$(".table-product-overview .count").toggle($(this).attr("data-target") === ".count");
|
$(".table-product-overview .count").toggle($(this).attr("data-target") === ".count");
|
||||||
@@ -700,18 +675,18 @@ $(function () {
|
|||||||
$(this).addClass("active");
|
$(this).addClass("active");
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.collapsible').collapse();
|
el.find('.collapsible').collapse();
|
||||||
$("input[data-toggle=radiocollapse]").change(function () {
|
el.find("input[data-toggle=radiocollapse]").change(function () {
|
||||||
$($(this).attr("data-parent")).find(".collapse.in").collapse('hide');
|
$($(this).attr("data-parent")).find(".collapse.in").collapse('hide');
|
||||||
$($(this).attr("data-target")).collapse('show');
|
$($(this).attr("data-target")).collapse('show');
|
||||||
});
|
});
|
||||||
$("div.collapsed").removeClass("collapsed").addClass("collapse");
|
el.find("div.collapsed").removeClass("collapsed").addClass("collapse");
|
||||||
$(".has-error").each(function () {
|
el.find(".has-error").each(function () {
|
||||||
$(this).closest("div.panel-collapse").collapse("show");
|
$(this).closest("div.panel-collapse").collapse("show");
|
||||||
});
|
});
|
||||||
|
|
||||||
$('[data-toggle="tooltip"]').tooltip();
|
el.find('[data-toggle="tooltip"]').tooltip();
|
||||||
$('[data-toggle="tooltip_html"]').tooltip({
|
el.find('[data-toggle="tooltip_html"]').tooltip({
|
||||||
'html': true,
|
'html': true,
|
||||||
'whiteList': {
|
'whiteList': {
|
||||||
// Global attributes allowed on any supplied element below.
|
// Global attributes allowed on any supplied element below.
|
||||||
@@ -733,7 +708,7 @@ $(function () {
|
|||||||
if (url.match('#')) {
|
if (url.match('#')) {
|
||||||
$('.nav-tabs a[href="#' + url.split('#')[1] + '"]').tab('show');
|
$('.nav-tabs a[href="#' + url.split('#')[1] + '"]').tab('show');
|
||||||
}
|
}
|
||||||
$('a[data-toggle="tab"]').on('click', function (e) {
|
el.find('a[data-toggle="tab"]').on('click', function (e) {
|
||||||
if (!$(this).closest(".tab-content").length) {
|
if (!$(this).closest(".tab-content").length) {
|
||||||
// only append hash if not inside a .panel
|
// only append hash if not inside a .panel
|
||||||
window.location.hash = this.hash;
|
window.location.hash = this.hash;
|
||||||
@@ -741,7 +716,7 @@ $(function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Event wizard
|
// Event wizard
|
||||||
$("#event-slug-random-generate").click(function () {
|
el.find("#event-slug-random-generate").click(function () {
|
||||||
var url = $(this).attr("data-rng-url");
|
var url = $(this).attr("data-rng-url");
|
||||||
$("#id_basics-slug").val("Generating...");
|
$("#id_basics-slug").val("Generating...");
|
||||||
$.getJSON(url, function (data) {
|
$.getJSON(url, function (data) {
|
||||||
@@ -749,10 +724,7 @@ $(function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
form_handlers($("body"));
|
el.find(".qrcode-canvas").each(function () {
|
||||||
$(document).trigger("pretix:bind-forms");
|
|
||||||
|
|
||||||
$(".qrcode-canvas").each(function () {
|
|
||||||
$(this).qrcode(
|
$(this).qrcode(
|
||||||
{
|
{
|
||||||
text: $.trim($($(this).attr("data-qrdata")).html())
|
text: $.trim($($(this).attr("data-qrdata")).html())
|
||||||
@@ -760,10 +732,10 @@ $(function () {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
$(".propagated-settings-box").find("input, textarea, select").not("[readonly]")
|
el.find(".propagated-settings-box").find("input, textarea, select").not("[readonly]")
|
||||||
.attr("data-propagated-locked", "true").prop("readonly", true);
|
.attr("data-propagated-locked", "true").prop("readonly", true);
|
||||||
|
|
||||||
$(".propagated-settings-box button[data-action=unlink]").click(function (ev) {
|
el.find(".propagated-settings-box button[data-action=unlink]").click(function (ev) {
|
||||||
var $box = $(this).closest(".propagated-settings-box");
|
var $box = $(this).closest(".propagated-settings-box");
|
||||||
$box.find("input[name=decouple]").val($(this).val());
|
$box.find("input[name=decouple]").val($(this).val());
|
||||||
$box.find("[data-propagated-locked]").prop("readonly", false);
|
$box.find("[data-propagated-locked]").prop("readonly", false);
|
||||||
@@ -773,7 +745,7 @@ $(function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Tables with bulk selection, e.g. subevent list
|
// Tables with bulk selection, e.g. subevent list
|
||||||
$("input[data-toggle-table]").each(function (ev) {
|
el.find("input[data-toggle-table]").each(function (ev) {
|
||||||
var $toggle = $(this);
|
var $toggle = $(this);
|
||||||
var $actionButtons = $(".batch-select-actions button", this.form);
|
var $actionButtons = $(".batch-select-actions button", this.form);
|
||||||
var countLabels = $("<span></span>").appendTo($actionButtons);
|
var countLabels = $("<span></span>").appendTo($actionButtons);
|
||||||
@@ -852,7 +824,7 @@ $(function () {
|
|||||||
if (!nrOfChecked) countLabels.empty();
|
if (!nrOfChecked) countLabels.empty();
|
||||||
else countLabels.text(" ("+nrOfChecked+")");
|
else countLabels.text(" ("+nrOfChecked+")");
|
||||||
|
|
||||||
if (!allChecked) $selectAll.find("input").prop("checked", false);
|
if (!allChecked) $selectAll.find("input").prop("checked", false);
|
||||||
|
|
||||||
$actionButtons.attr("disabled", !nrOfChecked);
|
$actionButtons.attr("disabled", !nrOfChecked);
|
||||||
$toggle.prop("checked", allChecked).prop("indeterminate", nrOfChecked > 0 && !allChecked);
|
$toggle.prop("checked", allChecked).prop("indeterminate", nrOfChecked > 0 && !allChecked);
|
||||||
@@ -875,7 +847,7 @@ $(function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Items and categories
|
// Items and categories
|
||||||
$(".internal-name-wrapper").each(function () {
|
el.find(".internal-name-wrapper").each(function () {
|
||||||
if ($(this).find("input").val() === "") {
|
if ($(this).find("input").val() === "") {
|
||||||
var $fg = $(this).find(".form-group");
|
var $fg = $(this).find(".form-group");
|
||||||
$fg.hide();
|
$fg.hide();
|
||||||
@@ -896,7 +868,7 @@ $(function () {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$("button[data-toggle=qrcode]").click(function (e) {
|
el.find("button[data-toggle=qrcode]").click(function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var $current = $(".qr-code-overlay[data-qrcode='" + $(this).attr("data-qrcode") + "']");
|
var $current = $(".qr-code-overlay[data-qrcode='" + $(this).attr("data-qrcode") + "']");
|
||||||
if ($current.length) {
|
if ($current.length) {
|
||||||
@@ -926,6 +898,37 @@ $(function () {
|
|||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
$(function () {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
$("body").removeClass("nojs");
|
||||||
|
lightbox.init();
|
||||||
|
|
||||||
|
$(document).on("click", ".variations .variations-select-all", function (e) {
|
||||||
|
$(this).parent().parent().find("input[type=checkbox]").prop("checked", true).change();
|
||||||
|
e.stopPropagation();
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
$(document).on("click", ".variations .variations-select-none", function (e) {
|
||||||
|
$(this).parent().parent().find("input[type=checkbox]").prop("checked", false).change();
|
||||||
|
e.stopPropagation();
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
if ($(".items-on-quota").length) {
|
||||||
|
$(".items-on-quota .panel").each(function () {
|
||||||
|
var $panel = $(this);
|
||||||
|
$panel.toggleClass("panel-success", $panel.find("input:checked").length > 0);
|
||||||
|
$(this).find("input").change(function () {
|
||||||
|
$panel.toggleClass("panel-success", $panel.find("input:checked").length > 0);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
setup_basics($("body"));
|
||||||
|
form_handlers($("body"));
|
||||||
|
$(document).trigger("pretix:bind-forms");
|
||||||
|
|
||||||
$("#ajaxerr").on("click", ".ajaxerr-close", ajaxErrDialog.hide);
|
$("#ajaxerr").on("click", ".ajaxerr-close", ajaxErrDialog.hide);
|
||||||
moment.locale($("body").attr("data-datetimelocale"));
|
moment.locale($("body").attr("data-datetimelocale"));
|
||||||
|
|||||||
Reference in New Issue
Block a user