From 9f9157a66dcf51039c891e6461881a51a439ff8f Mon Sep 17 00:00:00 2001 From: Mottie Date: Thu, 6 Mar 2014 06:01:54 -0600 Subject: [PATCH] Empty buttons class name return & can now include set widths. Fixes #244 --- js/jquery.keyboard.js | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/js/jquery.keyboard.js b/js/jquery.keyboard.js index 8d17ba3a..3e8afa98 100644 --- a/js/jquery.keyboard.js +++ b/js/jquery.keyboard.js @@ -1016,7 +1016,7 @@ $.keyboard = function(el, options){ // add "ui-keyboard-" + unicode of 1st character // (e.g. "~" is a regular key, class = 'ui-keyboard-126' // (126 is the unicode value - same as typing ~) - .addClass('ui-keyboard-' + kn + keyType + ' ' + o.css.buttonDefault) + .addClass( (kn === '' ? '' : 'ui-keyboard-' + kn + keyType + ' ') + o.css.buttonDefault) .html('' + n + '') .appendTo(base.temp[0]); }; @@ -1120,6 +1120,19 @@ $.keyboard = function(el, options){ .appendTo(newSet); } + // add empty button + if (/^empty(:((\d+)?([\.|,]\d+)?)(em|px)?)?$/.test(action)) { + margin = (/:/.test(action)) ? parseFloat( action + .replace(/,/,'.') + .match(/^empty:((\d+)?([\.|,]\d+)?)(em|px)?$/)[1] || 0 + ) : ''; + base + .addKey('', ' ') + .addClass(o.css.buttonDisabled + ' ' + o.css.buttonEmpty) + .attr('aria-disabled', true) + .width( margin ? (action.match('px') ? margin + 'px' : (margin * 2) + 'em') : '' ); + } + // meta keys if (/^meta\d+\:?(\w+)?/.test(action)){ base.addKey(action, action); @@ -1174,13 +1187,6 @@ $.keyboard = function(el, options){ .addClass(o.css.buttonAction); break; - case 'empty': - base - .addKey('', ' ') - .addClass(o.css.buttonDisabled) - .attr('aria-disabled', true); - break; - case 's': case 'shift': base.addKey('shift', action); @@ -1538,7 +1544,8 @@ $.keyboard = function(el, options){ // Action keys (e.g. Accept, Cancel, Tab, etc); this replaces "actionClass" option buttonAction : 'ui-state-active', // used when disabling the decimal button {dec} when a decimal exists in the input area - buttonDisabled : 'ui-state-disabled' + buttonDisabled : 'ui-state-disabled', + buttonEmpty : 'ui-keyboard-empty' }, // *** Useability ***