REFACTOR: Don't use `Discourse.Capabilities`, instead use injection.
Also fix broken test. /cc @Sam
This commit is contained in:
parent
c709ea8f9e
commit
8279752d3c
|
@ -10,11 +10,11 @@ export default Ember.ArrayController.extend(Discourse.HasCurrentUser, {
|
||||||
badgesUrl: Discourse.getURL('/badges'),
|
badgesUrl: Discourse.getURL('/badges'),
|
||||||
|
|
||||||
showKeyboardShortcuts: function(){
|
showKeyboardShortcuts: function(){
|
||||||
return !Discourse.Mobile.mobileView && !Discourse.Capabilities.touch;
|
return !Discourse.Mobile.mobileView && !this.capabilities.touch;
|
||||||
}.property(),
|
}.property(),
|
||||||
|
|
||||||
showMobileToggle: function(){
|
showMobileToggle: function(){
|
||||||
return Discourse.Mobile.mobileView || (Discourse.SiteSettings.enable_mobile_theme && Discourse.Capabilities.touch);
|
return Discourse.Mobile.mobileView || (Discourse.SiteSettings.enable_mobile_theme && this.capabilities.touch);
|
||||||
}.property(),
|
}.property(),
|
||||||
|
|
||||||
mobileViewLinkTextKey: function() {
|
mobileViewLinkTextKey: function() {
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
/*global Modernizr:true*/
|
/*global Modernizr:true*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Initializes the `Discourse.Capabilities` singleton by sniffing out the browser
|
Initializes an object that lets us know about our capabilities.
|
||||||
capabilities.
|
|
||||||
**/
|
**/
|
||||||
export default {
|
export default {
|
||||||
name: "sniff-capabilities",
|
name: "sniff-capabilities",
|
||||||
|
@ -28,7 +27,6 @@ export default {
|
||||||
// Inject it
|
// Inject it
|
||||||
application.register('capabilities:main', caps, { instantiate: false });
|
application.register('capabilities:main', caps, { instantiate: false });
|
||||||
application.inject('view', 'capabilities', 'capabilities:main');
|
application.inject('view', 'capabilities', 'capabilities:main');
|
||||||
|
application.inject('controller', 'capabilities', 'capabilities:main');
|
||||||
Discourse.Capabilities = caps;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -50,6 +50,7 @@ test("showMoblieToggle returns true when mobile theme is enabled in site setting
|
||||||
Discourse.SiteSettings.enable_mobile_theme = true;
|
Discourse.SiteSettings.enable_mobile_theme = true;
|
||||||
Discourse.Mobile.isMobileDevice = true;
|
Discourse.Mobile.isMobileDevice = true;
|
||||||
var controller = this.subject();
|
var controller = this.subject();
|
||||||
|
controller.capabilities = { touch: true };
|
||||||
equal(controller.get("showMobileToggle"), true);
|
equal(controller.get("showMobileToggle"), true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue