Koha/koha-tmpl/intranet-tmpl/lib/keyboard/js/jquery.keyboard.extension-navigation.min.js
Agustin Moyano 9e91662ac7
Bug 17178: Add virtual keyboard to advanced cataloguing editor
This patch adds Mottie keyboard (https://github.com/Mottie/Keyboard) to advanced editor.

To test:
1) Apply patches
2) perl install/data/mysql/updatedatabase.pl
3) Enable EnableAdvancedCatalogingEditor system preference
4) Go to cataloguing and to Advanced editor
5) Click on Keyboard shortcuts
SUCCESS => the keyboard shortcut "Ctrl-K" should be displayed, with "Toggle keyboard" as description
6) press Ctrl-K
SUCCESS => a virtual keyboard should be displayed, and a new toolbar button labeled "Keyboard layout" should appear.
	=> when you press a letter on both the physical and virtual keyboard, they should be added to the editor.
7) Click on "Keyboard layout"
SUCCESS => a modal should appear, where you can filter and select keyboard layouts.
	=> when you select a layout, it should be reflected on the keyboard.
	=> when you close the modal without selecting a layout, it should keep using the previous layout.
8) Sign off

Sponsored-by: Round Rock Public Library

Signed-off-by: Liz Rea <wizzyrea@gmail.com>
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
2019-06-28 15:54:33 +01:00

2 lines
No EOL
3.9 KiB
JavaScript

/*! jQuery UI Virtual Keyboard Navigation v1.7.0 */
!function(e){"function"==typeof define&&define.amd?define(["jquery"],e):"object"==typeof module&&"object"==typeof module.exports?module.exports=e(require("jquery")):e(jQuery)}(function(u){"use strict";u.keyboard=u.keyboard||{},u.keyboard.navigationKeys={toggle:112,enter:13,pageup:33,pagedown:34,end:35,home:36,left:37,up:38,right:39,down:40,caretrt:45,caretlt:46,caretright:function(e){u.keyboard.keyaction.right(e)},caretleft:function(e){u.keyboard.keyaction.left(e)}},u.fn.addNavigation=function(t){return this.each(function(){var c,e,v=u(this).data("keyboard"),y=v.options,n=u.keyboard.events,l=u.keyboard.css;v&&(v.navigation_options=c=u.extend({},{position:[0,0],toggleMode:!1,focusClass:"hasFocus",toggleKey:null,rowLooping:!1},t),v.navigation_keys=e=u.extend({},u.keyboard.navigationKeys),v.navigation_namespace=v.namespace+"Nav",v.extensionNamespace.push(v.navigation_namespace),v.saveNav=[v.options.tabNavigation,v.options.enterNavigation],v.allNavKeys=u.map(e,function(e){return e}),v.navigation_init=function(){v.$keyboard.toggleClass(c.focusClass,c.toggleMode).find("."+l.keySet+":visible").find("."+l.keyButton+'[data-pos="'+c.position[0]+","+c.position[1]+'"]').addClass(y.css.buttonHover),v.$preview.unbind(v.navigation_namespace).bind("keydown"+v.navigation_namespace,function(e){return v.checkKeys(e.which)})},v.checkKeys=function(e,t){if(void 0!==e&&v.isVisible()){var a=v.navigation_keys;return(e===(c.toggleKey||a.toggle)||t)&&(c.toggleMode=!t&&!c.toggleMode,v.options.tabNavigation=!c.toggleMode&&v.saveNav[0],v.options.enterNavigation=!c.toggleMode&&v.saveNav[1]),v.$keyboard.toggleClass(c.focusClass,c.toggleMode),c.toggleMode&&e===a.enter?(v.$keyboard.find("."+l.keySet+":visible").find("."+l.keyButton+'[data-pos="'+c.position[0]+","+c.position[1]+'"]').trigger(n.kbRepeater),!1):c.toggleMode&&0<=u.inArray(e,v.allNavKeys)?(v.navigateKeys(e),!1):void 0}},v.getMaxIndex=function(e,t){return e.find("."+l.keyButton+'[data-pos^="'+t+',"]').length-1},v.leftNavigateKey=function(e,t){var a=v.navigation_options.rowLooping,n=e-1;return 0<=n?n:a?t:0},v.rightNavigateKey=function(e,t){var a=v.navigation_options.rowLooping,n=e+1;return n<=t?n:a?0:t},v.navigateKeys=function(e,t,a){if(v.isVisible()){a="number"==typeof a?a:c.position[1],t="number"==typeof t?t:c.position[0];var n,o=v.$keyboard.find("."+l.keySet+":visible"),i=o.find("."+l.endRow).length-1,s=v.getMaxIndex(o,t),r=v.last,g=v.$preview.val().length,d=v.navigation_keys;switch(e){case d.pageup:t=0;break;case d.pagedown:t=i;break;case d.end:a=s;break;case d.home:a=0;break;case d.left:a=v.leftNavigateKey(a,s);break;case d.up:t+=0<t?-1:0,n=v.getMaxIndex(o,t),a=a===s?n:a;break;case d.right:a=v.rightNavigateKey(a,s);break;case d.down:t+=i<t+1?0:1,n=v.getMaxIndex(o,t),a=a===s?n:a;break;case d.caretrt:r.start++;break;case d.caretlt:r.start--}e!==d.caretrt&&e!==d.caretlt||(r.start=r.start<0?0:r.start>g?g:r.start,v.last.start=v.last.end=r.end=r.start,u.keyboard.caret(v.$preview,v.last)),(s=v.getMaxIndex(o,t))<a&&(a=s),o.find("."+y.css.buttonHover).removeClass(y.css.buttonHover),o.find("."+l.keyButton+'[data-pos="'+t+","+a+'"]').addClass(y.css.buttonHover),c.position=[t,a]}},v.options.alwaysOpen&&v.isVisible()&&(v.$keyboard.find("."+y.css.buttonHover).removeClass(y.css.buttonHover),v.navigation_init()),v.$el.unbind(v.navigation_namespace).bind(n.kbVisible,function(){v.$keyboard.find("."+y.css.buttonHover).removeClass(y.css.buttonHover),v.navigation_init()}).bind(n.kbInactive+" "+n.kbHidden,function(e){v.checkKeys(e.which,!0)}).bind(n.kbKeysetChange,function(){v.navigateKeys(null)}).bind("navigate navigateTo",function(e,t,a){var n;(t=isNaN(t)?t.toLowerCase():t)in v.navigation_keys?(n=v.navigation_keys[t],isNaN(n)&&n in u.keyboard.keyaction?u.keyboard.keyaction[n](v,this,e):"function"==typeof n?n(v):v.checkKeys(n)):"string"==typeof t&&t in u.keyboard.keyaction?u.keyboard.keyaction[t](v,this,e):v.navigateKeys(null,t,a)}))})}});