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