(function () {
$(document).ready(function () {
- $("input.searchField")
- .val("Search")
- .removeClass("activeField")
- .addClass("inactiveField")
- .focus(function () {
- if ($(this).attr("class").indexOf("inactiveField")) {
- $(this)
- .val("")
- .removeClass("inactiveField")
- .addClass("activeField");
- }
- })
- .keypress(function (e) {
+ var $fld = $("input.searchField")
+
+ $fld.keypress(function (e) {
if (e.which == 10 || e.which == 13) {
window.location = Rakka.baseURI + "search.html?q=" + encodeURI($(this).val());
}
});
+
+ /* 檢索 query が指定されてゐれば、それが最初から入力されてゐる
+ * 状態にする。
+ */
+ var form = Rakka.getQueryForm();
+ if (form["q"] == null) {
+ $fld.val("Search")
+ .removeClass("activeField")
+ .addClass("inactiveField")
+ .focus(function () {
+ if ($(this).attr("class").indexOf("inactiveField")) {
+ $(this)
+ .val("")
+ .removeClass("inactiveField")
+ .addClass("activeField");
+ }
+ });
+ }
+ else {
+ $fld.val(form["q"])
+ .removeClass("inactiveField")
+ .addClass("activeField");
+ }
});
})();
\ No newline at end of file