Fix dialog actions on Enter
[redakcja.git] / src / redakcja / static / js / wiki / base.js
index 1b031ca..3ee92c4 100644 (file)
             var self = this;
 
             /* bind buttons */
-            $('button[data-ui-action]', self.$elem).click(function(event) {
-                event.preventDefault();
-
+            function dataUiAction(elem) {
                 var action = $(this).attr('data-ui-action');
                 console.log("Button pressed, action: ", action);
 
                     if(action == 'cancel')
                         self.hide();
                 }
+            }
+            $('button[data-ui-action]', self.$elem).click(function(event) {
+                event.preventDefault();
+                dataUiAction(this);
+            }).on('keydown'), function(event) {
+                if (event.key == 'Enter') {
+                    event.preventDefault();
+                    dataUiAction(this);
+                }
             });
         }
 
                 var span = $("*[data-ui-error-for='"+field_name+"']", this.$elem);
 
                 if(!span.length) {
-                    unassigned.push(field_name);
+                    unassigned.push(errors[field_name]);
                     continue;
                 }
 
             }
 
             if(unassigned.length > 0)
-                global.text( global.text() + 'W formularzu wystąpiły błędy');
+                global.text(
+                    global.text() + 'Wystąpił błąd: ' + unassigned.join(', '));
         }
     }