diff --git a/.eslintrc b/.eslintrc index 818be27c2..2058cb5ca 100644 --- a/.eslintrc +++ b/.eslintrc @@ -16,7 +16,8 @@ "jsPlumbUtil": false, }, "rules": { - "max-len": [1, 150, 2, {ignoreComments: true}] + "max-len": [1, 150, 2, {ignoreComments: true}], + "no-console": "off" }, "extends": ["eslint:recommended", "plugin:react/recommended"] } diff --git a/ide/static/css/searchbar_style.css b/ide/static/css/searchbar_style.css new file mode 100644 index 000000000..3a304a166 --- /dev/null +++ b/ide/static/css/searchbar_style.css @@ -0,0 +1,36 @@ +.insert-layer-title { + position: relative; + margin-top: 10px !important; + margin-bottom: 21px !important; +} + +#layer-search-icon { + position: absolute; + left: -5px; + top: 31px; +} + +#layer-search-icon:hover { + cursor: pointer; +} + +#layer-search-input { + position: absolute; + top: 36px; + left: 20px; + font-size: 15px; + background: none; + border: none; + color: rgb(69, 80, 97); + outline: none; + opacity: 1; + transition: 0.3s; +} + +.layer-search-input-selected { + opacity: 1 !important; +} + +.matched-search-char { + color: rgb(69, 80, 97); +} diff --git a/ide/static/css/style.css b/ide/static/css/style.css index ba99bd919..edbcda391 100644 --- a/ide/static/css/style.css +++ b/ide/static/css/style.css @@ -1206,4 +1206,4 @@ input[type="file"] { background: white; transform: rotate(-45deg) } -} +} \ No newline at end of file diff --git a/ide/static/js/content.js b/ide/static/js/content.js index 5de25865d..1653e6f65 100644 --- a/ide/static/js/content.js +++ b/ide/static/js/content.js @@ -1275,7 +1275,11 @@ class Content extends React.Component { />
LOGIN
-
INSERT LAYER
+
+ +
INSERT LAYER
+ search +
0) { highlightClass = 'highlighted'; diff --git a/ide/static/js/pane.js b/ide/static/js/pane.js index 635a420bb..2f1f96217 100644 --- a/ide/static/js/pane.js +++ b/ide/static/js/pane.js @@ -26,7 +26,61 @@ class Pane extends React.Component { } this.setState(obj); } - render(){ + componentDidMount() { + let filter = (pattern) => { + let layerCompability = (searchQuery, layerName) => { + let j = 0; + let seq = []; + let full_match = true; + for (let i = 0; i < searchQuery.length; i++) { + while (j < layerName.length && layerName[j].toLowerCase() != searchQuery[i].toLowerCase()) { + seq[j] = false; + j++; + } + if (j < layerName.length && layerName[j].toLowerCase() == searchQuery[i].toLowerCase()) { + seq[j] = true; + j++; + } else { + full_match = false; + } + } + return { + match: seq, + full_match: full_match + }; + } + for (let elem of $('.drowpdown-button')) { + let sub = elem.innerText; + if (!sub) continue; + let resp = layerCompability(pattern, sub); + if (resp.full_match) { + elem.style.display = 'block'; + let final = ''; + for (let i = 0; i < sub.length; i++) { + if (resp.match[i]) { + final += '' + sub[i] + '' + } else { + final += sub[i]; + } + } + elem.innerHTML = final; + } else { + elem.style.display = 'none'; + } + } + for (let elem of $('.panel-heading')) { + let _p = pattern ? 'false' : 'true'; + if (elem.getAttribute('aria-expanded') == _p) { + elem.click(); + } + } + } + $('#layer-search-input').keyup((e) => { + filter(e.target.value); + }); + } + + render() { return (