More fun with XBL. Not used in build. a=ben

This commit is contained in:
hyatt%netscape.com 2000-12-07 09:52:13 +00:00
Родитель ef122d5552
Коммит 021da9b1d3
16 изменённых файлов: 434 добавлений и 28 удалений

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

@ -0,0 +1,69 @@
<?xml version="1.0"?>
<bindings id="checkboxBindings"
xmlns="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<binding id="checkbox" display="xul:button">
<implementation>
<property name="checked">
<getter>
var image = this.getElementByAttribute("cbattr", "image");
if (image) {
return image.hasAttribute("checked");
}
return false;
</getter>
<setter>
var image = this.getElementByAttribute("cbattr", "image");
if (image) {
if (val)
image.setAttribute("checked", "true");
else image.removeAttribute("checked");
}
</setter>
</property>
<!-- Internal Implementation Methods -->
<method name="getElementByAttribute">
<parameter name="aAttributeName"/>
<parameter name="aAttributeValue"/>
<body>
<![CDATA[
var anonymousNodes = document.getAnonymousNodes(this);
for (var i = 0; i < anonymousNodes.length; ++i)
return this.recursiveAttributeSearch(anonymousNodes[i], aAttributeName, aAttributeValue);
return null;
]]>
</body>
</method>
<method name="recursiveAttributeSearch">
<parameter name="aNode"/>
<parameter name="aAttributeName"/>
<parameter name="aAttributeValue"/>
<body>
<![CDATA[
if (aNode) {
if (aNode.getAttribute(aAttributeName) == aAttributeValue)
return aNode;
for (var i = 0; i < aNode.childNodes.length; ++i)
return this.recursiveAttributeSearch(aNode.childNodes[i], aAttributeName, aAttributeValue);
}
return null;
]]>
</body>
</method>
</implementation>
<handlers>
<handler event="command">
<![CDATA[
this.checked = !this.checked;
]]>
</handler>
</handlers>
</binding>
</bindings>

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

@ -29,8 +29,10 @@ install:: $(LIBRARY)
$(MAKE_INSTALL) htmlbindings.xml $(DIST)\bin\res\builtin
$(MAKE_INSTALL) buttonBindings.xml $(DIST)\bin\res\builtin
$(MAKE_INSTALL) selectBindings.xml $(DIST)\bin\res\builtin
$(MAKE_INSTALL) checkboxBindings.xml $(DIST)\bin\res\builtin
clobber::
rm -f $(DIST)\bin\res\builtin\htmlbindings.xml
rm -f $(DIST)\bin\res\builtin\buttonBindings.xml
rm -f $(DIST)\bin\res\builtin\selectBindings.xml
rm -f $(DIST)\bin\res\builtin\checkboxBindings.xml

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

@ -246,8 +246,11 @@
this._selectArray.push(this.childNodes[val]);
var textDisplayNode = this.getElementByAttribute("selectattr", "text");
if (textDisplayNode)
textDisplayNode.setAttribute("value", this.childNodes[val].text);
if (textDisplayNode) {
var text = this.childNodes[val].text;
text = text.replace(/\n/g, "");
textDisplayNode.setAttribute("value", text);
}
}
return val;
@ -302,9 +305,6 @@
var menuBox = boxObject.QueryInterface(Components.interfaces.nsIMenuBoxObject);
menuBox.activeChild = this._selectArray[0];
}
if (this._selectArray[0])
this.childNodes[this.selectedIndex].setAttribute("menuactive", "true");
]]>
</handler>
<handler event="mouseover">

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

