[XForms] refactor xbl messages. Bug 345729, patch by surkov, r=olli+aaronr

This commit is contained in:
aaronr%us.ibm.com 2006-08-02 18:29:37 +00:00
Родитель b08cf11e96
Коммит f057edb07e
4 изменённых файлов: 189 добавлений и 92 удалений

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

@ -377,6 +377,86 @@
</binding>
<!-- ALERT: <DEFAULT> -->
<binding id="xformswidget-alert"
extends="chrome://xforms/content/xforms.xml#xformswidget-alert-base">
<content>
<html:div anonid="container" class="-moz-xforms-message-container">
<html:div anonid="inlineData" style="display: inherit;">
<children/>
</html:div>
<html:div anonid="bindingData" style="display: inherit;"/>
</html:div>
</content>
<implementation>
<method name="getControlElement">
<body>
return {
inlineData: this.ownerDocument.
getAnonymousElementByAttribute(this, "anonid", "inlineData"),
bindingData: this.ownerDocument.
getAnonymousElementByAttribute(this, "anonid", "bindingData"),
setValue: function setValue(aUseInlineValue, aValue) {
if (aUseInlineValue) {
this.bindingData.style.display = "none";
this.inlineData.style.display = "inherit";
} else {
this.bindingData.textContent = aValue;
this.inlineData.style.display = "none";
this.bindingData.style.display = "inherit";
}
}
};
</body>
</method>
</implementation>
</binding>
<!-- MESSAGE: EPHEMERAL, HINT: <DEFAULT>
The widget reuses content of xformswidget-alert.
-->
<binding id="xformswidget-ephemeral-message"
extends="#xformswidget-alert">
<implementation implements="nsIXFormsEphemeralMessageUI">
<method name="show">
<parameter name="aPosX"/>
<parameter name="aPosY"/>
<body>
this.container.style.visibility = "visible";
this.container.style.display = "inherit";
this.container.style.left = aPosX + "px";
this.container.style.top = aPosY + "px";
</body>
</method>
<method name="hide">
<body>
this.container.style.left = "0px";
this.container.style.top = "0px";
this.container.style.visibility = "hidden";
this.container.style.display = "none";
</body>
</method>
<!-- internal -->
<property name="container" readonly="true">
<getter>
if (!this._container) {
this._container = this.ownerDocument.
getAnonymousElementByAttribute(this, "anonid", "container");
}
return this._container;
</getter>
</property>
<field name="_container"/>
</implementation>
</binding>
<!-- UPLOAD: <DEFAULT> -->
<binding id="xformswidget-upload"
extends="chrome://xforms/content/xforms.xml#xformswidget-upload-base">

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

@ -300,6 +300,86 @@
</binding>
<!-- ALERT: <DEFAULT> -->
<binding id="xformswidget-alert"
extends="chrome://xforms/content/xforms.xml#xformswidget-alert-base">
<content>
<xul:deck anonid="contentswitcher" flex="1" selectedIndex="1">
<xul:label anonid="implicitcontent" xbl:inherits="orient"/>
<xul:label xbl:inherits="orient"><children/></xul:label>
</xul:deck>
</content>
<implementation>
<method name="getControlElement">
<body>
return {
_contentSwitcher: this.ownerDocument.
getAnonymousElementByAttribute(this, 'anonid', 'contentswitcher'),
_implicitContent: this.ownerDocument.
getAnonymousElementByAttribute(this, 'anonid', 'implicitcontent'),
setValue: function setValue(aUseInlineValue, aValue) {
if (aUseInlineValue) {
this._contentSwitcher.selectedIndex = 1;
} else {
this._implicitContent.textContent = aValue;
this._contentSwitcher.selectedIndex = 0;
}
}
};
</body>
</method>
</implementation>
</binding>
<!-- MESSAGE: EPHEMERAL, HINT: <DEFAULT> -->
<binding id="xformswidget-ephemeral-message"
extends="#xformswidget-alert">
<content>
<xul:popup anonid="popup">
<xul:deck anonid="contentswitcher" flex="1" selectedIndex="1">
<xul:label anonid="implicitcontent" xbl:inherits="orient"/>
<xul:label xbl:inherits="orient"><children/></xul:label>
</xul:deck>
</xul:popup>
</content>
<implementation implements="nsIXFormsEphemeralMessageUI">
<method name="show">
<parameter name="aPosX"/>
<parameter name="aPosY"/>
<body>
aPosX += this.ownerDocument.defaultView.screenX;
aPosY += this.ownerDocument.defaultView.screenY;
this.popup.showPopup(this.ownerDocument.documentElement, aPosX, aPosY,
"popup", null, null);
</body>
</method>
<method name="hide">
<body>
this.popup.hidePopup();
</body>
</method>
<!-- internal -->
<property name="popup" readonly="true">
<getter>
if (!this._popup) {
this._popup = this.ownerDocument.
getAnonymousElementByAttribute(this, "anonid", "popup");
}
return this._popup;
</getter>
</property>
<field name="_popup"/>
</implementation>
</binding>
<!-- REPEAT -->
<binding id="xformswidget-repeat"
extends="chrome://xforms/content/xforms.xml#xformswidget-repeat-base">

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

