ActionBar: alte Funktionen zum E-Mail-Versand entfernt
[kivitendo-erp.git] / js / kivi.ActionBar.js
index 597b485..1d90bd6 100644 (file)
@@ -7,24 +7,31 @@ namespace('kivi', function(k){
     disabled: 'layout-actionbar-action-disabled',
     action:   'layout-actionbar-action',
     combobox: 'layout-actionbar-combobox',
-  }
+  };
 
   k.ActionBarCombobox = function(e) {
-    this.combobox = e;
-    this.head     = e.childNodes[0];
-    this.toggle   = this.head.childNodes[1];
-    this.list     = e.childNodes[0];
+    this.combobox  = e;
+    this.head      = e.childNodes[0];
+    this.topAction = this.head.childNodes[0];
+    this.toggle    = this.head.childNodes[1];
+    this.list      = e.childNodes[0];
     this.init();
-  }
+  };
 
   k.ActionBarCombobox.prototype = {
     init: function() {
-      var obj = this;
-      $(obj.toggle).on('click', function(event){
+      var obj     = this;
+      var toggler = function(event){
         $('div.' + CLASSES.combobox + '[id!=' + obj.combobox.id + ']').removeClass(CLASSES.active);
         $(obj.combobox).toggleClass(CLASSES.active);
         event.stopPropagation();
-      });
+      };
+
+      $(obj.toggle).on('click', toggler);
+
+      var data = $(this.topAction).data('action') || {};
+      if (!data.call && !data.submit)
+        $(this.topAction).on('click', toggler);
     }
   };
 
@@ -42,7 +49,6 @@ namespace('kivi', function(k){
       }
 
       var normalized = $.map(String.prototype.split.call(keystring, '+'), function(val, i) {
-        console.log(keystring)
         switch (val) {
           case 'ctrl':
           case 'alt':  return val;
@@ -80,9 +86,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();
@@ -103,6 +112,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) {
@@ -118,7 +129,7 @@ namespace('kivi', function(k){
       $(e).tooltipster({ content: data.tooltip, theme: 'tooltipster-light' });
     }
 
-    if (data.call || data.submit) {
+    if (data.call || data.submit || data.link) {
       $(e).click(function(event) {
         var $hidden, key, func, check;
         if ($(e).hasClass(CLASSES.disabled)) {
@@ -149,9 +160,12 @@ namespace('kivi', function(k){
           }
           $(form).submit();
         }
+        if (data.link) {
+          window.location.href = data.link;
+        }
       });
     }
-  }
+  };
 });
 
 $(function(){