fixed #10667: cannot change size of template editor
This commit is contained in:
parent
ecd89d349a
commit
38ff4f053b
7 changed files with 72 additions and 205 deletions
|
|
@ -133,40 +133,43 @@ Renders a code area field.
|
|||
=cut
|
||||
|
||||
sub toHtml {
|
||||
my $self = shift;
|
||||
my $output = "";
|
||||
|
||||
# Do our superclass's job
|
||||
my $self = shift;
|
||||
my ($style, $url, $stow) = $self->session->quick(qw(style url stow));
|
||||
|
||||
my $value = $self->fixMacros($self->fixTags($self->fixSpecialCharacters(scalar $self->getOriginalValue)));
|
||||
my $width = $self->get('width') || 400;
|
||||
my $height = $self->get('height') || 150;
|
||||
my ($style, $url) = $self->session->quick(qw(style url));
|
||||
my $styleAttribute = "width: ".$width."px; height: ".$height."px; ".$self->get("style");
|
||||
$style->setRawHeadTags(qq|<style type="text/css">\ntextarea#|.$self->get('id').qq|{ $styleAttribute }\n</style>|);
|
||||
$output = '<textarea id="'.$self->get('id').'" name="'.$self->get("name").'" '.$self->get("extras").' rows="#" cols="#" style="width: '.$width.'px; height: '.$height.'px;">'.$value.'</textarea>';
|
||||
my $width = $self->get('width') || 400;
|
||||
my $height = $self->get('height') || 150;
|
||||
my $id = $self->get('id');
|
||||
my $name = $self->get('name');
|
||||
my $extras = $self->get('extras');
|
||||
my $syntax = $self->get('syntax');
|
||||
my $styleAttr = $self->get('style');
|
||||
|
||||
# Vars for JS below
|
||||
my $id = $self->get( "id" );
|
||||
my $syntax = $self->get( "syntax" );
|
||||
my $editareaPath = $self->session->url->extras( 'editarea' );
|
||||
|
||||
$self->session->style->setScript($editareaPath . '/edit_area/edit_area_full.js',{type=>"text/javascript"});
|
||||
$output .= qq~
|
||||
<script type="text/javascript">
|
||||
editAreaLoader.init({
|
||||
id : "$id",
|
||||
syntax : "$syntax",
|
||||
start_highlight : true,
|
||||
show_line_colors: true,
|
||||
display : "later",
|
||||
toolbar : "search, go_to_line, |, undo, redo, |, syntax_selection, highlight, reset_highlight, |, help"
|
||||
});
|
||||
</script>
|
||||
~;
|
||||
|
||||
return $output;
|
||||
$style->setLink($url->extras("yui/build/resize/assets/skins/sam/resize.css"), {type=>"text/css", rel=>"stylesheet"});
|
||||
$style->setScript($url->extras("yui/build/utilities/utilities.js"), {type=>"text/javascript"});
|
||||
$style->setScript($url->extras("yui/build/resize/resize-min.js"), {type=>"text/javascript"});
|
||||
$style->setScript($url->extras('editarea/edit_area/edit_area_full.js'), {type=>"text/javascript"});
|
||||
my $out = <<"END_HTML";
|
||||
<div id="${id}_resizewrapper" style="padding-right: 6px; padding-bottom: 6px; margin-bottom: 1em; width: ${width}px; height: ${height}px">
|
||||
<textarea id="$id" name="$name" $extras rows="#" cols="#" style="font-family: monospace; $styleAttr; height: 100%; width: 100%;">$value</textarea>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
(function() {
|
||||
var resize = new YAHOO.util.Resize('${id}_resizewrapper', {useShim : true});
|
||||
editAreaLoader.init({
|
||||
id : '$id',
|
||||
syntax : '$syntax',
|
||||
start_highlight : true,
|
||||
show_line_colors : true,
|
||||
allow_resize : 'no',
|
||||
display : 'later',
|
||||
toolbar : 'search,go_to_line,|,undo,redo,|,syntax_selection,highlight,reset_highlight,|,help'
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
END_HTML
|
||||
return $out;
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
|
||||
|
|
|
|||
|
|
@ -143,61 +143,44 @@ sub toHtml {
|
|||
my $width = $self->get('width') || 400;
|
||||
my $height = $self->get('height') || 150;
|
||||
my ($style, $url, $stow) = $self->session->quick(qw(style url stow));
|
||||
my $out = '<textarea id="'.$self->get('id').'" name="'.$self->get("name").'" '
|
||||
. ( $self->get("maxlength") ? 'maxlength="' . $self->get( "maxlength" ) . '" ' : '' )
|
||||
. $self->get("extras") . ' rows="#" cols="#" style="width: '.$width.'px; height: '.$height.'px;">'.$value.'</textarea>'
|
||||
;
|
||||
my $sizeStyle = ' width: ' . $width . 'px; height: ' . $height . 'px;';
|
||||
my $out
|
||||
= '<textarea id="' . $self->get('id') . '"'
|
||||
. ' name="' . $self->get("name") . '"'
|
||||
. ( $self->get("maxlength") ? ' maxlength="' . $self->get( "maxlength" ) . '"' : '' )
|
||||
. ' ' . $self->get("extras")
|
||||
. ' rows="#" cols="#"'
|
||||
. ' style="' . $self->get('style')
|
||||
. ( $self->get("resizable") ? ' height: 100%; width: 100%' : $sizeStyle ) . '"'
|
||||
. '>' . $value . '</textarea>';
|
||||
|
||||
# Add the maxlength script
|
||||
$style->setScript(
|
||||
$url->extras( 'yui/build/yahoo-dom-event/yahoo-dom-event.js' ),
|
||||
{ type => 'text/javascript' },
|
||||
);
|
||||
$style->setScript(
|
||||
$url->extras( 'yui-webgui/build/form/textarea.js' ),
|
||||
{ type => 'text/javascript' },
|
||||
);
|
||||
|
||||
# Make sure we load the css for this plugin only once per id.
|
||||
unless ( $stow->get( 'textareaStyleLoaded_' . $self->get('id') ) ) {
|
||||
my $styleAttribute = "width: ".$width."px; height: ".$height."px; ".$self->get("style");
|
||||
$style->setRawHeadTags(qq|<style type="text/css">\ntextarea#|.$self->get('id').qq|{ $styleAttribute }\n</style>|);
|
||||
$stow->set( 'textareaStyleLoaded_' . $self->get('id'), 1 );
|
||||
}
|
||||
# Make sure we add the max length js only once for all texatareas.
|
||||
unless ( $stow->get( 'texareaHeadTagsLoaded' ) ) {
|
||||
$style->setRawHeadTags( q|
|
||||
<script type="text/javascript">
|
||||
YAHOO.util.Event.onDOMReady( function () { WebGUI.Form.Textarea.setMaxLength() } );
|
||||
</script>
|
||||
| );
|
||||
|
||||
$stow->set( 'texareaHeadTagsLoaded', 1 );
|
||||
}
|
||||
|
||||
if ($self->get("resizable")) {
|
||||
$style->setLink($url->extras("resize.css"), {type=>"text/css", rel=>"stylesheet"});
|
||||
$style->setLink($url->extras("resize-skin.css"), {type=>"text/css", rel=>"stylesheet"});
|
||||
if ($self->get("resizable")) {
|
||||
$style->setLink($url->extras("yui/build/resize/assets/skins/sam/resize.css"), {type=>"text/css", rel=>"stylesheet"});
|
||||
$style->setScript($url->extras("yui/build/utilities/utilities.js"), {type=>"text/javascript"});
|
||||
$style->setScript($url->extras("yui/build/resize/resize.js"), {type=>"text/javascript"});
|
||||
$out = qq|
|
||||
<div id="resize_| . $self->get('id'). qq|" style="width: | . ($width + 6) . qq|px; height: | . ($height + 6) . qq|px; overflow: hidden">
|
||||
$out
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
YAHOO.util.Event.onContentReady('| . $self->get('id') . qq|', function() {
|
||||
var Dom = YAHOO.util.Dom;
|
||||
var resize = new YAHOO.util.Resize('resize_| . $self->get('id'). qq|');
|
||||
resize.on('resize', function(ev) {
|
||||
Dom.setStyle('| . $self->get('id') . qq|', 'width', (ev.width - 6) + "px");
|
||||
Dom.setStyle('| . $self->get('id') . qq|', 'height', (ev.height - 6) + "px");
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|;
|
||||
}
|
||||
return $out;
|
||||
$style->setScript($url->extras("yui/build/resize/resize-min.js"), {type=>"text/javascript"});
|
||||
$out = sprintf <<'END_HTML', $self->get('id'), $out, $sizeStyle;
|
||||
<div id="%1$s_resizewrapper" style="padding-right: 6px; padding-bottom: 6px; %3$s">%2$s</div>
|
||||
<script type="text/javascript">
|
||||
(function() {
|
||||
var resize = new YAHOO.util.Resize('%1$s_resizewrapper');
|
||||
})();
|
||||
</script>
|
||||
END_HTML
|
||||
}
|
||||
elsif ($self->get('maxlength')) {
|
||||
$style->setScript(
|
||||
$url->extras( 'yui/build/yahoo-dom-event/yahoo-dom-event.js' ),
|
||||
{ type => 'text/javascript' },
|
||||
);
|
||||
}
|
||||
if ($self->get('maxlength')) {
|
||||
# Add the maxlength script
|
||||
$style->setScript(
|
||||
$url->extras( 'yui-webgui/build/form/textarea.js' ),
|
||||
{ type => 'text/javascript' },
|
||||
);
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue