Project

General

Profile

Patch #160 ยป mod_datepicker_disablebeforetofday_patch.diff

Fabrice Roger-Dalbert, 09/25/2010 10:29 AM

View differences:

globals.js (working copy)
18 18
	 */
19 19
	JSDatePicker = function() {
20 20
		var _aDisableDaysOfWeek = [false, false, false, false, false, false, false],
21
			_aAllowedRange = [null, null];
21
			_aAllowedRange = [null, null],
22
			_iDisableBeforeToday=0;
22 23

  
23 24
		this.form = {
24 25
			name: "mod_datepicker_form", // required, please use a unique name for all your instances
......
45 46
		this.setAllowedDateRange = function(From, To) {
46 47
			_aAllowedRange = [From, To];
47 48
		}
48

  
49
		this.disableBeforeToday = function(Disable) {
50
			_iDisableBeforeToday = Disable;
51
		}
49 52
		this.show = function(x, y) {
50 53
			var _oForm,
51 54
				_nWidth = 370,
......
71 74
			forms[this.form.name]._g_oDatePicker = this;
72 75
			// Pass on the disabled week days array
73 76
			forms[this.form.name]._g_aDisableDaysOfWeek = _aDisableDaysOfWeek;
77
			forms[this.form.name]._g_aAllowedRange = _aAllowedRange;
78
			forms[this.form.name]._g_iDisableBeforeToday = _iDisableBeforeToday;
79
			
80
			
74 81

  
75 82
			// Show the form in a modal dialog
76 83
			application.showFormInDialog(forms[this.form.name], (x == null) ? -1 : x, (y == null) ? -1 : y, -1, -1, this.form.title, false, false, this.form.name, true);
forms/mod_datepicker.js (working copy)
1 1
/**
2
 * @properties={typeid:35,uuid:"FF3AD843-565D-4059-AE10-0791A7676ED0",variableType:4}
3
 */
4
var _g_iDisableBeforeToday = 0;
5

  
6
/**
2 7
 * @properties={typeid:35,uuid:"EEE913E5-AEB9-48F1-93FF-52D3AF2FA7EC",variableType:-4}
3 8
 */
4 9
var _g_aAllowedRange = [null,null];
......
147 152

  
148 153
				// Button label
149 154
				_oLabel = _oForm.newLabel(_d.getDate(), _nX, _nY, _nBtnWidth, _nBtnHeight);
150
				if ( _g_aDisableDaysOfWeek[_d.getDay()] ) {
155
				if ( _g_aDisableDaysOfWeek[_d.getDay()]) {
151 156
					_oLabel.styleClass = "datebuttontext_disabled";
157
				} else if (_g_iDisableBeforeToday==1 && _d < Date.today()) {
158
					_oLabel.styleClass = "datebuttontext_disabled";	
159
				} else if ((_g_aAllowedRange[0] &&  _d < _g_aAllowedRange[0]) || (_g_aAllowedRange[1] &&  _d > _g_aAllowedRange[1]) ) {
160
					_oLabel.styleClass = "datebuttontext_disabled";	
161
					
152 162
				} else if (_d == Date.today()) {
153 163
					_oLabel.styleClass = "datebuttontext_today";
154 164
					_oLabel.onAction = _oMethod
    (1-1/1)