Skip to content

Commit 8ee40b6

Browse files
authored
Merge pull request #1050 from frknbasaran/server-1392
[server-1392] app selector - top bar improvement.
2 parents 40811ae + baa900b commit 8ee40b6

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed

frontend/express/public/javascripts/countly/countly.template.js

+70
Original file line numberDiff line numberDiff line change
@@ -2201,6 +2201,76 @@ var AppRouter = Backbone.Router.extend({
22012201
e.stopPropagation();
22022202
});
22032203

2204+
/**
2205+
* Clear highlights class from app items
2206+
* @param {array} filteredItems - filtered app items list
2207+
*/
2208+
function clearHighlights(filteredItems) {
2209+
var length = filteredItems.length;
2210+
for (var i = 0; i < length; i++) {
2211+
$(filteredItems[i]).removeClass('highlighted-app-item');
2212+
}
2213+
}
2214+
2215+
var arrowed = false;
2216+
var currentIndex;
2217+
$topbar.on('keydown', '.nav-search input', function(e) {
2218+
var code = (e.keyCode || e.which);
2219+
var filteredItems = $('#app-navigation > div.menu > div.list > .filtered-app-item');
2220+
var indexLimit = filteredItems.length;
2221+
if (code === 38) {
2222+
clearHighlights(filteredItems);
2223+
if (!arrowed) {
2224+
arrowed = true;
2225+
currentIndex = indexLimit - 1;
2226+
}
2227+
else {
2228+
currentIndex = currentIndex - 1;
2229+
if (currentIndex === -1) {
2230+
currentIndex = indexLimit - 1;
2231+
}
2232+
}
2233+
$(filteredItems[currentIndex]).addClass('highlighted-app-item');
2234+
}
2235+
else if (code === 40) {
2236+
clearHighlights(filteredItems);
2237+
if (!arrowed) {
2238+
arrowed = true;
2239+
currentIndex = 0;
2240+
}
2241+
else {
2242+
currentIndex = currentIndex + 1;
2243+
if (currentIndex === indexLimit) {
2244+
currentIndex = 0;
2245+
}
2246+
}
2247+
$(filteredItems[currentIndex]).addClass('highlighted-app-item');
2248+
}
2249+
else if (code === 13) {
2250+
$('#app-navigation').removeClass('clicked');
2251+
var appKey = $(filteredItems[currentIndex]).data("key"),
2252+
appId = $(filteredItems[currentIndex]).data("id"),
2253+
appName = $(filteredItems[currentIndex]).find(".name").text(),
2254+
appImage = $(filteredItems[currentIndex]).find(".app-icon").css("background-image");
2255+
2256+
$("#active-app-icon").css("background-image", appImage);
2257+
$("#active-app-name").text(appName);
2258+
$("#active-app-name").attr('title', appName);
2259+
2260+
if (self.activeAppKey !== appKey) {
2261+
self.activeAppName = appName;
2262+
self.activeAppKey = appKey;
2263+
countlyCommon.setActiveApp(appId);
2264+
self.activeView.appChanged(function() {
2265+
app.onAppSwitch(appId);
2266+
});
2267+
}
2268+
}
2269+
else {
2270+
return;
2271+
}
2272+
});
2273+
22042274
$topbar.on("click", ".dropdown .item", function(e) {
22052275
$topbar.find(".dropdown").removeClass("clicked");
22062276
e.stopPropagation();

frontend/express/public/stylesheets/main.css

+3
Original file line numberDiff line numberDiff line change
@@ -3507,4 +3507,7 @@ color:#E95C6C; transition:color 1s;
35073507
color: #868686;
35083508
cursor: pointer;
35093509
top: 7px;
3510+
}
3511+
.highlighted-app-item {
3512+
background-color: #ebebeb;
35103513
}

0 commit comments

Comments
 (0)