working on adding codearea form field type
This commit is contained in:
parent
a287beda58
commit
cbb4f662c4
5 changed files with 105 additions and 4 deletions
|
|
@ -1,3 +1,12 @@
|
||||||
|
assets = WebGUI::Asset::File::Image, \
|
||||||
|
WebGUI::Asset::File, \
|
||||||
|
WebGUI::Asset::Redirect, \
|
||||||
|
WebGUI::Asset::Wobject::Layout, \
|
||||||
|
WebGUI::Asset::Wobject::USS, \
|
||||||
|
WebGUI::Asset::Wobject::SyndicatedContent, \
|
||||||
|
WebGUI::Asset::Wobject::Article, \
|
||||||
|
WebGUI::Asset::FilePile
|
||||||
|
|
||||||
sitename = www.example.com, example.com
|
sitename = www.example.com, example.com
|
||||||
|
|
||||||
dsn = DBI:mysql:www_example_com
|
dsn = DBI:mysql:www_example_com
|
||||||
|
|
|
||||||
|
|
@ -237,6 +237,15 @@ sub checkList {
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
sub codearea {
|
||||||
|
my $params = shift;
|
||||||
|
WebGUI::Style::setScript($session{config}{extrasURL}.'/TabFix.js',{type=>"text/javascript"});
|
||||||
|
$params->{extras} = 'style="width: 99%; min-width: 440px; height: 400px" onkeypress="TabFix_keyPress(event.type)" onkeydown="TabFix_keyDown(event.type)"';
|
||||||
|
my $output = textarea($params);
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 combo ( hashRef )
|
=head2 combo ( hashRef )
|
||||||
|
|
@ -426,9 +435,9 @@ sub date {
|
||||||
my $params = shift;
|
my $params = shift;
|
||||||
my $value = epochToSet($params->{value}||$params->{defaultValue}) unless ($params->{noDate} && $params->{value} eq '');
|
my $value = epochToSet($params->{value}||$params->{defaultValue}) unless ($params->{noDate} && $params->{value} eq '');
|
||||||
my $size = $params->{size} || 10;
|
my $size = $params->{size} || 10;
|
||||||
WebGUI::Style::setScript($session{config}{extrasURL}.'/calendar/calendar.js',{ language=>'javascript' });
|
WebGUI::Style::setScript($session{config}{extrasURL}.'/calendar/calendar.js',{ type=>'text/javascript' });
|
||||||
WebGUI::Style::setScript($session{config}{extrasURL}.'/calendar/lang/calendar-en.js',{ language=>'javascript' });
|
WebGUI::Style::setScript($session{config}{extrasURL}.'/calendar/lang/calendar-en.js',{ type=>'text/javascript' });
|
||||||
WebGUI::Style::setScript($session{config}{extrasURL}.'/calendar/calendar-setup.js',{ language=>'javascript' });
|
WebGUI::Style::setScript($session{config}{extrasURL}.'/calendar/calendar-setup.js',{ type=>'text/javascript' });
|
||||||
WebGUI::Style::setLink($session{config}{extrasURL}.'/calendar/calendar-win2k-1.css', { rel=>"stylesheet", type=>"text/css", media=>"all" });
|
WebGUI::Style::setLink($session{config}{extrasURL}.'/calendar/calendar-win2k-1.css', { rel=>"stylesheet", type=>"text/css", media=>"all" });
|
||||||
return text({
|
return text({
|
||||||
name=>$params->{name},
|
name=>$params->{name},
|
||||||
|
|
|
||||||
|
|
@ -405,6 +405,33 @@ sub checkList {
|
||||||
$self->{_data} .= $output;
|
$self->{_data} .= $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub codearea {
|
||||||
|
my ($output);
|
||||||
|
my ($self, @p) = @_;
|
||||||
|
my ($name, $label, $value, $subtext, $extras, $wrap, $rows, $columns, $uiLevel, $defaultValue) =
|
||||||
|
rearrange([qw(name label value subtext extras wrap rows columns uiLevel defaultValue)], @p);
|
||||||
|
if (_uiLevelChecksOut($uiLevel)) {
|
||||||
|
$output = WebGUI::Form::codearea({
|
||||||
|
"name"=>$name,
|
||||||
|
"value"=>$value,
|
||||||
|
"wrap"=>$wrap,
|
||||||
|
"columns"=>$columns,
|
||||||
|
"rows"=>$rows,
|
||||||
|
"extras"=>$extras,
|
||||||
|
defaultValue =>$defaultValue
|
||||||
|
});
|
||||||
|
$output .= _subtext($subtext);
|
||||||
|
$output = $self->_tableFormRow($label,$output);
|
||||||
|
} else {
|
||||||
|
$output = WebGUI::Form::hidden({
|
||||||
|
"name"=>$name,
|
||||||
|
"value"=>$value,
|
||||||
|
defaultValue=>$defaultValue
|
||||||
|
});
|
||||||
|
}
|
||||||
|
$self->{_data} .= $output;
|
||||||
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 combo ( name, options [, label, value, size, multiple, extras, subtext, uiLevel, defaultValue ] )
|
=head2 combo ( name, options [, label, value, size, multiple, extras, subtext, uiLevel, defaultValue ] )
|
||||||
|
|
|
||||||
|
|
@ -124,7 +124,7 @@ sub www_editTemplate {
|
||||||
}
|
}
|
||||||
$f->hidden("tid",$session{form}{tid});
|
$f->hidden("tid",$session{form}{tid});
|
||||||
$f->text("name",WebGUI::International::get(528),$template{name});
|
$f->text("name",WebGUI::International::get(528),$template{name});
|
||||||
$f->textarea(
|
$f->codearea(
|
||||||
-name=>"template",
|
-name=>"template",
|
||||||
-label=>WebGUI::International::get(504),
|
-label=>WebGUI::International::get(504),
|
||||||
-value=>$template{template},
|
-value=>$template{template},
|
||||||
|
|
|
||||||
56
www/extras/TabFix.js
Normal file
56
www/extras/TabFix.js
Normal file
|
|
@ -0,0 +1,56 @@
|
||||||
|
|
||||||
|
function TabFix_keyDown(e) {
|
||||||
|
var dom = document.getElementById&&!document.all;
|
||||||
|
e=dom? e : event;
|
||||||
|
obj =dom? e.target : e.srcElement
|
||||||
|
|
||||||
|
if (e.keyCode == 9 && obj.type && obj.type=="textarea") {
|
||||||
|
topScroll = obj.scrollTop;
|
||||||
|
leftScroll = obj.scrollLeft;
|
||||||
|
var position = TabFix_insertAtCursor(obj,'\t');
|
||||||
|
|
||||||
|
obj.focus();
|
||||||
|
obj.selectionStart=position + 1 ;
|
||||||
|
obj.selectionEnd=position + 1;
|
||||||
|
obj.scrollTop = topScroll;
|
||||||
|
obj.scrollLeft = leftScroll;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function TabFix_keyPress(e) {
|
||||||
|
var dom = document.getElementById&&!document.all;
|
||||||
|
e=dom? e : event;
|
||||||
|
if (e.keyCode == 9) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function TabFix_insertAtCursor(myField, myValue) {
|
||||||
|
//IE
|
||||||
|
if (document.selection) {
|
||||||
|
myField.focus();
|
||||||
|
sel = document.selection.createRange();
|
||||||
|
sel.text = myValue;
|
||||||
|
}
|
||||||
|
//MOZILLA
|
||||||
|
else if (myField.selectionStart || myField.selectionStart == '0') {
|
||||||
|
var startPos = myField.selectionStart;
|
||||||
|
var endPos = myField.selectionEnd;
|
||||||
|
myField.value = myField.value.substring(0, startPos) + myValue + myField.value.substring(endPos, myField.value.length);
|
||||||
|
return startPos;
|
||||||
|
} else {
|
||||||
|
myField.value += myValue;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
We'd uncomment the following lines if we wanted
|
||||||
|
to apply this to all text areas, which we don't
|
||||||
|
|
||||||
|
document.onkeypress=TabFix_keyPress;
|
||||||
|
document.onkeydown=TabFix_keyDown;
|
||||||
|
*/
|
||||||
Loading…
Add table
Add a link
Reference in a new issue