Crazy editing stuff.

master
Nick Sergeant 2012-02-26 18:34:20 -05:00
parent b4832af05b
commit 0b67d804a2
6 changed files with 229 additions and 118 deletions

2
snipt/fabfile.py vendored
View File

@ -29,7 +29,7 @@ def staticfiles():
'%s/media/js/libs/ace/ace.js' % BASE_PATH,
]
local('cat %s > %s/media/cache/snipt.js' % (' '.join(js), BASE_PATH))
local('/Users/Nick/.virtualenvs/snipt/bin/python %s/manage.py collectstatic --ignore grappelli --ignore admin --noinput' % BASE_PATH)
local('/Users/Nick/.virtualenvs/snipt/bin/python %s/manage.py collectstatic --ignore grappelli --ignore admin --ignore ace --noinput' % BASE_PATH)
def deployapp(m):
try:

View File

@ -1309,6 +1309,25 @@ body.api-contest a.aea {
box-shadow: 3px 3px 10px rgba(0, 0, 0, 0.2); }
body.api-contest a.aea img {
display: block; }
body.editing header.main, body.editing header.sub {
display: none; }
body.editing article.editing {
margin-top: 50px; }
body.editing article.editing div.container section.code {
padding: 13px 11px; }
body.editing article.editing div.container section.code div#editor {
border: none;
font: normal 12px/16px Consolas, Menlo, "Courier New", monospace;
font-weight: normal !important;
height: 400px;
margin: 0;
position: relative;
width: 100%; }
body.editing article.editing div.container section.code div#editor .ace_print_margin {
display: none; }
body.editing article.editing div.container:after {
display: none; }
.autumn { background-color: #FFF; color: #000; }
.autumn .hll { background-color: #ffffcc }
.autumn .c { color: #aaaaaa; font-style: italic } /* Comment */

File diff suppressed because one or more lines are too long

View File

@ -1016,7 +1016,7 @@ body.editing {
div.container {
section.code {
padding: 13px 12px;
padding: 13px 11px;
div#editor {
border: none;

View File

@ -95,7 +95,7 @@
history.go(1);
}
});
$('input').bind('keydown', 'esc', function(e) {
this.$search_query.bind('keydown', 'esc', function(e) {
if (!window.ui_halted) {
e.preventDefault();
this.blur();

View File

@ -76,9 +76,17 @@
window.editor.renderer.setShowGutter(false);
var JavaScriptMode = require('ace/mode/javascript').Mode;
window.editor.getSession().setMode(new JavaScriptMode());
window.editor.$textarea = $('textarea', window.editor.container);
window.editor.focus();
window.editor.$textarea.bind('keydown', 'esc', function(e) {
$(this).blur();
return false;
});
window.scrollTo(0, 0);
window.editing = true;
window.ui_halted = true;
}
return false;
@ -243,7 +251,7 @@
}
var data = {
code: $('div.raw', $el).text(),
code: $('div.raw', $el).html(),
created: $created.attr('title'),
created_formatted: $created.text(),
embed_url: $('div.embed-url', $el).text(),
@ -313,24 +321,26 @@
}
});
$document.bind('keydown', 'esc', function() {
if (!window.ui_halted) {
if (window.site.$main_edit.is(':visible')) {
if (!window.site.$html.hasClass('detail')) {
window.site.$body.removeClass('detail');
}
window.site.$main_edit.hide();
window.site.$body.removeClass('editing');
window.site.$main.show();
if (window.$selected) {
if (window.site.$snipts.index($selected) === 0) {
window.scrollTo(0, 0);
} else {
window.site.$html_body.animate({
scrollTop: $selected.offset().top - 50
}, 0);
}
}
if (window.editing) {
if (!window.site.$html.hasClass('detail')) {
window.site.$body.removeClass('detail');
}
window.site.$main_edit.hide();
window.site.$body.removeClass('editing');
window.site.$main.show();
window.editing = true;
window.ui_halted = false;
if (window.site.$snipts.index(window.$selected) === 0) {
window.scrollTo(0, 0);
} else {
window.site.$html_body.animate({
scrollTop: window.$selected.offset().top - 50
}, 0);
}
} else {
if (!window.ui_halted) {
if ($selected) {
$selected.trigger('deselect');
}