Skip to content

Commit 6c7050f

Browse files
committed
CDB: Search bar can now be dragged
1 parent 32b6a9d commit 6c7050f

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

bin/style.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,6 +1062,9 @@ input[type=checkbox].indeterminate:after {
10621062
.search-box .buttons {
10631063
margin-right: 10px;
10641064
}
1065+
.search-box .buttons #grab {
1066+
cursor: grab;
1067+
}
10651068
.search-box .search-type {
10661069
margin-left: 30px;
10671070
}

bin/style.less

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,6 +1155,10 @@ input[type=checkbox] {
11551155

11561156
.buttons {
11571157
margin-right: 10px;
1158+
1159+
#grab {
1160+
cursor: grab;
1161+
}
11581162
}
11591163

11601164
.search-type {

hide/comp/cdb/Editor.hx

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1679,6 +1679,7 @@ class Editor extends Component {
16791679
// Setup for search bar
16801680
searchBox = new Element('<div>
16811681
<div class="buttons">
1682+
<div class="btn ico ico-ellipsis-v" id="grab" title="Add filter"></div>
16821683
<div class="btn add-btn ico ico-plus" title="Add filter"></div>
16831684
<div class="btn remove-btn ico ico-minus" title="Remove filter"></div>
16841685
</div>
@@ -1739,7 +1740,27 @@ class Editor extends Component {
17391740
inputs.attr("placeholder", "Find");
17401741
inputs.keyup(search);
17411742

1742-
var inputCont = searchBox.find(".input-cont");
1743+
function startDrag(onMove: js.jquery.Event->Void, onStop: js.jquery.Event->Void) {
1744+
var el = new Element(element[0].ownerDocument.body);
1745+
el.on("mousemove.cdb.search", onMove);
1746+
el.on("mouseup.cdb.search", function(e: js.jquery.Event) {
1747+
el.off("mousemove.cdb.search");
1748+
el.off("mouseup.cdb.search");
1749+
e.preventDefault();
1750+
e.stopPropagation();
1751+
onStop(e);
1752+
});
1753+
}
1754+
1755+
searchBox.find("#grab").mousedown(function(e) {
1756+
var x = Std.parseInt(searchBox.css("right"));
1757+
var prevClientX = e.clientX;
1758+
startDrag(function(e: js.jquery.Event) {
1759+
searchBox.css("right", x - (e.clientX - prevClientX));
1760+
}, function(e) {
1761+
1762+
});
1763+
});
17431764

17441765
searchBox.find(".add-btn").click(function(_) {
17451766
var newInput = new Element('<input type="text" class="search-bar-cdb"></input>');
@@ -1750,6 +1771,7 @@ class Editor extends Component {
17501771
searchBox.find(".remove-btn").show();
17511772
});
17521773

1774+
var inputCont = searchBox.find(".input-cont");
17531775
searchBox.find(".remove-btn").hide();
17541776
searchBox.find(".remove-btn").click(function(_) {
17551777
var searchBars = inputCont.find(".search-bar-cdb");

0 commit comments

Comments
 (0)