some new tweaks
This commit is contained in:
parent
979b2a3e8c
commit
d99c033411
9 changed files with 73 additions and 367 deletions
|
|
@ -286,9 +286,9 @@ sub epochToHuman {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 epochToSet ( epoch )
|
||||
=head2 epochToSet ( epoch, withTime )
|
||||
|
||||
Returns a set date (used by WebGUI::HTMLForm->date) in the format of MM/DD/YYYY.
|
||||
Returns a set date (used by WebGUI::HTMLForm->date) in the format of YYYY-MM-DD.
|
||||
|
||||
=over
|
||||
|
||||
|
|
@ -296,12 +296,19 @@ Returns a set date (used by WebGUI::HTMLForm->date) in the format of MM/DD/YYYY.
|
|||
|
||||
The number of seconds since January 1, 1970.
|
||||
|
||||
=item withTime
|
||||
|
||||
A boolean indicating that the time should be added to the output, thust turning the format into YYYY-MM-DD HH:MM:SS.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub epochToSet {
|
||||
return epochToHuman($_[0],"%m/%d/%y");
|
||||
if ($_[1]) {
|
||||
return epochToHuman($_[0],"%y-%m-%d %j:%n:%s");
|
||||
}
|
||||
return epochToHuman($_[0],"%y-%m-%d");
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -626,31 +633,33 @@ Returns an epoch date.
|
|||
|
||||
=item set
|
||||
|
||||
A string in the format of MM/DD/YYYY.
|
||||
A string in the format of YYYY-MM-DD or YYYY-MM-DD HH:MM:SS.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub setToEpoch {
|
||||
my @date = Date::Calc::Time_to_Date(time());
|
||||
my ($month, $day, $year) = split(/\//,$_[0]);
|
||||
my @now = Date::Calc::Time_to_Date(time());
|
||||
my ($date,$time) = split(/ /,$_[0]);
|
||||
my ($year, $month, $day) = split(/\-/,$date);
|
||||
my ($hour, $minute, $second) = split(/\:/,$time);
|
||||
if (int($year) < 2038 && int($year) > 1969) {
|
||||
$year = int($year);
|
||||
} else {
|
||||
$year = $date[0];
|
||||
$year = $now[0];
|
||||
}
|
||||
if (int($month) < 13 && int($month) > 0) {
|
||||
$month = int($month);
|
||||
} else {
|
||||
$month = $date[1]++;
|
||||
$month = $now[1]++;
|
||||
}
|
||||
if (int($day) < 32 && int($day) > 0) {
|
||||
$day = int($day);
|
||||
} else {
|
||||
$day = $date[2];
|
||||
$day = $now[2];
|
||||
}
|
||||
return Date::Calc::Date_to_Time($year,$month,$day,0,0,0);
|
||||
return Date::Calc::Date_to_Time($year,$month,$day,$hour,$minute,$second);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -354,9 +354,8 @@ By default a date is placed in the "value" field. Set this to "1" to turn off th
|
|||
=cut
|
||||
|
||||
sub date {
|
||||
my ($subtext, $noDate, $class, $name, $label, $extras, $size, $value);
|
||||
$value = epochToSet($_[0]->{value}) unless ($_[0]->{noDate} && $_[0]->{value} eq '');
|
||||
$size = $_[0]->{size} || 10;
|
||||
my $value = epochToSet($_[0]->{value}) unless ($_[0]->{noDate} && $_[0]->{value} eq '');
|
||||
my $size = $_[0]->{size} || 10;
|
||||
my $output = _cssFile("calendar/calendar-win2k-1.css")
|
||||
._javascriptFile('calendar/calendar.js')
|
||||
._javascriptFile('calendar/lang/calendar-en.js')
|
||||
|
|
@ -377,10 +376,6 @@ sub date {
|
|||
mondayFirst : false
|
||||
});
|
||||
</script>';
|
||||
# $output .= '<input type="button" style="font-size: 8pt;" onClick="window.dateField = this.form.'.
|
||||
# $_[0]->{name}.';calendar = window.open(\''.$session{config}{extrasURL}.
|
||||
# '/calendar.html\',\'cal\',\'WIDTH=220,HEIGHT=250\');return false" value="'.
|
||||
# WebGUI::International::get(34).'">';
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
|
@ -402,29 +397,36 @@ The the base name for this form element. This form element actually returns two
|
|||
|
||||
The date and time. Pass as an epoch value. Defaults to today and now.
|
||||
|
||||
=item dateExtras
|
||||
=item extras
|
||||
|
||||
Extra parameters to add to the date form element such as javascript or stylesheet information.
|
||||
|
||||
=item timeExtras
|
||||
|
||||
Extra parameters to add to the time form element such as javascript or stylesheet information.
|
||||
Extra parameters to add to the date/time form element such as javascript or stylesheet information.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub dateTime {
|
||||
my $output = date({
|
||||
name=>$_[0]->{name}."_date",
|
||||
value=>$_[0]->{value},
|
||||
extras=>$_[0]->{dateExtras}
|
||||
});
|
||||
$output .= timeField({
|
||||
name=>$_[0]->{name}."_time",
|
||||
value=>WebGUI::DateTime::getSecondsFromEpoch($_[0]->{value}),
|
||||
extras=>$_[0]->{timeExtras}
|
||||
});
|
||||
my $value = epochToSet($_[0]->{value},1);
|
||||
my $output = _cssFile("calendar/calendar-win2k-1.css")
|
||||
._javascriptFile('calendar/calendar.js')
|
||||
._javascriptFile('calendar/lang/calendar-en.js')
|
||||
._javascriptFile('calendar/calendar-setup.js');
|
||||
$output .= text({
|
||||
name=>$_[0]->{name},
|
||||
value=>$value,
|
||||
size=>19,
|
||||
extras=>'id="'.$_[0]->{name}.'Id" '.$_[0]->{extras},
|
||||
maxlength=>19
|
||||
});
|
||||
$output .= '<script type="text/javascript">
|
||||
Calendar.setup({
|
||||
inputField : "'.$_[0]->{name}.'Id",
|
||||
ifFormat : "%Y-%m-%d %H:%M:%S",
|
||||
showsTime : true,
|
||||
timeFormat : "12",
|
||||
mondayFirst : false
|
||||
});
|
||||
</script>';
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -191,10 +191,7 @@ The name of the form variable to retrieve.
|
|||
=cut
|
||||
|
||||
sub dateTime {
|
||||
my $date = date($_[0]."_date");
|
||||
my $time = timeField($_[0]."_time");
|
||||
my $epoch = $date+$time;
|
||||
return $epoch;
|
||||
return WebGUI::DateTime::setToEpoch($session{form}{$_[0]});
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -587,13 +587,9 @@ Extra text to describe this form element or to provide special instructions.
|
|||
|
||||
The UI level for this field. See the WebGUI developer's site for details. Defaults to "0".
|
||||
|
||||
=item dateExtras
|
||||
=item extras
|
||||
|
||||
Extra parameters such as javascript or style sheet information that you wish to add to the date form element.
|
||||
|
||||
=item timeExtras
|
||||
|
||||
Extra parameters such as javascript or style sheet information that you wish to add to the time form element.
|
||||
Extra parameters such as javascript or style sheet information that you wish to add to the form element.
|
||||
|
||||
=back
|
||||
|
||||
|
|
@ -602,14 +598,13 @@ Extra parameters such as javascript or style sheet information that you wish to
|
|||
sub dateTime {
|
||||
my ($output);
|
||||
my ($self, @p) = @_;
|
||||
my ($name, $label, $value, $subtext, $uiLevel, $dateExtras, $timeExtras) =
|
||||
rearrange([qw(name label value subtext uiLevel dateExtras timeExtras)], @p);
|
||||
my ($name, $label, $value, $subtext, $uiLevel, $extras) =
|
||||
rearrange([qw(name label value subtext uiLevel extras)], @p);
|
||||
if (_uiLevelChecksOut($uiLevel)) {
|
||||
$output = WebGUI::Form::dateTime({
|
||||
"name"=>$name,
|
||||
"value"=>$value,
|
||||
"dateExtras"=>$dateExtras,
|
||||
"timeExtras"=>$timeExtras
|
||||
"extras"=>$extras
|
||||
});
|
||||
$output .= _subtext($subtext);
|
||||
$output = $self->_tableFormRow($label,$output);
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ sub _selectPositions {
|
|||
);
|
||||
$output = '
|
||||
<script language="JavaScript">
|
||||
function checkBrowser(){
|
||||
function checkBrowserVersion(){
|
||||
this.ver=navigator.appVersion;
|
||||
this.dom=document.getElementById?1:0;
|
||||
this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
|
||||
|
|
@ -111,21 +111,21 @@ sub _selectPositions {
|
|||
this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5 || this.dom);
|
||||
return this;
|
||||
}
|
||||
bw=new checkBrowser();
|
||||
pbw=new checkBrowserVersion();
|
||||
function makeChangeTextObj(obj){
|
||||
this.css=bw.dom? document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?document.layers[obj]:0;
|
||||
this.writeref=bw.dom? document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?document.layers[obj].document:0
|
||||
this.css=pbw.dom? document.getElementById(obj).style:pbw.ie4?document.all[obj].style:pbw.ns4?document.layers[obj]:0;
|
||||
this.writeref=pbw.dom? document.getElementById(obj):pbw.ie4?document.all[obj]:pbw.ns4?document.layers[obj].document:0
|
||||
;
|
||||
this.writeIt=b_writeIt;
|
||||
}
|
||||
function b_writeIt(text){
|
||||
var obj;
|
||||
if(bw.ns4) {
|
||||
if(pbw.ns4) {
|
||||
if (document.loading) document.loading.visibility = "hidden";
|
||||
this.writeref.write(text + " ");
|
||||
this.writeref.close();
|
||||
} else {
|
||||
if (bw.ie4) {
|
||||
if (pbw.ie4) {
|
||||
if (document.all.loading) obj = document.all.loading;
|
||||
}
|
||||
if (obj) obj.style.visibility = "hidden";
|
||||
|
|
@ -133,7 +133,7 @@ sub _selectPositions {
|
|||
}
|
||||
}
|
||||
function init(){
|
||||
if(bw.bw){
|
||||
if(pbw.bw){
|
||||
oMessage=new makeChangeTextObj("templatePreview");
|
||||
oMessage.css.visibility="visible";
|
||||
changeTemplatePreview('.$_[0].');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue