Skip to content

Commit

Permalink
Save link now prompts a sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
tristen committed Jun 5, 2013
1 parent 1b95c28 commit bdc1d42
Show file tree
Hide file tree
Showing 10 changed files with 113 additions and 111 deletions.
80 changes: 31 additions & 49 deletions app.css
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ table { border-collapse: collapse; border-spacing:0; }

@font-face {
font-family:'Prose';
src:url('fonts/prose-80081ddd6bb627b0784ec9094fabb857.eot');
src:url('fonts/prose-80081ddd6bb627b0784ec9094fabb857.eot?#iefix') format('embedded-opentype'),
url('fonts/prose-80081ddd6bb627b0784ec9094fabb857.woff') format('woff');
src:url('fonts/prose-129b77953cd92a716f7e5224f4de015e.eot');
src:url('fonts/prose-129b77953cd92a716f7e5224f4de015e.eot?#iefix') format('embedded-opentype'),
url('fonts/prose-129b77953cd92a716f7e5224f4de015e.woff') format('woff');
font-weight:700;
font-style:normal;
}
Expand Down Expand Up @@ -285,22 +285,22 @@ textarea#code {
border-width:1px;
}

::-webkit-input-placeholder { color:#d4d7d9; }
::-moz-placeholder { color:#d4d7d9; }
:-ms-input-placeholder { color:#d4d7d9; }
input:-moz-placeholder { color:#d4d7d9; }
::-webkit-input-placeholder { color:#a8afb2; }
::-moz-placeholder { color:#a8afb2; }
:-ms-input-placeholder { color:#a8afb2; }
input:-moz-placeholder { color:#a8afb2; }

.filepath::-webkit-input-placeholder { font-style:italic; }
.filepath::-moz-placeholder { font-style:italic; }
.filepath:-ms-input-placeholder { font-style:italic; }
.filepath:-moz-placeholder { font-style:italic; }
.filepath::-webkit-input-placeholder { color:#d4d7d9; font-style:italic; }
.filepath::-moz-placeholder { color:#d4d7d9; font-style:italic; }
.filepath:-ms-input-placeholder { color:#d4d7d9; font-style:italic; }
.filepath:-moz-placeholder { color:#d4d7d9; font-style:italic; }

strong { font-weight:700; }
em { font-style:italic; }

/* For Diff Viewing */
del {
color:#d4d7d9;
color:#516066;
padding:1px 0;
}
ins {
Expand Down Expand Up @@ -483,7 +483,7 @@ ins {
width:60px;
height:30px;
bottom:0;
right:0;
right:-30px;
}
.heading .filepath:focus,
.heading .filepath:hover {
Expand Down Expand Up @@ -557,6 +557,7 @@ ins {
left:0;
width:100%;
padding:15px;
color:#3d494e;
}
.loading .loading-icon {
background:transparent url('img/loader@33x33.gif') no-repeat;
Expand Down Expand Up @@ -585,9 +586,10 @@ ins {
z-index:5000;
width:60px;
height:100%;
border-left:1px solid #fff;
}
.open .vert {
border-left:1px solid #d4d7d9;
border-color:#d4d7d9;
}

.vert ul {
Expand Down Expand Up @@ -690,18 +692,12 @@ ins {
.published .ico.checkmark,
.ico.checkmark,
.ico.added { color:#90bb74; }

.vert .ico.logout { color:#db6f6f; }

.ico.modified { color:#2099aa; }
.ico.removed { color:#d35252; }

.ico.error { color:#db6f6f; }
.ico.renamed { color:#bb9f1a; }
.ico.private { color:#deb400; }

.vert .ico.logout:hover { background-color:#db6f6f; color:#fff; }

.ico {
font-family:'Prose';
font-size:22px;
Expand Down Expand Up @@ -735,12 +731,12 @@ ins {
.ico.picture:before { content: "\f116"; }
.ico.private:before { content: "\f117"; }
.ico.question:before { content: "\f118"; }
.ico.quick-save:before { content: "\f119"; }
.ico.quote:before { content: "\f11a"; }
.ico.removed:before { content: "\f11b"; }
.ico.renamed:before { content: "\f11c"; }
.ico.repos:before { content: "\f11d"; }
.ico.rubbish:before { content: "\f11e"; }
.ico.quote:before { content: "\f119"; }
.ico.removed:before { content: "\f11a"; }
.ico.renamed:before { content: "\f11b"; }
.ico.repos:before { content: "\f11c"; }
.ico.rubbish:before { content: "\f11d"; }
.ico.save:before { content: "\f11e"; }
.ico.saving:before { content: "\f11f"; }
.ico.search:before { content: "\f120"; }
.ico.sprocket:before { content: "\f121"; }
Expand Down Expand Up @@ -1706,31 +1702,17 @@ ins {
.sidebar .commit {
position:relative;
bottom:-4px;
display:none;
}
.sidebar .commit .cancel {
position:absolute;
z-index:10;
top:30px;
right:5px;
display:block;
}
.cancel:hover {
color:#DB6F6F;
}
.sidebar .commit textarea {
padding-right:25px;
margin:8px 0 -2px;
display:block;
position:relative;
z-index:1;
height:90px;
resize:none;
-webkit-border-radius:4px 4px 0 0;
border-radius:4px 4px 0 0;
}
.sidebar .commit.active {
.sidebar .commit textarea {
padding-right:25px;
margin:8px 0 -2px;
display:block;
position:relative;
z-index:1;
height:115px;
resize:none;
-webkit-border-radius:4px 4px 0 0;
border-radius:4px 4px 0 0;
}

/* ------------------------------------------
Expand Down
Binary file not shown.
Binary file not shown.
Binary file removed fonts/prose-80081ddd6bb627b0784ec9094fabb857.woff
Binary file not shown.
2 changes: 1 addition & 1 deletion src/prose/models.js
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,7 @@ module.exports = {
q.await((function() {
cb(err, _.extend(post, {
'default_metadata': defaultMetadata,
'markdown': _.markdown(file),
'markdown': _.markdown(file.split('?')[0]),
'repo': repo,
'path': path,
'file': file.split('?')[0],
Expand Down
104 changes: 64 additions & 40 deletions src/prose/views/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ module.exports = Backbone.View.extend({
'click .logout': 'logout',
'click a.item.removed': 'restoreFile',
'click a.save': 'save',
'click a.save.confirm': 'updateFile',
'click a.quick-save': 'updateFile',
'click a.cancel': 'cancelSave',
'click a.confirm': 'updateFile',
'click a.delete': 'deleteFile',
'click a.translate': 'translate',
'click .mobile-menu .toggle': 'toggleMobileClass',
Expand Down Expand Up @@ -75,6 +73,7 @@ module.exports = Backbone.View.extend({
var errorPage = false;
var hideInterface = false; // Flag for unauthenticated landing
this.noMenu = false; // Prevents a mobile toggle from appearing when nto required.
this.viewing = app.state.mode;

if (options) {
if (options.hideInterface) hideInterface = options.hideInterface;
Expand All @@ -98,10 +97,8 @@ module.exports = Backbone.View.extend({

// When the sidebar should be open.
// Fix this in re-factor, could be much tighter
if (app.state.mode === 'tree') {
$('#prose').toggleClass('open', true);
$('#prose').toggleClass('mobile', false);
} else if (app.state.mode === '' && window.authenticated && app.state.user !== '') {
if (app.state.mode === 'tree' ||
app.state.mode === '' && window.authenticated && app.state.user) {
$('#prose').toggleClass('open', true);
$('#prose').toggleClass('mobile', false);
} else {
Expand All @@ -122,8 +119,12 @@ module.exports = Backbone.View.extend({
},

headerContext: function(data, alterable) {
var view = this;
var heading = _(window.app.templates.heading).template();

if (data.writable) this.writable = true;
if (data.lang) this.lang = data.lang;
if (data.metadata) this.metadata = data.metadata;

$('#heading').empty().append(heading(_.extend(data, {
alterable: alterable ? true : false
})));
Expand All @@ -134,23 +135,20 @@ module.exports = Backbone.View.extend({
},

sidebarContext: function(data) {
var sidebarTmpl;

if (app.state.mode === 'tree') {
sidebarTmpl = _(app.templates.sidebarProject).template();
} else if (data.file) {
this.writable = data.writable;
sidebarTmpl = _(app.templates.settings).template();
var tmpl = _(app.templates.sidebarProject).template();

// Branch Switching
_.defer(function() {
$('.chzn-select', this.el).chosen().change(function() {
router.navigate($(this).val(), true);
});
});

$('#drawer', this.el)
.empty()
.append(tmpl(data));
}

$('#drawer', this.el)
.empty()
.append(sidebarTmpl(data));

// Branch Switching
$('.chzn-select', this.el).chosen().change(function() {
router.navigate($(this).val(), true);
});
},

recentFiles: function(data) {
Expand Down Expand Up @@ -185,16 +183,27 @@ module.exports = Backbone.View.extend({
},

settings: function(e) {
$navItems = $('.navigation a', this.el);
if (!this.viewing) this.viewing = app.state.mode;
var tmpl = _(app.templates.settings).template();
var $navItems = $('.navigation a', this.el);

if ($(e.target, this.el).hasClass('active')) {
$navItems.removeClass('active');
$('.navigation .' + this.viewing, this.el).addClass('active');
$('#prose').toggleClass('open mobile', false);

this.cancelSave();
} else {
$navItems.removeClass('active');
$(e.target, this.el).addClass('active');

$('#drawer', this.el)
.empty()
.append(tmpl({
lang: this.lang,
writable: this.writable,
metadata: this.metadata
}));

$('#prose').toggleClass('open mobile', true);
}

Expand Down Expand Up @@ -258,31 +267,46 @@ module.exports = Backbone.View.extend({
},

save: function(e) {
var tmpl = _(app.templates.sidebarSave).template();
this.eventRegister.trigger('save', e);
$navItems = $('.navigation a', this.el);

var $message = $('.commit-message', this.el);
var filepath = $('input.filepath').val();
var filename = _.extractFilename(filepath)[1];
var placeholder = 'Updated ' + filename;
if (app.state.mode === 'new') placeholder = 'Created ' + filename;
if ($(e.target, this.el).hasClass('active')) {
$navItems.removeClass('active');
$('.navigation .' + this.viewing, this.el).addClass('active');
$('#prose').toggleClass('open mobile', false);
this.cancelSave();
} else {
$navItems.removeClass('active');
$(e.target, this.el).addClass('active');

$('#drawer', this.el)
.empty()
.append(tmpl({
writable: this.writable
}));

$('.commit', this.el).toggleClass('active', true);
$('.button.save', this.el).toggleClass('confirm', true);
$('#prose').toggleClass('open mobile', true);

var $message = $('.commit-message', this.el);
var filepath = $('input.filepath').val();
var filename = _.extractFilename(filepath)[1];
var placeholder = 'Updated ' + filename;
if (app.state.mode === 'new') placeholder = 'Created ' + filename;

$('.button.save', this.el)
.html($('.button.save', this.el)
.hasClass('confirm') ?
(this.writable ? 'Commit' : 'Send Change Request') :
(this.writable ? 'Save' : 'Submit Change'));
$('.confirm', this.el)
.html($('.button.save', this.el)
.hasClass('confirm') ?
(this.writable ? 'Commit' : 'Send Change Request') :
(this.writable ? 'Save' : 'Submit Change'));

$message.attr('placeholder', placeholder).focus();
$message.attr('placeholder', placeholder).focus();
}

return false;
},

cancelSave: function(e) {
$('.commit', this.el).toggleClass('active', false);
$('.button.save', this.el).toggleClass('confirm', false);
this.eventRegister.trigger('cancelSave', e);
return false;
},
Expand Down
10 changes: 3 additions & 7 deletions src/prose/views/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ module.exports = Backbone.View.extend({
this.eventRegister.bind('remove', this.remove);
this.eventRegister.bind('cancelSave', this.cancelSave);

this.eventRegister.trigger('sidebarContext', this.data);
this.renderHeading();

var tmpl = _(window.app.templates.post).template();
Expand Down Expand Up @@ -143,7 +142,9 @@ module.exports = Backbone.View.extend({
title: _.filepath(this.data.path, this.data.file),
writable: this.model.writable,
alterable: true,
translate: this.data.translate
translate: this.data.translate,
lang: this.data.lang,
metadata: this.data.metadata
};

this.eventRegister.trigger('headerContext', this.header, true);
Expand Down Expand Up @@ -470,11 +471,6 @@ module.exports = Backbone.View.extend({
view.model.persisted = true;
view.model.file = filename;

if (app.state.mode === 'new') {
app.state.mode = 'edit';
view.eventRegister.trigger('sidebarContext', view.data);
}

view.renderHeading();
view.updateURL();
view.prevFile = filecontent;
Expand Down
2 changes: 1 addition & 1 deletion templates/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
</a>
</li>
<li>
<a href='#' class='ico round quick-save'>
<a href='#' class='ico round save quick-save'>
<span class='popup round arrow-right'>Save</span>
</a>
</li>
Expand Down
14 changes: 1 addition & 13 deletions templates/settings.html
Original file line number Diff line number Diff line change
@@ -1,20 +1,8 @@
<% if (window.authenticated) { %>
<div class='inner'>
<h2 class='label'>Post Settings</h2>
<h2 class='label'>Post Options</h2>
</div>
<div class='inner authoring'>
<div class='commit'>
<h2 class='label'>Describe you changes</h2>
<textarea class='commit-message' placeholder></textarea>
<a class='ico small cancel round' href='#'>
<span class='popup round arrow-right'>Cancel</span>
</a>
</div>

<a class='save button round' href='#'>
<%= writable ? 'Save' : 'Submit Change' %>
</a>

<% if (app.state.config && app.state.config.languages && lang !== 'yaml') { %>
<% _(app.state.config.languages).each(function(lang) { %>
<% if (lang.value && (metadata && metadata.lang !== lang.value)) { %>
Expand Down
Loading

0 comments on commit bdc1d42

Please sign in to comment.