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>
This commit is contained in:
Agustin Moyano 2019-05-08 23:41:43 -03:00 committed by Martin Renvoize
parent 00b71e8ea3
commit 9e91662ac7
Signed by: martin.renvoize
GPG key ID: 422B469130441A0F
24 changed files with 3725 additions and 0 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1 @@
.ui-keyboard-keyset .ui-keyboard-button{position:relative}.ui-keyboard-keyset-normal .ui-keyboard-button::after{content:attr(data-shift);font-size:.6em;color:#999;position:absolute;top:-1em;left:2px;z-index:200}.ui-keyboard-keyset-shift .ui-keyboard-button::after{content:attr(data-normal);font-size:.6em;color:#999;position:absolute;top:-1em;left:2px;z-index:200}.ui-keyboard-keyset-alt .ui-keyboard-button::after{content:attr(data-alt-shift);font-size:.6em;color:#999;position:absolute;top:-1em;left:2px;z-index:200}.ui-keyboard-keyset-alt-shift .ui-keyboard-button::after{content:attr(data-alt);font-size:.6em;color:#999;position:absolute;top:-1em;left:2px;z-index:200}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,2 @@
/*! 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())})}});

View file

@ -0,0 +1,2 @@
/*! jQuery UI Virtual Keyboard Virtual Caret v1.1.5 (beta) */
!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(b){"use strict";var h=b.keyboard;h.firefox=void 0!==window.mozInnerScreenX,b.extend(h.css,{caret:"ui-keyboard-caret",caretMirror:"ui-keyboard-mirror-div"}),b.fn.addCaret=function(e){var t={caretClass:"",charAttr:"data-character",charIndex:1,offsetX:0,offsetY:0,adjustHt:0};return this.each(function(){var f,i,o=h.events,u=b(this).data("keyboard");u&&(f=u.caret_options=b.extend({},t,e),i=u.caret_namespace=u.namespace+"caret",u.extensionNamespace.push(i),u.textareaCaretProperties=["direction","boxSizing","width","height","overflowX","overflowY","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","borderStyle","paddingTop","paddingRight","paddingBottom","paddingLeft","fontStyle","fontVariant","fontWeight","fontStretch","fontSize","fontSizeAdjust","lineHeight","fontFamily","textAlign","textTransform","textIndent","textDecoration","letterSpacing","wordSpacing","tabSize","MozTabSize"],u.caret_setup=function(){var e=h.css,t="keyup keypress mouseup mouseleave ".split(" ").join(i+" "),r="position:absolute;visibility:hidden;top:-9999em;left:-9999em;white-space:pre-wrap;z-index:-10;"+("INPUT"===u.preview.nodeName?"":"word-wrap:break-word;");u.$keyboard.find("."+e.caretMirror).remove(),u.caret_$div=b('<div class="'+e.caretMirror+'" style="'+r+'">').appendTo(u.$keyboard),u.$caret&&u.$caret.remove(),u.$caret=b('<div class="'+e.caret+" "+f.caretClass+'" style="position:absolute;">').insertAfter(u.$preview),u.$el.unbind(o.kbChange+i).bind(o.kbChange+i,function(){u.findCaretPos()}),u.$preview.unbind(t).bind(t,function(){u.findCaretPos()})},u.findCaretPos=function(){if(u.caret_$div){var t,r,e,i,o,n,a,s,d=u.preview,c=parseFloat(u.$preview.css("fontSize")),p="INPUT"===d.nodeName,l=u.caret_$div[0];t=l.style,r=window.getComputedStyle?getComputedStyle(d,null):d.currentStyle,i=h.caret(u.$preview),o=Math["ltr"===r.direction?"max":"min"](i.start,i.end),u.textareaCaretProperties.forEach(function(e){t[e]=r[e]}),h.firefox&&(t.width=parseInt(r.width,10)-2+"px",d.scrollHeight>parseInt(r.height,10)&&(t.overflowY="scroll")),t.width=parseInt(p?d.scrollWidth:r.width,10)+(p?2*c:0)+"px",l.textContent=d.value.substring(0,o),"INPUT"===d.nodeName&&(l.textContent=l.textContent.replace(/\x20/g," ")),(a=document.createElement("span")).textContent=d.value.substring(o)||"",l.appendChild(a),s=b(a).position(),i="center"===t.textAlign?c:0,u.caretPos={top:s.top+parseInt(r.borderTopWidth,10)+f.offsetY,left:s.left+parseInt(r.borderLeftWidth,10)+f.offsetX-i},e=parseInt(u.$caret.css("margin-top"),10),t=Math.round(c+2*e)+f.adjustHt,s=u.$preview.position(),u.$caret.css({top:s.top-d.scrollTop+u.caretPos.top-e,left:s.left-d.scrollLeft+u.caretPos.left,height:t}),n=d.value.substring(o,o+f.charIndex).replace(/\s/," ")||" ",u.$caret.attr(f.charAttr,n)}},u.$el.unbind(i).bind(o.kbBeforeVisible+i,function(){u.caret_setup()}).bind(o.kbVisible+i,function(){u.findCaretPos()}).bind(o.kbHidden+i,function(){var e="keyup keypress mouseup mouseleave ".split(" ").join(i+" ");u.$preview.unbind(e),u.$caret.remove(),u.$caret=null,u.caret_$div=null}),u.options.alwaysOpen&&u.isVisible()&&(u.caret_setup(),u.findCaretPos()))})}});

