@@ -2201,6 +2201,76 @@ var AppRouter = Backbone.Router.extend({
2201
2201
e . stopPropagation ( ) ;
2202
2202
} ) ;
2203
2203
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
+
2204
2274
$topbar . on ( "click" , ".dropdown .item" , function ( e ) {
2205
2275
$topbar . find ( ".dropdown" ) . removeClass ( "clicked" ) ;
2206
2276
e . stopPropagation ( ) ;
0 commit comments