]> git.sur5r.net Git - bacula/bacula/blob - gui/baculum/framework/Web/Javascripts/source/prado/activecontrols/activedatepicker.js
baculum: New Baculum API and Baculum Web
[bacula/bacula] / gui / baculum / framework / Web / Javascripts / source / prado / activecontrols / activedatepicker.js
1 /**
2  * TActiveDatePicker control
3  */
4 Prado.WebUI.TActiveDatePicker = jQuery.klass(Prado.WebUI.TDatePicker,
5 {
6         onInit : function(options)
7         {
8                 this.options = options || [];
9                 this.control = jQuery('#'+options.ID).get(0);
10                 this.dateSlot = new Array(42);
11                 this.weekSlot = new Array(6);
12                 this.minimalDaysInFirstWeek     = 4;
13                 this.selectedDate = this.newDate();
14                 this.positionMode = 'Bottom';
15
16
17                 //which element to trigger to show the calendar
18                 if(this.options.Trigger)
19                 {
20                         this.trigger = jQuery('#'+this.options.Trigger).get(0) ;
21                         var triggerEvent = this.options.TriggerEvent || "click";
22                 }
23                 else
24                 {
25                         this.trigger  = this.control;
26                         var triggerEvent = this.options.TriggerEvent || "focus";
27                 }
28
29                 // Popup position
30                 if(this.options.PositionMode == 'Top')
31                 {
32                         this.positionMode = this.options.PositionMode;
33                 }
34
35                 jQuery.extend(this,options);
36
37                 if (this.options.ShowCalendar)
38                         this.observe(this.trigger, triggerEvent, jQuery.proxy(this.show,this));
39
40                 // Listen to change event
41                 if(this.options.InputMode == "TextBox")
42                 {
43                         this.observe(this.control, "change", jQuery.proxy(this.onDateChanged,this));
44                 }
45                 else
46                 {
47                         var day = Prado.WebUI.TDatePicker.getDayListControl(this.control);
48                         var month = Prado.WebUI.TDatePicker.getMonthListControl(this.control);
49                         var year = Prado.WebUI.TDatePicker.getYearListControl(this.control);
50                         if (day) this.observe (day, "change", jQuery.proxy(this.onDateChanged,this));
51                         if (month) this.observe (month, "change", jQuery.proxy(this.onDateChanged,this));
52                         if (year) this.observe (year, "change", jQuery.proxy(this.onDateChanged,this));
53
54                 }
55
56         },
57
58         // Respond to change event on the textbox or dropdown list
59         // This method raises OnDateChanged event on client side if it has been defined,
60         // and raise the callback request
61         onDateChanged : function ()
62         {
63                 var date;
64                 if (this.options.InputMode == "TextBox")
65                 {
66                         date=this.control.value;
67                  }
68                  else
69                  {
70                         var day = Prado.WebUI.TDatePicker.getDayListControl(this.control);
71                         if (day) day=day.selectedIndex+1;
72                         var month = Prado.WebUI.TDatePicker.getMonthListControl(this.control);
73                         if (month) month=month.selectedIndex;
74                         var year = Prado.WebUI.TDatePicker.getYearListControl(this.control);
75                         if (year) year=year.value;
76                         date=new Date(year, month, day, 0,0,0).SimpleFormat(this.Format, this);
77                 }
78                 if (typeof(this.options.OnDateChanged) == "function") this.options.OnDateChanged(this, date);
79
80                 if(this.options['AutoPostBack']==true)
81                 {
82                         // Make callback request
83                         var request = new Prado.CallbackRequest(this.options.EventTarget,this.options);
84                         request.dispatch();
85                 }
86         }
87 });