Skip to content

Commit

Permalink
Empty buttons class name return & can now include set widths. Fixes #244
Browse files Browse the repository at this point in the history
  • Loading branch information
Mottie committed Mar 6, 2014
1 parent 3e4641a commit 9f9157a
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions js/jquery.keyboard.js
Expand Up @@ -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('<span>' + n + '</span>')
.appendTo(base.temp[0]);
};
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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 ***
Expand Down

0 comments on commit 9f9157a

Please sign in to comment.