Never show preview pane in composer on mobile.

This commit is contained in:
Neil Lalonde 2013-10-17 12:19:09 -04:00
parent a215fc5bdc
commit 71571b9316
2 changed files with 18 additions and 2 deletions

View file

@ -257,7 +257,7 @@ Discourse.Composer = Discourse.Model.extend({
init: function() { init: function() {
this._super(); this._super();
var val = Discourse.KeyValueStore.get('composer.showPreview') || 'true'; var val = (Discourse.Mobile.mobileView ? false : (Discourse.KeyValueStore.get('composer.showPreview') || 'true'));
this.set('showPreview', val === 'true'); this.set('showPreview', val === 'true');
this.set('archetypeId', Discourse.Site.currentProp('default_archetype')); this.set('archetypeId', Discourse.Site.currentProp('default_archetype'));
}, },

View file

@ -187,4 +187,20 @@ test('initial category when uncategorized is not allowed', function() {
Discourse.SiteSettings.allow_uncategorized_topics = false; Discourse.SiteSettings.allow_uncategorized_topics = false;
var composer = Discourse.Composer.open({action: 'createTopic', draftKey: 'asfd', draftSequence: 1}); var composer = Discourse.Composer.open({action: 'createTopic', draftKey: 'asfd', draftSequence: 1});
ok(composer.get('categoryId') === undefined, "Uncategorized by default. Must choose a category."); ok(composer.get('categoryId') === undefined, "Uncategorized by default. Must choose a category.");
}); });
test('showPreview', function() {
var new_composer = function() {
return Discourse.Composer.open({action: 'createTopic', draftKey: 'asfd', draftSequence: 1});
};
Discourse.Mobile.mobileView = true;
equal(new_composer().get('showPreview'), false, "Don't show preview in mobile view");
Discourse.KeyValueStore.set({ key: 'composer.showPreview', value: 'true' });
equal(new_composer().get('showPreview'), false, "Don't show preview in mobile view even if KeyValueStore wants to");
Discourse.KeyValueStore.remove('composer.showPreview');
Discourse.Mobile.mobileView = false;
equal(new_composer().get('showPreview'), true, "Show preview by default in desktop view");
});