Cleaning up loose ends for edit.
parent
ac7248f9a1
commit
cc3af5faab
|
@ -21,11 +21,13 @@
|
||||||
'click a.embed': 'embedFromClick',
|
'click a.embed': 'embedFromClick',
|
||||||
'click a.expand': 'expand',
|
'click a.expand': 'expand',
|
||||||
'click .container': 'selectFromClick',
|
'click .container': 'selectFromClick',
|
||||||
|
'copyClose': 'copyClose',
|
||||||
'copyRaw': 'copy',
|
'copyRaw': 'copy',
|
||||||
'detail': 'detail',
|
'detail': 'detail',
|
||||||
'deselect': 'deselect',
|
'deselect': 'deselect',
|
||||||
'edit': 'edit',
|
'edit': 'edit',
|
||||||
'embed': 'embed',
|
'embed': 'embed',
|
||||||
|
'embedClose': 'embedClose',
|
||||||
'expand': 'expand',
|
'expand': 'expand',
|
||||||
'fadeAndRemove': 'fadeAndRemove',
|
'fadeAndRemove': 'fadeAndRemove',
|
||||||
'next': 'next',
|
'next': 'next',
|
||||||
|
@ -44,6 +46,9 @@
|
||||||
this.$copyModal.modal('show');
|
this.$copyModal.modal('show');
|
||||||
$textarea.select();
|
$textarea.select();
|
||||||
},
|
},
|
||||||
|
copyClose: function() {
|
||||||
|
$('textarea', this.$copyModal).remove();
|
||||||
|
},
|
||||||
copyFromClick: function() {
|
copyFromClick: function() {
|
||||||
this.copy();
|
this.copy();
|
||||||
return false;
|
return false;
|
||||||
|
@ -94,10 +99,10 @@
|
||||||
|
|
||||||
// Ace editor
|
// Ace editor
|
||||||
$('div#editor', window.site.$main_edit).css('height', ($(window).height() - 187));
|
$('div#editor', window.site.$main_edit).css('height', ($(window).height() - 187));
|
||||||
var editor = ace.edit('editor');
|
window.editor = ace.edit('editor');
|
||||||
editor.setTheme('ace/theme/tomorrow');
|
window.editor.setTheme('ace/theme/tomorrow');
|
||||||
editor.renderer.setShowGutter(false);
|
window.editor.renderer.setShowGutter(false);
|
||||||
editor.focus();
|
window.editor.focus();
|
||||||
$('textarea, input', window.site.$main_edit).bind('keydown', 'esc', function(e) {
|
$('textarea, input', window.site.$main_edit).bind('keydown', 'esc', function(e) {
|
||||||
$(this).blur();
|
$(this).blur();
|
||||||
return false;
|
return false;
|
||||||
|
@ -140,6 +145,9 @@
|
||||||
this.embed();
|
this.embed();
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
embedClose: function() {
|
||||||
|
$('textarea', this.$embedModal).remove();
|
||||||
|
},
|
||||||
expand: function() {
|
expand: function() {
|
||||||
this.$container.toggleClass('expanded', 100);
|
this.$container.toggleClass('expanded', 100);
|
||||||
this.$tags.toggleClass('expanded');
|
this.$tags.toggleClass('expanded');
|
||||||
|
@ -166,10 +174,12 @@
|
||||||
this.$tags = $('section.tags ul', this.$aside);
|
this.$tags = $('section.tags ul', this.$aside);
|
||||||
|
|
||||||
this.$copyModal.on('hidden', function(e) {
|
this.$copyModal.on('hidden', function(e) {
|
||||||
|
$(this).parent().trigger('copyClose');
|
||||||
window.ui_halted = false;
|
window.ui_halted = false;
|
||||||
window.from_modal = true;
|
window.from_modal = true;
|
||||||
});
|
});
|
||||||
this.$embedModal.on('hidden', function(e) {
|
this.$embedModal.on('hidden', function(e) {
|
||||||
|
$(this).parent().trigger('embedClose');
|
||||||
window.ui_halted = false;
|
window.ui_halted = false;
|
||||||
window.from_modal = true;
|
window.from_modal = true;
|
||||||
});
|
});
|
||||||
|
@ -199,7 +209,7 @@
|
||||||
}));
|
}));
|
||||||
this.initLocalVars();
|
this.initLocalVars();
|
||||||
|
|
||||||
if (this.model.get('pub') === true) {
|
if (this.model.get('public') === true) {
|
||||||
this.$el.removeClass('private-snipt');
|
this.$el.removeClass('private-snipt');
|
||||||
} else {
|
} else {
|
||||||
this.$el.addClass('private-snipt');
|
this.$el.addClass('private-snipt');
|
||||||
|
@ -226,6 +236,10 @@
|
||||||
that.model.set('title', $('input#snipt_title').val());
|
that.model.set('title', $('input#snipt_title').val());
|
||||||
that.model.set('tags', $('label.tags textarea').val());
|
that.model.set('tags', $('label.tags textarea').val());
|
||||||
that.model.set('tags_list', $('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();
|
that.model.save();
|
||||||
},
|
},
|
||||||
|
@ -276,9 +290,9 @@
|
||||||
var $el = $(this);
|
var $el = $(this);
|
||||||
var $created = $('li.created', $el);
|
var $created = $('li.created', $el);
|
||||||
var $h1 = $('header h1 a', $el);
|
var $h1 = $('header h1 a', $el);
|
||||||
var $pub = $('div.public', $el);
|
var $public = $('div.public', $el);
|
||||||
var $user = $('li.author a', $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 tag_lis = $('section.tags li', $el);
|
||||||
var tags = [];
|
var tags = [];
|
||||||
|
|
||||||
|
@ -302,7 +316,6 @@
|
||||||
lexer_name: $('div.lexer-name', $el).text(),
|
lexer_name: $('div.lexer-name', $el).text(),
|
||||||
line_count: parseInt($('div.line-count', $el).text(), 0),
|
line_count: parseInt($('div.line-count', $el).text(), 0),
|
||||||
modified: $('div.modified', $el).text(),
|
modified: $('div.modified', $el).text(),
|
||||||
pub: is_public,
|
|
||||||
resource_uri: $('div.resource-uri', $el).text(),
|
resource_uri: $('div.resource-uri', $el).text(),
|
||||||
slug: $('div.slug', $el).text(),
|
slug: $('div.slug', $el).text(),
|
||||||
stylized: $('div.stylized', $el).text(),
|
stylized: $('div.stylized', $el).text(),
|
||||||
|
@ -314,6 +327,7 @@
|
||||||
username: $user.text()
|
username: $user.text()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
data['public'] = is_public;
|
||||||
|
|
||||||
var view = new Snipt.SniptView({
|
var view = new Snipt.SniptView({
|
||||||
el: this,
|
el: this,
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
</select>
|
</select>
|
||||||
</label>
|
</label>
|
||||||
<label class="public is-private">
|
<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>
|
<span>Public</span>
|
||||||
</label>
|
</label>
|
||||||
<label class="tags">
|
<label class="tags">
|
||||||
|
|
|
@ -59,15 +59,16 @@
|
||||||
<div class="modal hide copy-modal">
|
<div class="modal hide copy-modal">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<a href="#" class="close">×</a>
|
<a href="#" class="close">×</a>
|
||||||
<h3>Copy snipt <span>“<%= snipt.title %>”</span></h3>
|
<h3>Copy <span>“<%= snipt.title %>”</span></h3>
|
||||||
<h4>(Text is selected. <span></span>+c to copy.)</h4>
|
<h4>(Text is selected. <span class="cmd-ctrl"></span>+C to copy.)</h4>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body"></div>
|
<div class="modal-body"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal hide embed-modal">
|
<div class="modal hide embed-modal">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<a href="#" class="close">×</a>
|
<a href="#" class="close">×</a>
|
||||||
<h3>Embed snipt <span>“<%= snipt.title %>”</span></h3>
|
<h3>Embed <span>“<%= snipt.title %>”</span></h3>
|
||||||
|
<h4>(Text is selected. <span class="cmd-ctrl"></span>+C to copy.)</h4>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<textarea><script type="text/javascript"><%= snipt.get_embed_url %></script></textarea>
|
<textarea><script type="text/javascript"><%= snipt.get_embed_url %></script></textarea>
|
||||||
|
|
|
@ -62,16 +62,16 @@
|
||||||
<div class="modal hide copy-modal">
|
<div class="modal hide copy-modal">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<a href="#" class="close">×</a>
|
<a href="#" class="close">×</a>
|
||||||
<h3>Copy snipt <span>“{{ snipt.title }}”</span></h3>
|
<h3>Copy <span>“{{ snipt.title }}”</span></h3>
|
||||||
<h4>(Text is selected. <span class="cmd-ctrl"></span>+c to copy.)</h4>
|
<h4>(Text is selected. <span class="cmd-ctrl"></span>+C to copy.)</h4>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body"></div>
|
<div class="modal-body"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal hide embed-modal">
|
<div class="modal hide embed-modal">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<a href="#" class="close">×</a>
|
<a href="#" class="close">×</a>
|
||||||
<h3>Embed snipt <span>“{{ snipt.title }}”</span></h3>
|
<h3>Embed <span>“{{ snipt.title }}”</span></h3>
|
||||||
<h4>(Text is selected. <span class="cmd-ctrl"></span>+c to copy.)</h4>
|
<h4>(Text is selected. <span class="cmd-ctrl"></span>+C to copy.)</h4>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body"></div>
|
<div class="modal-body"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue