master
Nick Sergeant 2012-03-08 08:59:15 -05:00
parent 58876ccd85
commit 7aa3f07050
1 changed files with 33 additions and 40 deletions

View File

@ -37,15 +37,13 @@
}, },
copy: function() { copy: function() {
if (!window.ui_halted) { window.ui_halted = true;
window.ui_halted = true;
this.$copyModalBody.append('<textarea class="raw"></textarea>'); this.$copyModalBody.append('<textarea class="raw"></textarea>');
$textarea = $('textarea.raw', this.$copyModalBody).val(this.model.get('code')); $textarea = $('textarea.raw', this.$copyModalBody).val(this.model.get('code'));
this.$copyModal.modal('show'); this.$copyModal.modal('show');
$textarea.select(); $textarea.select();
}
}, },
copyClose: function() { copyClose: function() {
$('textarea', this.$copyModal).remove(); $('textarea', this.$copyModal).remove();
@ -62,46 +60,42 @@
window.location = this.model.get('get_absolute_url'); window.location = this.model.get('get_absolute_url');
}, },
edit: function() { edit: function() {
if (!window.ui_halted) { window.editing = true;
this.select(); window.ui_halted = true;
var editPane = this.editTemplate({
snipt: this.model.toJSON()
});
window.site.$main.hide();
window.site.$body.addClass('detail editing');
window.site.$main_edit.html(editPane).show();
$('div#editor', window.site.$main_edit).css('height', ($(window).height() - 187)); this.select();
window.editor = ace.edit('editor');
window.editor.setTheme('ace/theme/tomorrow');
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); var editPane = this.editTemplate({snipt: this.model.toJSON()});
window.editor.focus(); var JavaScriptMode = require('ace/mode/javascript').Mode;
window.editor.$textarea.bind('keydown', 'esc', function(e) {
$(this).blur();
return false;
});
window.scrollTo(0, 0); window.site.$main.hide();
window.site.$body.addClass('detail editing');
window.site.$main_edit.html(editPane).show();
$('div#editor', window.site.$main_edit).css('height', ($(window).height() - 187));
window.editor = ace.edit('editor');
window.editor.setTheme('ace/theme/tomorrow');
window.editor.renderer.setShowGutter(false);
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; return false;
}, },
embed: function() { embed: function() {
if (!window.ui_halted) { window.ui_halted = true;
window.ui_halted = true;
this.$embedModalBody.append('<textarea class="raw"></textarea>'); this.$embedModalBody.append('<textarea class="raw"></textarea>');
$textarea = $('textarea.raw', this.$embedModalBody).val('<script type="text/javascript" src="' + this.model.get('embed_url') + '"></script>'); $textarea = $('textarea.raw', this.$embedModalBody).val('<script type="text/javascript" src="' + this.model.get('embed_url') + '"></script>');
this.$embedModal.modal('show'); this.$embedModal.modal('show');
$textarea.select(); $textarea.select();
}
}, },
embedClose: function() { embedClose: function() {
$('textarea', this.$embedModal).remove(); $('textarea', this.$embedModal).remove();
@ -123,7 +117,6 @@
this.$copyModal = $('div.copy-modal', this.$el); this.$copyModal = $('div.copy-modal', this.$el);
this.$copyModalBody = $('div.modal-body', this.$copyModal); this.$copyModalBody = $('div.modal-body', this.$copyModal);
this.$embedModal = $('div.embed-modal', this.$el); this.$embedModal = $('div.embed-modal', this.$el);
this.$embedModalBody = $('div.modal-body', this.$embedModal); this.$embedModalBody = $('div.modal-body', this.$embedModal);