Use Discourse.Resolver to load mobile templates when they exist
This commit is contained in:
parent
89265c3a8b
commit
009dec833f
|
@ -143,6 +143,8 @@ Discourse = Ember.Application.createWithMixins(Discourse.Ajax, {
|
||||||
bootbox.animate(false);
|
bootbox.animate(false);
|
||||||
bootbox.backdrop(true); // clicking outside a bootbox modal closes it
|
bootbox.backdrop(true); // clicking outside a bootbox modal closes it
|
||||||
|
|
||||||
|
this.set('mobile', $html.hasClass('mobile'));
|
||||||
|
|
||||||
setInterval(function(){
|
setInterval(function(){
|
||||||
Discourse.Formatter.updateRelativeAge($('.relative-date'));
|
Discourse.Formatter.updateRelativeAge($('.relative-date'));
|
||||||
},60 * 1000);
|
},60 * 1000);
|
||||||
|
|
|
@ -16,6 +16,15 @@ Discourse.Resolver = Ember.DefaultResolver.extend({
|
||||||
@returns {Template} the template (if found)
|
@returns {Template} the template (if found)
|
||||||
**/
|
**/
|
||||||
resolveTemplate: function(parsedName) {
|
resolveTemplate: function(parsedName) {
|
||||||
|
if (Discourse.get('mobile')) {
|
||||||
|
var mobileParsedName = this.parseName(parsedName.fullName.replace("template:", "template:mobile/"));
|
||||||
|
var mobileTemplate = this.findTemplate(mobileParsedName);
|
||||||
|
if (mobileTemplate) return mobileTemplate;
|
||||||
|
}
|
||||||
|
return this.findTemplate(parsedName) || Ember.TEMPLATES.not_found;
|
||||||
|
},
|
||||||
|
|
||||||
|
findTemplate: function(parsedName) {
|
||||||
var resolvedTemplate = this._super(parsedName);
|
var resolvedTemplate = this._super(parsedName);
|
||||||
if (resolvedTemplate) { return resolvedTemplate; }
|
if (resolvedTemplate) { return resolvedTemplate; }
|
||||||
|
|
||||||
|
@ -36,7 +45,6 @@ Discourse.Resolver = Ember.DefaultResolver.extend({
|
||||||
resolvedTemplate = Ember.TEMPLATES[decamelized];
|
resolvedTemplate = Ember.TEMPLATES[decamelized];
|
||||||
if (resolvedTemplate) { return resolvedTemplate; }
|
if (resolvedTemplate) { return resolvedTemplate; }
|
||||||
}
|
}
|
||||||
return Ember.TEMPLATES.not_found;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
|
@ -0,0 +1,9 @@
|
||||||
|
{{#if postStream.loaded}}
|
||||||
|
<div class='container'>
|
||||||
|
Mobile Topic Page Loaded!
|
||||||
|
</div>
|
||||||
|
{{else}}
|
||||||
|
<div class='container'>
|
||||||
|
<div class='spinner'>{{i18n loading}}</div>
|
||||||
|
</div>
|
||||||
|
{{/if}}
|
Loading…
Reference in New Issue