Permalink
Browse files

fix: local search fails to load when tooltip is disable

  • Loading branch information...
1 parent 6242ff7 commit 7c57db8257868274e2d1ec1610b33ccb83276ed3 @MOxFIVE committed May 28, 2016
Showing with 43 additions and 44 deletions.
  1. +43 −44 source/js/pc.js
View
@@ -107,7 +107,7 @@ define([], function(){
}
});
}
- }
+ }()
if (yiliaConfig.jquery_ui[0]) {
var tooltip = function(){
@@ -162,62 +162,61 @@ define([], function(){
}
})
})
- }
+ }()
}
- var search = function(){
- require([yiliaConfig.rootUrl + 'js/search.js'], function(){
- var inputArea = document.querySelector("#local-search-input");
- var $HideWhenSearch = $("#toc, #tocButton, .post-list, #post-nav-button a:nth-child(2)");
- var $resetButton = $("#search-form .fa-times");
- var $resultArea = $("#local-search-result");
-
- var getSearchFile = function(){
- var search_path = "search.xml";
- var path = yiliaConfig.rootUrl + search_path;
- searchFunc(path, 'local-search-input', 'local-search-result');
- }
-
- var getFileOnload = inputArea.getAttribute('searchonload');
- if (yiliaConfig.search && getFileOnload === "true") {
- getSearchFile();
- } else {
- inputArea.onfocus = function(){ getSearchFile() }
- }
-
- var HideTocArea = function(){
- $HideWhenSearch.css("visibility","hidden");
- $resetButton.show();
- }
- inputArea.oninput = function(){ HideTocArea() }
- inputArea.onkeydown = function(){ if(event.keyCode==13) return false}
-
- resetSearch = function(){
- $HideWhenSearch.css("visibility","initial");
- $resultArea.html("");
- document.querySelector("#search-form").reset();
- $resetButton.hide();
- $(".no-result").hide();
- }
+ if (yiliaConfig.search) {
+ var search = function(){
+ require([yiliaConfig.rootUrl + 'js/search.js'], function(){
+ var inputArea = document.querySelector("#local-search-input");
+ var $HideWhenSearch = $("#toc, #tocButton, .post-list, #post-nav-button a:nth-child(2)");
+ var $resetButton = $("#search-form .fa-times");
+ var $resultArea = $("#local-search-result");
+
+ var getSearchFile = function(){
+ var search_path = "search.xml";
+ var path = yiliaConfig.rootUrl + search_path;
+ searchFunc(path, 'local-search-input', 'local-search-result');
+ }
- $resultArea.bind("DOMNodeRemoved DOMNodeInserted", function(e) {
- if (!$(e.target).text()) {
- $(".no-result").show(200);
+ var getFileOnload = inputArea.getAttribute('searchonload');
+ if (yiliaConfig.search && getFileOnload === "true") {
+ getSearchFile();
} else {
- $(".no-result").hide();
+ inputArea.onfocus = function(){ getSearchFile() }
+ }
+
+ var HideTocArea = function(){
+ $HideWhenSearch.css("visibility","hidden");
+ $resetButton.show();
+ }
+ inputArea.oninput = function(){ HideTocArea() }
+ inputArea.onkeydown = function(){ if(event.keyCode==13) return false}
+
+ resetSearch = function(){
+ $HideWhenSearch.css("visibility","initial");
+ $resultArea.html("");
+ document.querySelector("#search-form").reset();
+ $resetButton.hide();
+ $(".no-result").hide();
}
+
+ $resultArea.bind("DOMNodeRemoved DOMNodeInserted", function(e) {
+ if (!$(e.target).text()) {
+ $(".no-result").show(200);
+ } else {
+ $(".no-result").hide();
+ }
+ })
})
- });
+ }()
}
return {
init: function(){
resetTags();
bind();
Tips.init();
- miniArchives();
- tooltip();
- search();
}
}
});

0 comments on commit 7c57db8

Please sign in to comment.