summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Tanghus <thomas@tanghus.net>2012-08-03 01:02:53 +0200
committerThomas Tanghus <thomas@tanghus.net>2012-08-03 21:32:27 +0200
commit3610975bc10f93caa5f6fde517e5988756246cf9 (patch)
treecfe5a8f49cb4d3c830fab30f7d0a9cf1e9733679
parente3de746bb617d81b84678015ee8fe7f41016b2fd (diff)
downloadnextcloud-server-3610975bc10f93caa5f6fde517e5988756246cf9.tar.gz
nextcloud-server-3610975bc10f93caa5f6fde517e5988756246cf9.zip
Some fixes for keyboard shortcuts.
-rw-r--r--apps/contacts/js/contacts.js49
-rw-r--r--apps/contacts/templates/index.php16
2 files changed, 43 insertions, 22 deletions
diff --git a/apps/contacts/js/contacts.js b/apps/contacts/js/contacts.js
index 4ccedf87ed6..d9fff25bc9a 100644
--- a/apps/contacts/js/contacts.js
+++ b/apps/contacts/js/contacts.js
@@ -1522,8 +1522,7 @@ OC.Contacts={
return false;
},
next:function(reverse) {
- // TODO: Check if we're last-child/first-child and jump to next/prev address book.
- var curlistitem = $('#contacts li[data-id="'+OC.Contacts.Card.id+'"]');
+ var curlistitem = this.getContact(OC.Contacts.Card.id);
var newlistitem = reverse ? curlistitem.prev('li') : curlistitem.next('li');
if(newlistitem) {
curlistitem.removeClass('active');
@@ -1536,6 +1535,30 @@ OC.Contacts={
previous:function() {
this.next(true);
},
+ nextAddressbook:function(reverse) {
+ console.log('nextAddressbook', reverse);
+ var curlistitem = this.getContact(OC.Contacts.Card.id);
+ var parent = curlistitem.parent('ul');
+ var newparent = reverse
+ ? parent.prevAll('ul').first()
+ : parent.nextAll('ul').first();
+ if(newparent) {
+ newlistitem = newparent.find('li:first-child');
+ if(newlistitem) {
+ parent.slideUp().prev('h3').removeClass('active');
+ newparent.slideDown().prev('h3').addClass('active');
+ curlistitem.removeClass('active');
+ OC.Contacts.Card.update({
+ cid:newlistitem.data('id'),
+ aid:newlistitem.data('bookid')
+ });
+ }
+ }
+ },
+ previousAddressbook:function() {
+ console.log('previousAddressbook');
+ this.nextAddressbook(true);
+ },
// Reload the contacts list.
update:function(params){
if(!params) { params = {}; }
@@ -1677,10 +1700,10 @@ $(document).ready(function(){
|| !OC.Contacts.Card.id) {
return;
}
- console.log(event.which + ' ' + event.target.nodeName);
+ //console.log(event.which + ' ' + event.target.nodeName);
/**
* To add:
- * (Shift)n/p: next/prev addressbook
+ * Shift-a: add addressbook
* u (85): hide/show leftcontent
* f (70): add field
*/
@@ -1688,18 +1711,13 @@ $(document).ready(function(){
case 27: // Esc
ninjahelp.hide();
break;
- case 46:
+ case 46: // Delete
if(event.shiftKey) {
OC.Contacts.Card.delayedDelete();
}
break;
- case 32: // space
- if(event.shiftKey) {
- OC.Contacts.Contacts.previous();
- break;
- }
case 40: // down
- case 75: // k
+ case 74: // j
OC.Contacts.Contacts.next();
break;
case 65: // a
@@ -1711,23 +1729,24 @@ $(document).ready(function(){
OC.Contacts.Card.editNew();
break;
case 38: // up
- case 74: // j
+ case 75: // k
OC.Contacts.Contacts.previous();
break;
+ case 34: // PageDown
case 78: // n
// next addressbook
- OC.Contacts.notImplemented();
+ OC.Contacts.Contacts.nextAddressbook();
break;
- case 13: // Enter
case 79: // o
var aid = $('#contacts h3.active').first().data('id');
if(aid) {
$('#contacts ul[data-id="'+aid+'"]').slideToggle(300);
}
break;
+ case 33: // PageUp
case 80: // p
// prev addressbook
- OC.Contacts.notImplemented();
+ OC.Contacts.Contacts.previousAddressbook();
break;
case 82: // r
OC.Contacts.Contacts.update({cid:OC.Contacts.Card.id});
diff --git a/apps/contacts/templates/index.php b/apps/contacts/templates/index.php
index 270d5c203cf..024b1d150f8 100644
--- a/apps/contacts/templates/index.php
+++ b/apps/contacts/templates/index.php
@@ -38,14 +38,16 @@
<div class="help-section">
<h3><?php echo $l->t('Navigation'); ?></h3>
<dl>
- <dt>j/Down/Space</dt>
+ <dt>j/Down</dt>
<dd><?php echo $l->t('Next contact in list'); ?></dd>
- <dt>k/Up/Shift-Space</dt>
+ <dt>k/Up</dt>
<dd><?php echo $l->t('Previous contact in list'); ?></dd>
- <dt>o/Enter</dt>
+ <dt>o</dt>
<dd><?php echo $l->t('Expand/collapse current addressbook'); ?></dd>
- <dt>n/p</dt>
- <dd><?php echo $l->t('Next/previous addressbook'); ?></dd>
+ <dt>n/PageDown</dt>
+ <dd><?php echo $l->t('Next addressbook'); ?></dd>
+ <dt>p/PageUp</dt>
+ <dd><?php echo $l->t('Previous addressbook'); ?></dd>
</dl>
</div>
<div class="help-section">
@@ -55,8 +57,8 @@
<dd><?php echo $l->t('Refresh contacts list'); ?></dd>
<dt>a</dt>
<dd><?php echo $l->t('Add new contact'); ?></dd>
- <dt>Shift-a</dt>
- <dd><?php echo $l->t('Add new addressbook'); ?></dd>
+ <!-- dt>Shift-a</dt>
+ <dd><?php echo $l->t('Add new addressbook'); ?></dd -->
<dt>Shift-Delete</dt>
<dd><?php echo $l->t('Delete current contact'); ?></dd>
</dl>