Working on edit
parent
1835b362e1
commit
d71b960ecf
|
@ -801,6 +801,7 @@ div.modal {
|
|||
}
|
||||
h3 {
|
||||
span {
|
||||
display: inline-block;
|
||||
max-width: 400px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
|
|
|
@ -82,7 +82,7 @@
|
|||
}
|
||||
},
|
||||
detail: function() {
|
||||
window.location = this.model.get('url');
|
||||
window.location = this.model.get('absolute_url');
|
||||
},
|
||||
edit: function() {
|
||||
if (!$('section.main-edit:visible').length) {
|
||||
|
@ -95,11 +95,13 @@
|
|||
},
|
||||
embed: function() {
|
||||
alert('TODO');
|
||||
return false;
|
||||
},
|
||||
expand: function() {
|
||||
this.$container.toggleClass('expanded', 100);
|
||||
this.$tags.toggleClass('expanded');
|
||||
this.select();
|
||||
return false;
|
||||
},
|
||||
next: function() {
|
||||
window.site.$copyModals.modal('hide');
|
||||
|
@ -144,7 +146,7 @@
|
|||
e.stopPropagation();
|
||||
},
|
||||
test: function() {
|
||||
this.model.set({'title': 'Changed title!'});
|
||||
console.log(this.model.attributes);
|
||||
}
|
||||
});
|
||||
SniptListView = Backbone.View.extend({
|
||||
|
@ -160,11 +162,31 @@
|
|||
},
|
||||
|
||||
addExistingSnipt: function() {
|
||||
var $h1 = $('header h1 a', this);
|
||||
|
||||
var $el = $(this);
|
||||
var $h1 = $('header h1 a', $el);
|
||||
|
||||
var data = {
|
||||
absolute_url: $h1.attr('href'),
|
||||
code: '',
|
||||
created: '',
|
||||
description: '',
|
||||
embed_url: '',
|
||||
id: parseInt($el.attr('id').replace('snipt-', ''), 0),
|
||||
key: '',
|
||||
lexer: '',
|
||||
line_count: 0,
|
||||
modified: '',
|
||||
pub: false,
|
||||
resource_uri: '',
|
||||
slug: '',
|
||||
stylized: '',
|
||||
tags: [],
|
||||
tags_list: '',
|
||||
title: $h1.text(),
|
||||
url: $h1.attr('href')
|
||||
user: ''
|
||||
};
|
||||
|
||||
var view = new SniptView({
|
||||
el: this,
|
||||
model: new SniptModel(data)
|
||||
|
@ -200,7 +222,7 @@
|
|||
$selected.trigger('copyRaw');
|
||||
}
|
||||
});
|
||||
$document.bind('keydown', 'e', function() {
|
||||
$document.bind('keydown', 'Ctrl+e', function() {
|
||||
if ($selected) {
|
||||
if ($selected.hasClass('editable')) {
|
||||
$selected.trigger('edit');
|
||||
|
@ -240,7 +262,7 @@
|
|||
}
|
||||
}
|
||||
});
|
||||
$document.bind('keydown', 'o', function() {
|
||||
$document.bind('keydown', 'e', function() {
|
||||
if ($selected) {
|
||||
if ($selected.hasClass('expandable')) {
|
||||
$selected.trigger('expand');
|
||||
|
@ -260,6 +282,11 @@
|
|||
$selected.trigger('embed');
|
||||
}
|
||||
});
|
||||
$document.bind('keydown', 'o', function() {
|
||||
if ($selected) {
|
||||
$selected.trigger('detail');
|
||||
}
|
||||
});
|
||||
$document.bind('keydown', 'return', function() {
|
||||
if ($selected) {
|
||||
$selected.trigger('detail');
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{% load humanize %}
|
||||
|
||||
<article class="snipt {% if not snipt.public %}private-snipt{% endif %} {% if snipt.line_count > 8 and not detail %}expandable{% endif %} {% if snipt.user == request.user %}editable{% endif %}">
|
||||
<article id="snipt-{{ snipt.pk }}" class="snipt {% if not snipt.public %}private-snipt{% endif %} {% if snipt.line_count > 8 and not detail %}expandable{% endif %} {% if snipt.user == request.user %}editable{% endif %}">
|
||||
<div class="number">#{{ snipt.id }}</div>
|
||||
<div class="group">
|
||||
<div class="container">
|
||||
|
@ -33,7 +33,7 @@
|
|||
<a class="embed" href="#">Embed</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="copy" href="#"><span class="do">Copy</span><span class="done">Copied!</span></a>
|
||||
<a class="copy" href="#"><span class="do">Copy</span></a>
|
||||
</li>
|
||||
</ul>
|
||||
<section class="tags">
|
||||
|
|
|
@ -210,7 +210,7 @@
|
|||
<td>Go to snipt</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>o</td>
|
||||
<td>e</td>
|
||||
<td>Expand / collapse snipt</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -222,7 +222,7 @@
|
|||
<td>Copy snipt</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>e</td>
|
||||
<td><ctrl-e></td>
|
||||
<td>Edit snipt</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
@ -249,7 +249,7 @@
|
|||
</div>
|
||||
<div id="edit">
|
||||
<div class="inner">
|
||||
{{url}}<br />
|
||||
{{absolute_url}}<br />
|
||||
{{title}}
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue