Fix bug 466288 - Make use of type="number" for textboxes representing integer preferences. r=dbo
--HG-- extra : rebase_source : 3dbaa44141fd0f418561ae3ffcbe700ad6289cd8
This commit is contained in:
Родитель
5d842bbb2d
Коммит
099b13c9b8
|
@ -397,7 +397,7 @@ function appendCategoryItems(aItem, aCategoryMenuList, aCommand) {
|
|||
*/
|
||||
function addMenuItem(aParent, aLabel, aValue, aCommand) {
|
||||
if (aParent.localName == "menupopup") {
|
||||
var item = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "menuitem");
|
||||
var item = createXULElement("menuitem");
|
||||
item.setAttribute("label", aLabel);
|
||||
if (aValue) {
|
||||
item.setAttribute("value", aValue);
|
||||
|
@ -665,56 +665,6 @@ function getOptimalMinimumHeight(aXULElement) {
|
|||
return (firstEntity + secondEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Use with textfields oninput to only allow integers
|
||||
*
|
||||
* @param event The event that contains the target
|
||||
* @param lowerBound The lower bound the number should have
|
||||
* @param upperBound The upper bound the number should have
|
||||
*/
|
||||
function validateIntegerRange(event, lowerBound, upperBound) {
|
||||
validateIntegers(event);
|
||||
|
||||
var num = Number(event.target.value);
|
||||
|
||||
// Only modify the number if a value is entered, otherwise deleting the
|
||||
// value (to maybe enter a new number) will cause the field to be set to the
|
||||
// lower bound.
|
||||
if (event.target.value != "" && (num < lowerBound || num > upperBound)) {
|
||||
event.target.value = Math.min(Math.max(num, lowerBound), upperBound);
|
||||
event.preventDefault();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate Integers, or rather validate numbers. Makes sure the input value is
|
||||
* a number.
|
||||
*
|
||||
* @param event The event that contains the target
|
||||
*/
|
||||
function validateIntegers(event) {
|
||||
if (isNaN(Number(event.target.value))) {
|
||||
var newValue = parseInt(event.target.value);
|
||||
event.target.value = isNaN(newValue) ? "" : newValue;
|
||||
event.preventDefault();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Make sure the number entered is 0 or more. A negative number is turned
|
||||
* positive.
|
||||
*
|
||||
* @param event The event that contains the target
|
||||
*/
|
||||
function validateNaturalNums(event) {
|
||||
validateIntegers(event);
|
||||
var num = event.target.value;
|
||||
if (num < 0) {
|
||||
event.target.value = -1 * num;
|
||||
event.preventDefault();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the "other" orientation value, i.e if "horizontal" is passed, "vertical"
|
||||
* is returned and vice versa.
|
||||
|
|
|
@ -114,9 +114,13 @@
|
|||
disable-on-readonly="true"
|
||||
disable-on-occurrence="true"
|
||||
selected="true"/>
|
||||
<textbox id="daily-days" value="1"
|
||||
<textbox id="daily-days"
|
||||
type="number"
|
||||
value="1"
|
||||
min="1"
|
||||
max="0x7FFF"
|
||||
size="3"
|
||||
oninput="validateIntegerRange(event, 1, 0x7FFF); updateRecurrenceControls();"
|
||||
oninput="updateRecurrenceControls();"
|
||||
disable-on-readonly="true"
|
||||
disable-on-occurrence="true"/>
|
||||
<label id="daily-group-every-units-label"
|
||||
|
@ -140,9 +144,12 @@
|
|||
disable-on-occurrence="true"
|
||||
control="weekly-weeks"/>
|
||||
<textbox id="weekly-weeks"
|
||||
type="number"
|
||||
value="1"
|
||||
min="1"
|
||||
max="0x7FFF"
|
||||
size="3"
|
||||
oninput="validateIntegerRange(event, 1, 0x7FFF); updateRecurrenceControls();"
|
||||
oninput="updateRecurrenceControls();"
|
||||
disable-on-readonly="true"
|
||||
disable-on-occurrence="true"/>
|
||||
<label id="weekly-period-units-label"
|
||||
|
@ -173,9 +180,12 @@
|
|||
disable-on-occurrence="true"
|
||||
control="monthly-interval"/>
|
||||
<textbox id="monthly-interval"
|
||||
type="number"
|
||||
value="1"
|
||||
min="1"
|
||||
max="0x7FFF"
|
||||
size="3"
|
||||
oninput="validateIntegerRange(event, 1, 0x7FFF); updateRecurrenceControls();"
|
||||
oninput="updateRecurrenceControls();"
|
||||
disable-on-readonly="true"
|
||||
disable-on-occurrence="true"/>
|
||||
<label id="monthly-period-units-label"
|
||||
|
@ -273,9 +283,12 @@
|
|||
value="&event.recurrence.every.label;"
|
||||
control="yearly-interval"/>
|
||||
<textbox id="yearly-interval"
|
||||
type="number"
|
||||
value="1"
|
||||
min="1"
|
||||
max="0x7FFF"
|
||||
size="3"
|
||||
oninput="validateIntegerRange(event, 1, 0x7FFF); updateRecurrenceControls();"
|
||||
oninput="updateRecurrenceControls();"
|
||||
disable-on-readonly="true"
|
||||
disable-on-occurrence="true"/>
|
||||
<label id="yearly-period-units-label" value="&repeat.units.years.both;"/>
|
||||
|
@ -298,7 +311,9 @@
|
|||
orient="horizontal"
|
||||
align="center">
|
||||
<textbox id="yearly-days"
|
||||
type="number"
|
||||
value="1"
|
||||
min="1"
|
||||
size="3"
|
||||
oninput="updateRecurrenceControls();"
|
||||
disable-on-readonly="true"
|
||||
|
@ -492,9 +507,12 @@
|
|||
disable-on-readonly="true"
|
||||
disable-on-occurrence="true"/>
|
||||
<textbox id="repeat-ntimes-count"
|
||||
size="3"
|
||||
type="number"
|
||||
value="5"
|
||||
oninput="validateIntegerRange(event, 1, 0x7FFF); updateRecurrenceControls();"
|
||||
min="1"
|
||||
max="0x7FFF"
|
||||
size="3"
|
||||
oninput="updateRecurrenceControls();"
|
||||
disable-on-readonly="true"
|
||||
disable-on-occurrence="true"/>
|
||||
<label id="repeat-appointments-label"
|
||||
|
|
|
@ -91,8 +91,10 @@
|
|||
<vbox id="reminder-relative-box" flex="1">
|
||||
<hbox id="reminder-relative-length-unit-relation" flex="1">
|
||||
<textbox id="reminder-length"
|
||||
type="number"
|
||||
size="1"
|
||||
oninput="validateIntegers(event); updateReminder(event)"/>
|
||||
min="1"
|
||||
oninput="updateReminder(event)"/>
|
||||
<menulist id="reminder-unit" oncommand="updateReminder(event)" flex="1">
|
||||
<menupopup id="reminder-unit-menupopup">
|
||||
<menuitem id="reminder-minutes-menuitem"
|
||||
|
|
|
@ -853,8 +853,10 @@
|
|||
disabled="true"
|
||||
value=""/>
|
||||
<textbox id="percent-complete-textbox"
|
||||
type="number"
|
||||
min="0"
|
||||
max="100"
|
||||
disable-on-readonly="true"
|
||||
oninput="validateIntegers(event);"
|
||||
size="3"/>
|
||||
<label id="percent-complete-label"
|
||||
class="todo-only"
|
||||
|
|
|
@ -200,8 +200,10 @@
|
|||
<hbox>
|
||||
<textbox id="eventdefalarmlen"
|
||||
preference="calendar.alarms.eventalarmlen"
|
||||
type="number"
|
||||
min="0"
|
||||
size="3"
|
||||
oninput="validateNaturalNums(event); gAlarmsPane.updateMenuPlural('eventdefalarmlen','eventdefalarmunit')"/>
|
||||
oninput="gAlarmsPane.updateMenuPlural('eventdefalarmlen','eventdefalarmunit')"/>
|
||||
<menulist id="eventdefalarmunit"
|
||||
crop="none"
|
||||
preference="calendar.alarms.eventalarmunit"
|
||||
|
@ -236,8 +238,10 @@
|
|||
<hbox>
|
||||
<textbox id="tododefalarmlen"
|
||||
preference="calendar.alarms.todoalarmlen"
|
||||
type="number"
|
||||
min="0"
|
||||
size="3"
|
||||
oninput="validateNaturalNums(event); gAlarmsPane.updateMenuPlural('tododefalarmlen','tododefalarmunit')"/>
|
||||
oninput="gAlarmsPane.updateMenuPlural('tododefalarmlen','tododefalarmunit')"/>
|
||||
<menulist id="tododefalarmunit"
|
||||
crop="none"
|
||||
preference="calendar.alarms.todoalarmunit"
|
||||
|
|
|
@ -108,7 +108,7 @@
|
|||
<textbox id="networkProxyHTTP" flex="1"
|
||||
preference="network.proxy.http" onsyncfrompreference="return gConnectionsDialog.readHTTPProxyServer();"/>
|
||||
<label value="&port.label;" accesskey="&HTTPport.accesskey;" control="networkProxyHTTP_Port"/>
|
||||
<textbox id="networkProxyHTTP_Port" size="5"
|
||||
<textbox id="networkProxyHTTP_Port" size="5" type="number" min="0" max="65535"
|
||||
preference="network.proxy.http_port" onsyncfrompreference="return gConnectionsDialog.readHTTPProxyPort();"/>
|
||||
</hbox>
|
||||
</row>
|
||||
|
@ -128,7 +128,7 @@
|
|||
<textbox id="networkProxySSL" flex="1" preference="network.proxy.ssl"
|
||||
onsyncfrompreference="return gConnectionsDialog.readProxyProtocolPref('ssl', false);"/>
|
||||
<label value="&port.label;" accesskey="&SSLport.accesskey;" control="networkProxySSL_Port"/>
|
||||
<textbox id="networkProxySSL_Port" size="5" preference="network.proxy.ssl_port"
|
||||
<textbox id="networkProxySSL_Port" size="5" preference="network.proxy.ssl_port" type="number" min="0" max="65535"
|
||||
onsyncfrompreference="return gConnectionsDialog.readProxyProtocolPref('ssl', true);"/>
|
||||
</hbox>
|
||||
</row>
|
||||
|
@ -140,7 +140,7 @@
|
|||
<textbox id="networkProxyFTP" flex="1" preference="network.proxy.ftp"
|
||||
onsyncfrompreference="return gConnectionsDialog.readProxyProtocolPref('ftp', false);"/>
|
||||
<label value="&port.label;" accesskey="&FTPport.accesskey;" control="networkProxyFTP_Port"/>
|
||||
<textbox id="networkProxyFTP_Port" size="5" preference="network.proxy.ftp_port"
|
||||
<textbox id="networkProxyFTP_Port" size="5" preference="network.proxy.ftp_port" type="number" min="0" max="65535"
|
||||
onsyncfrompreference="return gConnectionsDialog.readProxyProtocolPref('ftp', true);"/>
|
||||
</hbox>
|
||||
</row>
|
||||
|
@ -152,7 +152,7 @@
|
|||
<textbox id="networkProxySOCKS" flex="1" preference="network.proxy.socks"
|
||||
onsyncfrompreference="return gConnectionsDialog.readProxyProtocolPref('socks', false);"/>
|
||||
<label value="&port.label;" accesskey="&SOCKSport.accesskey;" control="networkProxySOCKS_Port"/>
|
||||
<textbox id="networkProxySOCKS_Port" size="5" preference="network.proxy.socks_port"
|
||||
<textbox id="networkProxySOCKS_Port" size="5" preference="network.proxy.socks_port" type="number" min="0" max="65535"
|
||||
onsyncfrompreference="return gConnectionsDialog.readProxyProtocolPref('socks', true);"/>
|
||||
</hbox>
|
||||
</row>
|
||||
|
|
|
@ -104,9 +104,10 @@
|
|||
control="defaultlength"/>
|
||||
<textbox id="defaultlength"
|
||||
preference="calendar.event.defaultlength"
|
||||
type="number"
|
||||
min="0"
|
||||
maxlength="3"
|
||||
size="3"
|
||||
oninput="validateNaturalNums(event);"/>
|
||||
size="3"/>
|
||||
<label value="&calendar.global.units.minutes;"/>
|
||||
</hbox>
|
||||
|
||||
|
@ -116,9 +117,10 @@
|
|||
control="defaultsnoozelength"/>
|
||||
<textbox id="defaultsnoozelength"
|
||||
preference="calendar.alarms.defaultsnoozelength"
|
||||
type="number"
|
||||
min="0"
|
||||
maxlength="3"
|
||||
size="3"
|
||||
oninput="validateNaturalNums(event);"/>
|
||||
size="3"/>
|
||||
<label value="&calendar.global.units.minutes;"/>
|
||||
</hbox>
|
||||
|
||||
|
@ -133,8 +135,10 @@
|
|||
accesskey="&pref.autorefresh.accesskey;"/>
|
||||
<textbox id="refreshtimeout"
|
||||
preference="calendar.autorefresh.timeout"
|
||||
size="3"
|
||||
oninput="validateIntegerRange(event, 1, 0x7FFFF);"/>
|
||||
type="number"
|
||||
min="1"
|
||||
max="0x7FFFF"
|
||||
size="3"/>
|
||||
<label value="&calendar.global.units.minutes;"/>
|
||||
</hbox>
|
||||
</groupbox>
|
||||
|
|
Загрузка…
Ссылка в новой задаче