зеркало из https://github.com/mozilla/pjs.git
Bug 400844 - "Label in organizer's search field becomes search text in some non-default modes (black, query)" [p=dao@mozilla.com (Dão Gottwald) r=Mano a=blocking-firefox3+]
This commit is contained in:
Родитель
138230c498
Коммит
a84d49e062
|
@ -794,22 +794,10 @@ var PlacesSearchBox = {
|
|||
* The title of the current collection.
|
||||
*/
|
||||
updateCollectionTitle: function PSB_updateCollectionTitle(title) {
|
||||
if (title) {
|
||||
this.searchFilter.grayText =
|
||||
PlacesUtils.getFormattedString("searchCurrentDefault", [title]);
|
||||
}
|
||||
else
|
||||
this.searchFilter.grayText = PlacesUtils.getString("searchByDefault");
|
||||
|
||||
this.syncGrayText();
|
||||
},
|
||||
|
||||
/**
|
||||
* Updates the display with the current gray text.
|
||||
*/
|
||||
syncGrayText: function PSB_syncGrayText() {
|
||||
this.searchFilter.value = this.searchFilter.grayText;
|
||||
this.searchFilter.setAttribute("label", this.searchFilter.grayText);
|
||||
this.searchFilter.emptyText =
|
||||
title ?
|
||||
PlacesUtils.getFormattedString("searchCurrentDefault", [title]) :
|
||||
PlacesUtils.getString("searchByDefault");
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -840,10 +828,7 @@ var PlacesSearchBox = {
|
|||
* Set up the gray text in the search bar as the Places View loads.
|
||||
*/
|
||||
init: function PSB_init() {
|
||||
var searchFilter = this.searchFilter;
|
||||
searchFilter.grayText = PlacesUtils.getString("searchByDefault");
|
||||
searchFilter.setAttribute("label", searchFilter.grayText);
|
||||
searchFilter.reset();
|
||||
this.updateCollectionTitle();
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
<!-- XXXben - replace this upon checkin by allowing generic textboxes to show
|
||||
arbitrary content before the html:input itself using a
|
||||
<children/> -->
|
||||
<binding id="textbox-timed-arbitrary"
|
||||
<binding id="textbox-timed-arbitrary"
|
||||
extends="chrome://global/content/bindings/textbox.xml#timed-textbox">
|
||||
<resources>
|
||||
<stylesheet src="chrome://browser/skin/places/places.css"/>
|
||||
|
@ -25,86 +25,37 @@
|
|||
</xul:hbox>
|
||||
</content>
|
||||
<implementation>
|
||||
<property name="grayText"
|
||||
onget="return this.getAttribute('grayText');"
|
||||
onset="this.setAttribute('grayText', val); return val;"/>
|
||||
<method name="reset">
|
||||
<body><![CDATA[
|
||||
this.setAttribute("empty", "true");
|
||||
this.removeAttribute("filtered");
|
||||
this.value = this.grayText;
|
||||
]]></body>
|
||||
</method>
|
||||
<method name="_resetInternal">
|
||||
<body><![CDATA[
|
||||
this.value = "";
|
||||
this.removeAttribute("empty");
|
||||
this.removeAttribute("filtered");
|
||||
]]></body>
|
||||
</method>
|
||||
<method name="_fireEvent">
|
||||
<parameter name="type"/>
|
||||
<body><![CDATA[
|
||||
this.reset();
|
||||
|
||||
var event = document.createEvent("Events");
|
||||
event.initEvent(type, true, true);
|
||||
|
||||
event.initEvent("reset", true, true);
|
||||
|
||||
var cancel = !this.dispatchEvent(event);
|
||||
var handler = this.getAttribute("on" + type);
|
||||
var handler = this.getAttribute("onreset");
|
||||
if (handler) {
|
||||
var handlerFunction = new Function("event", handler);
|
||||
var handlerCanceled = handlerFunction(event) === false;
|
||||
if (handlerCanceled)
|
||||
cancel = handlerCanceled;
|
||||
handlerFunction(event);
|
||||
}
|
||||
return !cancel;
|
||||
]]></body>
|
||||
</method>
|
||||
<method name="_clearReliably">
|
||||
<body><![CDATA[
|
||||
// This method exists to clear the field's text. The reason this does
|
||||
// not work reliably is unknown... appears to be some kind of event
|
||||
// handling synchronization issue. We need to clear the field
|
||||
// asynchronously.
|
||||
var field = this;
|
||||
setTimeout(function() {
|
||||
field.value = "";
|
||||
field.removeAttribute("empty");
|
||||
}, 0);
|
||||
]]></body>
|
||||
</method>
|
||||
<method name="onFocus">
|
||||
<body><![CDATA[
|
||||
if (this.hasAttribute("empty"))
|
||||
this._clearReliably();
|
||||
else
|
||||
this.select();
|
||||
]]></body>
|
||||
</method>
|
||||
<method name="onBlur">
|
||||
<body><![CDATA[
|
||||
if (this.hasAttribute("empty") || !this.value)
|
||||
this.reset();
|
||||
]]></body>
|
||||
</method>
|
||||
</implementation>
|
||||
<handlers>
|
||||
<handler event="focus" phase="capturing"><![CDATA[
|
||||
if (event.originalTarget.className != "textbox-input-closebutton")
|
||||
this.onFocus();
|
||||
]]></handler>
|
||||
<handler event="blur" phase="capturing"><![CDATA[
|
||||
if (event.originalTarget.className != "textbox-input-closebutton")
|
||||
this.onBlur();
|
||||
]]></handler>
|
||||
<handler event="click"><![CDATA[
|
||||
if (event.originalTarget.className == "textbox-input-closebutton") {
|
||||
this.inputField.focus();
|
||||
this._resetInternal();
|
||||
this._fireEvent("reset");
|
||||
}
|
||||
]]></handler>
|
||||
<handler event="keypress" keycode="VK_ESCAPE"><![CDATA[
|
||||
this._resetInternal();
|
||||
this._fireEvent("reset");
|
||||
]]></handler>
|
||||
</handlers>
|
||||
</binding>
|
||||
|
|
|
@ -328,9 +328,9 @@
|
|||
|
||||
<spacer flex="1"/>
|
||||
|
||||
<textbox id="searchFilter" style="width: 23em;" timeout="500"
|
||||
oncommand="PlacesSearchBox.search(this.value);"
|
||||
onreset="PlacesOrganizer.onPlaceSelected(false); return true;"
|
||||
<textbox id="searchFilter" style="width: 23em;" timeout="500" clickSelectsAll="true"
|
||||
oncommand="PlacesSearchBox.search(this.value);"
|
||||
onreset="PlacesOrganizer.onPlaceSelected(false);"
|
||||
collection="bookmarks">
|
||||
</textbox>
|
||||
</toolbar>
|
||||
|
|
|
@ -117,10 +117,6 @@
|
|||
padding: 0px;
|
||||
}
|
||||
|
||||
#searchFilter[empty="true"] {
|
||||
color: GrayText;
|
||||
}
|
||||
|
||||
#searchFilter .textbox-input-box {
|
||||
padding: 2px 2px 3px 4px;
|
||||
}
|
||||
|
|
|
@ -287,10 +287,6 @@
|
|||
-moz-padding-start: 14px;
|
||||
}
|
||||
|
||||
#searchFilter[empty="true"] {
|
||||
color: GrayText;
|
||||
}
|
||||
|
||||
#searchFilter > .textbox-input-box {
|
||||
padding: 2px;
|
||||
border-left: 2px solid transparent;
|
||||
|
|
|
@ -118,10 +118,6 @@
|
|||
padding: 0px;
|
||||
}
|
||||
|
||||
#searchFilter[empty="true"] {
|
||||
color: GrayText;
|
||||
}
|
||||
|
||||
#searchFilter .textbox-input-box {
|
||||
padding: 2px 2px 3px 4px;
|
||||
}
|
||||
|
|
|
@ -159,7 +159,9 @@
|
|||
|
||||
<method name="_updateVisibleText">
|
||||
<body><![CDATA[
|
||||
if (!this.value && this.emptyText) {
|
||||
if (!this.hasAttribute("focused") &&
|
||||
!this.value &&
|
||||
this.emptyText) {
|
||||
// This section is a wee bit hacky; without the timeout, the CSS
|
||||
// style corresponding to the "empty" attribute doesn't kick in
|
||||
// until the text has changed, leading to an unpleasant moment
|
||||
|
|
Загрузка…
Ссылка в новой задаче