Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose periods as an option to override displayed periods #17

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cron/jquery-cron-min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions cron/jquery-cron.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
closeEffect : "slide",
hideOnMouseOut : true
},
periods : ["minute", "hour", "day", "week", "month", "year"],
url_set : undefined,
customValues : undefined,
onChange: undefined, // callback function each time value changes
Expand Down Expand Up @@ -139,13 +140,6 @@
str_opt_dow += "<option value='"+i+"'>" + days[i] + "</option>\n";
}

// options for period
var str_opt_period = "";
var periods = ["minute", "hour", "day", "week", "month", "year"];
for (var i = 0; i < periods.length; i++) {
str_opt_period += "<option value='"+periods[i]+"'>" + periods[i] + "</option>\n";
}

// display matrix
var toDisplay = {
"minute" : [],
Expand Down Expand Up @@ -298,6 +292,12 @@

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

// options for period
var str_opt_period = "";
for (var i = 0; i < o.periods.length; i++) {
str_opt_period += "<option value='" + o.periods[i] + "'>" + o.periods[i] + "</option>\n";
}

var block = [], custom_periods = "", cv = o.customValues;
if (defined(cv)) { // prepend custom values if specified
for (var key in cv) {
Expand Down Expand Up @@ -389,9 +389,9 @@
var block = this.data("block");
var useGentleSelect = o.useGentleSelect;
var t = getCronType(cron_str, o);

if (!defined(t)) { return false; }

if (defined(o.customValues) && o.customValues.hasOwnProperty(t)) {
t = o.customValues[t];
} else {
Expand Down Expand Up @@ -420,7 +420,7 @@
}
}
}

// trigger change event
var bp = block["period"].find("select").val(t);
if (useGentleSelect) bp.gentleSelect("update");
Expand Down