Koha/koha-tmpl/intranet-tmpl/lib/keyboard/js/jquery.keyboard.extension-altkeyspopup.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
5.9 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*! jQuery UI Virtual Keyboard Alt Key Popup v2.0.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(k){"use strict";var b=k.keyboard;k.extend(b.css,{altKeyPopup:"ui-keyboard-popup",altKeyOverlay:"ui-keyboard-overlay",altKeyPopupOpen:"ui-keyboard-popup-open"}),b.altKeys=k.extend({a:"å æ ā ă ą à á â ã ä",A:"Å Æ Ā Ă Ą À Á  à Ä",c:"ç ć ĉ ċ č",C:"Ç Ć Ĉ Ċ Č",d:"ď ð ď",D:"Ď Ð Ď",e:"ė ę ĕ ě ə è é ê ë ē",E:"Ė Ę Ĕ Ě Ǝ È É Ê Ë Ē",g:"ģ ğ ĝ ġ",G:"Ģ Ğ Ĝ Ġ",h:"ĥ ħ",H:"Ĥ Ħ",i:"ı į ī ï î í ì ĩ ĭ",I:"İ Į Ī Ï Î Í Ì Ĩ Ĭ",j:"ĵ",J:"Ĵ",k:"ķ",K:"Ķ",l:"Ł Ľ Ļ Ĺ Ŀ",L:"ł ľ ļ ĺ ŀ",n:"ʼn ň ņ ń ñ",N:"ʼn Ň Ņ Ń Ñ",o:"œ ő ø ö õ ô ó ò ō ŏ",O:"Œ Ő Ø Ö Õ Ô Ó Ò Ō Ŏ",r:"ŕ ř ŗ",R:"Ŕ Ř Ŗ",s:"ś š ş ß § ŝ",S:"Ś Š Ş ẞ § Ŝ",t:"þ ť ț ţ ŧ",T:"Þ Ť Ț Ţ Ŧ",u:"ų ű ů ū ü û ú ù ũ ŭ",U:"Ų Ű Ů Ū Ü Û Ú Ù Ũ Ŭ",w:"ŵ",W:"Ŵ",y:"ý",Y:"Ý",z:"ź ż ž",Z:"Ź Ż Ž","!":"¡",$:"€ £ ¤ ¥ ¢ ₡ ₱ ₩ ₹ ₪ ₭ ₮ ₦ ₤","?":"¿","'":"〈 「 『 “",'"':"〉 」 』 ”","(":"《 【 ",")":"》 】 "},b.altKeys),k.fn.addAltKeyPopup=function(e){var p={holdTime:500,popupVisible:"popup-visible",popupHidden:"popup-hidden",popupPosition:null};return this.each(function(){var d=k(this).data("keyboard");if(d){if(d.altkeypopup_options=k.extend({},p,d.altkeypopup_options,e),d.altkeypopup_namespace)return d.altkeypopup_setup();d.altkeypopup_namespace=d.namespace+"AltKeyPopup",d.extensionNamespace.push(d.altkeypopup_namespace),d.altkeypopup_setup=function(){var n,e="mousedown touchstart ".split(" ").join(d.altkeypopup_namespace+" "),p="mouseup touchend touchcancel ".split(" ").join(d.altkeypopup_namespace+" ");d.options.repeatRate=0,d.unbindButton(d.altkeypopup_namespace).bindButton(e,function(){clearTimeout(n);var e=k(this),p=e.attr("data-value")||"",o=d.altkeypopup_options.holdTime;p in b.altKeys&&(o?n=setTimeout(function(){d.altKeyPopup_popup(p,e)},o):d.altKeyPopup_popup(p,e))}).bindButton(p,function(){clearTimeout(n)}),d.altkeypopup_blockingFlag=!1,d.$preview.unbind("keypress keydown keyup ".split(" ").join(d.altkeypopup_namespace+" ").trim()).bind("keypress keydown keyup ".split(" ").join(d.altkeypopup_namespace+" "),function(e){if("keyup"===e.type)return clearTimeout(n),d.altkeypopup_blockingFlag=!1,"Escape"!==e.key;var p=b.builtLayouts[d.layout],o=k(e.target),t=e.key,a=e.key;return"keydown"===e.type&&a in b.altKeys?d.altkeypopup_blockingFlag!==t&&(d.altkeypopup_blockingFlag=t,!0):d.altkeypopup_blockingFlag?(p.hasMappedKeys&&p.mappedKeys.hasOwnProperty(a)&&(a=p.mappedKeys[a]),a in b.altKeys&&(clearTimeout(n),n=setTimeout(function(){d.altkeypopup_blockingFlag===t&&d.altKeyPopup_popup(a,o)},d.altkeypopup_options.holdTime)),!0):void 0})},d.altKeyPopup_close=function(){d.altkeypopup_blockingFlag=!1,d.altKeyPopup_$overlay=null,setTimeout(function(){if(d.$keyboard.length){d.$keyboard.removeClass(b.css.altKeyPopupOpen);var e=d.$keyboard.find("."+b.css.altKeyOverlay);e&&e.remove()}},1),k(document).unbind(d.altkeypopup_namespace),d.$preview.focus(),d.options.ignoreEsc=d.altKeyPopup_savedIgnoreEsc,d.$el.trigger(d.altkeypopup_options.popupHidden,[d])},d.altKeyPopup_popup=function(e,p){if(!d.$keyboard.find("."+b.css.altKeyOverlay).length){var o,t,a,n,i,u,s,l,y,r=b.css,c={$kb:d.$keyboard,kbWidth:d.$keyboard.outerWidth(),kbHeight:d.$keyboard.outerHeight(),$key:p};d.altKeyPopup_$overlay=k('<div class="'+r.altKeyOverlay+'" />').css({width:c.kbWidth,height:c.kbHeight}).appendTo(d.$keyboard).bind("click touchstart",function(){d.altKeyPopup_close()}),y="inactive hidden ".split(" ").join(d.altkeypopup_namespace+" "),d.$keyboard.addClass(b.css.altKeyPopupOpen),d.$el.unbind(y).bind(y,function(){d.altKeyPopup_close()}),"bksp"!==e&&b.keyaction.bksp(d),t=k('<div class="'+r.altKeyPopup+" "+d.options.css.container+'" />'),o=b.altKeys[e].split(/\s+/),d.buildRow(t,0,o,[]),a=t.appendTo(d.altKeyPopup_$overlay).children().bind("mousedown touchstart",function(){d.altKeyPopup_close()}).bind("mouseover mouseleave",function(e){a.removeClass(d.options.css.buttonHover),"mouseleave"!==e.type&&k(this).addClass(d.options.css.buttonHover)}),d.altKeyPopup_navigate(!0),d.altKeyPopup_savedIgnoreEsc=d.options.ignoreEsc,d.options.ignoreEsc=!0,k(document).unbind(d.altkeypopup_namespace).bind("keydown"+d.altkeypopup_namespace,function(){return!1}).bind("keyup"+d.altkeypopup_namespace,function(e){return"Escape"===e.key?(e.which=0,d.altKeyPopup_close()):d.altKeyPopup_navigate(e),!1}),s=(c.$popup=t).outerWidth(),(n=p.position().left-s/2)+s>c.kbWidth&&(n=c.kbWidth-s)<0&&t.css({width:c.kbWidth,height:"auto"}),i=p.position().top-p.outerHeight()-5,l=t.outerHeight(),u=d.$keyboard.find("."+r.keySet).position().top,i+l>c.kbHeight&&(i=c.kbHeight-l)<u&&t.css({height:c.popupHeight,width:"auto"}),c.popupWidth=t.outerWidth(),c.popupHeight=t.outerHeight(),c.popupLeft=n<0?0:n,c.popupTop=i<u?u:i,t.css({position:"absolute",left:c.popupLeft,top:c.popupTop}),"function"==typeof d.altkeypopup_options.popupPosition&&d.altkeypopup_options.popupPosition(d,c),d.$preview.blur(),d.$el.trigger(d.altkeypopup_options.popupVisible,[d])}},d.altKeyPopup_navigate=function(e){var p,o=b.css,t=(b.navigationKeys,d.options.css.buttonHover),a=d.$keyboard.find("."+o.altKeyPopup).find("."+o.keyButton),n=a.length-1;if(!0===e)return a.eq(0).addClass(t),void(d.altKeyPopup_currentIndex=0);if(p=d.altKeyPopup_currentIndex,"Enter"===e.key)return d.insertText(a.eq(p).attr("data-value")),d.altKeyPopup_close(),!0;switch(e.key){case"End":p=n;break;case"Home":p=0;break;case"ArrowLeft":p-=1;break;case"ArrowRight":p+=1}p<0&&(p=0),n<p&&(p=n),d.altKeyPopup_currentIndex=p,a.removeClass(t).eq(p).addClass(t)},d.options.alwaysOpen&&d.isVisible()&&d.altkeypopup_setup(),d.$el.unbind(b.events.kbBeforeVisible+d.altkeypopup_namespace).bind(b.events.kbBeforeVisible+d.altkeypopup_namespace,function(){d.altkeypopup_setup()})}})}});