keyboard access + direct link scrolling
This commit is contained in:
parent
43fed43e03
commit
7d802b57a2
15 changed files with 167 additions and 14 deletions
|
@ -103,7 +103,6 @@
|
|||
try{
|
||||
var focusobj = document.getElementById(fid);
|
||||
if(focusobj) focusobj.focus();
|
||||
if(focusobj) console.log(focusobj);
|
||||
}catch(err){
|
||||
this._debug('exception: '+err);
|
||||
}
|
||||
|
|
4
js/base/velocity.min.js
vendored
Normal file
4
js/base/velocity.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
130
js/direct.js
Normal file
130
js/direct.js
Normal file
|
@ -0,0 +1,130 @@
|
|||
|
||||
/**
|
||||
* Sets up the behaviour of direct menu links
|
||||
*
|
||||
* @author Jana Deutschlaender <deutschlaender@cosmocode.de>
|
||||
*/
|
||||
(function($) {
|
||||
|
||||
|
||||
var $body,
|
||||
|
||||
/**
|
||||
* Register the click handler for the direct links
|
||||
* should scroll to the page area whether there is a fixed magic matcher bar or not
|
||||
*
|
||||
* @param $directMenu
|
||||
*/
|
||||
scrollingForDirectNav = function($directMenu) {
|
||||
$body = $('body');
|
||||
checkAnchorsOnLoad($directMenu);
|
||||
registerClickForDirectLinks($directMenu);
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* register click event listener for direct links
|
||||
* @param $menu
|
||||
*/
|
||||
registerClickForDirectLinks = function($menu) {
|
||||
$menu.find('a').on('click', function (e) {
|
||||
e.stopPropagation();
|
||||
var target = $(this).attr('href');
|
||||
tasksBeforeScrolling(target);
|
||||
scrollToTarget(target);
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* scroll to / set focus to target of direct link if value of location hash equals direct link
|
||||
* @param $menu
|
||||
*/
|
||||
checkAnchorsOnLoad = function($menu) {
|
||||
var hash = window.location.hash;
|
||||
if (hash) {
|
||||
$menu.find('a').each(function() {
|
||||
var target = $(this).attr('href');
|
||||
if(hash === target) {
|
||||
tasksBeforeScrolling(target);
|
||||
scrollToTarget(target);
|
||||
setFocusOnLoad(target);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* todos that needs to be done before the scrolling can start
|
||||
* @param target
|
||||
*/
|
||||
tasksBeforeScrolling = function(target) {
|
||||
switch (target) {
|
||||
case '#qsearch__in':
|
||||
showSearchField(target);
|
||||
break;
|
||||
|
||||
case '#dokuwiki__usertools':
|
||||
$(target).find('li:first-child').find('a').focus();
|
||||
break;
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* set focus on target or first link found in target
|
||||
* @param target
|
||||
*/
|
||||
setFocusOnLoad = function(target) {
|
||||
var $target = $(target);
|
||||
switch (target) {
|
||||
|
||||
case '#qsearch__in':
|
||||
case '#spr__toggle-content':
|
||||
$target.focus();
|
||||
break;
|
||||
|
||||
case '#dokuwiki__usertools':
|
||||
break;
|
||||
|
||||
default:
|
||||
$target.attr('tabindex',0);
|
||||
$target.focus();
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* trigger content toggle link to make the search field visible otherwise it neither be used for scrolling nor
|
||||
* for focus setting
|
||||
* @param target
|
||||
*/
|
||||
showSearchField = function(target) {
|
||||
if($body.hasClass('wide-content')) {
|
||||
$('#spr__toggle-content').trigger('click');
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* scrolls to the target with an offset of 60px
|
||||
* @param target
|
||||
*/
|
||||
scrollToTarget = function(target) {
|
||||
// scroll to each target
|
||||
$(target).velocity('scroll', {
|
||||
duration: 400,
|
||||
offset: -60,
|
||||
easing: 'ease-in-out'
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
$(function(){
|
||||
|
||||
var $directMenu = $('#spr__direct');
|
||||
if (!$directMenu.length) return;
|
||||
|
||||
scrollingForDirectNav($directMenu);
|
||||
});
|
||||
|
||||
|
||||
})(jQuery);
|
|
@ -1,5 +1,10 @@
|
|||
|
||||
|
||||
/**
|
||||
* Sets up the behaviour of the meta box
|
||||
*
|
||||
* @author Andreas Gohr <gohr@cosmocode.de>
|
||||
* @author Jana Deutschlaender <deutschlaender@cosmocode.de>
|
||||
*/
|
||||
(function($) {
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
/**
|
||||
* prevents Uncaught TypeError in detail template if bookcreator plug-in is installed
|
||||
*
|
||||
* @author Jana Deutschlaender <deutschlaender@cosmocode.de>
|
||||
*
|
||||
*/
|
||||
(function($) {
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
/**
|
||||
* prevents Uncaught TypeError in detail template if folded plug-in is installed
|
||||
*
|
||||
* @author Jana Deutschlaender <deutschlaender@cosmocode.de>
|
||||
*
|
||||
*/
|
||||
(function($) {
|
||||
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
/**
|
||||
* Add custom QC functionality instead of using the plugin's mechanism
|
||||
*
|
||||
* @author Andreas Gohr <gohr@cosmocode.de>
|
||||
* @author Jana Deutschlaender <deutschlaender@cosmocode.de>
|
||||
*/
|
||||
jQuery(function () {
|
||||
var $panel = jQuery('div.qc-output').hide();
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
/**
|
||||
* Sets up the sidebar behaviour
|
||||
*
|
||||
* @author Andreas Gohr <gohr@cosmocode.de>
|
||||
* @author Michael Große <gohr@cosmocode.de>
|
||||
* @author Jana Deutschlaender <deutschlaender@cosmocode.de>
|
||||
*/
|
||||
jQuery(function () {
|
||||
var $nav = jQuery('#dokuwiki__aside');
|
||||
|
@ -266,7 +270,7 @@ jQuery(function () {
|
|||
setActive(stModes,$siteTools);
|
||||
setActive(utModes,$userTools);
|
||||
|
||||
if(jQuery('body').is('.wide-content')) {
|
||||
if($body.is('.wide-content')) {
|
||||
window.sessionStorage.setItem('wide-content', true);
|
||||
isWideContent = true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue