X-Git-Url: https://code.wpia.club/?a=blobdiff_plain;f=static%2Fstatic%2Fjs%2Fexpert.js;h=731dddde58f991e28868b2ec48e016fe4ab21384;hb=df34ffdb62c871885de7a0570c174b5169980943;hp=a4d14acac95b41e0fbaabbfb335749e7399b6362;hpb=d7be034f96e06985f57d86d2779c434276b5bd4d;p=gigi.git
diff --git a/static/static/js/expert.js b/static/static/js/expert.js
index a4d14aca..731dddde 100644
--- a/static/static/js/expert.js
+++ b/static/static/js/expert.js
@@ -1,4 +1,53 @@
(function() {
+ var modal = undefined;
+
+ function showModal(content){
+ var HTML = `
`;
+ if(modal === undefined) {
+ modal = $(HTML);
+ modal.action = function(){};
+ modal.appendTo("body");
+ $(modal.get(0)).find(".modal-footer .btn-confirm").click(function(){
+ modal.action();
+ modal.modal("hide");
+ });
+ }
+ var m = $(modal.get(0));
+ m.find(".modal-body").text($(content).attr("data-confirm"));
+ var reply = $(content).attr("data-reply").split(",");
+ m.find(".modal-footer .btn-cancel").text(reply[0]);
+ m.find(".modal-footer .btn-confirm").text(reply[1]);
+ modal.action=function(){
+ content.confirmed=true;
+ $(content).click();
+ };
+ modal.modal("show");
+ }
+ function initConfirm() {
+ $(".btn-confirm").click(function(){
+ if(this.confirmed === true){
+ return true;
+ }
+ showModal(this);
+ return false;
+ });
+ }
function showExpert(isExpert)
{
var elements = document.getElementsByClassName("expert");
@@ -17,6 +66,33 @@
if(expert !== null) {
expert.onchange = (function(expert){return function(){showExpert(expert.checked)}})(expert);
}
+ $(".panel-activatable").map(function() {
+ var panel = $(this);
+ var refresh = function(){
+ var radio = this.type == "radio";
+ if(radio && this.form.currentRadios === undefined) {
+ this.form.currentRadios = {};
+ }
+ if(this.checked) {
+ panel.find(".panel-body").removeClass("hidden");
+ if(radio) {
+ var rds = this.form.currentRadios;
+ if(rds[this.name] !== undefined){
+ $(rds[this.name]).trigger("change");
+ }
+ rds[this.name] = this;
+ }
+ } else {
+ panel.find(".panel-body").addClass("hidden");
+ }
+ };
+ panel.find(".panel-heading [type=\"checkbox\"]").map(refresh);
+ panel.find(".panel-heading [type=\"checkbox\"]").change(refresh);
+ panel.find(".panel-heading [type=\"radio\"]").map(refresh);
+ panel.find(".panel-heading [type=\"radio\"]").change(refresh);
+ return this.id;
+ });
+ initConfirm();
}
(function(oldLoad) {
if (oldLoad == undefined) {