Add keyboard navigation module from http://photo.dragonsoft.us/clickcount/click.php?id=9
This commit is contained in:
parent
4fe8e21836
commit
6e5e05755c
20
modules/kbd_nav/changelog.txt
Normal file
20
modules/kbd_nav/changelog.txt
Normal file
|
@ -0,0 +1,20 @@
|
|||
Kbd Navigation Changelog
|
||||
|
||||
version 1.5:
|
||||
- Fix for RTL detection
|
||||
- Added support for Wind theme
|
||||
|
||||
version 1.4:
|
||||
- Added RTL detection
|
||||
|
||||
version 1.3:
|
||||
- Internal revision
|
||||
|
||||
version 1.2:
|
||||
- Added support for GreyDragon Photo Slideshow navigation - in Photo SB slideshow mode, key navigation is superseded by slideshow navigation.
|
||||
|
||||
version 1.1:
|
||||
- Internal revision
|
||||
|
||||
version 1.0:
|
||||
- Initial release
|
8
modules/kbd_nav/helpers/kbd_nav_theme.php
Normal file
8
modules/kbd_nav/helpers/kbd_nav_theme.php
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?php defined("SYSPATH") or die("No direct script access.");
|
||||
|
||||
class Kbd_Nav_theme_Core {
|
||||
|
||||
static function head($theme) {
|
||||
$theme->script("kbd_nav.js");
|
||||
}
|
||||
}
|
97
modules/kbd_nav/js/kbd_nav.js
Normal file
97
modules/kbd_nav/js/kbd_nav.js
Normal file
|
@ -0,0 +1,97 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (c) 2010 Serguei Dosyukov, http://blog.dragonsoft.us
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
|
||||
* files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
|
||||
* modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
|
||||
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
$.fn.KbdNavigation = function(options, callback) {
|
||||
|
||||
this.options = options || {};
|
||||
var opt = this.options;
|
||||
this.callback = callback || null;
|
||||
var clbk = this.callback;
|
||||
|
||||
$(this).bind("keydown", function(event) {
|
||||
if ($('#sb-body-inner>img#sb-content').is(':visible')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var direction = "ltr";
|
||||
if (document.body) {
|
||||
if (window.getComputedStyle) {
|
||||
direction = window.getComputedStyle(document.body, null).direction;
|
||||
} else if (document.body.currentStyle) {
|
||||
direction = document.body.currentStyle.direction;
|
||||
}
|
||||
}
|
||||
|
||||
var lnk = "";
|
||||
var lnk_first, lnk_prev, lnk_parent, lnk_next, lnk_last;
|
||||
|
||||
if(opt.first) { lnk_first = opt.first; } else { lnk_first = $("#g-navi-first").attr("href"); }
|
||||
if(opt.prev) { lnk_prev = opt.prev; } else { lnk_prev = $("#g-navi-prev").attr("href"); }
|
||||
if(opt.parent) { lnk_parent = opt.parent; } else { lnk_parent = $("#g-navi-parent").attr("href"); }
|
||||
if(opt.next) { lnk_next = opt.next; } else { lnk_next = $("#g-navi-next").attr("href"); }
|
||||
if(opt.last) { lnk_last = opt.last; } else { lnk_last = $("#g-navi-last").attr("href"); }
|
||||
|
||||
// Support for standard Wind Theme tags
|
||||
if(!lnk_first) { lnk_first = $(".g-paginator .ui-icon-seek-first").parent().attr("href"); }
|
||||
if(!lnk_prev) { lnk_prev = $(".g-paginator .ui-icon-seek-prev").parent().attr("href"); }
|
||||
if(!lnk_next) { lnk_next = $(".g-paginator .ui-icon-seek-next").parent().attr("href"); }
|
||||
if(!lnk_last) { lnk_last = $(".g-paginator .ui-icon-seek-end").parent().attr("href"); }
|
||||
|
||||
var keyCode = event.keyCode;
|
||||
|
||||
if (direction == "rtl") {
|
||||
switch(keyCode) {
|
||||
case 0x25: // Left
|
||||
keyCode = 0x27;
|
||||
break;
|
||||
case 0x27: // Right
|
||||
keyCode = 0x25;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch(keyCode) {
|
||||
case 0x25: // Ctr+Left/Left
|
||||
if(event.ctrlKey) { lnk = lnk_first; } else { lnk = lnk_prev; }
|
||||
break;
|
||||
case 0x26: // Ctrl+Up
|
||||
if(event.ctrlKey) { lnk = lnk_parent; }
|
||||
break;
|
||||
case 0x27: // Ctrl+Right/Right
|
||||
if(event.ctrlKey) { lnk = lnk_last; } else { lnk = lnk_next; }
|
||||
break;
|
||||
}
|
||||
|
||||
if(lnk) {
|
||||
if(typeof clbk == 'function') {
|
||||
clbk();
|
||||
return false;
|
||||
} else {
|
||||
window.location = lnk;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
$(document).ready( function() {
|
||||
$(document).KbdNavigation({});
|
||||
if ($('#sb-content').is(':visible')) { return true; }
|
||||
});
|
3
modules/kbd_nav/module.info
Normal file
3
modules/kbd_nav/module.info
Normal file
|
@ -0,0 +1,3 @@
|
|||
name = "Kbd Navigation"
|
||||
description = "Adds keyboard navigation to the gallery.<br />Version 1.5 | By <a href=http://blog.dragonsoft.us>Serguei Dosyukov</a> | <a href=http://codex.gallery2.org/Gallery3:Modules:kbd_nav>Visit plugin Site</a> | <a href=http://gallery.menalto.com/node/95438>Support</a>"
|
||||
version = 5
|
Reference in New Issue
Block a user