Commit 77398f5a authored by matty%chariot.net.au's avatar matty%chariot.net.au

Bug 104677 : Votes field (text style) on showvotes.cgi defaults to size 5, not…

Bug 104677 : Votes field (text style) on showvotes.cgi defaults to size 5, not natural size and doesn't include a maxlength attribute. Patch by Christoper Aillon <caillon@returnzero.com>.
parent 684e6deb
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
# Dan Mosedale <dmose@mozilla.org> # Dan Mosedale <dmose@mozilla.org>
# Jake <jake@acutex.net> # Jake <jake@acutex.net>
# Bradley Baetz <bbaetz@cs.mcgill.ca> # Bradley Baetz <bbaetz@cs.mcgill.ca>
# Christopher Aillon <christopher@aillon.com>
# Contains some global variables and routines used throughout bugzilla. # Contains some global variables and routines used throughout bugzilla.
...@@ -1502,6 +1503,22 @@ sub PerformSubsts { ...@@ -1502,6 +1503,22 @@ sub PerformSubsts {
return $str; return $str;
} }
# Min and max routines.
sub min {
my $min = shift(@_);
foreach my $val (@_) {
$min = $val if $val < $min;
}
return $min;
}
sub max {
my $max = shift(@_);
foreach my $val (@_) {
$max = $val if $val > $max;
}
return $max;
}
# Trim whitespace from front and back. # Trim whitespace from front and back.
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
# #
# Contributor(s): Terry Weissman <terry@mozilla.org> # Contributor(s): Terry Weissman <terry@mozilla.org>
# Stephan Niemz <st.n@gmx.net> # Stephan Niemz <st.n@gmx.net>
# Christopher Aillon <christopher@aillon.com>
use diagnostics; use diagnostics;
use strict; use strict;
...@@ -138,13 +139,14 @@ if (defined $::FORM{'bug_id'}) { ...@@ -138,13 +139,14 @@ if (defined $::FORM{'bug_id'}) {
$summary = html_quote($summary); $summary = html_quote($summary);
$sum += $count; $sum += $count;
if ($canedit) { if ($canedit) {
my $min = $maxvotesperbug{$product}; # minimum of these two my $min = min($::prodmaxvotes{$product}, $maxvotesperbug{$product});
$min = $::prodmaxvotes{$product} if $::prodmaxvotes{$product} < $min; if ($min < 2) { # checkbox
if( $min < 2 ) { # checkbox my $checked = $count ? ' checked="checked"' : '';
my $checked = $count ? ' checked' : '';
$count = qq{<input type="checkbox" name="$id" value="1"$checked>}; $count = qq{<input type="checkbox" name="$id" value="1"$checked>};
}else { # normal input }
$count = qq{<input name="$id" value="$count" size="5">}; else { # text input
my $maxlength = length $min;
$count = qq{<input name="$id" value="$count" size="$maxlength" maxlength="$maxlength">};
} }
} }
print qq{ print qq{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment