A ton of stuff for editing and deleting
parent
df6b1f5208
commit
ac7248f9a1
|
@ -9,7 +9,6 @@
|
|||
initialize: function() {
|
||||
this.model.view = this;
|
||||
this.model.bind('change', this.render, this);
|
||||
this.model.bind('destroy', this.remove, this);
|
||||
|
||||
this.template = _.template($('#snipt').html());
|
||||
this.editTemplate = _.template($('#edit').html());
|
||||
|
@ -23,19 +22,20 @@
|
|||
'click a.expand': 'expand',
|
||||
'click .container': 'selectFromClick',
|
||||
'copyRaw': 'copy',
|
||||
'copyClose': 'copyClose',
|
||||
'detail': 'detail',
|
||||
'deselect': 'deselect',
|
||||
'edit': 'edit',
|
||||
'embed': 'embed',
|
||||
'embedClose': 'embedClose',
|
||||
'expand': 'expand',
|
||||
'fadeAndRemove': 'fadeAndRemove',
|
||||
'next': 'next',
|
||||
'prev': 'prev',
|
||||
'selectSnipt': 'select'
|
||||
},
|
||||
|
||||
copy: function() {
|
||||
$('textarea', this.$copyModal).remove();
|
||||
|
||||
window.ui_halted = true;
|
||||
|
||||
this.$copyModalBody.append('<textarea class="raw"></textarea>');
|
||||
|
@ -44,9 +44,6 @@
|
|||
this.$copyModal.modal('show');
|
||||
$textarea.select();
|
||||
},
|
||||
copyClose: function() {
|
||||
$('textarea', this.$copyModal).remove();
|
||||
},
|
||||
copyFromClick: function() {
|
||||
this.copy();
|
||||
return false;
|
||||
|
@ -66,7 +63,7 @@
|
|||
this.select();
|
||||
|
||||
// Local vars
|
||||
var that = this;
|
||||
that = this;
|
||||
var editPane = this.editTemplate({snipt: this.model.toJSON()});
|
||||
|
||||
// Init main view
|
||||
|
@ -107,23 +104,21 @@
|
|||
});
|
||||
|
||||
// Edit buttons
|
||||
$('button.delete', window.site.$main_edit).on('click', function(e) {
|
||||
$('button.delete', window.site.$main_edit).on('click', function() {
|
||||
if (confirm('Are you sure you want to delete this snipt?')) {
|
||||
that.model.destroy();
|
||||
}
|
||||
e.preventDefault();
|
||||
window.site.snipt_list.escapeUI(true);
|
||||
return false;
|
||||
});
|
||||
$('button.cancel', window.site.$main_edit).on('click', function(e) {
|
||||
$('button.cancel', window.site.$main_edit).on('click', function() {
|
||||
window.site.snipt_list.escapeUI();
|
||||
return false;
|
||||
});
|
||||
$('button.save', window.site.$main_edit).on('click', function(e) {
|
||||
that.model.set('title', $('input#snipt_title').val());
|
||||
that.model.save();
|
||||
|
||||
$('button.save', window.site.$main_edit).on('click', function() {
|
||||
that.save();
|
||||
window.site.snipt_list.escapeUI();
|
||||
|
||||
e.preventDefault();
|
||||
return false;
|
||||
});
|
||||
|
||||
window.scrollTo(0, 0);
|
||||
|
@ -131,6 +126,8 @@
|
|||
return false;
|
||||
},
|
||||
embed: function() {
|
||||
$('textarea', this.$embedModal).remove();
|
||||
|
||||
window.ui_halted = true;
|
||||
|
||||
this.$embedModalBody.append('<textarea class="raw"></textarea>');
|
||||
|
@ -139,9 +136,6 @@
|
|||
this.$embedModal.modal('show');
|
||||
$textarea.select();
|
||||
},
|
||||
embedClose: function() {
|
||||
$('textarea', this.$embedModal).remove();
|
||||
},
|
||||
embedFromClick: function() {
|
||||
this.embed();
|
||||
return false;
|
||||
|
@ -152,8 +146,14 @@
|
|||
this.select();
|
||||
return false;
|
||||
},
|
||||
fadeAndRemove: function() {
|
||||
window.$selected = false;
|
||||
$(this.el).fadeOut('fast', function() {
|
||||
$(this).remove();
|
||||
});
|
||||
return false;
|
||||
},
|
||||
initLocalVars: function() {
|
||||
this.$el = $(this.el);
|
||||
this.$aside = $('aside', this.$el);
|
||||
this.$container = $('div.container', this.$el);
|
||||
|
||||
|
@ -166,12 +166,10 @@
|
|||
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;
|
||||
});
|
||||
|
@ -193,11 +191,9 @@
|
|||
}
|
||||
},
|
||||
remove: function() {
|
||||
console.log('remove() on view called');
|
||||
return false;
|
||||
},
|
||||
render: function() {
|
||||
console.log('render called');
|
||||
|
||||
this.$el.html(this.template({
|
||||
snipt: this.model.toJSON()
|
||||
}));
|
||||
|
@ -226,6 +222,13 @@
|
|||
|
||||
return this;
|
||||
},
|
||||
save: function() {
|
||||
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.save();
|
||||
},
|
||||
select: function(fromClick) {
|
||||
|
||||
$('article.selected', window.site.snipt_list.$el).removeClass('selected');
|
||||
|
@ -254,7 +257,6 @@
|
|||
initialize: function(opts) {
|
||||
|
||||
opts.snipts.each(this.addExistingSnipt);
|
||||
this.$el = $(this.el);
|
||||
|
||||
this.keyboardShortcuts();
|
||||
|
||||
|
@ -318,7 +320,7 @@
|
|||
model: new Snipt.SniptModel(data)
|
||||
});
|
||||
},
|
||||
escapeUI: function() {
|
||||
escapeUI: function(destroyed) {
|
||||
if (window.editing) {
|
||||
if (!window.site.$html.hasClass('detail')) {
|
||||
window.site.$body.removeClass('detail');
|
||||
|
@ -337,6 +339,10 @@
|
|||
scrollTop: window.$selected.offset().top - 50
|
||||
}, 0);
|
||||
}
|
||||
|
||||
if (destroyed) {
|
||||
window.$selected.trigger('fadeAndRemove');
|
||||
}
|
||||
} else {
|
||||
if (!window.ui_halted) {
|
||||
if ($selected) {
|
||||
|
|
|
@ -91,6 +91,7 @@ class PrivateUserResource(ModelResource):
|
|||
list_allowed_methods = []
|
||||
authentication = ApiKeyAuthentication()
|
||||
authorization = DjangoAuthorization()
|
||||
always_return_data = True
|
||||
cache = SimpleCache()
|
||||
|
||||
def apply_authorization_limits(self, request, object_list):
|
||||
|
@ -104,6 +105,7 @@ class PrivateTagResource(ModelResource):
|
|||
allowed_methods = ['get']
|
||||
authentication = ApiKeyAuthentication()
|
||||
authorization = DjangoAuthorization()
|
||||
always_return_data = True
|
||||
cache = SimpleCache()
|
||||
|
||||
def dehydrate(self, bundle):
|
||||
|
@ -142,6 +144,7 @@ class PrivateSniptResource(ModelResource):
|
|||
ordering = ['created', 'modified',]
|
||||
# TODO max_limit does not work.
|
||||
max_limit = 200
|
||||
always_return_data = True
|
||||
cache = SimpleCache()
|
||||
|
||||
def dehydrate(self, bundle):
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
{% compress css %}
|
||||
<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/bootstrap.css" />
|
||||
<link rel="stylesheet" type="text/scss" href="{{ STATIC_URL }}css/style.css" />
|
||||
<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/style.css" />
|
||||
<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/themes.css" />
|
||||
<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/chosen.css" />
|
||||
{% endcompress %}
|
||||
|
@ -119,9 +119,11 @@
|
|||
</div>
|
||||
{% block aside %}
|
||||
<aside class="main">
|
||||
<section class="ad coffee">
|
||||
<script type="text/javascript" src="http://adsbycoffee.appspot.com/partner.js?publisher=ag1zfmFkc2J5Y29mZmVlchALEglQdWJsaXNoZXIY-VUM"></script>
|
||||
</section>
|
||||
{% if not debug %}
|
||||
<section class="ad coffee">
|
||||
<script type="text/javascript" src="http://adsbycoffee.appspot.com/partner.js?publisher=ag1zfmFkc2J5Y29mZmVlchALEglQdWJsaXNoZXIY-VUM"></script>
|
||||
</section>
|
||||
{% endif %}
|
||||
{% block tags %}{% endblock %}
|
||||
<nav class="footer">
|
||||
<ul>
|
||||
|
|
Loading…
Reference in New Issue