View file

@ -0,0 +1,2 @@
/*! jQuery UI Virtual Keyboard Extender v1.0.3 */
!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(o){"use strict";var s=o.keyboard;s.css.extender="ui-keyboard-extender",s.language.en.display.extender=" :toggle_numpad",s.layouts.numpad={normal:["{clear} / * -","7 8 9 +","4 5 6 %","1 2 3 =","0 {dec} {left} {right}"]},s.keyaction.extender=function(e){return e.extender_toggle(),!1},o.fn.addExtender=function(e){var n={layout:"numpad",showing:!1,reposition:!0};return this.each(function(){var t=o(this).data("keyboard");if(t){if(t.extender_options=o.extend({},n,t.extender_options,e),t.extender_namespace)return t.extender_layoutSwitcher();t.extender_namespace=t.namespace+"extender",t.extensionNamespace.push(t.extender_namespace),t.extender_layoutSwitcher=function(){t.extender_lastKeyset=t.last.keyset,t.extender_bindEvents(!1),t.$el.one(s.events.kbBeforeVisible,function(){t.shiftActive=t.extender_lastKeyset[0],t.altActive=t.extender_lastKeyset[1],t.metaActive=t.extender_lastKeyset[2],t.showKeySet(),t.extender_setup(),t.extender_bindEvents()}),t.redraw()},t.extender_bindEvents=function(e){var n=s.events.kbBeforeVisible+t.extender_namespace;t.$el.unbind(n),!1!==e&&t.$el.bind(n,function(){t.extender_setup()})},t.extender_setup=function(){var e,n=t.extender_options.layout;void 0===s.builtLayouts[n]&&t.buildKeyboard(n),(e=s.builtLayouts[n].$keyboard.find("."+s.css.keySet+"-normal").clone()).removeClass().removeAttr("name").addClass(s.css.extender).children("button").removeAttr("data-pos"),e[0].style.display=t.extender_options.showing?"inline-block":"none",t.$keyboard.find("div."+s.css.extender).remove(),t.$keyboard.append(e),t.extender_toggle(t.extender_options.showing),t.bindKeys()},t.extender_toggle=function(e){t.extender_options.showing=void 0===e?!t.extender_options.showing:e,t.$keyboard.find("button."+s.css.extender).toggleClass(t.options.css.buttonActive,t.extender_options.showing).end().find("div."+s.css.extender)[0].style.display=t.extender_options.showing?"inline-block":"none",t.extender_options.reposition&&o(window).trigger("resize")},t.options.alwaysOpen&&t.isVisible()&&t.extender_setup(),t.extender_bindEvents()}})}});

View file

