Koha/koha-tmpl/intranet-tmpl/lib/keyboard/js/jquery.keyboard.extension-autocomplete.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.2 KiB
JavaScript

/*! jQuery UI Virtual Keyboard Autocomplete v1.11.4 */
!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(c){"use strict";c.fn.addAutocomplete=function(l){var u={position:{of:null,my:"right top",at:"left top",collision:"flip"},events:"autocomplete",data:""};return this.each(function(){var t,o,a=c(this).data("keyboard");a&&(o=a.namespace+"Autocomplete",a.autocomplete_namespace=o,a.extensionNamespace.push(o),a.autocomplete_init=function(){var e=(t=a.autocomplete_options=c.extend(!0,{},u,l)).events||t.data||"autocomplete";a.options.alwaysOpen&&a.isVisible()&&a.autocomplete_setup(),a.$el.unbind(o).bind(c.keyboard.events.kbVisible+o,function(){a.autocomplete_setup()}).bind(c.keyboard.events.kbHidden+o,function(){a.$el[t.data||"autocomplete"]("close")}).bind(c.keyboard.events.kbChange+o,function(){a.hasAutocomplete&&a.isVisible()&&a.$el.val(a.$preview.val())}).bind(e+"open"+o,function(){if(a.hasAutocomplete){var e=c.extend({},t.position);e.of=e.of||a.$keyboard,a.$autocomplete.menu.element.position(e)}}).bind(e+"select"+o,function(e,t){a.autocomplete_getVal(t.item)})},a.autocomplete_getVal=function(e){var t;switch(typeof e){case"string":t=e||"";break;case"object":t=e.label||e.value||"";break;default:t=a.preview&&a.preview.value||a.el.value}t=t.toString(),a.hasAutocomplete&&""!==t&&((a.$preview||a.$el).val(t).focus(),a.last.start=t.length,a.last.end=t.length,a.last.val=t)},a.autocomplete_update=function(e){clearTimeout(a.$autocomplete.searching),a.$autocomplete.searching=setTimeout(function(){a.$autocomplete.term!==a.$autocomplete.element.val()&&(a.$autocomplete.selectedItem=null,a.$autocomplete.search(null,e))},a.$autocomplete.options.delay)},a.autocomplete_navKeys={8:"backSpace",9:"tab",13:"enter",20:"capsLock",27:"escape",32:"space",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"insert",46:"delete"},a.autocomplete_setup=function(){var t;if(a.$autocomplete=a.$el.data(a.autocomplete_options.data)||a.$el.data("uiAutocomplete")||a.$el.data("ui-autocomplete")||a.$el.data("autocomplete"),a.hasAutocomplete=void 0!==a.$autocomplete&&!a.$autocomplete.options.disabled,a.hasAutocomplete){a.$preview.bind("keydown"+o+" keypress"+o,function(e){a.$preview&&e.namespace!==a.$autocomplete.eventNamespace&&(e.namespace=a.$autocomplete.eventNamespace.slice(1),(t=a.autocomplete_navKeys[e.which])?a.el!==a.preview&&(a.$el.triggerHandler(e),"enter"===t&&setTimeout(function(){a.$autocomplete&&(a.$preview.val(a.$autocomplete.selectedItem.value),a.$preview.focus())},100)):a.autocomplete_update(e))});var e="mouseup mousedown mouseleave touchstart touchend touchcancel ".split(" ").join(o+" ");a.bindButton(e,function(e){a.autocomplete_update(e)})}a.escCloseCallback.autocomplete||(a.escCloseCallback.autocomplete=a.checkAutocompleteMenu)},a.checkAutocompleteMenu=function(e){return a.hasAutocomplete&&e.closest("ul").hasClass("ui-autocomplete")},a.autocomplete_destroy=function(){clearTimeout(a.$autocomplete.searching),a.hasAutocomplete=!1,a.$el.unbind(o),a.$preview&&(a.$preview.unbind(o),a.unbindButton(o)),delete a.$autocomplete},a.autocomplete_init())})}});