Bug 260335 Teach pref window and wsm how to lock colourpickers r=varga sr=jag

This commit is contained in:
neil%parkwaycc.co.uk 2004-10-11 12:39:12 +00:00
Родитель 9c467335b8
Коммит 4ee3b58110
5 изменённых файлов: 73 добавлений и 27 удалений

Просмотреть файл

@ -246,6 +246,8 @@ nsPrefWindow.prototype =
prefattribute = "value";
else if (elt == "checkbox" || elt == "listitem")
prefattribute = "checked";
else if (elt == "colorpicker")
prefattribute = "color";
else if (elt == "button")
prefattribute = "disabled";
}
@ -253,7 +255,7 @@ nsPrefWindow.prototype =
var value = itemObject[prefattribute];
var preftype = itemObject.preftype;
if (!preftype) {
if (elt == "textbox")
if (elt == "textbox" || elt == "colorpicker")
preftype = "string";
else if (elt == "checkbox" || elt == "listitem" || elt == "button")
preftype = "bool";
@ -363,7 +365,7 @@ nsPrefWindow.prototype =
var preftype = prefElements[i].getAttribute( "preftype" );
var elt = prefElements[i].localName;
if (!preftype) {
if (elt == "textbox")
if (elt == "textbox" || elt == "colorpicker")
preftype = "string";
else if (elt == "checkbox" || elt == "listitem" || elt == "button")
preftype = "bool";
@ -377,6 +379,8 @@ nsPrefWindow.prototype =
prefattribute = "value";
else if (elt == "checkbox" || elt == "listitem")
prefattribute = "checked";
else if (elt == "colorpicker")
prefattribute = "color";
else if (elt == "button")
prefattribute = "disabled";
}

Просмотреть файл

Просмотреть файл

@ -52,22 +52,20 @@
]]>
</script>
<script type="application/x-javascript" src="chrome://communicator/content/pref/pref-colors.js"/>
<hbox>
<groupbox flex="1" id="pageColours">
<caption label="&color;"/>
<hbox align="center">
<label value="&textColor.label;" accesskey="&textColor.accesskey;" control="foregroundtextmenu"/>
<spacer flex="1"/>
<colorpicker type="button" id="foregroundtextmenu" palettename="standard" onchange="setColorWell(this)"/>
<data id="foregroundText" preftype="color" prefstring="browser.display.foreground_color" prefattribute="value" wsm_attributes="value"/>
<label control="foregroundText" value="&textColor.label;"
accesskey="&textColor.accesskey;" flex="1"/>
<colorpicker type="button" id="foregroundText" palettename="standard"
prefstring="browser.display.foreground_color"/>
</hbox>
<hbox align="center" style="margin-top: 5px">
<label value="&backgroundColor.label;" accesskey="&backgroundColor.accesskey;" control="backgroundmenu"/>
<spacer flex="1"/>
<colorpicker type="button" id="backgroundmenu" palettename="standard" onchange="setColorWell(this)"/>
<data id="background" preftype="color" prefstring="browser.display.background_color" prefattribute="value" wsm_attributes="value"/>
<label control="background" value="&backgroundColor.label;"
accesskey="&backgroundColor.accesskey;" flex="1"/>
<colorpicker type="button" id="background" palettename="standard"
prefstring="browser.display.background_color"/>
</hbox>
<separator class="thin"/>
<hbox align="center">
@ -79,22 +77,22 @@
<groupbox flex="1">
<caption label="&links;"/>
<hbox align="center">
<label value="&linkColor.label;" accesskey="&linkColor.accesskey;" control="unvisitedlinkmenu"/>
<spacer flex="1"/>
<colorpicker type="button" id="unvisitedlinkmenu" palettename="standard" onchange="setColorWell(this)"/>
<data id="unvisitedLinks" preftype="string" prefstring="browser.anchor_color" prefattribute="value" wsm_attributes="value"/>
<label control="unvisitedLinks" value="&linkColor.label;"
accesskey="&linkColor.accesskey;" flex="1"/>
<colorpicker type="button" id="unvisitedLinks" palettename="standard"
prefstring="browser.anchor_color"/>
</hbox>
<hbox align="center" style="margin-top: 5px">
<label value="&activeLinkColor.label;" accesskey="&activeLinkColor.accesskey;" control="activelinkmenu"/>
<spacer flex="1"/>
<colorpicker type="button" id="activelinkmenu" palettename="standard" onchange="setColorWell(this)"/>
<data id="activeLinks" preftype="string" prefstring="browser.active_color" prefattribute="value" wsm_attributes="value"/>
<label control="activeLinks" value="&activeLinkColor.label;"
accesskey="&activeLinkColor.accesskey;" flex="1"/>
<colorpicker type="button" id="activeLinks" palettename="standard"
prefstring="browser.active_color"/>
</hbox>
<hbox align="center" style="margin-top: 5px">
<label value="&visitedLinkColor.label;" accesskey="&visitedLinkColor.accesskey;" control="visitedlinkmenu"/>
<spacer flex="1"/>
<colorpicker type="button" id="visitedlinkmenu" palettename="standard" onchange="setColorWell(this)"/>
<data id="visitedLinks" preftype="string" prefstring="browser.visited_color" prefattribute="value" wsm_attributes="value"/>
<label control="visitedLinks" value="&visitedLinkColor.label;"
accesskey="&visitedLinkColor.accesskey;" flex="1"/>
<colorpicker type="button" id="visitedLinks" palettename="standard"
prefstring="browser.visited_color"/>
</hbox>
<separator class="thin"/>
<hbox align="center">

