return this._findRobust(q, callback);
}
-
var algo = this.getSearchWordSelectionAlgorithm(q);
if (algo === 'expression') {
return this._findExpression(q, callback);
if (terms.length === 0) {
return;
}
- var algo = this.getSearchWordSelectionAlgorithm(terms.join(' '));
- if (algo === 'expression') {
- return;
- }
- for (var t in terms) {
- var term = terms[t];
- for (var w in HIGHLIGHTS) {
- if (algo !== 'expression' && w.length < this.fluidbook.settings.ignoreWordLimit) {
- continue;
- }
- if (algo === 'begins' && w.indexOf(term) !== 0) {
- continue;
- } else if (algo === 'contains' && w.indexOf(term) === -1) {
- continue;
- } else if (algo === 'exact' && w !== term) {
- continue;
- }
+ if (this.robust) {
+ this.setRobustHighlightTerms(terms);
+ } else {
+ var algo = this.getSearchWordSelectionAlgorithm(terms.join(' '));
+ if (algo === 'expression') {
+ return;
+ }
+ for (var t in terms) {
+ var term = terms[t];
+ for (var w in HIGHLIGHTS) {
+ if (algo !== 'expression' && w.length < this.fluidbook.settings.ignoreWordLimit) {
+ continue;
+ }
- var color = t;
- if (algo === 'expression') {
- color = 0;
- }
+ if (algo === 'begins' && w.indexOf(term) !== 0) {
+ continue;
+ } else if (algo === 'contains' && w.indexOf(term) === -1) {
+ continue;
+ } else if (algo === 'exact' && w !== term) {
+ continue;
+ }
- var h = {occurences: HIGHLIGHTS[w], color: color, word: w, term: term};
- this.highlights.push(h);
+ var color = t;
+ if (algo === 'expression') {
+ color = 0;
+ }
+
+ var h = {occurences: HIGHLIGHTS[w], color: color, word: w, term: term};
+ this.highlights.push(h);
+ }
}
}
},
+ setRobustHighlightTerms: function (terms) {
+ let term = terms.join('');
+ let firstLetter = term.split('')[0];
+ var h = {occurences: HIGHLIGHTS[firstLetter], color: 0, word: firstLetter, term: term};
+ this.highlights.push(h);
+ },
+
clearHighlights: function () {
$("#searchHighlights").html('');
for (var p in this.plugins) {
var padding = position.height * 0.2;
var z = this.fluidbook.settings.cssScale;
- var h = $('<div class="highlight" data-color="' + color + '"></div>');
+ var h = $('<div class="highlight' + (this.robust ? ' robust' : '') + '" data-color="' + color + '"></div>');
var coords = {
top: (position.y - position.height - padding * 2) * z,
left: (position.x + x - padding) * z + offset,
width: (width + 2 * padding) * z,
height: (position.height + padding * 3) * z
};
+ if (this.robust) {
+ coords.width = coords.height;
+ }
var transform = {};
if (position.rotation) {
transform.rotate = -position.rotation + 'deg';