if (v.length > 2) {
termType = v[2];
}
- $this.menuSearchHints.append('<a class="hint" data-termtype="' + termType + '" term="' + v[0] + '" href="#/search/' + termType + '/' + v[0] + '">' + v[0] + '</a>');
+ $this.menuSearchHints.append('<a class="hint" term="' + v[0] + '" href="#/search/' + v[0] + '">' + v[0] + '</a>');
});
var qoffset = $("#q").offset();
var top = qoffset.top + $("#q").outerHeight() + 5;
window.location.hash = '/search/' + q;
this.fluidbook.stats.track(1, this.fluidbook.currentPage, q);
+
+ var continueProcessingAfterPlugins = true;
+ for (var p in this.plugins) {
+ if (!continueProcessingAfterPlugins) {
+ continue;
+ }
+
+ var plugin = this.plugins[p];
+ continueProcessingAfterPlugins = plugin.submitQuery(q);
+ }
+
+ if (!continueProcessingAfterPlugins) {
+ return;
+ }
+
var $this = this;
this.find(q, function (results) {
$this.openResults(results);
});
},
- openResults: function (results) {
+ openResults: function (results, gotoPageIfOneResult) {
+ if (gotoPageIfOneResult === undefined) {
+ gotoPageIfOneResult = false;
+ }
var $this = this;
// Handle empty result set
// Use the index of all pages as a starting point to filter results thumbnails
this.menuSearchResults.html(this.fluidbook.menu.index.getView()).hide();
+ var spreadEnabled = 0;
// Process each spread of pages to collect the ones with results
this.menuSearchResults.find('.doubleThumb').each(function () {
var currentPages = $(this).data('pages').toString().split(','),
return;
}
} else {
+ spreadEnabled++;
+ $(this).attr('data-enabled', '1');
// Add the link to the main result page. Link around the hits div is for better usability (previously wasn't clickable)
$(this).append('<a href="#/page/' + $(this).attr('page') + '"><div class="hits yes">' + totalHits + ' ' + $this.fluidbook.l10n.__('hit(s)') + '</div></a>');
if ($this.fluidbook.pad.enabled) {
$(this).find('a').attr('href', '#/page/' + $(this).attr('page'));
}
}
-
});
// Set Highlighting of results keywords
this.setHighlightTerms(results.terms);
- this.highlightSearchTerms(this.fluidbook.currentPage);
+ this.hideSearchHints();
+ // Redirect to the only result page if the flag is enabled
+ if (gotoPageIfOneResult && spreadEnabled === 1) {
+ setTimeout(function () {
+ fluidbook.setCurrentPage($this.menuSearchResults.find('.doubleThumb[data-enabled="1"]').attr('page'));
+ fluidbook.nav.menuAPI.close();
+ }, 100);
+ return;
+ }
+
+ this.highlightSearchTerms(this.fluidbook.currentPage);
- this.hideSearchHints();
this.menuSearchResults.fadeIn(300).scrollTop(0);
// On some phones, the height of the search results is miscalculated due to the
$(this).closest('.wescosaleswindow').remove();
return false;
});
+
+ setTimeout(function () {
+ getAllRefs();
+ }, 5000);
}
function wescoResize() {
res.push(r);
}
}
+ break;
}
allrefs = res;
}
});
return res;
- }
-};
+ },
+
+ submitQuery: function (q) {
+ if (!q.match(/(\d\s*)/gm)) {
+ return true;
+ }
+ q = q.replace(/\s/gm, '');
+
+ if (q.length != 5) {
+ return true;
+ }
+ var all = getAllRefs();
+ var res = false;
+ $.each(all, function (k, v) {
+ if (v.indexOf(q) === 0) {
+ var pages = fluidbook.datas.pagesOfCustomLinks[q];
+ if (pages !== undefined && pages !== null && pages.length > 0) {
+ var results = {total: pages.length, results: []};
+ $.each(pages, function (k, v) {
+ results.results[v] = 1;
+ });
+ results.terms = [];
+ res = true;
+ fluidbook.search.openResults(results, true);
+ return true;
+ }
+ }
+ });
+
+ return !res;
+ },
+};
\ No newline at end of file