]> wagnertech.de Git - mfinanz.git/blobdiff - js/kivi.ActionBar.js
ActionBar.js: Enter auf Comboboxes von Combobox bearbeiten lassen
[mfinanz.git] / js / kivi.ActionBar.js
index 17fd7f7bbcdf597f81bd379e04f3263b08d88d07..adc3eb380cc87f22ece42a1e7aa5648a4de5b377 100644 (file)
@@ -40,9 +40,27 @@ namespace('kivi', function(k){
       if (target === undefined) {
         target = 'document';
       }
+
+      var normalized = $.map(String.prototype.split.call(keystring, '+'), function(val, i) {
+        console.log(keystring)
+        switch (val) {
+          case 'ctrl':
+          case 'alt':  return val;
+          case 'enter': return 13;
+          default:
+            if (val.length == 1) {
+              return val.charChodeAt(0)
+            } else if (val % 1 === 0) {
+              return val;
+            } else {
+              console.log('can not normalize access key token: ' + val);
+            }
+        }
+      }).join('+');
+
       if (!(target in this.actions))
         this.actions[target] = {};
-      this.actions[target][keystring] = action;
+      this.actions[target][normalized] = action;
     },
 
     bind_targets: function(){
@@ -62,9 +80,12 @@ namespace('kivi', function(k){
       accesskey += e.which;
 
       // special case. HTML elements that make legitimate use of enter will also trigger the enter accesskey.
-      // so. if accesskey is '13' and the event source is one of these (currently only textarea) ignore it.
+      // so. if accesskey is '13' and the event source is one of these (currently only textareas & combo boxes) ignore it.
       // higher level widgets will usually prevent their key events from bubbling if used.
-      if (accesskey == 13 && e.target.tagName == 'TEXTAREA') return true;
+      if (   (accesskey == 13)
+          && (   (e.target.tagName == 'TEXTAREA')
+              || (e.target.tagName == 'SELECT')))
+        return true;
 
       if ((target in k.ActionBarAccesskeys.actions) && (accesskey in k.ActionBarAccesskeys.actions[target])) {
         e.stopPropagation();
@@ -85,6 +106,8 @@ namespace('kivi', function(k){
 
     if (data.disabled) {
       $(e).addClass(CLASSES.disabled);
+      if (!data.tooltip && (data.disabled != '1'))
+        data.tooltip = data.disabled;
     }
 
     if (data.accesskey) {
@@ -96,6 +119,10 @@ namespace('kivi', function(k){
       }
     }
 
+    if (data.tooltip) {
+      $(e).tooltipster({ content: data.tooltip, theme: 'tooltipster-light' });
+    }
+
     if (data.call || data.submit) {
       $(e).click(function(event) {
         var $hidden, key, func, check;