Skip to content

Commit c3345ab

Browse files
author
p01
committed
Keyboard shortcut to select the previous/next visible resource
1 parent 9f80f8a commit c3345ab

File tree

4 files changed

+53
-0
lines changed

4 files changed

+53
-0
lines changed

src/resource-manager/resource_service.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,32 @@ cls.ResourceManagerService = function(view, network_logger)
268268
e.classList.add('resource-highlight');
269269
}.bind(this);
270270

271+
this._highlight_sibling_resource = function(increment)
272+
{
273+
if(!this._context || !this._context.visibleResources || !this._context.visibleResources.length)
274+
return;
275+
276+
var uid;
277+
var list = this._context.visibleResources;
278+
var pos = list.indexOf(this._selectedResourceUID);
279+
if (pos == -1)
280+
uid = list[ increment > 0 ? 0 : list.length-1 ];
281+
else
282+
uid = list[ (list.length+pos+increment) % list.length ];
283+
284+
this.highlight_resource( uid );
285+
cls.ResourceDetailView.instance.show_resource(uid);
286+
}
287+
288+
this.highlight_next_resource_bound = function()
289+
{
290+
this._highlight_sibling_resource(1);
291+
}.bind(this);
292+
293+
this.highlight_previous_resource_bound = function()
294+
{
295+
this._highlight_sibling_resource(-1);
296+
}.bind(this);
271297

272298
this._resource_request_update_bound = function(msg)
273299
{

src/resource-manager/resource_templates.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ templates.resource_tree =
4848

4949
update:function(context)
5050
{
51+
context.visibleResources = [];
5152
return this.windows(context);
5253
},
5354

@@ -224,6 +225,8 @@ templates.resource_tree =
224225
partial_URL_match = (pos_first>0?'…':'')+r.url.substring( pos_first, pos_last)+(pos_last<r.url.length?'…':'');
225226
}
226227

228+
context.visibleResources.push(r.uid);
229+
227230
var tpl =
228231
['li',
229232
['h2',

src/resource-manager/resource_tree_view.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,14 @@ cls.ResourceTreeView = function(id, name, container_class, html, default_handler
124124
doc_service.addListener("abouttoloaddocument", this._on_abouttoloaddocument_bound);
125125
doc_service.addListener("documentloaded", this._on_documentloaded_bound);
126126

127+
ActionHandlerInterface.apply(this);
128+
this._handlers = {
129+
"select-next-entry": this._service.highlight_next_resource_bound,
130+
"select-previous-entry": this._service.highlight_previous_resource_bound
131+
};
132+
this.id = id;
133+
ActionBroker.get_instance().register_handler(this);
134+
127135
this.init(id, name, container_class, html, default_handler);
128136
};
129137

src/scripts/ini.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,14 @@
215215
"down": "select-next-entry"
216216
}
217217
},
218+
"resource_tree_view":
219+
{
220+
"default":
221+
{
222+
"up": "select-previous-entry",
223+
"down": "select-next-entry"
224+
}
225+
},
218226
"search":
219227
{
220228
"default":
@@ -433,6 +441,14 @@
433441
"down": "select-next-entry"
434442
}
435443
},
444+
"resource_tree_view":
445+
{
446+
"default":
447+
{
448+
"up": "select-previous-entry",
449+
"down": "select-next-entry"
450+
}
451+
},
436452
"search":
437453
{
438454
"default":

0 commit comments

Comments
 (0)