ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ja...@apache.org
Subject git commit: AMBARI-7728 Dialog overlays do not receive keyboard focus (apenniston via jaoki)
Date Sat, 25 Oct 2014 01:05:10 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 33ed5921d -> ad9b02b15


AMBARI-7728 Dialog overlays do not receive keyboard focus (apenniston via jaoki)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/ad9b02b1
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/ad9b02b1
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/ad9b02b1

Branch: refs/heads/trunk
Commit: ad9b02b155d3b1e7f9a47b20a5dc4328fe016081
Parents: 33ed592
Author: Jun Aoki <jaoki@apache.org>
Authored: Fri Oct 24 18:04:46 2014 -0700
Committer: Jun Aoki <jaoki@apache.org>
Committed: Fri Oct 24 18:04:46 2014 -0700

----------------------------------------------------------------------
 ambari-web/app/assets/test/tests.js             |  1 +
 ambari-web/app/views/common/modal_popup.js      | 21 ++++++---
 .../test/views/common/modal_popup_test.js       | 46 ++++++++++++++++++++
 3 files changed, 62 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/ad9b02b1/ambari-web/app/assets/test/tests.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/assets/test/tests.js b/ambari-web/app/assets/test/tests.js
index ed515cb..3061733 100644
--- a/ambari-web/app/assets/test/tests.js
+++ b/ambari-web/app/assets/test/tests.js
@@ -140,6 +140,7 @@ var files = ['test/init_model_test',
   'test/views/common/table_view_test',
   'test/views/common/quick_link_view_test',
   'test/views/common/rolling_restart_view_test',
+  'test/views/common/modal_popup_test',
   'test/views/common/configs/config_history_flow_test',
   'test/views/main/dashboard_test',
   'test/views/main/menu_test',

http://git-wip-us.apache.org/repos/asf/ambari/blob/ad9b02b1/ambari-web/app/views/common/modal_popup.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/modal_popup.js b/ambari-web/app/views/common/modal_popup.js
index 223a77a..78c9387 100644
--- a/ambari-web/app/views/common/modal_popup.js
+++ b/ambari-web/app/views/common/modal_popup.js
@@ -63,21 +63,30 @@ App.ModalPopup = Ember.View.extend({
 
   didInsertElement: function () {
     if (this.autoHeight) {
-      var block = this.$().find('#modal > .modal-body').first();
-      block.css('max-height', $(window).height() - block.offset().top - 300 + $(window).scrollTop());
// fix popup height
+      var block = $('#modal > .modal-body').first();
+      if(block.offset()) {
+        block.css('max-height', $(window).height() - block.offset().top  - 300 + $(window).scrollTop());
// fix popup height
+      }
     }
     // If popup is opened from another popup it should be displayed above
-    var existedPopups = $(document).find('.modal-backdrop');
+    var existedPopups = $('.modal-backdrop');
     if (existedPopups) {
       var maxZindex = 1;
       existedPopups.each(function(index, popup) {
         if ($(popup).css('z-index') > maxZindex) {
           maxZindex = $(popup).css('z-index');
-        }
+      }
       });
-      this.$().find('.modal-backdrop').css('z-index', maxZindex * 2);
-      this.$().find('.modal').css('z-index', maxZindex * 2 + 1);
+      $('.modal-backdrop').css('z-index', maxZindex * 2);
+      $('.modal').css('z-index', maxZindex * 2 + 1);
     }
+
+    var firstInputElement = $('#modal').find(':input').not(':disabled').first();
+    this.focusElement(firstInputElement);
+  },
+
+  focusElement: function(elem) {
+    elem.focus();
   },
 
   fitHeight: function () {

http://git-wip-us.apache.org/repos/asf/ambari/blob/ad9b02b1/ambari-web/test/views/common/modal_popup_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/modal_popup_test.js b/ambari-web/test/views/common/modal_popup_test.js
new file mode 100644
index 0000000..cd473aa
--- /dev/null
+++ b/ambari-web/test/views/common/modal_popup_test.js
@@ -0,0 +1,46 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var App = require('app');
+require('views/common/modal_popup');
+
+describe('App.ModalPopup', function() {
+
+  var popup;
+
+  beforeEach(function () {
+    popup = App.ModalPopup.create(
+        {
+          primary: 'test',
+          secondary: 'test',
+          header: 'test',
+          body: '<p>text</p><input type="text"><input type="checkbox"><input
type="button">'
+        }
+    );
+  });
+
+  describe('#didInsertElement', function () {
+
+    it('should focus on the first input element', function () {
+      var spy = sinon.spy(popup, "focusElement");
+      popup.didInsertElement();
+      expect(spy.called);
+    });
+  });
+
+});
\ No newline at end of file


Mime
View raw message