diff options
Diffstat (limited to 'framework/Web')
-rw-r--r-- | framework/Web/Javascripts/source/prado/datepicker/datepicker.js | 22 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TDatePicker.php | 44 |
2 files changed, 59 insertions, 7 deletions
diff --git a/framework/Web/Javascripts/source/prado/datepicker/datepicker.js b/framework/Web/Javascripts/source/prado/datepicker/datepicker.js index 834e89cf..13637f6d 100644 --- a/framework/Web/Javascripts/source/prado/datepicker/datepicker.js +++ b/framework/Web/Javascripts/source/prado/datepicker/datepicker.js @@ -67,6 +67,7 @@ Prado.WebUI.TDatePicker.prototype = this.weekSlot = new Array(6);
this.minimalDaysInFirstWeek = 4;
this.selectedDate = this.newDate();
+ this.positionMode = 'Bottom';
//which element to trigger to show the calendar
if(this.options.Trigger)
@@ -79,6 +80,12 @@ Prado.WebUI.TDatePicker.prototype = this.trigger = this.control;
var triggerEvent = this.options.TriggerEvent || "focus";
}
+
+ // Popup position
+ if(this.options.PositionMode == 'Top')
+ {
+ this.positionMode = this.options.PositionMode;
+ }
Object.extend(this,options);
@@ -309,8 +316,8 @@ Prado.WebUI.TDatePicker.prototype = if(this.iePopUp)
{
this.iePopUp.style.display = "block";
- this.iePopUp.style.top = (this._calDiv.offsetTop -1 ) + "px";
this.iePopUp.style.left = (this._calDiv.offsetLeft -1)+ "px";
+ this.iePopUp.style.top = (this._calDiv.offsetTop -1 ) + "px";
this.iePopUp.style.width = Math.abs(this._calDiv.offsetWidth -2)+ "px";
this.iePopUp.style.height = (this._calDiv.offsetHeight + 1)+ "px";
if(cleanup) this.iePopUp.style.display = "none";
@@ -602,10 +609,17 @@ Prado.WebUI.TDatePicker.prototype = {
var pos = this.control.positionedOffset();
- pos[1] += this.getDatePickerOffsetHeight();
-
+ if(this.positionMode=='Top')
+ {
+ pos[1] = (document.body.clientHeight - pos[1]);
+ this._calDiv.style.bottom = (pos[1]-1) + "px";
+ }
+ else
+ {
+ pos[1] += this.getDatePickerOffsetHeight();
+ this._calDiv.style.top = (pos[1]-1) + "px";
+ }
this._calDiv.style.display = "block";
- this._calDiv.style.top = (pos[1]-1) + "px";
this._calDiv.style.left = pos[0] + "px";
this.ieHack(false);
diff --git a/framework/Web/UI/WebControls/TDatePicker.php b/framework/Web/UI/WebControls/TDatePicker.php index 6b7e96a9..916902cd 100644 --- a/framework/Web/UI/WebControls/TDatePicker.php +++ b/framework/Web/UI/WebControls/TDatePicker.php @@ -4,7 +4,7 @@ *
* @author Wei Zhuo <weizhuo[at]gmail[dot]com>
* @link http://www.pradosoft.com/
- * @copyright Copyright © 2005-2008 PradoSoft + * @copyright Copyright © 2005-2008 PradoSoft
* @license http://www.pradosoft.com/license/
* @version $Id$
* @package System.Web.UI.WebControls
@@ -59,6 +59,10 @@ Prado::using('System.Web.UI.WebControls.TTextBox'); * In <tt>DropDownList</tt> mode, in addition to the popup date picker, three
* drop down list (day, month and year) are presented to select the date .
*
+ * The <b>PositionMode</b> property can be set to "Top" or "Bottom" with default
+ * as "Bottom". It specifies the position of the calendar popup, relative to the
+ * input field.
+ *
* @author Wei Zhuo <weizhuo[at]gmail[dot]com>
* @version $Id$
* @package System.Web.UI.WebControls
@@ -263,6 +267,22 @@ class TDatePicker extends TTextBox {
return $this->getViewState('UpToYear', intval(@date('Y'))+10);
}
+
+ /**
+ * @param TDatePickerPositionMode calendar UI position
+ */
+ public function setPositionMode($value)
+ {
+ $this->setViewState('PositionMode', TPropertyValue::ensureEnum($value, 'TDatePickerPositionMode'), TDatePickerPositionMode::Bottom);
+ }
+
+ /**
+ * @return TDatePickerPositionMode current calendar UI position.
+ */
+ public function getPositionMode()
+ {
+ return $this->getViewState('PositionMode', TDatePickerPositionMode::Bottom);
+ }
/**
* @return integer current selected date from the date picker as timestamp, NULL if timestamp is not set previously.
@@ -505,6 +525,7 @@ class TDatePicker extends TTextBox $options['UpToYear'] = $this->getUpToYear();
if($this->getMode()!==TDatePickerMode::Basic)
$options['Trigger'] = $this->getDatePickerButtonID();
+ $options['PositionMode'] = $this->getPositionMode();
$options = array_merge($options, $this->getCulturalOptions());
if(!is_null($this->_clientScript))
@@ -853,8 +874,8 @@ class TDatePicker extends TTextBox *
* The <tt>OnDateChanged</tt> event is raise when the date picker's date
* is changed.
- * The formatted date according to {@link TDatePicker::getDateFormat DateFormat} is sent - * as parameter to this event + * The formatted date according to {@link TDatePicker::getDateFormat DateFormat} is sent
+ * as parameter to this event
*
* @author Wei Zhuo <weizhuo[at]gmail[dot]com>
* @version $Id$
@@ -923,3 +944,20 @@ class TDatePickerMode extends TEnumerable const ImageButton='ImageButton';
}
+/**
+ * TDatePickerPositionMode class.
+ * TDatePickerPositionMode defines the positions available for the calendar popup, relative to the corresponding input.
+ *
+ * The following enumerable values are defined:
+ * - Top: the date picker is placed above the input field
+ * - Bottom: the date picker is placed below the input field
+ *
+ * @author Carl G. Mathisen <carlgmathisen@gmail.com>
+ * @package System.Web.UI.WebControls
+ * @since 3.1.4
+ */
+class TDatePickerPositionMode extends TEnumerable
+{
+ const Top='Top';
+ const Bottom='Bottom';
+}
\ No newline at end of file |