289361 - checkbox constructor is weird, back out rv1.7 to 1.6, moving common initialization logic for checkboxes and colorpickers into special cases in the preferences XML rather than exposing new apis on checkbox and colorpicker. r=mconnor, a=brendan
git-svn-id: svn://10.0.0.236/trunk@178701 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -35,9 +35,9 @@
|
||||
<body>
|
||||
<![CDATA[
|
||||
var change = (aValue != (this.getAttribute('checked') == 'true'));
|
||||
if (aValue)
|
||||
if (aValue)
|
||||
this.setAttribute('checked', 'true');
|
||||
else
|
||||
else
|
||||
this.removeAttribute('checked');
|
||||
if (change) {
|
||||
var event = document.createEvent('Events');
|
||||
@@ -50,15 +50,8 @@
|
||||
</method>
|
||||
|
||||
<!-- public implementation -->
|
||||
<property name="value" onset="return this.checked = val;"
|
||||
onget="return this.checked;"/>
|
||||
<property name="checked" onset="return this.setChecked(val);"
|
||||
onget="return this.getAttribute('checked') == 'true';"/>
|
||||
|
||||
<constructor>
|
||||
// Sync the checked value from the "value" attribute if necessary.
|
||||
this.checked = this.value;
|
||||
</constructor>
|
||||
</implementation>
|
||||
|
||||
<handlers>
|
||||
|
||||
@@ -451,7 +451,6 @@
|
||||
</property>
|
||||
|
||||
<property name="open" onget="return this.mOpen"/>
|
||||
<property name="value" onget="return this.color;" onset="return (this.color = val);"/>
|
||||
<property name="color">
|
||||
<getter><![CDATA[
|
||||
return this.getAttribute("color");
|
||||
|
||||
@@ -336,10 +336,26 @@
|
||||
}
|
||||
}
|
||||
var val = rv !== undefined ? rv : (this.instantApply ? this.valueFromPreferences : this.value);
|
||||
if ("value" in aElement)
|
||||
aElement.value = val;
|
||||
else
|
||||
aElement.setAttribute("value", val);
|
||||
|
||||
/**
|
||||
* Initialize a UI element property with a value. Handles the case
|
||||
* where an element has not yet had a XBL binding attached for it and
|
||||
* the property setter does not yet exist by setting the same attribute
|
||||
* on the XUL element using DOM apis and assuming the element's
|
||||
* constructor or property getters appropriately handle this state.
|
||||
*/
|
||||
function setValue(element, attribute, value) {
|
||||
if (attribute in element)
|
||||
element[attribute] = value;
|
||||
else
|
||||
element.setAttribute(attribute, value);
|
||||
}
|
||||
if (aElement.localName == "checkbox")
|
||||
setValue(aElement, "checked", val);
|
||||
else if (aElement.localName == "colorpicker")
|
||||
setValue(aElement, "color", val);
|
||||
else
|
||||
setValue(aElement, "value", val);
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
@@ -363,7 +379,24 @@
|
||||
dump(e);
|
||||
}
|
||||
}
|
||||
var value = ("value" in aElement) ? aElement.value : aElement.getAttribute("value");
|
||||
|
||||
/**
|
||||
* Read the value of an attribute from an element, assuming the
|
||||
* attribute is a property on the element's node API. If the property
|
||||
* is not present in the API, then assume its value is contained in
|
||||
* an attribute, as is the case before a binding has been attached.
|
||||
*/
|
||||
function getValue(element, attribute) {
|
||||
if (attribute in element)
|
||||
return element[attribute];
|
||||
return element.getAttribute(attribute);
|
||||
}
|
||||
if (aElement.localName == "checkbox")
|
||||
var value = getValue(aElement, "checked");
|
||||
else if (aElement.localName == "colorpicker")
|
||||
value = getValue(aElement, "color");
|
||||
else
|
||||
value = getValue(aElement, "value");
|
||||
|
||||
switch (this.type) {
|
||||
case "int":
|
||||
|
||||
Reference in New Issue
Block a user