@ -0,0 +1,99 @@
/*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* David Hyatt & Ben Goodger
*/
@namespace url(http://www.w3.org/1999/xhtml); /* set default namespace to HTML */
/* stylesheet for XUL <checkbox> element */
/* default checkbox for dialogs */
/* outer frame */
input[type="checkbox"]
{
border : 1px solid transparent;
padding : 2px !important;
margin : 0px;
cursor : default;
}
.input-checkbox-checkmark-box-1
{
border-top : 1px solid threedshadow;
border-left : 1px solid threedshadow;
border-right : 1px solid threedhighlight;
border-bottom : 1px solid threedhighlight;
background-color : window;
width : 13px;
height : 13px;
-moz-user-focus : ignore;
}
.input-checkbox-checkmark-box-1[disabled]
{
background-color : threedface;
}
.input-checkbox-checkmark-box-2
{
border-left : 1px solid threeddarkshadow;
border-top : 1px solid threeddarkshadow;
border-right : 1px solid threedface;
border-bottom : 1px solid threedface;
padding : 1px;
width : 11px;
height : 11px;
}
/* ensure that no list-style-image is inherited in from the Outside */
.input-checkbox-check
{
list-style-image : none;
}
.input-checkbox-check[checked]
{
list-style-image : url(chrome://global/skin/check-check.gif);
}
.input-checkbox-check[checked][disabled]
{
list-style-image : url(chrome://global/skin/check-check-disabled.gif);
}
input[type="checkbox"]:hover:active > .input-checkbox-checkmark-box-1
{
background-color : threedface;
}
/* text/icon frames */
input[type="checkbox"]:focus
{
border : 1px dotted threeddarkshadow;
padding : 0px;
}
.input-checkbox-checkmark-box-1
{
-moz-user-focus : none;
}

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

@ -27,16 +27,20 @@ install:: $(LIBRARY)
$(MAKE_INSTALL) platformHTMLBindings.xml $(DIST)\bin\res\builtin
$(MAKE_INSTALL) platformButtonBindings.xml $(DIST)\bin\res\builtin
$(MAKE_INSTALL) platformSelectBindings.xml $(DIST)\bin\res\builtin
$(MAKE_INSTALL) platformCheckboxBindings.xml $(DIST)\bin\res\builtin
$(MAKE_INSTALL) xbl-forms.css $(DIST)\bin\res\builtin
$(MAKE_INSTALL) buttons.css $(DIST)\bin\res\builtin
$(MAKE_INSTALL) select.css $(DIST)\bin\res\builtin
$(MAKE_INSTALL) textfields.css $(DIST)\bin\res\builtin
$(MAKE_INSTALL) checkbox.css $(DIST)\bin\res\builtin
clobber::
rm -f $(DIST)\bin\res\builtin\platformHTMLBindings.xml
rm -f $(DIST)\bin\res\builtin\platformButtonBindings.xml
rm -f $(DIST)\bin\res\builtin\platformSelectBindings.xml
rm -f $(DIST)\bin\res\builtin\platformCheckboxBindings.xml
rm -f $(DIST)\bin\res\builtin\xbl-forms.css
rm -f $(DIST)\bin\res\builtin\buttons.css
rm -f $(DIST)\bin\res\builtin\select.css
rm -f $(DIST)\bin\res\builtin\textfields.css
rm -f $(DIST)\bin\res\builtin\checkbox.css

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

@ -0,0 +1,19 @@
<?xml version="1.0"?>
<bindings id="platformCheckboxBindings"
xmlns="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<binding id="checkbox" extends="resource:///res/builtin/checkboxBindings.xml#checkbox">
<content>
<xul:box class="input-checkbox-checkmark-box-1" autostretch="never" inherits="disabled">
<xul:box class="input-checkbox-checkmark-box-2" autostretch="never" flex="1">
<xul:image class="input-checkbox-check" cbattr="image" inherits="checked,disabled"/>
</xul:box>
</xul:box>
</content>
</binding>
</bindings>

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

@ -37,18 +37,23 @@ select[size]
option
{
font : button;
font : list;
border : 1px solid transparent;
color : windowtext;
}
/*
select option[selected]
select[size] option[selected]
{
background-color : highlight;
color : highlighttext;
}
*/
select option[selected],
select[size="1"] option[selected]
{
background-color : transparent;
color : windowtext;
}
/* menulist based select */
@ -60,7 +65,7 @@ select, select[size="1"]
border-bottom : 1px solid threedhighlight;
background-color : -moz-field;
color : menutext;
font : pull-down-menu;
font : list;
margin : 1px 5px 2px 5px;
}

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

@ -22,6 +22,7 @@
@import url(resource:/res/builtin/textfields.css);
@import url(resource:/res/builtin/buttons.css);
@import url(resource:/res/builtin/select.css);
@import url(resource:/res/builtin/checkbox.css);
@namespace url(http://www.w3.org/1999/xhtml); /* set default namespace to HTML */
@ -31,9 +32,8 @@
/* widgets will be removed from this as their XBL counterparts are implemented */
input[type="image"],
input[type="checkbox"],
input[type="radio"],
fieldset, legend, select {
fieldset, legend {
display : none;
}
@ -109,4 +109,9 @@ select option, select[size="1"] option
-moz-binding : url("resource:///res/builtin/platformSelectBindings.xml#option");
}
input[type="checkbox"]
{
-moz-binding : url("resource:///res/builtin/platformCheckboxBindings.xml#checkbox");
}

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

@ -0,0 +1,69 @@
<?xml version="1.0"?>
<bindings id="checkboxBindings"
xmlns="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<binding id="checkbox" display="xul:button">
<implementation>
<property name="checked">
<getter>
var image = this.getElementByAttribute("cbattr", "image");
if (image) {
return image.hasAttribute("checked");
}
return false;
</getter>
<setter>
var image = this.getElementByAttribute("cbattr", "image");
if (image) {
if (val)
image.setAttribute("checked", "true");
else image.removeAttribute("checked");
}
</setter>
</property>
<!-- Internal Implementation Methods -->
<method name="getElementByAttribute">
<parameter name="aAttributeName"/>
<parameter name="aAttributeValue"/>
<body>
<![CDATA[
var anonymousNodes = document.getAnonymousNodes(this);
for (var i = 0; i < anonymousNodes.length; ++i)
return this.recursiveAttributeSearch(anonymousNodes[i], aAttributeName, aAttributeValue);
return null;
]]>
</body>
</method>
<method name="recursiveAttributeSearch">
<parameter name="aNode"/>
<parameter name="aAttributeName"/>
<parameter name="aAttributeValue"/>
<body>
<![CDATA[
if (aNode) {
if (aNode.getAttribute(aAttributeName) == aAttributeValue)
return aNode;
for (var i = 0; i < aNode.childNodes.length; ++i)
return this.recursiveAttributeSearch(aNode.childNodes[i], aAttributeName, aAttributeValue);
}
return null;
]]>
</body>
</method>
</implementation>
<handlers>
<handler event="command">
<![CDATA[
this.checked = !this.checked;
]]>
</handler>
</handlers>
</binding>
</bindings>

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

@ -29,8 +29,10 @@ install:: $(LIBRARY)
$(MAKE_INSTALL) htmlbindings.xml $(DIST)\bin\res\builtin
$(MAKE_INSTALL) buttonBindings.xml $(DIST)\bin\res\builtin
$(MAKE_INSTALL) selectBindings.xml $(DIST)\bin\res\builtin
$(MAKE_INSTALL) checkboxBindings.xml $(DIST)\bin\res\builtin
clobber::
rm -f $(DIST)\bin\res\builtin\htmlbindings.xml
rm -f $(DIST)\bin\res\builtin\buttonBindings.xml
rm -f $(DIST)\bin\res\builtin\selectBindings.xml
rm -f $(DIST)\bin\res\builtin\checkboxBindings.xml

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

@ -246,8 +246,11 @@
this._selectArray.push(this.childNodes[val]);
var textDisplayNode = this.getElementByAttribute("selectattr", "text");
if (textDisplayNode)
textDisplayNode.setAttribute("value", this.childNodes[val].text);
if (textDisplayNode) {
var text = this.childNodes[val].text;
text = text.replace(/\n/g, "");
textDisplayNode.setAttribute("value", text);
}
}
return val;
@ -302,9 +305,6 @@
var menuBox = boxObject.QueryInterface(Components.interfaces.nsIMenuBoxObject);
menuBox.activeChild = this._selectArray[0];
}
if (this._selectArray[0])
this.childNodes[this.selectedIndex].setAttribute("menuactive", "true");
]]>
</handler>
<handler event="mouseover">

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

