" )
2588 | .attr( "id", id )
2589 | .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
2590 | .data( "ui-tabs-destroy", true );
2591 | },
2592 |
2593 | _setupDisabled: function( disabled ) {
2594 | if ( $.isArray( disabled ) ) {
2595 | if ( !disabled.length ) {
2596 | disabled = false;
2597 | } else if ( disabled.length === this.anchors.length ) {
2598 | disabled = true;
2599 | }
2600 | }
2601 |
2602 | // disable tabs
2603 | for ( var i = 0, li; ( li = this.tabs[ i ] ); i++ ) {
2604 | if ( disabled === true || $.inArray( i, disabled ) !== -1 ) {
2605 | $( li )
2606 | .addClass( "ui-state-disabled" )
2607 | .attr( "aria-disabled", "true" );
2608 | } else {
2609 | $( li )
2610 | .removeClass( "ui-state-disabled" )
2611 | .removeAttr( "aria-disabled" );
2612 | }
2613 | }
2614 |
2615 | this.options.disabled = disabled;
2616 | },
2617 |
2618 | _setupEvents: function( event ) {
2619 | var events = {};
2620 | if ( event ) {
2621 | $.each( event.split(" "), function( index, eventName ) {
2622 | events[ eventName ] = "_eventHandler";
2623 | });
2624 | }
2625 |
2626 | this._off( this.anchors.add( this.tabs ).add( this.panels ) );
2627 | // Always prevent the default action, even when disabled
2628 | this._on( true, this.anchors, {
2629 | click: function( event ) {
2630 | event.preventDefault();
2631 | }
2632 | });
2633 | this._on( this.anchors, events );
2634 | this._on( this.tabs, { keydown: "_tabKeydown" } );
2635 | this._on( this.panels, { keydown: "_panelKeydown" } );
2636 |
2637 | this._focusable( this.tabs );
2638 | this._hoverable( this.tabs );
2639 | },
2640 |
2641 | _setupHeightStyle: function( heightStyle ) {
2642 | var maxHeight,
2643 | parent = this.element.parent();
2644 |
2645 | if ( heightStyle === "fill" ) {
2646 | maxHeight = parent.height();
2647 | maxHeight -= this.element.outerHeight() - this.element.height();
2648 |
2649 | this.element.siblings( ":visible" ).each(function() {
2650 | var elem = $( this ),
2651 | position = elem.css( "position" );
2652 |
2653 | if ( position === "absolute" || position === "fixed" ) {
2654 | return;
2655 | }
2656 | maxHeight -= elem.outerHeight( true );
2657 | });
2658 |
2659 | this.element.children().not( this.panels ).each(function() {
2660 | maxHeight -= $( this ).outerHeight( true );
2661 | });
2662 |
2663 | this.panels.each(function() {
2664 | $( this ).height( Math.max( 0, maxHeight -
2665 | $( this ).innerHeight() + $( this ).height() ) );
2666 | })
2667 | .css( "overflow", "auto" );
2668 | } else if ( heightStyle === "auto" ) {
2669 | maxHeight = 0;
2670 | this.panels.each(function() {
2671 | maxHeight = Math.max( maxHeight, $( this ).height( "" ).height() );
2672 | }).height( maxHeight );
2673 | }
2674 | },
2675 |
2676 | _eventHandler: function( event ) {
2677 | var options = this.options,
2678 | active = this.active,
2679 | anchor = $( event.currentTarget ),
2680 | tab = anchor.closest( "li" ),
2681 | clickedIsActive = tab[ 0 ] === active[ 0 ],
2682 | collapsing = clickedIsActive && options.collapsible,
2683 | toShow = collapsing ? $() : this._getPanelForTab( tab ),
2684 | toHide = !active.length ? $() : this._getPanelForTab( active ),
2685 | eventData = {
2686 | oldTab: active,
2687 | oldPanel: toHide,
2688 | newTab: collapsing ? $() : tab,
2689 | newPanel: toShow
2690 | };
2691 |
2692 | event.preventDefault();
2693 |
2694 | if ( tab.hasClass( "ui-state-disabled" ) ||
2695 | // tab is already loading
2696 | tab.hasClass( "ui-tabs-loading" ) ||
2697 | // can't switch durning an animation
2698 | this.running ||
2699 | // click on active header, but not collapsible
2700 | ( clickedIsActive && !options.collapsible ) ||
2701 | // allow canceling activation
2702 | ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
2703 | return;
2704 | }
2705 |
2706 | options.active = collapsing ? false : this.tabs.index( tab );
2707 |
2708 | this.active = clickedIsActive ? $() : tab;
2709 | if ( this.xhr ) {
2710 | this.xhr.abort();
2711 | }
2712 |
2713 | if ( !toHide.length && !toShow.length ) {
2714 | $.error( "jQuery UI Tabs: Mismatching fragment identifier." );
2715 | }
2716 |
2717 | if ( toShow.length ) {
2718 | this.load( this.tabs.index( tab ), event );
2719 | }
2720 | this._toggle( event, eventData );
2721 | },
2722 |
2723 | // handles show/hide for selecting tabs
2724 | _toggle: function( event, eventData ) {
2725 | var that = this,
2726 | toShow = eventData.newPanel,
2727 | toHide = eventData.oldPanel;
2728 |
2729 | this.running = true;
2730 |
2731 | function complete() {
2732 | that.running = false;
2733 | that._trigger( "activate", event, eventData );
2734 | }
2735 |
2736 | function show() {
2737 | eventData.newTab.closest( "li" ).addClass( "ui-tabs-active ui-state-active" );
2738 |
2739 | if ( toShow.length && that.options.show ) {
2740 | that._show( toShow, that.options.show, complete );
2741 | } else {
2742 | toShow.show();
2743 | complete();
2744 | }
2745 | }
2746 |
2747 | // start out by hiding, then showing, then completing
2748 | if ( toHide.length && this.options.hide ) {
2749 | this._hide( toHide, this.options.hide, function() {
2750 | eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
2751 | show();
2752 | });
2753 | } else {
2754 | eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
2755 | toHide.hide();
2756 | show();
2757 | }
2758 |
2759 | toHide.attr( "aria-hidden", "true" );
2760 | eventData.oldTab.attr({
2761 | "aria-selected": "false",
2762 | "aria-expanded": "false"
2763 | });
2764 | // If we're switching tabs, remove the old tab from the tab order.
2765 | // If we're opening from collapsed state, remove the previous tab from the tab order.
2766 | // If we're collapsing, then keep the collapsing tab in the tab order.
2767 | if ( toShow.length && toHide.length ) {
2768 | eventData.oldTab.attr( "tabIndex", -1 );
2769 | } else if ( toShow.length ) {
2770 | this.tabs.filter(function() {
2771 | return $( this ).attr( "tabIndex" ) === 0;
2772 | })
2773 | .attr( "tabIndex", -1 );
2774 | }
2775 |
2776 | toShow.attr( "aria-hidden", "false" );
2777 | eventData.newTab.attr({
2778 | "aria-selected": "true",
2779 | "aria-expanded": "true",
2780 | tabIndex: 0
2781 | });
2782 | },
2783 |
2784 | _activate: function( index ) {
2785 | var anchor,
2786 | active = this._findActive( index );
2787 |
2788 | // trying to activate the already active panel
2789 | if ( active[ 0 ] === this.active[ 0 ] ) {
2790 | return;
2791 | }
2792 |
2793 | // trying to collapse, simulate a click on the current active header
2794 | if ( !active.length ) {
2795 | active = this.active;
2796 | }
2797 |
2798 | anchor = active.find( ".ui-tabs-anchor" )[ 0 ];
2799 | this._eventHandler({
2800 | target: anchor,
2801 | currentTarget: anchor,
2802 | preventDefault: $.noop
2803 | });
2804 | },
2805 |
2806 | _findActive: function( index ) {
2807 | return index === false ? $() : this.tabs.eq( index );
2808 | },
2809 |
2810 | _getIndex: function( index ) {
2811 | // meta-function to give users option to provide a href string instead of a numerical index.
2812 | if ( typeof index === "string" ) {
2813 | index = this.anchors.index( this.anchors.filter( "[href$='" + index + "']" ) );
2814 | }
2815 |
2816 | return index;
2817 | },
2818 |
2819 | _destroy: function() {
2820 | if ( this.xhr ) {
2821 | this.xhr.abort();
2822 | }
2823 |
2824 | this.element.removeClass( "ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible" );
2825 |
2826 | this.tablist
2827 | .removeClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" )
2828 | .removeAttr( "role" );
2829 |
2830 | this.anchors
2831 | .removeClass( "ui-tabs-anchor" )
2832 | .removeAttr( "role" )
2833 | .removeAttr( "tabIndex" )
2834 | .removeUniqueId();
2835 |
2836 | this.tablist.unbind( this.eventNamespace );
2837 |
2838 | this.tabs.add( this.panels ).each(function() {
2839 | if ( $.data( this, "ui-tabs-destroy" ) ) {
2840 | $( this ).remove();
2841 | } else {
2842 | $( this )
2843 | .removeClass( "ui-state-default ui-state-active ui-state-disabled " +
2844 | "ui-corner-top ui-corner-bottom ui-widget-content ui-tabs-active ui-tabs-panel" )
2845 | .removeAttr( "tabIndex" )
2846 | .removeAttr( "aria-live" )
2847 | .removeAttr( "aria-busy" )
2848 | .removeAttr( "aria-selected" )
2849 | .removeAttr( "aria-labelledby" )
2850 | .removeAttr( "aria-hidden" )
2851 | .removeAttr( "aria-expanded" )
2852 | .removeAttr( "role" );
2853 | }
2854 | });
2855 |
2856 | this.tabs.each(function() {
2857 | var li = $( this ),
2858 | prev = li.data( "ui-tabs-aria-controls" );
2859 | if ( prev ) {
2860 | li
2861 | .attr( "aria-controls", prev )
2862 | .removeData( "ui-tabs-aria-controls" );
2863 | } else {
2864 | li.removeAttr( "aria-controls" );
2865 | }
2866 | });
2867 |
2868 | this.panels.show();
2869 |
2870 | if ( this.options.heightStyle !== "content" ) {
2871 | this.panels.css( "height", "" );
2872 | }
2873 | },
2874 |
2875 | enable: function( index ) {
2876 | var disabled = this.options.disabled;
2877 | if ( disabled === false ) {
2878 | return;
2879 | }
2880 |
2881 | if ( index === undefined ) {
2882 | disabled = false;
2883 | } else {
2884 | index = this._getIndex( index );
2885 | if ( $.isArray( disabled ) ) {
2886 | disabled = $.map( disabled, function( num ) {
2887 | return num !== index ? num : null;
2888 | });
2889 | } else {
2890 | disabled = $.map( this.tabs, function( li, num ) {
2891 | return num !== index ? num : null;
2892 | });
2893 | }
2894 | }
2895 | this._setupDisabled( disabled );
2896 | },
2897 |
2898 | disable: function( index ) {
2899 | var disabled = this.options.disabled;
2900 | if ( disabled === true ) {
2901 | return;
2902 | }
2903 |
2904 | if ( index === undefined ) {
2905 | disabled = true;
2906 | } else {
2907 | index = this._getIndex( index );
2908 | if ( $.inArray( index, disabled ) !== -1 ) {
2909 | return;
2910 | }
2911 | if ( $.isArray( disabled ) ) {
2912 | disabled = $.merge( [ index ], disabled ).sort();
2913 | } else {
2914 | disabled = [ index ];
2915 | }
2916 | }
2917 | this._setupDisabled( disabled );
2918 | },
2919 |
2920 | load: function( index, event ) {
2921 | index = this._getIndex( index );
2922 | var that = this,
2923 | tab = this.tabs.eq( index ),
2924 | anchor = tab.find( ".ui-tabs-anchor" ),
2925 | panel = this._getPanelForTab( tab ),
2926 | eventData = {
2927 | tab: tab,
2928 | panel: panel
2929 | };
2930 |
2931 | // not remote
2932 | if ( this._isLocal( anchor[ 0 ] ) ) {
2933 | return;
2934 | }
2935 |
2936 | this.xhr = $.ajax( this._ajaxSettings( anchor, event, eventData ) );
2937 |
2938 | // support: jQuery <1.8
2939 | // jQuery <1.8 returns false if the request is canceled in beforeSend,
2940 | // but as of 1.8, $.ajax() always returns a jqXHR object.
2941 | if ( this.xhr && this.xhr.statusText !== "canceled" ) {
2942 | tab.addClass( "ui-tabs-loading" );
2943 | panel.attr( "aria-busy", "true" );
2944 |
2945 | this.xhr
2946 | .success(function( response ) {
2947 | // support: jQuery <1.8
2948 | // http://bugs.jquery.com/ticket/11778
2949 | setTimeout(function() {
2950 | panel.html( response );
2951 | that._trigger( "load", event, eventData );
2952 | }, 1 );
2953 | })
2954 | .complete(function( jqXHR, status ) {
2955 | // support: jQuery <1.8
2956 | // http://bugs.jquery.com/ticket/11778
2957 | setTimeout(function() {
2958 | if ( status === "abort" ) {
2959 | that.panels.stop( false, true );
2960 | }
2961 |
2962 | tab.removeClass( "ui-tabs-loading" );
2963 | panel.removeAttr( "aria-busy" );
2964 |
2965 | if ( jqXHR === that.xhr ) {
2966 | delete that.xhr;
2967 | }
2968 | }, 1 );
2969 | });
2970 | }
2971 | },
2972 |
2973 | _ajaxSettings: function( anchor, event, eventData ) {
2974 | var that = this;
2975 | return {
2976 | url: anchor.attr( "href" ),
2977 | beforeSend: function( jqXHR, settings ) {
2978 | return that._trigger( "beforeLoad", event,
2979 | $.extend( { jqXHR: jqXHR, ajaxSettings: settings }, eventData ) );
2980 | }
2981 | };
2982 | },
2983 |
2984 | _getPanelForTab: function( tab ) {
2985 | var id = $( tab ).attr( "aria-controls" );
2986 | return this.element.find( this._sanitizeSelector( "#" + id ) );
2987 | }
2988 | });
2989 |
2990 |
2991 |
2992 | }));
--------------------------------------------------------------------------------
/js/jquery.croneditor.js:
--------------------------------------------------------------------------------
1 | $.fn.croneditor = function(opts) {
2 |
3 | var el = this;
4 |
5 | // Write the HTML template to the document
6 | $(el).html(tmpl);
7 |
8 | var cronArr = ["*", "*", "*", "*", "*", "*"];
9 | if (typeof opts.value === "string") {
10 | cronArr = opts.value.split(' ');
11 | }
12 |
13 | $( ".tabs" ).tabs({
14 | activate: function( event, ui ) {
15 | switch ($(ui.newTab).attr('id')) {
16 |
17 | // Seconds
18 | case 'button-second-every':
19 | cronArr[0] = "*";
20 | break;
21 | case 'button-second-n':
22 | cronArr[0] = "*/" + $( "#tabs-second .slider" ).slider("value");
23 | break;
24 |
25 | // Minutes
26 | case 'button-minute-every':
27 | cronArr[1] = "*";
28 | break;
29 | case 'button-minute-n':
30 | cronArr[1] = "*/" + $( "#tabs-minute .slider" ).slider("value");
31 | break;
32 | case 'button-minute-each':
33 | cronArr[1] = "*";
34 | // TODO: toggle off selected minutes on load
35 | //$('.tabs-minute-format input[checked="checked"]').click()
36 | $('.tabs-minute-format').html('');
37 | drawEachMinutes();
38 | break;
39 |
40 | // Hours
41 | case 'button-hour-every':
42 | cronArr[2] = "*";
43 | break;
44 | case 'button-hour-n':
45 | cronArr[2] = "*/" + $( "#tabs-hour .slider" ).slider("value");
46 | break;
47 | case 'button-hour-each':
48 | cronArr[2] = "*";
49 | $('.tabs-hour-format').html('');
50 | drawEachHours();
51 | break;
52 |
53 | // Days
54 | case 'button-day-every':
55 | cronArr[3] = "*";
56 | break;
57 | case 'button-day-each':
58 | cronArr[3] = "*";
59 | $('.tabs-day-format').html('');
60 | drawEachDays();
61 | break;
62 |
63 | // Months
64 | case 'button-month-every':
65 | cronArr[4] = "*";
66 | break;
67 | case 'button-month-each':
68 | cronArr[4] = "*";
69 | $('.tabs-month-format').html('');
70 | drawEachMonths();
71 | break;
72 |
73 | // Weeks
74 | case 'button-week-every':
75 | cronArr[5] = "*";
76 | break;
77 | case 'button-week-each':
78 | cronArr[5] = "*";
79 | $('.tabs-week-format').html('');
80 | drawEachWeek();
81 | break;
82 |
83 | }
84 |
85 | drawCron();
86 | }
87 | });
88 |
89 | function drawCron () {
90 |
91 | var newCron = cronArr.join(' ');
92 | $('#cronString').val(newCron);
93 | // TODO: add back next estimated cron time
94 | /*
95 | var last = new Date();
96 | $('.next').html('');
97 | var job = new cron.CronTime(newCron);
98 | var next = job._getNextDateFrom(new Date());
99 | $('.next').append('
' + dateformat(next, "ddd mmm dd yyyy HH:mm:ss") + ' ');
100 | */
101 | /*
102 | setInterval(function(){
103 | drawCron();
104 | }, 500);
105 | */
106 | /*
107 | $('#cronString').keyup(function(){
108 | cronArr = $('#cronString').val().split(' ');
109 | console.log('updated', cronArr)
110 | });
111 | */
112 | }
113 |
114 | $('#clear').click(function(){
115 | $('#cronString').val('* * * * * *');
116 | cronArr = ["*","*","*","*","*", "*"];
117 |
118 | });
119 |
120 | $( "#tabs-second .slider" ).slider({
121 | min: 1,
122 | max: 59,
123 | slide: function( event, ui ) {
124 | cronArr[0] = "*/" + ui.value;
125 | $('#tabs-second-n .preview').html('Every ' + ui.value + ' seconds');
126 | drawCron();
127 | }
128 | });
129 |
130 | $( "#tabs-minute .slider" ).slider({
131 | min: 1,
132 | max: 59,
133 | slide: function( event, ui ) {
134 | cronArr[1] = "*/" + ui.value;
135 | $('#tabs-minute-n .preview').html('Every ' + ui.value + ' minutes');
136 | drawCron();
137 | }
138 | });
139 |
140 | $( "#tabs-hour .slider" ).slider({
141 | min: 1,
142 | max: 23,
143 | slide: function( event, ui ) {
144 | cronArr[2] = "*/" + ui.value;
145 | $('#tabs-hour-n .preview').html('Every ' + ui.value + ' Hours');
146 | drawCron();
147 | }
148 | });
149 |
150 | // TOOD: All draw* functions can be combined into a few smaller methods
151 |
152 | function drawEachMinutes () {
153 | // minutes
154 | for (var i = 0; i < 60; i++) {
155 | var padded = i;
156 | if(padded.toString().length === 1) {
157 | padded = "0" + padded;
158 | }
159 | $('.tabs-minute-format').append('
' + padded + ' ');
160 | if (i !== 0 && (i+1) % 10 === 0) {
161 | $('.tabs-minute-format').append('
');
162 | }
163 | }
164 | $('.tabs-minute-format input').button();
165 | $('.tabs-minute-format').buttonset();
166 |
167 | $('.tabs-minute-format input[type="checkbox"]').click(function(){
168 | var newItem = $(this).attr('id').replace('minute-check', '');
169 | if(cronArr[1] === "*") {
170 | cronArr[1] = $(this).attr('id').replace('minute-check', '');
171 | } else {
172 |
173 | // if value already in list, toggle it off
174 | var list = cronArr[1].split(',');
175 | if (list.indexOf(newItem) !== -1) {
176 | list.splice(list.indexOf(newItem), 1);
177 | cronArr[1] = list.join(',');
178 | } else {
179 | // else toggle it on
180 | cronArr[1] = cronArr[1] + "," + newItem;
181 | }
182 | if(cronArr[1] === "") {
183 | cronArr[1] = "*";
184 | }
185 | }
186 | drawCron();
187 | });
188 |
189 | }
190 |
191 |
192 | function drawEachHours () {
193 | // hours
194 | for (var i = 0; i < 24; i++) {
195 | var padded = i;
196 | if(padded.toString().length === 1) {
197 | padded = "0" + padded;
198 | }
199 | $('.tabs-hour-format').append('
' + padded + ' ');
200 | if (i !== 0 && (i+1) % 12 === 0) {
201 | $('.tabs-hour-format').append('
');
202 | }
203 | }
204 |
205 | $('.tabs-hour-format input').button();
206 | $('.tabs-hour-format').buttonset();
207 |
208 |
209 | $('.tabs-hour-format input[type="checkbox"]').click(function(){
210 | var newItem = $(this).attr('id').replace('hour-check', '');
211 | if(cronArr[2] === "*") {
212 | cronArr[2] = $(this).attr('id').replace('hour-check', '');
213 | } else {
214 |
215 | // if value already in list, toggle it off
216 | var list = cronArr[2].split(',');
217 | if (list.indexOf(newItem) !== -1) {
218 | list.splice(list.indexOf(newItem), 1);
219 | cronArr[2] = list.join(',');
220 | } else {
221 | // else toggle it on
222 | cronArr[2] = cronArr[2] + "," + newItem;
223 | }
224 | if(cronArr[2] === "") {
225 | cronArr[2] = "*";
226 | }
227 | }
228 | drawCron();
229 | });
230 |
231 | };
232 |
233 | function drawEachDays () {
234 |
235 | // days
236 | for (var i = 1; i < 32; i++) {
237 | var padded = i;
238 | if(padded.toString().length === 1) {
239 | padded = "0" + padded;
240 | }
241 | $('.tabs-day-format').append('
' + padded + ' ');
242 | if (i !== 0 && (i) % 7 === 0) {
243 | $('.tabs-day-format').append('
');
244 | }
245 | }
246 |
247 | $('.tabs-day-format input').button();
248 | $('.tabs-day-format').buttonset();
249 |
250 | $('.tabs-day-format input[type="checkbox"]').click(function(){
251 | var newItem = $(this).attr('id').replace('day-check', '');
252 | if(cronArr[3] === "*") {
253 | cronArr[3] = $(this).attr('id').replace('day-check', '');
254 | } else {
255 |
256 | // if value already in list, toggle it off
257 | var list = cronArr[3].split(',');
258 | if (list.indexOf(newItem) !== -1) {
259 | list.splice(list.indexOf(newItem), 1);
260 | cronArr[3] = list.join(',');
261 | } else {
262 | // else toggle it on
263 | cronArr[3] = cronArr[3] + "," + newItem;
264 | }
265 | if(cronArr[3] === "") {
266 | cronArr[3] = "*";
267 | }
268 |
269 | }
270 | drawCron();
271 | });
272 |
273 | };
274 |
275 |
276 | function drawEachMonths () {
277 | // months
278 | var months = [null, 'Jan', 'Feb', 'March', 'April', 'May', 'June', 'July', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec'];
279 |
280 | for (var i = 1; i < 13; i++) {
281 | var padded = i;
282 | if(padded.toString().length === 1) {
283 | //padded = "0" + padded;
284 | }
285 | $('.tabs-month-format').append('
' + months[i] + ' ');
286 | }
287 |
288 | $('.tabs-month-format input').button();
289 | $('.tabs-month-format').buttonset();
290 |
291 |
292 | $('.tabs-month-format input[type="checkbox"]').click(function(){
293 | var newItem = $(this).attr('id').replace('month-check', '');
294 | if(cronArr[4] === "*") {
295 | cronArr[4] = $(this).attr('id').replace('month-check', '');
296 | } else {
297 |
298 | // if value already in list, toggle it off
299 | var list = cronArr[4].split(',');
300 | if (list.indexOf(newItem) !== -1) {
301 | list.splice(list.indexOf(newItem), 1);
302 | cronArr[4] = list.join(',');
303 | } else {
304 | // else toggle it on
305 | cronArr[4] = cronArr[4] + "," + newItem;
306 | }
307 | if(cronArr[4] === "") {
308 | cronArr[4] = "*";
309 | }
310 |
311 | }
312 | drawCron();
313 | });
314 |
315 | };
316 |
317 | function drawEachWeek () {
318 | // weeks
319 | var days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
320 | for (var i = 0; i < 7; i++) {
321 | var padded = i;
322 | if(padded.toString().length === 1) {
323 | //padded = "0" + padded;
324 | }
325 |
326 | $('.tabs-week-format').append('
' + days[i] + ' ');
327 | }
328 |
329 | $('.tabs-week-format input').button();
330 | $('.tabs-week-format').buttonset();
331 |
332 | $('.tabs-week-format input[type="checkbox"]').click(function(){
333 | var newItem = $(this).attr('id').replace('week-check', '');
334 | if(cronArr[5] === "*") {
335 | cronArr[5] = $(this).attr('id').replace('week-check', '');
336 | } else {
337 |
338 | // if value already in list, toggle it off
339 | var list = cronArr[5].split(',');
340 | if (list.indexOf(newItem) !== -1) {
341 | list.splice(list.indexOf(newItem), 1);
342 | cronArr[5] = list.join(',');
343 | } else {
344 | // else toggle it on
345 | cronArr[5] = cronArr[5] + "," + newItem;
346 | }
347 | if(cronArr[5] === "") {
348 | cronArr[5] = "*";
349 | }
350 |
351 | }
352 | drawCron();
353 | });
354 |
355 | };
356 |
357 | // TODO: Refactor these methods into smaller methods
358 | drawEachMinutes();
359 | drawEachHours();
360 | drawEachDays();
361 | drawEachMonths();
362 | drawCron();
363 | };
364 |
365 | // HTML Template for plugin
366 | var tmpl = '
\
367 |
\
368 |
\
369 |
\
370 |
Note: If your Cron manager does not support seconds you will need to ignore the first parameter of the generated Cron\
371 | \
372 | \
373 | \
374 |
\
375 |
\
383 |
\
384 |
\
385 |
\
389 |
\
390 |
*
\
391 |
Every second.
\
392 |
\
393 |
\
394 |
Every 1 seconds
\
395 |
\
396 |
\
397 |
\
398 |
\
399 |
\
400 |
\
401 |
\
406 |
\
407 |
*
\
408 |
Every minute.
\
409 |
\
410 |
\
411 |
Every 1 minutes
\
412 |
\
413 |
\
414 |
\
415 |
Each selected minute
\
416 |
\
417 |
\
418 |
\
419 |
\
420 |
\
421 |
\
422 |
\
427 |
\
428 |
*
\
429 |
Every hour
\
430 |
\
431 |
\
432 |
Every 1 hours
\
433 |
\
434 |
\
435 |
\
436 |
Each selected hour
\
437 |
\
438 |
\
439 |
\
440 |
\
441 |
\
442 |
\
443 |
\
447 |
\
448 |
*
\
449 |
Every Day
\
450 |
\
451 |
\
452 |
Each selected Day
\
453 |
\
454 |
\
455 |
\
456 |
\
457 |
\
458 |
\
459 |
\
463 |
\
464 |
*
\
465 |
Every month
\
466 |
\
467 |
\
468 |
Each selected month
\
469 |
\
470 |
\
471 |
\
472 |
\
473 |
\
474 |
\
475 |
\
479 |
\
480 |
*
\
481 |
Every Day
\
482 |
\
483 |
\
484 |
Each selected Day
\
485 |
\
486 |
\
487 |
\
488 |
\
489 |
';
--------------------------------------------------------------------------------