[limb-svn] r6412 - in 3.x/trunk/limb/calendar: shared/js src src/template/tags
svn at limb-project.com
svn at limb-project.com
Fri Oct 12 08:49:01 MSD 2007
Author: svk
Date: 2007-10-12 08:49:01 +0400 (Fri, 12 Oct 2007)
New Revision: 6412
URL: http://fisheye.limb-project.com/changelog/limb/?cs=6412
Modified:
3.x/trunk/limb/calendar/shared/js/datewidget.js
3.x/trunk/limb/calendar/src/lmbDateWidget.class.php
3.x/trunk/limb/calendar/src/template/tags/date_select.tag.php
Log:
-- min_year and max_year attributes added to date_select tag.
Modified: 3.x/trunk/limb/calendar/shared/js/datewidget.js
===================================================================
--- 3.x/trunk/limb/calendar/shared/js/datewidget.js 2007-10-10 18:46:01 UTC (rev 6411)
+++ 3.x/trunk/limb/calendar/shared/js/datewidget.js 2007-10-12 04:49:01 UTC (rev 6412)
@@ -1,7 +1,7 @@
var DATE_WIDGETS = new Object();
-function DateWidget_Init(name, show_default)
+function DateWidget_Init(name, show_default, min_year, max_year)
{
- DATE_WIDGETS[name] = new DateWidget(name, show_default);
+ DATE_WIDGETS[name] = new DateWidget(name, show_default, min_year, max_year);
DATE_WIDGETS[name].init();
}
@@ -19,7 +19,7 @@
}
}
-function DateWidget(name, show_default)
+function DateWidget(name, show_default, min_year, max_year)
{
if (!document.getElementById(name))
{
@@ -36,6 +36,8 @@
this.year = this.value ? this.value.substr(0,4) : 0;
this.month = this.value ? parseInt(this.value.substr(5,2), 10) : 0;
this.day = this.value ? this.value.substr(8, 2) : 0;
+ this.min_year = min_year;
+ this.max_year = max_year;
}
DateWidget.prototype.init = function()
@@ -105,7 +107,7 @@
opts[opts.length] = {value: -1, text: '---'};
}
}
- for (var i=2000; i>=1950; i--)
+ for (var i=this.max_year; i>=this.min_year; i--)
{
opts[opts.length] = {value: i, text:i};
}
Modified: 3.x/trunk/limb/calendar/src/lmbDateWidget.class.php
===================================================================
--- 3.x/trunk/limb/calendar/src/lmbDateWidget.class.php 2007-10-10 18:46:01 UTC (rev 6411)
+++ 3.x/trunk/limb/calendar/src/lmbDateWidget.class.php 2007-10-12 04:49:01 UTC (rev 6412)
@@ -24,6 +24,8 @@
protected $calendar_lib_path = '/shared/calendar/js/';
protected $calendar_file = 'calendar.js';
protected $show_default = false;
+ protected $min_year;
+ protected $max_year;
function __construct($lang = 'en',
$year_class = "",
@@ -39,6 +41,8 @@
$this -> dw_month_class = $month_class;
$this -> dw_day_class = $day_class;
$this -> dw_lib_path = preg_replace('/\/+$/', '/', $this->calendar_lib_path).'datewidget.js';
+ $this -> min_year = 1950;
+ $this -> max_year = 2000;
}
function loadFiles()
@@ -69,9 +73,25 @@
$out = '<select name="'.$field_name.'_day" id="'.$field_name.'_day" class="'.$this->dw_day_class.'" onchange="DateWidget_Action(\''.$field_name.'\', \'handle_change\', \'day\');"></select>'.$this->newline;
$out .= '<select name="'.$field_name.'_month" id="'.$field_name.'_month" class="'.$this->dw_month_class.'" onchange="DateWidget_Action(\''.$field_name.'\', \'handle_change\', \'month\');"></select>'.$this->newline;
$out .= '<select name="'.$field_name.'_year" id="'.$field_name.'_year" class="'.$this->dw_year_class.'" onchange="DateWidget_Action(\''.$field_name.'\', \'handle_change\', \'year\');"></select>'.$this->newline;
- $out .= '<script type="text/javascript">DateWidget_Init("'.$field_name.'", '.($this->show_default ? 'true' : 'false').');</script>'.$this->newline;
+ $out .= '<script type="text/javascript">DateWidget_Init("'.$field_name.'", '.($this->show_default ? 'true' : 'false').', '.$this->min_year.', '.$this->max_year.');</script>'.$this->newline;
return $out;
}
+ function setMinYear($year)
+ {
+ if ($year > 0)
+ {
+ $this -> min_year = $year;
+ }
+ }
+
+ function setMaxYear($year)
+ {
+ if ($year > 0)
+ {
+ $this -> max_year = $year;
+ }
+ }
+
}
\ No newline at end of file
Modified: 3.x/trunk/limb/calendar/src/template/tags/date_select.tag.php
===================================================================
--- 3.x/trunk/limb/calendar/src/template/tags/date_select.tag.php 2007-10-10 18:46:01 UTC (rev 6411)
+++ 3.x/trunk/limb/calendar/src/template/tags/date_select.tag.php 2007-10-12 04:49:01 UTC (rev 6412)
@@ -39,10 +39,20 @@
$month_class = $this->getAttribute('year_class');
$day_class = $this->getAttribute('year_class');
$show_default = $this->getBoolAttribute('show_default');
+ $min_year = $this->getAttribute('min_year');
+ $max_year = $this->getAttribute('max_year');
$widget = new lmbDateWidget($lang, $year_class, $month_class, $day_class, $show_default);
+ if ($min_year)
+ {
+ $widget -> setMinYear(intval($min_year));
+ }
+ if ($max_year)
+ {
+ $widget -> setMaxYear(intval($max_year));
+ }
+
-
$code->writeHTML($widget->loadFiles() .
$widget->makeFields($this->getAttribute('id') ));
More information about the limb-svn
mailing list