@ -0,0 +1,2 @@
/*! jQuery UI Virtual Keyboard for jQuery Mobile Themes v1.4.1 */
!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(a){a.fn.addMobile=function(e){var n,t={container:{theme:"b",cssClass:"ui-body"},input:{theme:"b",cssClass:""},buttonMarkup:{theme:"b",cssClass:"ui-btn",shadow:"true",corners:"true"},buttonHover:{theme:"b",cssClass:"ui-btn-hover"},buttonAction:{theme:"b",cssClass:"ui-btn-active"},buttonActive:{theme:"b",cssClass:"ui-btn-active"},allThemes:"a b c"};return this.each(function(){var o=a(this).data("keyboard");o&&void 0!==a.fn.textinput&&(o.mobile_options=n=a.extend(!0,{},t,e),o.mobile_themes=a.trim((" "+n.allThemes).split(" ").join(" "+n.buttonMarkup.cssClass+"-")+(" "+n.allThemes).split(" ").join(" "+n.buttonAction.cssClass+"-")+(" "+n.allThemes).split(" ").join(" "+n.buttonActive.cssClass+"-")),void 0===o.options.mobile_savedActiveClass&&(o.options.mobile_savedActiveClass=""+o.options.css.buttonActive),o.mobile_init=function(){var e=o.namespace+"Mobile";a("."+a.keyboard.css.input).textinput(),o.options.alwaysOpen&&o.isVisible&&o.mobile_setup(),o.extensionNamespace.push(e),o.$el.unbind(e).bind(a.keyboard.events.kbBeforeVisible+e,function(){o&&o.el.active&&o.$keyboard.length&&o.$keyboard.css("visibility","hidden")}).bind(a.keyboard.events.kbVisible+e,function(){o&&o.el.active&&o.$keyboard.length&&(o.mobile_setup(),o.$keyboard.css("visibility","visible"),o.$preview.focus())})},o.mobile_setup=function(){var e,t=a.keyboard.css,s=o.options,i=o.mobile_themes;o.mobile_$actionKeys=o.$keyboard.find("."+o.options.css.buttonAction),s.css.buttonActive=s.mobile_savedActiveClass+" "+o.modOptions(n.buttonActive,n.buttonMarkup),o.$keyboard.addClass(o.modOptions(n.container,n.container)).find("."+t.preview).removeClass("ui-widget ui-widget-content").addClass(o.modOptions(n.input,n.input)).end().find("button").removeClass(a.trim("ui-corner-all ui-state-default "+i)).addClass(o.modOptions(n.buttonMarkup,n.buttonMarkup)).not(o.mobile_$actionKeys).hover(function(){a(this).removeClass(i).addClass(o.modOptions(n.buttonHover,n.buttonMarkup))},function(){a(this).removeClass(i+" "+n.buttonHover.cssClass).addClass(o.modOptions(n.buttonMarkup,n.buttonMarkup))}),o.mobile_$actionKeys.removeClass(i).addClass(o.modOptions(n.buttonAction,n.buttonMarkup)),o.msie&&o.$preview[0]!==o.el&&(o.$preview.hide(),o.$keyboard.css("width",""),o.width=o.$keyboard.outerWidth(),o.$keyboard.width(o.width+parseInt(o.$preview.css("fontSize"),10)),o.$preview.width(o.width),o.$preview.show()),a.ui&&a.ui.position&&((e=s.position).of=e.of||o.$el.data("keyboardPosition")||o.$el,e.collision=e.collision||"flipfit flipfit",o.$keyboard.position(e))},o.modOptions=function(e,t){return" "+(e.cssClass||"")+" "+(t&&t.cssClass?t.cssClass+"-"+(e.theme||""):"")+("true"==e.shadow?" ui-shadow":"")+("true"==e.corners?" ui-corner-all":"")},o.mobile_init())})}});

View file

@ -0,0 +1,2 @@
/*! 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)}))})}});

View file

@ -0,0 +1,2 @@
/*! jQuery UI Virtual Keyboard previewKeyset v1.1.1 */
!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(d){"use strict";d.keyboard=d.keyboard||{},d.fn.previewKeyset=function(n){return this.each(function(){var e=d(this).data("keyboard"),t=e.namespace+"Preview";e&&(e.previewKeyset_options=d.extend({},{sets:["normal","shift","alt","alt-shift"]},n),e.extensionNamespace.push(t),e.previewKeyset=function(){var a=d.keyboard.css,r=e.previewKeyset_options.sets,s=e.$keyboard.find("."+a.keySet).filter('[name="'+r.join('"],[name="')+'"]');1<s.length&&s.eq(0).find("."+a.keyButton).not("."+a.keyAction).each(function(){var e,t,n={},i=r.length,o=s.find('button[data-pos="'+d(this).attr("data-pos")+'"]');for(e=0;e<i;e++)t=o.eq(e).parent().attr("name"),0<=d.inArray(t,r)&&(n["data-"+t]=o.eq(e).find("."+a.keyText).text());o.attr(n)})},e.options.alwaysOpen&&e.isVisible()?e.previewKeyset():e.$el.unbind(d.keyboard.events.kbBeforeVisible+t).bind(d.keyboard.events.kbBeforeVisible+t,function(){e.previewKeyset()}))})}});