Просмотреть файл

@ -412,7 +412,7 @@
</resources>
<content>
<xul:hbox class="colorpicker-button-colorbox" anonid="colorbox" flex="1"/>
<xul:hbox class="colorpicker-button-colorbox" anonid="colorbox" flex="1" xbl:inherits="disabled"/>
<xul:popupset>
<xul:popup class="colorpicker-button-menupopup" anonid="colorpopup"
@ -420,14 +420,14 @@
onpopupshowing="this._colorPicker.onPopupShowing()"
onpopuphiding="this._colorPicker.onPopupHiding()">
<xul:colorpicker xbl:inherits="palettename" allowevents="true" anonid="colorpicker"
<xul:colorpicker xbl:inherits="palettename,disabled" allowevents="true" anonid="colorpicker"
onselect="this.parentNode.parentNode.parentNode.pickerChange()"/>
</xul:popup>
</xul:popupset>
</content>
<implementation implements="nsIAccessibleProvider" >
<implementation implements="nsIAccessibleProvider, nsIDOMXULControlElement">
<property name="accessible">
<getter>
<![CDATA[
@ -439,6 +439,11 @@
<property name="open" onget="return this.mOpen"/>
<property name="disabled" onset="if (val) this.setAttribute('disabled',true);
else this.removeAttribute('disabled');
return val;"
onget="return this.hasAttribute('disabled');"/>
<property name="color">
<getter><![CDATA[
return this.getAttribute("color");
@ -533,6 +538,9 @@
]]></handler>
<handler event="mousedown"><![CDATA[
if (this.disabled)
return;
// Though I would prefer the open the popup using the built-in
// popup="_child" mechanism, I can't use that because I can't seem to
// get it to recognize the popupalign and popupanchor attributes that way

Просмотреть файл

@ -95,6 +95,8 @@ function nsWidgetStateManager ( aFrameID )
**/
this.handlers =
{
colorpicker:
{ get: wsm.get_Colorpicker, set: wsm.set_Colorpicker },
menulist:
{ get: wsm.get_Menulist, set: wsm.set_Menulist },
radiogroup:
@ -251,6 +253,40 @@ nsWidgetStateManager.prototype =
return null;
},
// <colorpicker>
set_Colorpicker:
function ( aElementID, aDataObject )
{
var element = wsm.contentArea.document.getElementById( aElementID );
// set all generic properties
wsm.generic_Set( element, aDataObject );
// set colorpicker specific properties
if( 'color' in aDataObject )
{
try {
element.color = aDataObject.color;
}
catch (ex) {
dump(aElementID +", ex: " + ex + "\n");
}
}
},
get_Colorpicker:
function ( aElementID )
{
var element = wsm.contentArea.document.getElementById( aElementID );
// retrieve all generic attributes
var dataObject = wsm.generic_Get( element );
// retrieve all colorpicker specific attributes
if( dataObject )
{
dataObject.color = element.color;
return dataObject;
}
return null;
},
// <menulist>
set_Menulist:
function ( aElementID, aDataObject )