@ -109,7 +109,7 @@ message, alert, help {
display: none;
}
action, message[level="ephemeral"], hint {
html|*:root message[level="ephemeral"], html|*:root hint {
position: absolute;
z-index: 2147481647;
visibility: hidden;
@ -120,25 +120,40 @@ action, message[level="ephemeral"], hint {
display: block;
}
alert {
-moz-binding: url('chrome://xforms/content/xforms.xml#inline-alert');
html|*:root alert {
-moz-binding: url('chrome://xforms/content/xforms-xhtml.xml#xformswidget-alert');
}
xul|*:root alert {
-moz-binding: url('chrome://xforms/content/xforms-xul.xml#xformswidget-alert');
}
message[level="ephemeral"], hint {
-moz-binding: url('chrome://xforms/content/xforms.xml#ephemeral-message');
html|*:root message[level="ephemeral"], html|*:root hint {
-moz-binding: url('chrome://xforms/content/xforms-xhtml.xml#xformswidget-ephemeral-message');
}
xul|*:root message[level="ephemeral"], xul|*:root hint {
-moz-binding: url('chrome://xforms/content/xforms-xul.xml#xformswidget-ephemeral-message');
}
html|*:root message[level="ephemeral"], html|*:root hint {
background-color: InfoBackground;
color: InfoText;
border: 1px black solid;
padding: 2px 3px;
font: message-box;
position: absolute !important;
width: auto;
height: auto;
display: block;
}
message[level="ephemeral"] > html|div.-moz-xforms-message-container,
hint > html|div.-moz-xforms-message-container {
xul|*:root message[level="ephemeral"] xul|deck , xul|*:root hint xul|deck {
background-color: InfoBackground;
color: InfoText;
padding: 2px 3px;
font: message-box;
}
html|*:root message[level="ephemeral"] > html|div.-moz-xforms-message-container,
html|*:root hint > html|div.-moz-xforms-message-container {
background-color: inherit;
color: inherit;
border: inherit;

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

@ -390,95 +390,17 @@
<!-- ALERT: <DEFAULT> -->
<binding id="inline-alert"
<binding id="xformswidget-alert-base"
extends="chrome://xforms/content/xforms.xml#xformswidget-base">
<content>
<html:div anonid="container" class="-moz-xforms-message-container">
<html:div anonid="inlineData" style="display: inherit;">
<children/>
</html:div>
<html:div anonid="bindingData" style="display: inherit;"/>
</html:div>
</content>
<implementation>
<field name="_inlineData">null</field>
<property name="inlineData" readonly="true">
<getter>
if (!this._inlineData) {
this._inlineData = document.
getAnonymousElementByAttribute(this, "anonid", "inlineData");
}
return this._inlineData;
</getter>
</property>
<field name="_bindingData">null</field>
<property name="bindingData" readonly="true">
<getter>
if (!this._bindingData) {
this._bindingData = document.
getAnonymousElementByAttribute(this, "anonid", "bindingData");
}
return this._bindingData;
</getter>
</property>
<method name="refresh">
<body>
if (this.accessors.hasBoundNode() ||
this.hasAttribute('src')) {
this.bindingData.textContent = this.stringValue;
this.inlineData.style.display = "none";
this.bindingData.style.display = "inherit";
} else {
this.bindingData.style.display = "none";
this.inlineData.style.display = "inherit";
}
</body>
</method>
</implementation>
</binding>
<!-- MESSAGE: <DEFAULT>, reusing the content of inline-alert -->
<binding id="ephemeral-message"
extends="chrome://xforms/content/xforms.xml#inline-alert">
<implementation implements="nsIXFormsEphemeralMessageUI">
<field name="_container">null</field>
<property name="container" readonly="true">
<getter>
if (!this._container) {
this._container = document.
getAnonymousElementByAttribute(this, "anonid", "container");
}
return this._container;
</getter>
</property>
<method name="show">
<parameter name="x"/>
<parameter name="y"/>
<body>
this.container.style.visibility = "visible";
this.container.style.display = "inherit";
this.container.style.left = x + "px";
this.container.style.top = y + "px";
return true;
</body>
</method>
<method name="hide">
<body>
this.container.style.left = "0px";
this.container.style.top = "0px";
this.container.style.visibility = "hidden";
this.container.style.display = "none";
</body>
<![CDATA[
var useInlineValue = !this.accessors.hasBoundNode() &&
!this.hasAttribute('src');
this.control.setValue(useInlineValue, this.stringValue);
]]></body>
</method>
</implementation>
</binding>