Skip to content

Commit eece43f

Browse files
devvaannshabose
authored andcommitted
feat: add dropdown in more-options
1 parent 77d50aa commit eece43f

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

src/extensionsIntegrated/TabBar/main.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable no-invalid-this */
12
define(function (require, exports, module) {
23
const AppInit = require("utils/AppInit");
34
const MainViewManager = require("view/MainViewManager");
@@ -11,6 +12,7 @@ define(function (require, exports, module) {
1112

1213
const Helper = require("./helper");
1314
const Preference = require("./preference");
15+
const MoreOptions = require("./more-options");
1416
const TabBarHTML = require("text!./html/tabbar-pane.html");
1517
const TabBarHTML2 = require("text!./html/tabbar-second-pane.html");
1618

@@ -306,7 +308,7 @@ define(function (require, exports, module) {
306308

307309

308310
/**
309-
* handle click events on the tabs to open the file or close the tab
311+
* handle click events on the tabs to open the file
310312
*/
311313
function handleTabClick() {
312314

@@ -402,5 +404,7 @@ define(function (require, exports, module) {
402404

403405
// handle when a single tab gets clicked
404406
handleTabClick();
407+
408+
MoreOptions.handleMoreOptionsClick();
405409
});
406410
});
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
define(function (require, exports, module) {
2+
const DropdownButton = brackets.getModule("widgets/DropdownButton");
3+
4+
function showMoreOptionsContextMenu(x, y) {
5+
const items = [
6+
"close all tabs",
7+
"close unmodified tabs"
8+
];
9+
10+
const dropdown = new DropdownButton.DropdownButton("", items);
11+
12+
$(".tab-bar-more-options").append(dropdown.$button);
13+
dropdown.showDropdown();
14+
15+
dropdown.$button.on(DropdownButton.EVENT_SELECTED, function (e, item, index) {
16+
console.log("Selected item:", item);
17+
// TODO: Add the logic here
18+
// check for index and then call the items
19+
});
20+
21+
$(document).one("click", function () {
22+
dropdown.closeDropdown();
23+
});
24+
}
25+
26+
function handleMoreOptionsClick() {
27+
$(document).on("click", ".tab-bar-more-options", function (event) {
28+
event.stopPropagation();
29+
showMoreOptionsContextMenu(event.pageX, event.pageY);
30+
});
31+
}
32+
33+
module.exports = {
34+
handleMoreOptionsClick
35+
};
36+
});

0 commit comments

Comments
 (0)