Cleaning up loose ends for edit.

master
Nick Sergeant 2012-04-07 19:11:05 -04:00
parent ac7248f9a1
commit cc3af5faab
4 changed files with 31 additions and 16 deletions

View File

@ -21,11 +21,13 @@
'click a.embed': 'embedFromClick',
'click a.expand': 'expand',
'click .container': 'selectFromClick',
'copyClose': 'copyClose',
'copyRaw': 'copy',
'detail': 'detail',
'deselect': 'deselect',
'edit': 'edit',
'embed': 'embed',
'embedClose': 'embedClose',
'expand': 'expand',
'fadeAndRemove': 'fadeAndRemove',
'next': 'next',
@ -44,6 +46,9 @@
this.$copyModal.modal('show');
$textarea.select();
},
copyClose: function() {
$('textarea', this.$copyModal).remove();
},
copyFromClick: function() {
this.copy();
return false;
@ -94,10 +99,10 @@
// Ace editor
$('div#editor', window.site.$main_edit).css('height', ($(window).height() - 187));
var editor = ace.edit('editor');
editor.setTheme('ace/theme/tomorrow');
editor.renderer.setShowGutter(false);
editor.focus();
window.editor = ace.edit('editor');
window.editor.setTheme('ace/theme/tomorrow');
window.editor.renderer.setShowGutter(false);
window.editor.focus();
$('textarea, input', window.site.$main_edit).bind('keydown', 'esc', function(e) {
$(this).blur();
return false;
@ -140,6 +145,9 @@
this.embed();
return false;
},
embedClose: function() {
$('textarea', this.$embedModal).remove();
},
expand: function() {
this.$container.toggleClass('expanded', 100);
this.$tags.toggleClass('expanded');
@ -166,10 +174,12 @@
this.$tags = $('section.tags ul', this.$aside);
this.$copyModal.on('hidden', function(e) {
$(this).parent().trigger('copyClose');
window.ui_halted = false;
window.from_modal = true;
});
this.$embedModal.on('hidden', function(e) {
$(this).parent().trigger('embedClose');
window.ui_halted = false;
window.from_modal = true;
});
@ -199,7 +209,7 @@
}));
this.initLocalVars();
if (this.model.get('pub') === true) {
if (this.model.get('public') === true) {
this.$el.removeClass('private-snipt');
} else {
this.$el.addClass('private-snipt');
@ -226,6 +236,10 @@
that.model.set('title', $('input#snipt_title').val());
that.model.set('tags', $('label.tags textarea').val());
that.model.set('tags_list', $('label.tags textarea').val());
that.model.set('lexer', $('select[name="lexer"]').val());
that.model.set('lexer_name', $('select[name="lexer"] option:selected').text());
that.model.set('code', window.editor.getSession().getValue());
that.model.set('public', $('label.public input').is(':checked'));
that.model.save();
},
@ -276,9 +290,9 @@
var $el = $(this);
var $created = $('li.created', $el);
var $h1 = $('header h1 a', $el);
var $pub = $('div.public', $el);
var $public = $('div.public', $el);
var $user = $('li.author a', $el);
var is_public = $pub.text() === 'True' ? true : false;
var is_public = $public.text() === 'True' ? true : false;
var tag_lis = $('section.tags li', $el);
var tags = [];
@ -302,7 +316,6 @@
lexer_name: $('div.lexer-name', $el).text(),
line_count: parseInt($('div.line-count', $el).text(), 0),
modified: $('div.modified', $el).text(),
pub: is_public,
resource_uri: $('div.resource-uri', $el).text(),
slug: $('div.slug', $el).text(),
stylized: $('div.stylized', $el).text(),
@ -314,6 +327,7 @@
username: $user.text()
}
};
data['public'] = is_public;
var view = new Snipt.SniptView({
el: this,

View File

@ -40,7 +40,7 @@
</select>
</label>
<label class="public is-private">
<input type="checkbox" <% if (snipt.pub) { %>checked="checked"<% } %> name="" value="" />
<input type="checkbox" <% if (snipt.public) { %>checked="checked"<% } %> name="" value="" />
<span>Public</span>
</label>
<label class="tags">

View File

@ -59,15 +59,16 @@
<div class="modal hide copy-modal">
<div class="modal-header">
<a href="#" class="close">×</a>
<h3>Copy snipt <span>&ldquo;<%= snipt.title %>&rdquo;</span></h3>
<h4>(Text is selected. <span></span>+c to copy.)</h4>
<h3>Copy <span>&ldquo;<%= snipt.title %>&rdquo;</span></h3>
<h4>(Text is selected. <span class="cmd-ctrl"></span>+C to copy.)</h4>
</div>
<div class="modal-body"></div>
</div>
<div class="modal hide embed-modal">
<div class="modal-header">
<a href="#" class="close">×</a>
<h3>Embed snipt <span>&ldquo;<%= snipt.title %>&rdquo;</span></h3>
<h3>Embed <span>&ldquo;<%= snipt.title %>&rdquo;</span></h3>
<h4>(Text is selected. <span class="cmd-ctrl"></span>+C to copy.)</h4>
</div>
<div class="modal-body">
<textarea><script type="text/javascript"><%= snipt.get_embed_url %></script></textarea>

View File

@ -62,16 +62,16 @@
<div class="modal hide copy-modal">
<div class="modal-header">
<a href="#" class="close">×</a>
<h3>Copy snipt <span>&ldquo;{{ snipt.title }}&rdquo;</span></h3>
<h4>(Text is selected. <span class="cmd-ctrl"></span>+c to copy.)</h4>
<h3>Copy <span>&ldquo;{{ snipt.title }}&rdquo;</span></h3>
<h4>(Text is selected. <span class="cmd-ctrl"></span>+C to copy.)</h4>
</div>
<div class="modal-body"></div>
</div>
<div class="modal hide embed-modal">
<div class="modal-header">
<a href="#" class="close">×</a>
<h3>Embed snipt <span>&ldquo;{{ snipt.title }}&rdquo;</span></h3>
<h4>(Text is selected. <span class="cmd-ctrl"></span>+c to copy.)</h4>
<h3>Embed <span>&ldquo;{{ snipt.title }}&rdquo;</span></h3>
<h4>(Text is selected. <span class="cmd-ctrl"></span>+C to copy.)</h4>
</div>
<div class="modal-body"></div>
</div>