Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for CTRL+CLICK opening of documents in search dropdown #425

Open
made-by-chris opened this issue Apr 19, 2016 · 1 comment
Open

Allow for CTRL+CLICK opening of documents in search dropdown #425

made-by-chris opened this issue Apr 19, 2016 · 1 comment

Comments

@made-by-chris
Copy link

It is common for people to open multiple links from a list of links in one go with the shortcut ctrl-click (or cmd-click on macOS).
The paperhive prefix search dropdown box currently ignores the ctrl-click and just opens the clicked document in the current tab.
It would be nice if we can add the ctrl(cmd)-click behaviour.

@pure180
Copy link
Contributor

pure180 commented Apr 19, 2016

Yes, you are right. I usually use the mousewheel-key to open links in a new tabs.

@andrenarchy, you could use something like this for the associated ng-controller:

function openLinkInNewTab(ele, event){
  var url = ele.getAttribute('src');
  if( event.type === 'click' && event.which === 2 ) {
    window.open(url, '_blank');
  }
  else if ( event.ctrlKey && event.type === 'keydown' && event.repeat ) {
    ele.addEventListener('click', function() {
      window.open(url, '_blank');
    });     
  }
}

var ele = document.getElementById('link');

ele.addEventListener('click', function(event) {
    openLinkInNewTab(ele, event)
});

window.addEventListener('keydown', function(event) {
    openLinkInNewTab(ele, event)
});

Take a look on this fiddle:
https://jsfiddle.net/hgLyc4rk/

Sorry, my previous comment which i deleted was from my business account.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants