-
Notifications
You must be signed in to change notification settings - Fork 0
Tami/boolean operators #10
base: master
Are you sure you want to change the base?
Changes from all commits
0ad5a22
9939561
02ecf21
7dd8fd2
a85102a
6a82ee5
7bf6241
dfdc314
bffc2d8
0788af3
6b90e92
fff0120
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,30 @@ | |
.autocomplete-suggestion { position: relative; padding: 0 .6em; line-height: 23px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 1.02em; color: #333; } | ||
.autocomplete-suggestion b { font-weight: normal; color: #1f8dd6; } | ||
.autocomplete-suggestion.selected { background: #f0f0f0; } | ||
|
||
.autocomplete-chip { | ||
border: 1px solid transparent; | ||
margin-right: 12px; | ||
} | ||
|
||
.autocomplete-chip:hover { | ||
border-color:black; | ||
} | ||
|
||
.autocomplete-chip::before { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This element does not have any text, also it should keep the mystique default style, remove |
||
font-size: 14px; | ||
line-height: 16px; | ||
letter-spacing: 0.4px; | ||
} | ||
|
||
.autocomplete-boolean-button { | ||
font-size: 10px; | ||
line-height: 16px; | ||
margin-inline-start: 10px; | ||
align-items: center; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This does not work without flex, remove |
||
letter-spacing: 0.4px; | ||
} | ||
|
||
.row{ | ||
margin-inline-start: 5px; | ||
} | ||
Comment on lines
+34
to
+36
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove this, it's a mystique class |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -62,6 +62,78 @@ | |||||
}); | ||||||
} | ||||||
|
||||||
|
||||||
function createTooltipChip(tooltip, text) { | ||||||
|
||||||
return ( | ||||||
'<span class="autocomplete-chip chip chip--outline chip--sm tooltip-lg" data-toggle="tooltip" data-placement="bottom-right" data-tooltip ="' + | ||||||
tooltip + | ||||||
'">' + | ||||||
text + | ||||||
'</span>' | ||||||
); | ||||||
} | ||||||
|
||||||
var booleanTooltips = ( | ||||||
'<div class="row">' + | ||||||
createTooltipChip('Identifique as palavras ou termos que, obrigatoriamente,estejam na sua pesquisa. Exemplo: Direitos E Humanos', 'E') + | ||||||
createTooltipChip('Identifique palavras ou termos para obter resultados com pelo menos uma das palavras-chave especificadas. É possível utilizar parênteses para agrupar frases. Exemplo: (Dano moral) OU (Recurso Especial)', 'OU') + | ||||||
createTooltipChip('Nenhum dos resultados conterão o(s) termo(s) excludentes, indicados após o NÃO. Exemplo: (dano moral) NÃO material', 'Não Incluir') + | ||||||
createTooltipChip('Os resultados conterão os termos na ordem exata e com a exata grafia indicada. Exemplo: princípio da presunção de inocência', 'Exatamente') + | ||||||
'</div>' | ||||||
); | ||||||
|
||||||
function cumulativeOffset(element) { | ||||||
var top = 0; | ||||||
var left = 0; | ||||||
do { | ||||||
top += element.offsetTop || 0; | ||||||
left += element.offsetLeft || 0; | ||||||
element = element.offsetParent; | ||||||
} while (element); | ||||||
return { | ||||||
top: top, | ||||||
left: left, | ||||||
}; | ||||||
} | ||||||
|
||||||
function createOverElemTooltip() { | ||||||
var pos = cumulativeOffset(this); | ||||||
// + 1 to consider border as offset | ||||||
var left = pos.left + 1; | ||||||
var top = pos.top + 1; | ||||||
var clonedNode = this.cloneNode(true); | ||||||
clonedNode.style = | ||||||
'color:transparent;box-shadow:none;z-index:10000;position:absolute;left:' + left + 'px;top:' + top + 'px'; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
addEvent(clonedNode, 'mouseout', function () { | ||||||
|
||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where is the remove child function? |
||||||
}); | ||||||
document.body.appendChild(clonedNode); | ||||||
} | ||||||
|
||||||
function replaceButtonWithTooltips() { | ||||||
var parentElement = this.parentElement; | ||||||
if (parentElement) { | ||||||
parentElement.innerHTML = booleanTooltips; | ||||||
|
||||||
var chips = document.getElementsByClassName('autocomplete-chip'); | ||||||
for (var i = 0; i < chips.length; i++) { | ||||||
var chip = chips[i]; | ||||||
addEvent(chip, 'mouseenter', createOverElemTooltip); | ||||||
} | ||||||
} | ||||||
} | ||||||
|
||||||
var footerBooleanOperators = ( | ||||||
'<hr style= "width: 575px">' + | ||||||
'<div>' + | ||||||
'<button class="btn btn--flat btn--sm btn--blue autocomplete-boolean-button">' + | ||||||
'DICAS PARA ESPECIFICAR SUA BUSCA' + | ||||||
'</button>' + | ||||||
'</div>' | ||||||
); | ||||||
|
||||||
var o = { | ||||||
selector: 0, | ||||||
source: 0, | ||||||
|
@@ -81,7 +153,8 @@ | |||||
queryHistoryStorageName: null, | ||||||
formSelector: null, | ||||||
buildTerm: function (term) { return term }, | ||||||
target: null | ||||||
target: null, | ||||||
enableFooterBooleanOperators: false | ||||||
}; | ||||||
for (var k in options) { if (options.hasOwnProperty(k)) o[k] = options[k]; } | ||||||
|
||||||
|
@@ -170,6 +243,8 @@ | |||||
removeQueryFromLocalStorage(o.queryHistoryStorageName, rawData[index]); | ||||||
}, that.sc); | ||||||
|
||||||
live('autocomplete-boolean-button', 'click', replaceButtonWithTooltips); | ||||||
|
||||||
that.blurHandler = function () { | ||||||
try { var over_sb = document.querySelector('.autocomplete-suggestions:hover'); } catch (e) { var over_sb = 0; } | ||||||
if (!over_sb) { | ||||||
|
@@ -196,7 +271,7 @@ | |||||
if (data.length) { | ||||||
var s = ''; | ||||||
for (var i = 0; i < data.length; i++) s += o.renderItem(data[i], val, i); | ||||||
that.sc.innerHTML = s; | ||||||
that.sc.innerHTML = s + (o.enableFooterBooleanOperators ? footerBooleanOperators : ''); | ||||||
that.updateSC(0); | ||||||
} | ||||||
else | ||||||
|
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -359,4 +359,15 @@ describe('Autocomplete Instance', function () { | |
// THEN | ||
expect(queries).toBe(null); | ||
}); | ||
}) | ||
|
||
}) | ||
|
||
function renderText(tooltip, text) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is this? |
||
|
||
return '<span class="autocomplete-chip chip chip--outline chip--sm tooltip-lg" data-toggle="tooltip" data-placement="bottom-right" data-tooltip ="' + tooltip + | ||
'">' + | ||
text + | ||
'</span>'; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.