Add shortcuts for reshare, expand Post and open first link in a post
This commit is contained in:
parent
aaadf2926f
commit
099974ddef
5 changed files with 142 additions and 37 deletions
|
|
@ -154,6 +154,7 @@ diaspora.yml file**. The existing settings from 0.4.x and before will not work a
|
|||
* Hide user setting if the community spotlight is not enabled on the pod [#5562](https://github.com/diaspora/diaspora/pull/5562)
|
||||
* Add HTML view for pod statistics [#5464](https://github.com/diaspora/diaspora/pull/5464)
|
||||
* Added/Moved hide, block user, report and delete button in SPV [#5547](https://github.com/diaspora/diaspora/pull/5547)
|
||||
* Added keyboard shortcuts r(reshare), m(expand Post), o(open first link in post) [#5602](https://github.com/diaspora/diaspora/pull/5602)
|
||||
|
||||
# 0.4.1.2
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,9 @@ app.views.StreamShortcuts = {
|
|||
this.on('hotkey:gotoPrev', this.gotoPrev, this);
|
||||
this.on('hotkey:likeSelected', this.likeSelected, this);
|
||||
this.on('hotkey:commentSelected', this.commentSelected, this);
|
||||
this.on('hotkey:reshareSelected', this.reshareSelected, this);
|
||||
this.on('hotkey:expandSelected', this.expandSelected, this);
|
||||
this.on('hotkey:openFirstLinkSelected', this.openFirstLinkSelected, this);
|
||||
},
|
||||
|
||||
_onHotkeyDown: function(event) {
|
||||
|
|
@ -49,6 +52,15 @@ app.views.StreamShortcuts = {
|
|||
case "l":
|
||||
this.trigger('hotkey:likeSelected');
|
||||
break;
|
||||
case "r":
|
||||
this.trigger('hotkey:reshareSelected');
|
||||
break;
|
||||
case "m":
|
||||
this.trigger('hotkey:expandSelected');
|
||||
break;
|
||||
case "o":
|
||||
this.trigger('hotkey:openFirstLinkSelected');
|
||||
break;
|
||||
default:
|
||||
}
|
||||
},
|
||||
|
|
@ -95,6 +107,22 @@ app.views.StreamShortcuts = {
|
|||
$('a.like:first',this.$('div.stream_element.loaded.shortcut_selected')).click();
|
||||
},
|
||||
|
||||
reshareSelected: function() {
|
||||
$('a.reshare:first',this.$('div.stream_element.loaded.shortcut_selected')).click();
|
||||
},
|
||||
|
||||
expandSelected: function() {
|
||||
$('div.expander:first',this.$('div.stream_element.loaded.shortcut_selected')).click();
|
||||
},
|
||||
|
||||
openFirstLinkSelected: function() {
|
||||
var link = $('div.collapsible a[target="_blank"]:first',this.$('div.stream_element.loaded.shortcut_selected'));
|
||||
if(link.length > 0) {
|
||||
// click does only work with vanilla javascript
|
||||
link[0].click();
|
||||
}
|
||||
},
|
||||
|
||||
selectPost: function(element){
|
||||
//remove the selection and selected-class from all posts
|
||||
var selected=this.$('div.stream_element.loaded.shortcut_selected');
|
||||
|
|
|
|||
|
|
@ -10,6 +10,9 @@
|
|||
<li>{{ keyboard_shortcuts_li2 }}</li>
|
||||
<li>{{ keyboard_shortcuts_li3 }}</li>
|
||||
<li>{{ keyboard_shortcuts_li4 }}</li>
|
||||
<li>{{ keyboard_shortcuts_li5 }}</li>
|
||||
<li>{{ keyboard_shortcuts_li6 }}</li>
|
||||
<li>{{ keyboard_shortcuts_li7 }}</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -565,13 +565,16 @@ en:
|
|||
filter_tags_q: "How can I filter/exclude some tags from my stream?"
|
||||
filter_tags_a: "This is not yet available directly through diaspora*, but some %{third_party_tools} have been written that might provide this."
|
||||
keyboard_shortcuts:
|
||||
title: "Keyboard shortcuts"
|
||||
keyboard_shortcuts_q: "What keyboard shortcuts are available?"
|
||||
keyboard_shortcuts_a1: "In the stream view you can use the following keyboard shortcuts:"
|
||||
keyboard_shortcuts_li1: "j - jump to the next post"
|
||||
keyboard_shortcuts_li2: "k - jump to the previous post"
|
||||
keyboard_shortcuts_li3: "c - comment on the current post"
|
||||
keyboard_shortcuts_li4: "l - like the current post"
|
||||
title: "Keyboard shortcuts"
|
||||
keyboard_shortcuts_li5: "r - reshare the current post"
|
||||
keyboard_shortcuts_li6: "m - expand the current post"
|
||||
keyboard_shortcuts_li7: "o - open the first link in the current post"
|
||||
miscellaneous:
|
||||
title: "Miscellaneous"
|
||||
back_to_top_q: "Is there a quick way to go back to the top of a page after I scroll down?"
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
describe("app.views.StreamShortcuts", function () {
|
||||
|
||||
beforeEach(function() {
|
||||
this.post1 = factory.post({author : factory.author({name : "Rebecca Black", id : 1492})})
|
||||
this.post2 = factory.post({author : factory.author({name : "John Stamos", id : 1987})})
|
||||
this.post1 = factory.post({author : factory.author({name : "Rebecca Black", id : 1492})});
|
||||
this.post2 = factory.post({author : factory.author({name : "John Stamos", id : 1987})});
|
||||
|
||||
this.stream = new app.models.Stream();
|
||||
this.stream.add([this.post1, this.post2]);
|
||||
|
|
@ -127,4 +127,74 @@ describe("app.views.StreamShortcuts", function () {
|
|||
expect(this.view.likeSelected).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
})
|
||||
|
||||
describe("pressing 'r'", function(){
|
||||
|
||||
it("should click on the reshare-button if not pressed in an input field", function(){
|
||||
spyOn(this.view, 'reshareSelected');
|
||||
this.view.initialize();
|
||||
var e = $.Event("keyup", { which: 82, target: {type: "div"} });
|
||||
//verify that the test is correct
|
||||
expect(String.fromCharCode( e.which ).toLowerCase()).toBe('r');
|
||||
this.view._onHotkeyUp(e);
|
||||
expect(this.view.reshareSelected).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("shouldn't do anything if the user types in an input field", function(){
|
||||
spyOn(this.view, 'reshareSelected');
|
||||
this.view.initialize();
|
||||
var e = $.Event("keyup", { which: 82, target: {type: "textarea"} });
|
||||
//verify that the test is correct
|
||||
expect(String.fromCharCode( e.which ).toLowerCase()).toBe('r');
|
||||
this.view._onHotkeyUp(e);
|
||||
expect(this.view.reshareSelected).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe("pressing 'm'", function(){
|
||||
|
||||
it("should click on the more-button if not pressed in an input field", function(){
|
||||
spyOn(this.view, 'expandSelected');
|
||||
this.view.initialize();
|
||||
var e = $.Event("keyup", { which: 77, target: {type: "div"} });
|
||||
//verify that the test is correct
|
||||
expect(String.fromCharCode( e.which ).toLowerCase()).toBe('m');
|
||||
this.view._onHotkeyUp(e);
|
||||
expect(this.view.expandSelected).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("shouldn't do anything if the user types in an input field", function(){
|
||||
spyOn(this.view, 'expandSelected');
|
||||
this.view.initialize();
|
||||
var e = $.Event("keyup", { which: 77, target: {type: "textarea"} });
|
||||
//verify that the test is correct
|
||||
expect(String.fromCharCode( e.which ).toLowerCase()).toBe('m');
|
||||
this.view._onHotkeyUp(e);
|
||||
expect(this.view.expandSelected).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe("pressing 'o'", function(){
|
||||
|
||||
it("should click on the more-button if not pressed in an input field", function(){
|
||||
spyOn(this.view, 'openFirstLinkSelected');
|
||||
this.view.initialize();
|
||||
var e = $.Event("keyup", { which: 79, target: {type: "div"} });
|
||||
//verify that the test is correct
|
||||
expect(String.fromCharCode( e.which ).toLowerCase()).toBe('o');
|
||||
this.view._onHotkeyUp(e);
|
||||
expect(this.view.openFirstLinkSelected).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("shouldn't do anything if the user types in an input field", function(){
|
||||
spyOn(this.view, 'openFirstLinkSelected');
|
||||
this.view.initialize();
|
||||
var e = $.Event("keyup", { which: 79, target: {type: "textarea"} });
|
||||
//verify that the test is correct
|
||||
expect(String.fromCharCode( e.which ).toLowerCase()).toBe('o');
|
||||
this.view._onHotkeyUp(e);
|
||||
expect(this.view.openFirstLinkSelected).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue