summaryrefslogtreecommitdiff
path: root/static
diff options
context:
space:
mode:
authorKevin Chabowski <kevin@kch42.de>2013-09-12 22:40:35 +0200
committerKevin Chabowski <kevin@kch42.de>2013-09-12 22:40:35 +0200
commitb0e40b8764eab7c40b3f5e6f994af3c423b92dfc (patch)
tree1f7774fd4bcd68a089c8af9f1c5420cc4a90c926 /static
parent31236b61353e1c8f1bf96db4fad6647b1c5c402c (diff)
downloadmailremind-b0e40b8764eab7c40b3f5e6f994af3c423b92dfc.tar.gz
mailremind-b0e40b8764eab7c40b3f5e6f994af3c423b92dfc.tar.bz2
mailremind-b0e40b8764eab7c40b3f5e6f994af3c423b92dfc.zip
Improved Job editor.
Jobs that will never be executed can not be saved now.
Diffstat (limited to 'static')
-rw-r--r--static/mailremind.js42
1 files changed, 20 insertions, 22 deletions
diff --git a/static/mailremind.js b/static/mailremind.js
index 8f3079f..0e3725a 100644
--- a/static/mailremind.js
+++ b/static/mailremind.js
@@ -1,15 +1,15 @@
$(function() {
var mkRow = function() {
var row = $("<tr/>");
-
+
row.append($("<td><input type=\"text\" name=\"Start\" /></td>"));
-
+
var yn = mkYNCheckbox("RepetitionEnabled", false);
var cell = $("<td/>");
cell.append(yn.hidden);
cell.append(yn.checkbox);
row.append(cell);
-
+
cell = $("<td/>");
cell.append($("<input type=\"text\" class=\"quant\" name=\"Count\" /><span> </span>"));
var unitsel = $("<select name=\"Unit\" size=\"0\" />");
@@ -19,79 +19,77 @@ $(function() {
}
cell.append(unitsel);
row.append(cell);
-
+
yn = mkYNCheckbox("EndEnabled", false);
cell = $("<td/>");
cell.append(yn.hidden);
cell.append(yn.checkbox);
row.append(cell);
-
+
row.append($("<td><input type=\"text\" name=\"End\" /></td>"));
-
+
attachFocusHandler($("input, select", row));
return row;
};
-
+
var mkYNCheckbox = function(name, b) {
var hidden = $("<input type=\"hidden\" />");
hidden.prop("value", b ? "yes" : "no");
hidden.prop("name", name);
-
+
var checkbox = $("<input type=\"checkbox\" />");
checkbox.prop("checked", b);
checkbox.change(function() {
hidden.prop("value", checkbox.prop("checked") ? "yes" : "no");
});
-
+
return {"hidden": hidden, "checkbox": checkbox};
};
-
+
$("select.enabler").each(function(i) {
var self = $(this);
var yn = mkYNCheckbox(self.prop("name"), self.val() == "yes");
-
+
self.before(yn.hidden);
self.before(yn.checkbox);
self.remove();
});
-
+
var maxSchedules = $("table.schedules tbody tr").length;
var checkInsRow = function() {
if($("table.schedules tbody tr").length >= maxSchedules) {
return;
}
-
+
$("table.schedules tbody").append(mkRow());
};
-
+
var attachFocusHandler = function(q) {
q.focus(function() {
var myrow = $(this).parent().parent();
$("table.schedules tbody tr").not(myrow).each(function(i) {
checkRemoveRow($(this));
});
-
+
checkInsRow();
});
};
-
-
-
+
var checkRemoveRow = function(row) {
if($("input[name=\"Start\"]", row).val() == "") {
row.remove();
}
};
-
+
var updateSchedulesTab = function() {
$("table.schedules tbody tr").each(function(i) {
checkRemoveRow($(this));
});
-
+
checkInsRow();
};
-
+
attachFocusHandler($("table.schedules input, table.schedules select"));
-
+
updateSchedulesTab();
}); \ No newline at end of file