Few improvements on search, history and title
This commit is contained in:
parent
72338b8ccb
commit
0d898998b1
1 changed files with 10 additions and 5 deletions
|
@ -52,14 +52,14 @@
|
||||||
var start = elemClass.indexOf(className);
|
var start = elemClass.indexOf(className);
|
||||||
if (start == -1) {
|
if (start == -1) {
|
||||||
return false;
|
return false;
|
||||||
} else if (elemClass.length == className.length) {
|
} else if (elemClass.length === className.length) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
if (start > 0 && elemClass[start - 1] != ' ') {
|
if (start > 0 && elemClass[start - 1] !== ' ') {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var end = start + className.length;
|
var end = start + className.length;
|
||||||
if (end < elemClass.length && elemClass[end] != ' ') {
|
if (end < elemClass.length && elemClass[end] !== ' ') {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -151,7 +151,7 @@
|
||||||
removeClass(document.getElementById("main"), "hidden");
|
removeClass(document.getElementById("main"), "hidden");
|
||||||
var hash = ev.newURL.slice(ev.newURL.indexOf('#') + 1);
|
var hash = ev.newURL.slice(ev.newURL.indexOf('#') + 1);
|
||||||
if (browserSupportsHistoryApi()) {
|
if (browserSupportsHistoryApi()) {
|
||||||
history.replaceState(hash, "", "#" + hash);
|
history.replaceState(hash, "", "?search=#" + hash);
|
||||||
}
|
}
|
||||||
var elem = document.getElementById(hash);
|
var elem = document.getElementById(hash);
|
||||||
if (elem) {
|
if (elem) {
|
||||||
|
@ -1568,9 +1568,14 @@
|
||||||
|
|
||||||
if (search_input) {
|
if (search_input) {
|
||||||
search_input.onfocus = function() {
|
search_input.onfocus = function() {
|
||||||
if (search.value !== "") {
|
if (search_input.value !== "") {
|
||||||
addClass(document.getElementById("main"), "hidden");
|
addClass(document.getElementById("main"), "hidden");
|
||||||
removeClass(document.getElementById("search"), "hidden");
|
removeClass(document.getElementById("search"), "hidden");
|
||||||
|
if (browserSupportsHistoryApi()) {
|
||||||
|
history.replaceState(search_input.value,
|
||||||
|
"",
|
||||||
|
"?search=" + encodeURIComponent(search_input.value));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue