TWEAK: Don't focus on progress expansion on touch interfaces.

This commit is contained in:
Robin Ward 2014-06-19 15:19:30 -04:00
parent 12a0260a8c
commit 49ae01ddea
3 changed files with 11 additions and 14 deletions

View File

@ -6,10 +6,10 @@
**/
export default {
name: "sniff-capabilities",
initialize: function() {
initialize: function(container, application) {
var $html = $('html'),
touch = $html.hasClass('touch') || (Modernizr.prefixed("MaxTouchPoints", navigator) > 1),
caps = Discourse.Capabilities.current();
caps = Ember.Object.create();
// Store the touch ability in our capabilities object
caps.set('touch', touch);
@ -24,5 +24,9 @@ export default {
// We consider high res a device with 1280 horizontal pixels. High DPI tablets like
// iPads should report as 1024.
caps.set('highRes', window.screen.width >= 1280);
// Inject it
application.register('capabilities:main', caps, { instantiate: false });
application.inject('view', 'capabilities', 'capabilities:main');
}
};

View File

@ -1,10 +0,0 @@
/**
Singleton to store the application's capabilities
@class Capabilities
@namespace Discourse
@module Discourse
**/
Discourse.Capabilities = Ember.Object.extend({});
Discourse.Capabilities.reopenClass(Discourse.Singleton);

View File

@ -77,8 +77,11 @@ export default Ember.View.extend({
},
_focusWhenOpened: function() {
// Don't focus on mobile
if (Discourse.Mobile.mobileView) { return; }
// Don't focus on mobile or touch
if (Discourse.Mobile.mobileView || this.capabilities.get('touch')) {
return;
}
if (this.get('controller.expanded')) {
var self = this;