View file

@ -0,0 +1,2 @@
/*! jQuery UI Virtual Keyboard Scramble Extension v1.8.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(f){"use strict";f.keyboard=f.keyboard||{},f.fn.addScramble=function(e){var a={targetKeys:/[a-z\d]/i,byRow:!0,byKeySet:!1,randomizeOnce:!0,randomizeInput:!1,init:null,sameForAll:!1};return this.each(function(){var b,c=f(this).data("keyboard"),t=c.namespace+"Scramble",o=c.options;c&&!c.scramble_options&&(b=c.scramble_options=f.extend({},a,e),c.extensionNamespace.push(t),b.orig_create=o.create,c.scramble_setup=function(e){var t,o,a,n,r,i,u,y,d,s,l;if(t=e.find("."+f.keyboard.css.keySet),e.length){for(b.byKeySet&&(t=t.eq(0)),o=0;o<t.length;o++)if(a=t.eq(o),u=0,l=[],d=[],y=[],s=[],a.children("button, span, br").each(function(){"BR"===this.tagName?(b.byRow?(l.push(this),d.push(!1),s[u]=l,y[u]=d,l=[],d=[]):(s[u]=this,y[u]=!1),u++):(i=!(1!==(i=f(this).attr("data-value")||"").length||!b.targetKeys.test(i))&&i,b.byRow?(l.push(this),d.push(i)):(s[u]=this,y[u]=i,u++))}),a.find("."+f.keyboard.css.endRow).remove(),b.byRow)for(r=0;r<s.length;r++)for(l=c.shuffle(s[r],y[r]),n=0;n<l.length;n++)a.append(l[n]);else for(l=c.shuffle(s,y),n=0;n<l.length;n++)a.append(l[n]);return b.byKeySet&&(e=c.realign(e)),e}},c.getRandomUInt=function(e){var t=window.crypto||window.msCrypto;if(void 0===t)return Math.floor(Math.random()*e);var o=new Uint32Array(1);return t.getRandomValues(o),o[0]%e},c.shuffle=function(e,t){for(var o,a,n=e.length;0<n;)a=c.getRandomUInt(n),!1===t[n-1]&&n--,!1!==t[n-1]&&!1!==t[a]&&(o=e[--n],e[n]=e[a],e[a]=o);return e},c.realign=function(e){var o,a,n,r=e.find("."+f.keyboard.css.keySet),t=r.eq(0);return r=r.filter(":gt(0)"),t.children().each(function(e,t){a="BR"===t.tagName,n=f(t).attr("data-pos"),r.each(function(e,t){o=a?"br:first":'button[data-pos="'+n+'"]',f(t).find(o).appendTo(t)})}),e},c.setScrambleLayout=function(){if(!/^scrambled/.test(o.layout)){c.orig_layout=o.layout;var e=e||"scrambled"+Math.round(1e4*Math.random());o.layout=b.sameForAll?e:"scrambled"+Math.round(1e4*Math.random())}},o.create=function(){var e=o.layout;f.keyboard.builtLayouts[e]={mappedKeys:{},acceptedKeys:[],$keyboard:null},c.layout=o.layout=c.orig_layout,c.buildKeyboard(c.layout,!0),c.layout=o.layout=e,f.keyboard.builtLayouts[e]=f.extend(!0,{},f.keyboard.builtLayouts[c.orig_layout]),b.randomizeOnce&&(f.keyboard.builtLayouts[e].$keyboard=c.scramble_setup(f.keyboard.builtLayouts[c.orig_layout].$keyboard.clone())),c.$keyboard=f.keyboard.builtLayouts[e].$keyboard,b.randomizeInput?c.$el.unbind(f.keyboard.events.kbChange+t).bind(f.keyboard.events.kbChange+t,function(e,t){b.targetKeys.test(t.last.key)&&(t.$keyboard.find("."+o.css.buttonHover).removeClass(o.css.buttonHover),t.$keyboard=t.scramble_setup(t.$keyboard),f(document.elementFromPoint(e.clientX,e.clientY)).trigger("mouseenter"))}):b.randomizeOnce||c.$el.unbind(f.keyboard.events.kbBeforeVisible+t).bind(f.keyboard.events.kbBeforeVisible+t,function(e,t){t.$keyboard=t.scramble_setup(t.$keyboard)}),"function"==typeof b.orig_create&&b.orig_create(c)},c.setScrambleLayout(),o.alwaysOpen&&c.$keyboard.length?setTimeout(function(){var e=f.keyboard.builtLayouts;c.$keyboard=c.scramble_setup(c.$keyboard),c.setScrambleLayout(),void 0===e[o.layout]&&(e[o.layout]={mappedKeys:f.extend({},e[c.layout].mappedKeys),acceptedKeys:f.extend([],e[c.layout].acceptedKeys),$keyboard:c.$keyboard.clone()}),"function"==typeof b.init&&b.init(c)},0):"function"==typeof b.init&&b.init(c))})}});

View file

@ -0,0 +1,2 @@
/*! jQuery UI Virtual Keyboard Typing Simulator v1.12.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(p){p.fn.addTyping=function(e){var t={showTyping:!0,lockTypeIn:!1,delay:250,hoverDelay:250},f=p.keyboard;return this.each(function(){var g,l=p(this).data("keyboard");l&&(g=l.typing_options=p.extend({},t,e),l.typing_keymap={" ":"space",'"':"34","'":"39","&nbsp;":"space","\b":"bksp","{b}":"bksp","{d}":"del","{l}":"left","{r}":"right","\n":"enter","\r":"enter","{e}":"enter","\t":"tab","{t}":"tab"},l.typing_xref={8:"bksp",9:"tab",13:"enter",32:"space",37:"left",39:"right",46:"del"},l.typing_event=!1,l.typing_namespace=l.namespace+"typing",l.extensionNamespace.push(l.typing_namespace),g.savedLockInput=l.options.lockInput,l.typing_setup_reset=function(){var e=f.events,t=l.typing_namespace,n=[e.kbHidden,e.kbInactive,""].join(t+" ");l.$el.unbind(t).bind(n,function(){l.typing_reset()}),l.unbindButton(t).bindButton("mousedown"+t,function(){l.typing_reset()})},l.typing_setup=function(){var e=l.typing_namespace;l.typing_setup_reset(),l.$el.bind(f.events.kbBeforeVisible+e,function(){l.typing_setup()}),l.$preview.unbind(e).bind("keyup"+e,function(e){return!(g.init&&g.lockTypeIn||!g.showTyping)&&(37<=e.which&&e.which<=40?void 0:(16===e.which&&(l.shiftActive=!1),18===e.which&&(l.altActive=!1),16===e.which||18===e.which?(l.showSet(),void setTimeout(function(){l.$preview&&l.$preview.focus()},200)):void 0))}).bind("keydown"+e,function(e){if(g.init&&g.lockTypeIn||!g.showTyping)return!1;e.temp=!1,16===e.which&&(e.temp=!l.shiftActive,l.shiftActive=!0),18===e.which&&(e.temp=!l.altActive,l.altActive=!0),e.temp&&(l.showSet(),l.$preview.focus()),l.typing_event=!0,l.typing_xref[e.which]&&l.typing_findKey("",e)}).bind("keypress"+e,function(e){if(g.init&&g.lockTypeIn)return!1;l.typing_event&&!l.options.lockInput&&(l.typing_reset(),l.typing_event=!0,l.typing_findKey("",e))})},l.typing_reset=function(){l.typing_event=g.init=!1,g.text="",g.len=g.current=0,l.options.lockInput=g.savedLockInput},l.typeIn=function(e,t,n,i){if(!l.isVisible())return clearTimeout(l.typing_timer),void l.typing_reset();if(l.typing_event){if(void 0===e)return l.typing_event=!1,void(l.options.lockInput=g.savedLockInput)}else!0!==g.init&&(g.init=!0,l.options.lockInput=g.lockTypeIn,g.text=e||g.text||"",g.len=g.text.length,g.delay=t||g.delay,g.current=0,n&&(g.callback=n)),"{"===(e=g.text.substring(g.current,++g.current))&&"}"===g.text.substring(g.current+1,g.current+2)&&(e+=g.text.substring(g.current,g.current+=2)),l.typing_findKey(e,i)},l.typing_findKey=function(e,t){var n,i,p,y,s,o,r,a,c=f.css,u=f.builtLayouts[l.layout].mappedKeys;if(l.isOpen&&l.$keyboard.length)if(o=l.$keyboard.find("."+c.keySet),y=e in l.typing_keymap?l.typing_keymap[e]:e,n="."+c.keyButton+'[data-action="'+y+'"]',l.typing_event&&t&&(n="keypress"!==t.type&&l.typing_xref.hasOwnProperty(t.keyCode||t.which)?"."+c.keyPrefix+l.processName(l.typing_xref[t.keyCode||t.which]):(i=String.fromCharCode(t.charCode||t.which),u.hasOwnProperty(i)?"."+c.keyButton+'[data-value="'+u[i].replace(/"/g,'\\"')+'"]':"."+c.keyPrefix+l.processName(i))),(s=o.filter(":visible").find(n)).length?l.typing_simulateKey(s,e,t):(a=(s=l.typing_event?o.find(n):(p=e in l.typing_keymap?l.typing_keymap[e]:l.processName(e),o.find("."+c.keyPrefix+p))).closest("."+c.keySet)).attr("name")?(g.showTyping&&(r=a.attr("name"),l.shiftActive=/shift/.test(r),l.altActive=/alt/.test(r),l.metaActive=l.last.keyset[2]=!!/\bmeta/.test(r)&&r.match(/meta[\w-]+/)[0],l.showSet(l.metaActive)),l.typing_simulateKey(s,e,t)):l.typing_event||(e in l.typing_keymap&&l.typing_keymap[e]in f.keyaction?f.keyaction[l.typing_keymap[e]](l,s,t):l.insertText(e),l.checkCombos(),l.$el.trigger(f.events.kbChange,[l,l.el])),g.current<=g.len&&0!==g.len){if(!l.isVisible())return;l.typing_timer=setTimeout(function(){l.typeIn()},g.delay)}else{if(0!==g.len)return l.typing_reset(),void("function"==typeof g.callback&&(l.typing_timer=setTimeout(function(){"function"==typeof g.callback&&g.callback(l)},g.delay)));l.typing_reset()}},l.typing_simulateKey=function(e,t,n){var i=e.length;l.isVisible()&&(g.showTyping&&i&&(e.filter(":visible").trigger("mouseenter"+l.namespace),g.showTyping&&i&&setTimeout(function(){e.trigger("mouseleave"+l.namespace)},Math.min(g.hoverDelay,g.delay))),l.typing_event||setTimeout(function(){t in l.typing_keymap&&l.typing_keymap[t]in f.keyaction?((n=n||p.Event("keypress")).target=e,f.keyaction[l.typing_keymap[t]](l,e,n)):l.insertText(t),l.checkCombos(),l.$el.trigger(f.events.kbChange,[l,l.el])},g.delay/3))},g.showTyping&&l.options.alwaysOpen&&l.isVisible()?l.typing_setup():l.$el.unbind(f.events.kbBeforeVisible+l.typing_namespace).bind(f.events.kbBeforeVisible+l.typing_namespace,function(){g.showTyping?l.typing_setup():l.typing_setup_reset()}))})}});

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,2 @@
/*! Mousewheel version: 3.1.12 * (c) 2014 Brandon Aaron * MIT License */
!function(e){"function"==typeof define&&define.amd?define(["jquery"],e):"object"==typeof exports?module.exports=e:e(jQuery)}(function(d){var c,m,e=["wheel","mousewheel","DOMMouseScroll","MozMousePixelScroll"],t="onwheel"in document||9<=document.documentMode?["wheel"]:["mousewheel","DomMouseScroll","MozMousePixelScroll"],g=Array.prototype.slice;if(d.event.fixHooks)for(var i=e.length;i;)d.event.fixHooks[e[--i]]=d.event.mouseHooks;var w=d.event.special.mousewheel={version:"3.1.12",setup:function(){if(this.addEventListener)for(var e=t.length;e;)this.addEventListener(t[--e],n,!1);else this.onmousewheel=n;d.data(this,"mousewheel-line-height",w.getLineHeight(this)),d.data(this,"mousewheel-page-height",w.getPageHeight(this))},teardown:function(){if(this.removeEventListener)for(var e=t.length;e;)this.removeEventListener(t[--e],n,!1);else this.onmousewheel=null;d.removeData(this,"mousewheel-line-height"),d.removeData(this,"mousewheel-page-height")},getLineHeight:function(e){var t=d(e),i=t["offsetParent"in d.fn?"offsetParent":"parent"]();return i.length||(i=d("body")),parseInt(i.css("fontSize"),10)||parseInt(t.css("fontSize"),10)||16},getPageHeight:function(e){return d(e).height()},settings:{adjustOldDeltas:!0,normalizeOffset:!0}};function n(e){var t,i=e||window.event,n=g.call(arguments,1),o=0,l=0,s=0,a=0,h=0;if((e=d.event.fix(i)).type="mousewheel","detail"in i&&(s=-1*i.detail),"wheelDelta"in i&&(s=i.wheelDelta),"wheelDeltaY"in i&&(s=i.wheelDeltaY),"wheelDeltaX"in i&&(l=-1*i.wheelDeltaX),"axis"in i&&i.axis===i.HORIZONTAL_AXIS&&(l=-1*s,s=0),o=0===s?l:s,"deltaY"in i&&(o=s=-1*i.deltaY),"deltaX"in i&&(l=i.deltaX,0===s&&(o=-1*l)),0!==s||0!==l){if(1===i.deltaMode){var r=d.data(this,"mousewheel-line-height");o*=r,s*=r,l*=r}else if(2===i.deltaMode){var u=d.data(this,"mousewheel-page-height");o*=u,s*=u,l*=u}if(t=Math.max(Math.abs(s),Math.abs(l)),(!m||t<m)&&p(i,m=t)&&(m/=40),p(i,t)&&(o/=40,l/=40,s/=40),o=Math[1<=o?"floor":"ceil"](o/m),l=Math[1<=l?"floor":"ceil"](l/m),s=Math[1<=s?"floor":"ceil"](s/m),w.settings.normalizeOffset&&this.getBoundingClientRect){var f=this.getBoundingClientRect();a=e.clientX-f.left,h=e.clientY-f.top}return e.deltaX=l,e.deltaY=s,e.deltaFactor=m,e.offsetX=a,e.offsetY=h,e.deltaMode=0,n.unshift(e,o,l,s),c&&clearTimeout(c),c=setTimeout(v,200),(d.event.dispatch||d.event.handle).apply(this,n)}}function v(){m=null}function p(e,t){return w.settings.adjustOldDeltas&&"mousewheel"===e.type&&t%120==0}d.fn.extend({mousewheel:function(e){return e?this.bind("mousewheel",e):this.trigger("mousewheel")},unmousewheel:function(e){return this.unbind("mousewheel",e)}})});

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -241,6 +241,11 @@ define( [ 'marc-record', 'koha-backend', 'preferences', 'text-marc', 'widget' ],
cm.replaceRange( "‡", cur, null );
}
_editorKeys[toggle_keyboard] = function( cm ) {
let keyboard = $(cm.getInputField()).getkeyboard();
keyboard.isVisible()?keyboard.close():keyboard.reveal();
}
// The objects below are part of a field/subfield manipulation API, accessed through the base
// editor object.
//
@ -493,6 +498,79 @@ define( [ 'marc-record', 'koha-backend', 'preferences', 'text-marc', 'widget' ],
}
}
);
var inf = this.cm.getInputField();
var self = this;
var kb = $(inf).keyboard({
//keyBinding: "mousedown touchstart",
usePreview: false,
lockInput: false,
autoAccept: true,
autoAcceptOnEsc: true,
userClosed: true,
//alwaysOpen: true,
openOn : '',
position: {
of: $("#statusbar"), // optional - null (attach to input/textarea) or a jQuery object (attach elsewhere)
my: 'center top',
at: 'center bottom',
at2: 'center bottom' // used when "usePreview" is false (centers keyboard at bottom of the input/textarea)
},
beforeInsert: function(evnt, keyboard, elem, txt) {
var position = self.cm.getCursor();
if (txt === "\b") {
self.cm.execCommand("delCharBefore");
}
if (txt === "\b" && position.ch === 0 && position.line !== 0) {
elem.value = self.cm.getLine(position.line) || "";
txt = "";
}
return txt;
},
visible: function() {
$('#set-keyboard-layout').removeClass('hide');
},
hidden: function(e, keyboard, el, accepted) {
inf.focus();
$('#set-keyboard-layout').addClass('hide');
}
}).getkeyboard();
Object.keys($.keyboard.layouts).forEach(function(layout) {
var div = $('#keyboard-layout .layouts').append('<div class="layout" data-layout="'+layout+'" data-name="'+($.keyboard.layouts[layout].name||layout)+'" >'+($.keyboard.layouts[layout].name||layout)+'</div>')
if(kb.layout == layout) {
div.addClass('active');
}
});
$('#keyboard-layout')
.on('show.bs.modal', function() {
kb.close();
$('#keyboard-layout .filter').focus();
$('#set-keyboard-layout').removeClass('hide');
})
.on('hide.bs.modal', function() {
!kb.isVisible() && kb.reveal();
});
$('#keyboard-layout .layout').click(function(event) {
$('#keyboard-layout .layout').removeClass('active');
$(this).addClass('active');
var layout = $(this).data().layout;
kb.redraw(layout);
$('#keyboard-layout').modal('hide');
$('#keyboard-layout .filter').val('');
$('#keyboard-layout .layout').show();
});
$('#keyboard-layout .filter').keyup(function() {
var val = $(this).val();
if(!val||!val.length) return $('#keyboard-layout .layout').show();
var filter = new RegExp(val, 'i');
$('#keyboard-layout .layout').hide();
$('#keyboard-layout .layout').each(function() {
var name = $(this).data().name;
if(filter.test(name)) $(this).show();
})
});
this.cm.marceditor = this;
this.cm.on( 'beforeChange', editorBeforeChange );

