Permalink
Browse files

Show document controls only when needed.

Also, default to preview mode when not authenticated. Closes #186.
  • Loading branch information...
1 parent 889dd23 commit 23a514f100e19915aef6acc63daa4be3584a3c02 Michael Aufreiter committed Jul 12, 2012
Showing with 13 additions and 13 deletions.
  1. +0 −1 _includes/styles/style.css
  2. +8 −8 _includes/templates/post._
  3. +4 −2 _includes/views/application.js
  4. +1 −2 _includes/views/post.js
@@ -1095,7 +1095,6 @@ ul.site li a {
}
.document .metadata-content {
- padding: 20px 0px;
width: 960px;
margin: 0 auto;
}
View
@@ -1,3 +1,4 @@
+<% if (window.authenticated) { %>
<div class="document-menu">
<div class="document-menu-content">
@@ -6,14 +7,13 @@
<div class="state"></div>
</div>
- <% if (window.authenticated) { %>
- <div class="fr menu-item save-state">
- <div class="state fl">
- <a class='toggle-options button' href='#'>&nbsp;</a>
- <a class='save button inactive' href='#' title="CTRL+S">SAVE</a>
- </div>
+ <div class="fr menu-item save-state">
+ <div class="state fl">
+ <a class='toggle-options button' href='#'>&nbsp;</a>
+ <a class='save button inactive' href='#' title="CTRL+S">SAVE</a>
</div>
- <% } %>
+ </div>
+
<% if (jekyll) { %><a class="toggle meta fr menu-item" href="#" title="CTRL+SHIFT+M">Metadata</a> <% } %>
@@ -37,8 +37,8 @@
<br class="clear"/>
</div>
-
</div>
+<% } %>
<div class='inner clearfix'>
<div class='document prose'>
@@ -51,6 +51,8 @@ views.Application = Backbone.View.extend({
replaceMainView: function (name, view) {
$('body').removeClass().addClass('current-view '+name);
+ // Make sure the header gets shown
+ if (name !== "start") $('#header').show();
if (this.mainView) {
this.mainView.remove();
@@ -88,9 +90,9 @@ views.Application = Backbone.View.extend({
this.loaded();
this.header.render();
if (err) return this.notify('error', 'The requested resource could not be found.');
- data.preview = !(mode === "edit");
+ data.preview = !(mode === "edit") || !window.authenticated;
data.lang = _.mode(file);
- this.replaceMainView("post", new views.Post({ model: data, id: 'post' }).render());
+ this.replaceMainView(window.authenticated ? "post" : "read-post", new views.Post({ model: data, id: 'post' }).render());
var that = this;
}, this));
this.header.render();
View
@@ -263,15 +263,14 @@ views.Post = Backbone.View.extend({
theme: 'prose-bright',
onChange: _.bind(that._makeDirty, that)
});
-
}, 100);
},
render: function() {
var that = this;
$(this.el).html(templates.post(_.extend(this.model, { mode: this.mode })));
if (this.model.metadata && this.model.metadata.published) $(this.el).addClass('published');
- this.initEditor();
+ if (window.authenticated) this.initEditor();
return this;
}
});

0 comments on commit 23a514f

Please sign in to comment.