| 123456789 |
- /*
- * This file is part of the Arnapou jqCron package.
- *
- * (c) Arnaud Buathier <arnaud@arnapou.net>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
- var jqCronDefaultSettings={texts:{fr:{empty:"-tout-",name_minute:"minute",name_hour:"heure",name_day:"jour",name_week:"semaine",name_month:"mois",name_year:"année",text_period:"Chaque <b />",text_mins:"à <b /> minutes",text_time:"à <b />:<b />",text_dow:"le <b />",text_month:"de <b />",text_dom:"le <b />",error1:"La balise %s n'est pas supportée !",error2:"Mauvais nombre d'éléments",error3:"La propriété jquery_element doit être définie dans les paramètres jqCron",error4:"Expression non reconnue",weekdays:["dimanche","lundi","mardi","mercredi","jeudi","vendredi","samedi"],months:["janvier","février","mars","avril","mai","juin","juillet","août","septembre","octobre","novembre","décembre"]},en:{empty:"-all-",name_minute:"minute",name_hour:"hour",name_day:"day",name_week:"week",name_month:"month",name_year:"year",text_period:"Every <b />",text_mins:"at <b /> minutes past the hour",text_time:"at <b />:<b />",text_dow:"on <b />",text_month:"of <b />",text_dom:"on the <b />",error1:"The tag %s is not supported !",error2:"Bad number of elements",error3:"The jquery_element should be set into jqCron settings",error4:"Unrecognized expression",weekdays:["sunday","monday","tuesday","wednesday","thursday","friday","saturday"],months:["january","february","march","april","may","june","july","august","september","october","november","december"]}},monthdays:[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31],hours:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23],minutes:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59],lang:"fr",enabled_minute:false,enabled_hour:true,enabled_day:true,enabled_week:true,enabled_month:true,enabled_year:true,multiple_dom:false,multiple_month:false,multiple_mins:false,multiple_dow:false,multiple_time_hours:false,multiple_time_minutes:false,numeric_zero_pad:false,default_period:"day",default_value:"",no_reset_button:true,disabled:false,bind_to:null,bind_method:{set:function(e,t){e.is(":input")?e.val(t):e.data("jqCronValue",t)},get:function(e){return e.is(":input")?e.val():e.data("jqCronValue")}}};(function(e){var t=function(n,r){for(var i in r){if(e.isPlainObject(r[i])){n[i]=t(n[i]&&e.isPlainObject(n[i])?n[i]:{},r[i])}else if(e.isArray(r[i])){n[i]=r[i].slice(0)}else if(r[i]!==undefined){n[i]=r[i]}}return n};this.jqCronMergeSettings=function(e){return t(t({},jqCronDefaultSettings),e||{})}}).call(this,jQuery);(function(e){e.fn.jqCronGetInstance=function(){return this.data("jqCron")}}).call(this,jQuery);(function(e){e.fn.jqCron=function(t){return this.each(function(){var n,r;var i=e(this);t=jqCronMergeSettings(t);if(!t.jquery_container){if(i.is(":container")){t.jquery_element=i.uniqueId("jqCron")}else if(i.is(":autoclose")){if(i.next(".jqCron").length==1){i.next(".jqCron").remove()}t.jquery_element=e('<span class="jqCron"></span>').uniqueId("jqCron").insertAfter(i)}else{console&&console.error(t.texts[t.lang].error1.replace("%s",this.tagName));return}}if(i.is(":input")){t.bind_to=t.bind_to||i}if(t.bind_to){if(t.bind_to.is(":input")){t.bind_to.blur(function(){var e=t.bind_method.get(t.bind_to);i.jqCronGetInstance().setCron(e)})}r=t.bind_method.get(t.bind_to);n=new jqCron(t);n.setCron(r)}else{n=new jqCron(t)}e(this).data("jqCron",n)})}}).call(this,jQuery);(function(e){function n(n){function x(e,s){var u=new jqCronSelector(i,e,s);u.$.bind("selector:open",function(){for(var e=t.length;e--;){if(t[e]!=i){t[e].closeSelectors()}else{for(var n=v.length;n--;){if(v[n]!=u){v[n].close()}}}}});u.$.bind("selector:change",function(){var e=false;if(!r)return;if(n.multiple_mins==n.multiple_time_minutes){if(u==g){e=b.setValue(g.getValue())}else if(u==b){e=g.setValue(b.getValue())}}e||o.trigger("cron:change",i.getCron())});v.push(u);return u}var r=false;var i=this;var s=this;var o=e('<span class="jqCron-container"></span>');var u=e('<span class="jqCron-blocks"></span>');var a=e('<span class="jqCron-period"></span>');var f=e('<span class="jqCron-dom"></span>');var l=e('<span class="jqCron-month"></span>');var c=e('<span class="jqCron-mins"></span>');var h=e('<span class="jqCron-dow"></span>');var p=e('<span class="jqCron-time"></span>');var d=e('<span class="jqCron-cross">✘</span>');var v=[];var m,g,y,b,w,E,S;this.disable=function(){o.addClass("disable");n.disable=true;i.closeSelectors()};this.isDisabled=function(){return n.disable==true};this.enable=function(){o.removeClass("disable");n.disable=false};this.getCron=function(){var e=m.getValue();var t=["*","*","*","*","*"];if(e=="hour"){t[0]=g.getCronValue()}if(e=="day"||e=="week"||e=="month"||e=="year"){t[0]=b.getCronValue();t[1]=y.getCronValue()}if(e=="month"||e=="year"){t[2]=E.getCronValue()}if(e=="year"){t[3]=S.getCronValue()}if(e=="week"){t[4]=w.getCronValue()}return t.join(" ")};this.setCron=function(e){if(!e)return;try{e=e.replace(/\s+/g," ").replace(/^ +/,"").replace(/ +$/,"");var t=e.replace(/[^\* ]/g,"-").replace(/-+/g,"-").replace(/ +/g,"");var n=e.split(" ");if(n.length!=5)i.error(i.getText("error2"));if(t=="*****"){m.setValue("minute")}else if(t=="-****"){m.setValue("hour");g.setCronValue(n[0]);b.setCronValue(n[0])}else if(t.substring(2,t.length)=="***"){m.setValue("day");g.setCronValue(n[0]);b.setCronValue(n[0]);y.setCronValue(n[1])}else if(t.substring(2,t.length)=="-**"){m.setValue("month");g.setCronValue(n[0]);b.setCronValue(n[0]);y.setCronValue(n[1]);E.setCronValue(n[2])}else if(t.substring(2,t.length)=="**-"){m.setValue("week");g.setCronValue(n[0]);b.setCronValue(n[0]);y.setCronValue(n[1]);w.setCronValue(n[4])}else if(t.substring(3,t.length)=="-*"){m.setValue("year");g.setCronValue(n[0]);b.setCronValue(n[0]);y.setCronValue(n[1]);E.setCronValue(n[2]);S.setCronValue(n[3])}else{i.error(i.getText("error4"))}i.clearError()}catch(r){}};this.closeSelectors=function(){for(var e=v.length;e--;){v[e].close()}};this.getId=function(){return s.attr("id")};this.getText=function(e){var t=n.texts[n.lang][e]||null;if(typeof t=="string"&&t.match("<b")){t=t.replace(/(<b *\/>)/gi,'</span><b /><span class="jqCron-text">');t='<span class="jqCron-text">'+t+"</span>"}return t};this.getHumanText=function(){var t=[];o.find("> span > span:visible").find(".jqCron-text, .jqCron-selector > span").each(function(){var n=e(this).text().replace(/\s+$/g,"").replace(/^\s+/g,"");n&&t.push(n)});return t.join(" ").replace(/\s:\s/g,":")};this.getSettings=function(){return n};this.error=function(e){console&&console.error("[jqCron Error] "+e);o.addClass("jqCron-error").attr("title",e);throw e};this.clearError=function(){o.attr("title","").removeClass("jqCron-error")};this.clear=function(){E.setValue([]);w.setValue([]);g.setValue([]);S.setValue([]);y.setValue([]);b.setValue([]);i.triggerChange()};this.init=function(){var t,T,N;if(r)return;n=jqCronMergeSettings(n);n.jquery_element||i.error(i.getText("error3"));s=n.jquery_element;s.append(o);o.data("id",n.id);o.data("jqCron",i);o.append(u);n.no_reset_button||o.append(d);!n.disable||o.addClass("disable");u.append(a);u.append(f);u.append(l);u.append(c);u.append(h);u.append(p);d.click(function(){i.isDisabled()||i.clear()});o.bind("cron:change",function(e,t){if(!n.bind_to)return;n.bind_method.set&&n.bind_method.set(n.bind_to,t);i.clearError()});a.append(i.getText("text_period"));m=x(a,false);n.enabled_minute&&m.add("minute",i.getText("name_minute"));n.enabled_hour&&m.add("hour",i.getText("name_hour"));n.enabled_day&&m.add("day",i.getText("name_day"));n.enabled_week&&m.add("week",i.getText("name_week"));n.enabled_month&&m.add("month",i.getText("name_month"));n.enabled_year&&m.add("year",i.getText("name_year"));m.$.bind("selector:change",function(e,t){f.hide();l.hide();c.hide();h.hide();p.hide();if(t=="hour"){c.show()}else if(t=="day"){p.show()}else if(t=="week"){h.show();p.show()}else if(t=="month"){f.show();p.show()}else if(t=="year"){f.show();l.show();p.show()}});m.setValue(n.default_period);c.append(i.getText("text_mins"));g=x(c,n.multiple_mins);for(T=0,N=n.minutes;T<N.length;T++){g.add(N[T],N[T])}p.append(i.getText("text_time"));y=x(p,n.multiple_time_hours);for(T=0,N=n.hours;T<N.length;T++){y.add(N[T],N[T])}b=x(p,n.multiple_time_minutes);for(T=0,N=n.minutes;T<N.length;T++){b.add(N[T],N[T])}h.append(i.getText("text_dow"));w=x(h,n.multiple_dow);for(T=0,N=i.getText("weekdays");T<N.length;T++){w.add(T+1,N[T])}f.append(i.getText("text_dom"));E=x(f,n.multiple_dom);for(T=0,N=n.monthdays;T<N.length;T++){E.add(N[T],N[T])}l.append(i.getText("text_month"));S=x(l,n.multiple_month);for(T=0,N=i.getText("months");T<N.length;T++){S.add(T+1,N[T])}e("body").click(function(){var e,t=v.length;for(e=0;e<t;e++){v[e].close()}});r=true;if(n.default_value){i.setCron(n.default_value)}};this.triggerChange=function(){o.trigger("cron:change",i.getCron())};t.push(this);this.$=o;try{this.init();i.triggerChange()}catch(T){}}var t=[];this.jqCron=n}).call(this,jQuery);(function(e){function t(t,n,r){function h(e){var t=0,n=e.length,r={},i=[];while(t<n){r[e[t]]||(r[e[t]]=1&&i.push(e[t]));t++}return i}var i=this;var s=e('<ul class="jqCron-selector-list"></ul>');var o=e('<span class="jqCron-selector-title"></span>');var u=e('<span class="jqCron-selector"></span>');var a={};var f=[];var l=true;var c=t.getSettings().numeric_zero_pad;this.getValue=function(){return r?f:f[0]};this.getCronValue=function(){if(f.length==0)return"*";var e=[f[0]],t,n=f[0],r=f[0],i=f.length;for(t=1;t<i;t++){if(f[t]==r+1){r=f[t];e[e.length-1]=n+"-"+r}else{n=r=f[t];e.push(r)}}return e.join(",")};this.setCronValue=function(e){var t=[],n,r,s;if(e!=="*"){while(e!=""){n=e.match(/^\*\/([0-9]+),?/);if(n&&n.length==2){for(r=0;r<=59;r+=n[1]|0){t.push(r)}e=e.replace(n[0],"");continue}n=e.match(/^([0-9]+)-([0-9]+)\/([0-9]+),?/);if(n&&n.length==4){for(r=n[1]|0;r<=(n[2]|0);r+=n[3]|0){t.push(r)}e=e.replace(n[0],"");continue}n=e.match(/^([0-9]+)-([0-9]+),?/);if(n&&n.length==3){for(r=n[1]|0;r<=(n[2]|0);r++){t.push(r)}e=e.replace(n[0],"");continue}n=e.match(/^([0-9]+),?/);if(n&&n.length==2){t.push(n[1]|0);e=e.replace(n[0],"");continue}return}}i.setValue(t)};this.close=function(){u.trigger("selector:close")};this.open=function(){u.trigger("selector:open")};this.isOpened=function(){return s.is(":visible")};this.addValue=function(e){var t=r?f.slice(0):[];t.push(e);i.setValue(t)};this.removeValue=function(e){if(r){var t,n=[];for(t=0;t<f.length;t++){if(e!=[f[t]]){n.push(f[t])}}i.setValue(n)}else{i.clear()}};this.setValue=function(t){var n,i=[],o=f.join(" ");if(!e.isArray(t))t=[t];s.find("li").removeClass("selected");t=h(t);t.sort(function(e,t){var n=typeof e;var r=typeof t;if(n==r&&n=="number")return e-t;else return String(e)==String(t)?0:String(e)<String(t)?-1:1});if(r){for(n=0;n<t.length;n++){if(t[n]in a){a[t[n]].addClass("selected");i.push(t[n])}}}else{if(t[0]in a){a[t[0]].addClass("selected");i.push(t[0])}}f=i;if(o!=f.join(" ")){u.trigger("selector:change",r?t:t[0]);return true}return false};this.getTitleText=function(){var e=function(e){return e in a?a[e].text():e};if(f.length==0)return t.getText("empty");var n=[e(f[0])],r,i=f[0],s=f[0],o=f.length;for(r=1;r<o;r++){if(f[r]==s+1){s=f[r];n[n.length-1]=e(i)+"-"+e(s)}else{i=s=f[r];n.push(e(s))}}return n.join(",")};this.clear=function(){a={};i.setValue([]);s.empty()};this.add=function(t,n){if(!(n+"").match(/^[0-9]+$/))l=false;if(c&&l&&n<10){n="0"+n}var o=e("<li>"+n+"</li>");s.append(o);a[t]=o;o.click(function(){if(r&&e(this).hasClass("selected")){i.removeValue(t)}else{i.addValue(t);if(!r)i.close()}})};this.$=u;n.find("b:eq(0)").after(u).remove();u.addClass("jqCron-selector-"+n.find(".jqCron-selector").length).append(o).append(s).bind("selector:open",function(){if(l){var e=1,t=s.find("li").length;if(t>5&&t<=16)e=2;else if(t>16&&t<=23)e=3;else if(t>23&&t<=40)e=4;else if(t>40)e=5;s.addClass("cols"+e)}s.show()}).bind("selector:close",function(){s.hide()}).bind("selector:change",function(){o.html(i.getTitleText())}).click(function(e){e.stopPropagation()}).trigger("selector:change");e.fn.disableSelection&&u.disableSelection();o.click(function(e){i.isOpened()||t.isDisabled()?i.close():i.open()});i.close();i.clear()}this.jqCronSelector=t}).call(this,jQuery);(function(e){var t=0;var n=function(e){var n;while(1){t++;n=(e||"JQUID")+""+t;if(!document.getElementById(n))return n}};e.fn.uniqueId=function(t){return this.each(function(){if(e(this).attr("id"))return;var r=n(t);e(this).attr("id",r)})}}).call(this,jQuery);(function(e){e.extend(e.expr[":"],{container:function(e){return(e.tagName+"").toLowerCase()in{a:1,abbr:1,acronym:1,address:1,b:1,big:1,blockquote:1,button:1,cite:1,code:1,dd:1,del:1,dfn:1,div:1,dt:1,em:1,fieldset:1,form:1,h1:1,h2:1,h3:1,h4:1,h5:1,h6:1,i:1,ins:1,kbd:1,label:1,li:1,p:1,pre:1,q:1,samp:1,small:1,span:1,strong:1,sub:1,sup:1,td:1,tt:1}},autoclose:function(e){return(e.tagName+"").toLowerCase()in{area:1,base:1,basefont:1,br:1,col:1,frame:1,hr:1,img:1,input:1,link:1,meta:1,param:1}}})}).call(this,jQuery)
|