Skip to content

Commit c4a486c

Browse files
authored
Update to allow limiting of Period choices
Taken from the uncommitted PR here shawnchin#17 This allows us to supply the Periods that can be selected
1 parent 59a6e7c commit c4a486c

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

cron/jquery-cron.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
closeEffect : "slide",
9191
hideOnMouseOut : true
9292
},
93+
periods : ["minute", "hour", "day", "week", "month", "year"],
9394
url_set : undefined,
9495
customValues : undefined,
9596
onChange: undefined, // callback function each time value changes
@@ -139,13 +140,6 @@
139140
str_opt_dow += "<option value='"+i+"'>" + days[i] + "</option>\n";
140141
}
141142

142-
// options for period
143-
var str_opt_period = "";
144-
var periods = ["minute", "hour", "day", "week", "month", "year"];
145-
for (var i = 0; i < periods.length; i++) {
146-
str_opt_period += "<option value='"+periods[i]+"'>" + periods[i] + "</option>\n";
147-
}
148-
149143
// display matrix
150144
var toDisplay = {
151145
"minute" : [],
@@ -298,6 +292,12 @@
298292

299293
// ---- define select boxes in the right order -----
300294

295+
// options for period
296+
var str_opt_period = "";
297+
for (var i = 0; i < o.periods.length; i++) {
298+
str_opt_period += "<option value='" + o.periods[i] + "'>" + o.periods[i] + "</option>\n";
299+
}
300+
301301
var block = [], custom_periods = "", cv = o.customValues;
302302
if (defined(cv)) { // prepend custom values if specified
303303
for (var key in cv) {
@@ -389,9 +389,9 @@
389389
var block = this.data("block");
390390
var useGentleSelect = o.useGentleSelect;
391391
var t = getCronType(cron_str, o);
392-
392+
393393
if (!defined(t)) { return false; }
394-
394+
395395
if (defined(o.customValues) && o.customValues.hasOwnProperty(t)) {
396396
t = o.customValues[t];
397397
} else {
@@ -420,7 +420,7 @@
420420
}
421421
}
422422
}
423-
423+
424424
// trigger change event
425425
var bp = block["period"].find("select").val(t);
426426
if (useGentleSelect) bp.gentleSelect("update");

0 commit comments

Comments
 (0)