View file

@ -461,4 +461,16 @@ body {
border-radius: 6px 6px 0 0;
margin-bottom: -32px;
}
}
#keyboard-layout .layouts {
column-count: 2;
}
#keyboard-layout .layouts > div {
cursor: pointer;
}
.ui-keyboard-accept {
display: none;
}

View file

@ -2,6 +2,10 @@
[% USE Koha %]
[% Asset.js("lib/codemirror/codemirror-compressed.js") | $raw %]
[% Asset.js("lib/filesaver.js") | $raw %]
[% Asset.css("lib/keyboard/css/keyboard.min.css") | $raw %]
[% Asset.js("lib/keyboard/js/jquery.keyboard.js") | $raw %]
[% Asset.js("lib/keyboard/languages/all.min.js") | $raw %]
[% Asset.js("lib/keyboard/layouts/all.min.js") | $raw %]
[% Asset.js("lib/koha/cateditor/marc-mode.js") | $raw %]
[% Asset.js("lib/require.js") | $raw %]
<script>

View file

@ -11,5 +11,6 @@
[%- CASE 'line_break' -%]<span>Insert line break</span>
[%- CASE 'next_position' -%]<span>Move to next position</span>
[%- CASE 'prev_position' -%]<span>Move to previous position</span>
[%- CASE 'toggle_keyboard' -%]<span>Toggle Keyboard</span>
[%- END -%]
[%- END -%]