@ -0,0 +1,99 @@
/*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* David Hyatt & Ben Goodger
*/
@namespace url(http://www.w3.org/1999/xhtml); /* set default namespace to HTML */
/* stylesheet for XUL <checkbox> element */
/* default checkbox for dialogs */
/* outer frame */
input[type="checkbox"]
{
border : 1px solid transparent;
padding : 2px !important;
margin : 0px;
cursor : default;
}
.input-checkbox-checkmark-box-1
{
border-top : 1px solid threedshadow;
border-left : 1px solid threedshadow;
border-right : 1px solid threedhighlight;
border-bottom : 1px solid threedhighlight;
background-color : window;
width : 13px;
height : 13px;
-moz-user-focus : ignore;
}
.input-checkbox-checkmark-box-1[disabled]
{
background-color : threedface;
}
.input-checkbox-checkmark-box-2
{
border-left : 1px solid threeddarkshadow;
border-top : 1px solid threeddarkshadow;
border-right : 1px solid threedface;
border-bottom : 1px solid threedface;
padding : 1px;
width : 11px;
height : 11px;
}
/* ensure that no list-style-image is inherited in from the Outside */
.input-checkbox-check
{
list-style-image : none;
}
.input-checkbox-check[checked]
{
list-style-image : url(chrome://global/skin/check-check.gif);
}
.input-checkbox-check[checked][disabled]
{
list-style-image : url(chrome://global/skin/check-check-disabled.gif);
}
input[type="checkbox"]:hover:active > .input-checkbox-checkmark-box-1
{
background-color : threedface;
}
/* text/icon frames */
input[type="checkbox"]:focus
{
border : 1px dotted threeddarkshadow;
padding : 0px;
}
.input-checkbox-checkmark-box-1
{
-moz-user-focus : none;
}

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

@ -27,16 +27,20 @@ install:: $(LIBRARY)
$(MAKE_INSTALL) platformHTMLBindings.xml $(DIST)\bin\res\builtin
$(MAKE_INSTALL) platformButtonBindings.xml $(DIST)\bin\res\builtin
$(MAKE_INSTALL) platformSelectBindings.xml $(DIST)\bin\res\builtin
$(MAKE_INSTALL) platformCheckboxBindings.xml $(DIST)\bin\res\builtin
$(MAKE_INSTALL) xbl-forms.css $(DIST)\bin\res\builtin
$(MAKE_INSTALL) buttons.css $(DIST)\bin\res\builtin
$(MAKE_INSTALL) select.css $(DIST)\bin\res\builtin
$(MAKE_INSTALL) textfields.css $(DIST)\bin\res\builtin
$(MAKE_INSTALL) checkbox.css $(DIST)\bin\res\builtin
clobber::
rm -f $(DIST)\bin\res\builtin\platformHTMLBindings.xml
rm -f $(DIST)\bin\res\builtin\platformButtonBindings.xml
rm -f $(DIST)\bin\res\builtin\platformSelectBindings.xml
rm -f $(DIST)\bin\res\builtin\platformCheckboxBindings.xml
rm -f $(DIST)\bin\res\builtin\xbl-forms.css
rm -f $(DIST)\bin\res\builtin\buttons.css
rm -f $(DIST)\bin\res\builtin\select.css
rm -f $(DIST)\bin\res\builtin\textfields.css
rm -f $(DIST)\bin\res\builtin\checkbox.css

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

@ -0,0 +1,19 @@
<?xml version="1.0"?>
<bindings id="platformCheckboxBindings"
xmlns="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<binding id="checkbox" extends="resource:///res/builtin/checkboxBindings.xml#checkbox">
<content>
<xul:box class="input-checkbox-checkmark-box-1" autostretch="never" inherits="disabled">
<xul:box class="input-checkbox-checkmark-box-2" autostretch="never" flex="1">
<xul:image class="input-checkbox-check" cbattr="image" inherits="checked,disabled"/>
</xul:box>
</xul:box>
</content>
</binding>
</bindings>

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

@ -37,18 +37,23 @@ select[size]
option
{
font : button;
font : list;
border : 1px solid transparent;
color : windowtext;
}
/*
select option[selected]
select[size] option[selected]
{
background-color : highlight;
color : highlighttext;
}
*/
select option[selected],
select[size="1"] option[selected]
{
background-color : transparent;
color : windowtext;
}
/* menulist based select */
@ -60,7 +65,7 @@ select, select[size="1"]
border-bottom : 1px solid threedhighlight;
background-color : -moz-field;
color : menutext;
font : pull-down-menu;
font : list;
margin : 1px 5px 2px 5px;
}

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

@ -22,6 +22,7 @@
@import url(resource:/res/builtin/textfields.css);
@import url(resource:/res/builtin/buttons.css);
@import url(resource:/res/builtin/select.css);
@import url(resource:/res/builtin/checkbox.css);
@namespace url(http://www.w3.org/1999/xhtml); /* set default namespace to HTML */
@ -31,9 +32,8 @@
/* widgets will be removed from this as their XBL counterparts are implemented */
input[type="image"],
input[type="checkbox"],
input[type="radio"],
fieldset, legend, select {
fieldset, legend {
display : none;
}
@ -109,4 +109,9 @@ select option, select[size="1"] option
-moz-binding : url("resource:///res/builtin/platformSelectBindings.xml#option");
}
input[type="checkbox"]
{
-moz-binding : url("resource:///res/builtin/platformCheckboxBindings.xml#checkbox");
}