diff --git a/3rdparty/jquery.cron/img/disk.png b/3rdparty/jquery.cron/img/disk.png deleted file mode 100644 index 99d532e8b1..0000000000 Binary files a/3rdparty/jquery.cron/img/disk.png and /dev/null differ diff --git a/3rdparty/jquery.cron/img/loading.gif b/3rdparty/jquery.cron/img/loading.gif deleted file mode 100644 index d0bce15423..0000000000 Binary files a/3rdparty/jquery.cron/img/loading.gif and /dev/null differ diff --git a/3rdparty/jquery.cron/jquery.cron.css b/3rdparty/jquery.cron/jquery.cron.css deleted file mode 100644 index d2a1322ac5..0000000000 --- a/3rdparty/jquery.cron/jquery.cron.css +++ /dev/null @@ -1,24 +0,0 @@ -.cron-button { - height: 16px; - padding-left: 20px; - margin-left: 5px; - background-repeat: no-repeat; - background-position: center center; - cursor: pointer; -} -.cron-button-save { - background-image: url('img/disk.png'); -} -.cron-changed { - padding-top: 5px; - padding-bottom: 5px; - background-color: #fdd; -} -.cron-controls { - margin-left: 10px; - color: #c77; - font-size: 0.9em; -} -.cron-controls > span.cron-loading { - background-image: url('img/loading.gif'); -} \ No newline at end of file diff --git a/3rdparty/jquery.cron/jquery.cron.min.js b/3rdparty/jquery.cron/jquery.cron.min.js deleted file mode 100644 index 933db1ba40..0000000000 --- a/3rdparty/jquery.cron/jquery.cron.min.js +++ /dev/null @@ -1,392 +0,0 @@ -(function(e) { - var n = { - initial: "* * * * *", - minuteOpts: { - minWidth: 100, - itemWidth: 30, - columns: 4, - rows: undefined, - title: "Minutes après l'heure" - }, - timeHourOpts: { - minWidth: 100, - itemWidth: 20, - columns: 2, - rows: undefined, - title: "Heure: heure" - }, - domOpts: { - minWidth: 100, - itemWidth: 30, - columns: undefined, - rows: 10, - title: "Jour du mois" - }, - monthOpts: { - minWidth: 100, - itemWidth: 100, - columns: 2, - rows: undefined, - title: undefined - }, - dowOpts: { - minWidth: 100, - itemWidth: undefined, - columns: undefined, - rows: undefined, - title: undefined - }, - timeMinuteOpts: { - minWidth: 100, - itemWidth: 20, - columns: 4, - rows: undefined, - title: "Temps: minute" - }, - effectOpts: { - openSpeed: 400, - closeSpeed: 400, - openEffect: "slide", - closeEffect: "slide", - hideOnMouseOut: true - }, - url_set: undefined, - customValues: undefined, - onChange: undefined, - useGentleSelect: false - }; - var y = ""; - for (var u = 0; u < 60; u++) { - var t = (u < 10) ? "0" : ""; - y += "\n" - } - var d = ""; - for (var u = 0; u < 24; u++) { - var t = (u < 10) ? "0" : ""; - d += "\n" - } - var v = ""; - for (var u = 1; u < 32; u++) { - v += "\n" - } - var h = ""; - var l = ["Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Aout", "Septembre", "Octobre", "Novembre", "Décembre"]; - for (var u = 0; u < l.length; u++) { - h += "\n" - } - var s = ""; - var g = ["Dimanche", "Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi"]; - for (var u = 0; u < g.length; u++) { - s += "\n" - } - var r = ""; - var b = {"minute" : "Minute","hour" : "Heure","day" :"Jour","week" : "Semaine","month" : "Mois","year" : "Année"}; - for(var u in b){ - r += "\n" - } - var p = { - minute: [], - hour: ["mins"], - day: ["time"], - week: ["dow", "time"], - month: ["dom", "time"], - year: ["dom", "month", "time"] - }; - var w = { - minute: /^(\*\s){4}\*$/, - hour: /^\d{1,2}\s(\*\s){3}\*$/, - day: /^(\d{1,2}\s){2}(\*\s){2}\*$/, - week: /^(\d{1,2}\s){2}(\*\s){2}\d{1,2}$/, - month: /^(\d{1,2}\s){3}\*\s\*$/, - year: /^(\d{1,2}\s){4}\*$/ - }; - - function a(i) { - if (typeof i == "undefined") { - return false - } else { - return true - } - } - - function q(i) { - return (!a(i) || typeof i == "object") - } - - function z(A, j) { - if (a(j.customValues)) { - for (key in j.customValues) { - if (A == j.customValues[key]) { - return key - } - } - } - var E = /^((\d{1,2}|\*)\s){4}(\d{1,2}|\*)$/; - if (typeof A != "string" || !E.test(A)) { - e.error("cron: invalid initial value"); - return undefined - } - var C = A.split(" "); - var D = [0, 0, 1, 1, 0]; - var G = [59, 23, 31, 12, 6]; - for (var B = 0; B < C.length; B++) { - if (C[B] == "*") { - continue - } - var F = parseInt(C[B]); - if (a(F) && F <= G[B] && F >= D[B]) { - continue - } - e.error("cron: invalid value found (col " + (B + 1) + ") in " + o.initial); - return undefined - } - for (var H in w) { - if (w[H].test(A)) { - return H - } - } - e.error("cron: valid but unsupported cron format. sorry."); - return undefined - } - - function f(j, i) { - if (!a(z(i.initial, i))) { - return true - } - if (!q(i.customValues)) { - return true - } - if (a(i.customValues)) { - for (key in i.customValues) { - if (w.hasOwnProperty(key)) { - e.error("cron: reserved keyword '" + key + "' should not be used as customValues key."); - return true - } - } - } - return false - } - - function k(B) { - var i = B.data("block"); - var j = hour = day = month = dow = "*"; - var A = i.period.find("select").val(); - switch (A) { - case "minute": - break; - case "hour": - j = i.mins.find("select").val(); - break; - case "day": - j = i.time.find("select.cron-time-min").val(); - hour = i.time.find("select.cron-time-hour").val(); - break; - case "week": - j = i.time.find("select.cron-time-min").val(); - hour = i.time.find("select.cron-time-hour").val(); - dow = i.dow.find("select").val(); - break; - case "month": - j = i.time.find("select.cron-time-min").val(); - hour = i.time.find("select.cron-time-hour").val(); - day = i.dom.find("select").val(); - break; - case "year": - j = i.time.find("select.cron-time-min").val(); - hour = i.time.find("select.cron-time-hour").val(); - day = i.dom.find("select").val(); - month = i.month.find("select").val(); - break; - default: - return A - } - return [j, hour, day, month, dow].join(" ") - } - var x = { - init: function(i) { - var G = i ? i : {}; - var B = e.extend([], n, G); - var j = e.extend({}, n.effectOpts, G.effectOpts); - e.extend(B, { - minuteOpts: e.extend({}, n.minuteOpts, j, G.minuteOpts), - domOpts: e.extend({}, n.domOpts, j, G.domOpts), - monthOpts: e.extend({}, n.monthOpts, j, G.monthOpts), - dowOpts: e.extend({}, n.dowOpts, j, G.dowOpts), - timeHourOpts: e.extend({}, n.timeHourOpts, j, G.timeHourOpts), - timeMinuteOpts: e.extend({}, n.timeMinuteOpts, j, G.timeMinuteOpts) - }); - if (f(this, B)) { - return this - } - var C = [], - A = "", - D = B.customValues; - if (a(D)) { - for (var F in D) { - A += "\n" - } - } - C.period = e("
").appendTo(this).data("root", this); - var E = C.period.find("select"); - E.bind("change.cron", m.periodChanged).data("root", this); - if (B.useGentleSelect) { - E.gentleSelect(j) - } - C.dom = e("
").appendTo(this).data("root", this); - E = C.dom.find("select").data("root", this); - if (B.useGentleSelect) { - E.gentleSelect(B.domOpts) - } - C.month = e("
").appendTo(this).data("root", this); - E = C.month.find("select").data("root", this); - if (B.useGentleSelect) { - E.gentleSelect(B.monthOpts) - } - C.mins = e("
minutes après l'heure
").appendTo(this).data("root", this); - E = C.mins.find("select").data("root", this); - if (B.useGentleSelect) { - E.gentleSelect(B.minuteOpts) - } - C.dow = e("
").appendTo(this).data("root", this); - E = C.dow.find("select").data("root", this); - if (B.useGentleSelect) { - E.gentleSelect(B.dowOpts) - } - C.time = e("
").appendTo(this).data("root", this); - E = C.time.find("select.cron-time-hour").data("root", this); - if (B.useGentleSelect) { - E.gentleSelect(B.timeHourOpts) - } - E = C.time.find("select.cron-time-min").data("root", this); - if (B.useGentleSelect) { - E.gentleSelect(B.timeMinuteOpts) - } - C.controls = e("« save ").appendTo(this).data("root", this).find("span.cron-button-save").bind("click.cron", m.saveClicked).data("root", this).end(); - this.find("select").bind("change.cron-callback", m.somethingChanged); - this.data("options", B).data("block", C); - this.data("current_value", B.initial); - return x.value.call(this, B.initial) - }, - value: function(C) { - if (!C) { - return k(this) - } - var A = this.data("options"); - var D = this.data("block"); - var F = A.useGentleSelect; - var K = z(C, A); - if (!a(K)) { - return false - } - if (a(A.customValues) && A.customValues.hasOwnProperty(K)) { - K = A.customValues[K] - } else { - var H = C.split(" "); - var J = { - mins: H[0], - hour: H[1], - dom: H[2], - month: H[3], - dow: H[4] - }; - var G = p[K]; - for (var E = 0; E < G.length; E++) { - var B = G[E]; - if (B == "time") { - var I = D[B].find("select.cron-time-hour").val(J.hour); - if (F) { - I.gentleSelect("update") - } - I = D[B].find("select.cron-time-min").val(J.mins); - if (F) { - I.gentleSelect("update") - } - } else { - var I = D[B].find("select").val(J[B]); - if (F) { - I.gentleSelect("update") - } - } - } - } - var j = D.period.find("select").val(K); - if (F) { - j.gentleSelect("update") - } - j.trigger("change"); - return this - } - }; - var m = { - periodChanged: function() { - var A = e(this).data("root"); - var E = A.data("block"), - C = A.data("options"); - var D = e(this).val(); - A.find(".cron-block").hide(); - if (p.hasOwnProperty(D)) { - var j = p[e(this).val()]; - for (var B = 0; B < j.length; B++) { - E[j[B]].show() - } - } - }, - somethingChanged: function() { - root = e(this).data("root"); - if (a(root.data("options").url_set)) { - if (x.value.call(root) != root.data("current_value")) { - root.addClass("cron-changed"); - root.data("block")["controls"].fadeIn() - } else { - root.removeClass("cron-changed"); - root.data("block")["controls"].fadeOut() - } - } else { - root.data("block")["controls"].hide() - } - var i = root.data("options").onChange; - if (a(i) && e.isFunction(i)) { - i.call(root) - } - }, - saveClicked: function() { - var j = e(this); - var i = j.data("root"); - var A = x.value.call(i); - if (j.hasClass("cron-loading")) { - return - } - j.addClass("cron-loading"); - e.ajax({ - type: "POST", - url: i.data("options").url_set, - data: { - cron: A - }, - success: function() { - i.data("current_value", A); - j.removeClass("cron-loading"); - if (A == x.value.call(i)) { - i.removeClass("cron-changed"); - i.data("block").controls.fadeOut() - } - }, - error: function() { - alert("An error occured when submitting your request. Try again?"); - j.removeClass("cron-loading") - } - }) - } - }; - e.fn.cron = function(i) { - if (x[i]) { - return x[i].apply(this, Array.prototype.slice.call(arguments, 1)) - } else { - if (typeof i === "object" || !i) { - return x.init.apply(this, arguments) - } else { - e.error("Method " + i + " does not exist on jQuery.cron") - } - } - } -})(jQuery); diff --git a/core/dom/jeeCron.js b/core/dom/jeeCron.js new file mode 100644 index 0000000000..6f4c28b754 --- /dev/null +++ b/core/dom/jeeCron.js @@ -0,0 +1,310 @@ +/* + * Adapted from http://shawnchin.github.com/jquery-cron without jQuery requirement + * Some options like url, save, user input have been removed for simplification + * + * Notes: + * At this stage, we only support a subset of possible cron options. + * For example, each cron entry can only be digits or "*", no commas + * to denote multiple entries. We also limit the allowed combinations: + * - Every minute : * * * * * + * - Every hour : ? * * * * + * - Every day : ? ? * * * + * - Every week : ? ? * * ? + * - Every month : ? ? ? * * + * - Every year : ? ? ? ? * + */ + +var jeeCron = function(_UIgenerator, _options) { + 'use strict' + var jCrInstance = { + _description: 'js cron generator. /core/dom/jeeCron.js' + } + + var _c_ = {} //Internal passthrough + + var defaultOptions = { + initial : "* * * * *", + minuteOpts : { + minWidth : 100, // only applies if columns and itemWidth not set + itemWidth : 30, + columns : 4, + rows : undefined, + title : "{{Minutes Past the Hour}}" + }, + timeHourOpts : { + minWidth : 100, // only applies if columns and itemWidth not set + itemWidth : 20, + columns : 2, + rows : undefined, + title : "{{Time: Hour}}" + }, + domOpts : { + minWidth : 100, // only applies if columns and itemWidth not set + itemWidth : 30, + columns : undefined, + rows : 10, + title : "{{Day of Month}}" + }, + monthOpts : { + minWidth : 100, // only applies if columns and itemWidth not set + itemWidth : 100, + columns : 2, + rows : undefined, + title : undefined + }, + dowOpts : { + minWidth : 100, // only applies if columns and itemWidth not set + itemWidth : undefined, + columns : undefined, + rows : undefined, + title : undefined + }, + timeMinuteOpts : { + minWidth : 100, // only applies if columns and itemWidth not set + itemWidth : 20, + columns : 4, + rows : undefined, + title : "{{Time: Minute}}" + }, + customValues : undefined, + onChange: undefined, // callback function each time value changes + } + var options = _options ? _options : {} + var o = domUtils.extend({}, defaultOptions, options) + domUtils.extend(o, { + minuteOpts : domUtils.extend({}, defaultOptions.minuteOpts, options.minuteOpts), + domOpts : domUtils.extend({}, defaultOptions.domOpts, options.domOpts), + monthOpts : domUtils.extend({}, defaultOptions.monthOpts, options.monthOpts), + dowOpts : domUtils.extend({}, defaultOptions.dowOpts, options.dowOpts), + timeHourOpts : domUtils.extend({}, defaultOptions.timeHourOpts, options.timeHourOpts), + timeMinuteOpts : domUtils.extend({}, defaultOptions.timeMinuteOpts, options.timeMinuteOpts) + }) + + jCrInstance.root = _UIgenerator + // store options and block pointer + jCrInstance.options = o + jCrInstance.block = {} + + getDefaultStrOps() + build() + // remember base value to detect changes: + jCrInstance.current_value = o.initial + + function getDefaultStrOps() { + // ------- build some static data ------- + + // options for minutes in an hour + _c_.str_opt_mih = "" + for (var i = 0; i < 60; i++) { + var j = (i < 10)? "0":"" + _c_.str_opt_mih += "\n" + } + + // options for hours in a day + _c_.str_opt_hid = "" + for (var i = 0; i < 24; i++) { + var j = (i < 10)? "0":"" + _c_.str_opt_hid += "\n" + } + + // options for days of month + _c_.str_opt_dom = "" + for (var i = 1; i < 32; i++) { + if (i == 1 || i == 21 || i == 31) { var suffix = "st" } + else if (i == 2 || i == 22) { var suffix = "nd" } + else if (i == 3 || i == 23) { var suffix = "rd" } + else { var suffix = "th"; } + _c_.str_opt_dom += "\n"; + } + + // options for months + _c_.str_opt_month = "" + var months = ['{{Janvier}}', '{{Février}}', '{{Mars}}', '{{Avril}}', '{{Mai}}', '{{Juin}}', '{{Juillet}}', '{{Août}}', '{{Septembre}}', '{{Octobre}}', '{{Novembre}}', '{{Décembre}}'] + for (var i = 0; i < months.length; i++) { + _c_.str_opt_month += "\n" + } + + // options for day of week + _c_.str_opt_dow = "" + var days = ['{{Dimanche}}', '{{Lundi}}', '{{Mardi}}', '{{Mercredi}}', '{{Jeudi}}', '{{Vendredi}}', '{{Samedi}}'] + for (var i = 0; i < days.length; i++) { + _c_.str_opt_dow += "\n" + } + + // options for period + _c_.str_opt_period = "" + var periods = {'minute':'{{minute}}', 'hour':'{{heure}}', 'day':'{{jour}}', 'week':'{{semaine}}', 'month':'{{mois}}', 'year':'{{année}}'} + for (var i in periods) { + _c_.str_opt_period += "\n" + } + + // display matrix + _c_.toDisplay = { + "minute" : [], + "hour" : ["mins"], + "day" : ["time"], + "week" : ["dow", "time"], + "month" : ["dom", "time"], + "year" : ["dom", "month", "time"] + } + + _c_.combinations = { + "minute" : /^(\*\s){4}\*$/, // "* * * * *" + "hour" : /^\d{1,2}\s(\*\s){3}\*$/, // "? * * * *" + "day" : /^(\d{1,2}\s){2}(\*\s){2}\*$/, // "? ? * * *" + "week" : /^(\d{1,2}\s){2}(\*\s){2}\d{1,2}$/, // "? ? * * ?" + "month" : /^(\d{1,2}\s){3}\*\s\*$/, // "? ? ? * *" + "year" : /^(\d{1,2}\s){4}\*$/ // "? ? ? ? *" + } + } + + function build() { + var custom_periods = "" + var cv = o.customValues + if (cv) { // prepend custom values if specified + for (var key in cv) { + custom_periods += "\n" + } + } + + jCrInstance.block["period"] = "" + + "{{Chaque}} " + _UIgenerator.insertAdjacentHTML('beforeend', jCrInstance.block["period"]) + jCrInstance.block["period"] = _UIgenerator.querySelector('span.cron-period') + jCrInstance.block["period"]._jeeCron = {root: _UIgenerator} + + var select = jCrInstance.block["period"].querySelector("select") + select._jeeCron = {root: _UIgenerator, options: o} + + select.addEventListener("change", function(event) { + jCrInstance.periodChanged(event) + }) + + jCrInstance.block["dom"] = "" + + "{{Le}} " + _UIgenerator.insertAdjacentHTML('beforeend', jCrInstance.block["dom"]) + jCrInstance.block["dom"] = _UIgenerator.querySelector('span.cron-block-dom') + jCrInstance.block["dom"]._jeeCron = {root: _UIgenerator} + + select = jCrInstance.block["dom"].querySelector("select")._jeeCron = {root: _UIgenerator} + + jCrInstance.block["month"] = "" + + "{{De}} " + _UIgenerator.insertAdjacentHTML('beforeend', jCrInstance.block["month"]) + jCrInstance.block["month"] = _UIgenerator.querySelector('span.cron-block-month') + jCrInstance.block["month"]._jeeCron = {root: _UIgenerator} + + select = jCrInstance.block["month"].querySelector("select")._jeeCron = {root: _UIgenerator} + + jCrInstance.block["mins"] = "" + + "{{A}} {{minutes après l'heure}} " + _UIgenerator.insertAdjacentHTML('beforeend', jCrInstance.block["mins"]) + jCrInstance.block["mins"] = _UIgenerator.querySelector('span.cron-block-mins') + jCrInstance.block["mins"]._jeeCron = {root: _UIgenerator} + + select = jCrInstance.block["mins"].querySelector("select")._jeeCron = {root: _UIgenerator} + + jCrInstance.block["dow"] = "" + + "{{Le}} " + _UIgenerator.insertAdjacentHTML('beforeend', jCrInstance.block["dow"]) + jCrInstance.block["dow"] = _UIgenerator.querySelector('span.cron-block-dow') + jCrInstance.block["dow"]._jeeCron = {root: _UIgenerator} + + select = jCrInstance.block["dow"].querySelector("select")._jeeCron = {root: _UIgenerator} + + jCrInstance.block["time"] = "" + + "{{A}} : -
+