From aed8f22c99b1f4701b36bb5ec45971667c4acd95 Mon Sep 17 00:00:00 2001 From: Thibaut Date: Mon, 11 Nov 2013 22:05:58 +0100 Subject: [PATCH] Fix single-doc mode detection --- assets/javascripts/app/app.coffee | 3 +++ assets/javascripts/views/content/root_page.coffee | 2 +- assets/javascripts/views/layout/document.coffee | 2 +- assets/javascripts/views/sidebar/doc_list.coffee | 2 +- assets/javascripts/views/sidebar/sidebar.coffee | 2 +- 5 files changed, 7 insertions(+), 4 deletions(-) diff --git a/assets/javascripts/app/app.coffee b/assets/javascripts/app/app.coffee index c7565894..adfa5186 100644 --- a/assets/javascripts/app/app.coffee +++ b/assets/javascripts/app/app.coffee @@ -145,6 +145,9 @@ getComputedStyle(document.querySelector('._header')).backgroundImage isnt 'none' catch + isSingleDoc: -> + !!(@DOC or @doc) + isMobile: -> # Need to sniff the user agent because some Android and Windows Phone devices don't take # resolution (dpi) into account when reporting device width/height. diff --git a/assets/javascripts/views/content/root_page.coffee b/assets/javascripts/views/content/root_page.coffee index 3a99cf71..27db1bc0 100644 --- a/assets/javascripts/views/content/root_page.coffee +++ b/assets/javascripts/views/content/root_page.coffee @@ -23,7 +23,7 @@ class app.views.RootPage extends app.View return isHidden: -> - app.doc or app.store.get 'hideIntro' + app.isSingleDoc() or app.store.get 'hideIntro' onRoute: -> diff --git a/assets/javascripts/views/layout/document.coffee b/assets/javascripts/views/layout/document.coffee index ce9d3e0b..01d0ade5 100644 --- a/assets/javascripts/views/layout/document.coffee +++ b/assets/javascripts/views/layout/document.coffee @@ -23,7 +23,7 @@ class app.views.Document extends app.View app.router.show '/help#shortcuts' onEscape: -> - if app.doc then window.location = '/' else app.router.show '/' + if app.isSingleDoc() then window.location = '/' else app.router.show '/' onBack: -> history.back() diff --git a/assets/javascripts/views/sidebar/doc_list.coffee b/assets/javascripts/views/sidebar/doc_list.coffee index 96a949b0..626e780c 100644 --- a/assets/javascripts/views/sidebar/doc_list.coffee +++ b/assets/javascripts/views/sidebar/doc_list.coffee @@ -31,7 +31,7 @@ class app.views.DocList extends app.View render: => @html @tmpl('sidebarDoc', app.docs.all()) - unless app.doc or app.settings.hasDocs() + unless app.isSingleDoc() or app.settings.hasDocs() @append @tmpl('sidebarDoc', app.disabledDocs.all(), disabled: true) return diff --git a/assets/javascripts/views/sidebar/sidebar.coffee b/assets/javascripts/views/sidebar/sidebar.coffee index d15ba99d..2133f8c6 100644 --- a/assets/javascripts/views/sidebar/sidebar.coffee +++ b/assets/javascripts/views/sidebar/sidebar.coffee @@ -16,7 +16,7 @@ class app.views.Sidebar extends app.View @results = new app.views.Results @search @docList = new app.views.DocList - @docPicker = new app.views.DocPicker unless app.doc + @docPicker = new app.views.DocPicker unless app.isSingleDoc() app.on 'ready', @showDocList $.on document, 'click', @onGlobalClick if @docPicker