View file

@ -79,6 +79,7 @@
</div>
<button class="btn btn-default" id="show-alerts" title="Previous alerts"><i class="fa fa-bell"></i> Alerts <span class="caret"></span></button>
<button class="btn btn-default" id="show-shortcuts" title="Supported keyboard shortcuts"><i class="fa fa-keyboard-o"></i> Keyboard shortcuts <span class="caret"></span></button>
<button class="btn btn-default hide" id="set-keyboard-layout" data-target="#keyboard-layout" data-toggle="modal" title="Set virtual keyboard layout"><i class="fa fa-keyboard-o"></i> Keyboard layout </button>
</div>
[%# CodeMirror instance will be inserted here %]
<div id="statusbar">
@ -268,6 +269,25 @@
</div>
</div>
<div id="keyboard-layout" class="modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="closebtn" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title">Set virtual keyboard layout</h4>
</div>
<div class="modal-body">
<div class="form-group">
<label for="exampleInputEmail1">Filter layouts</label>
<input type="search" class="form-control filter"/>
</div>
<hr/>
<div class="layouts"></div>
</div>
</div>
</div>
</div>
<div id="shortcuts-contents" style="display: none">
[% IF ( CAN_user_parameters_manage_keyboard_shortcuts ) %]
<a id="redefine_shortcuts" href="/cgi-bin/koha/admin/adveditorshortcuts.pl">Redefine shortcuts</a>