mirror of
https://github.com/pinry/pinry.git
synced 2025-11-14 09:05:41 +01:00
Allow pin deleting from interface
This commit is contained in:
@@ -37,6 +37,14 @@ function getPinData(pinId) {
|
|||||||
return $.get(apiUrl);
|
return $.get(apiUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function deletePinData(pinId) {
|
||||||
|
var apiUrl = '/api/v1/pin/'+pinId+'/?format=json';
|
||||||
|
return $.ajax(apiUrl, {
|
||||||
|
type: 'DELETE'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function postPinData(data) {
|
function postPinData(data) {
|
||||||
return $.ajax({
|
return $.ajax({
|
||||||
type: "post",
|
type: "post",
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
* Descrip: This is for creation new pins on everything, the bookmarklet, on the
|
* Descrip: This is for creation new pins on everything, the bookmarklet, on the
|
||||||
* site and even editing pins in some limited situations.
|
* site and even editing pins in some limited situations.
|
||||||
* Authors: Pinry Contributors
|
* Authors: Pinry Contributors
|
||||||
* Updated: Feb 27th, 2013
|
* Updated: March 3rd, 2013
|
||||||
* Require: jQuery, Pinry JavaScript Helpers
|
* Require: jQuery, Pinry JavaScript Helpers
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -110,6 +110,7 @@ $(window).load(function() {
|
|||||||
var promise = postPinData(data);
|
var promise = postPinData(data);
|
||||||
promise.success(function(pin) {
|
promise.success(function(pin) {
|
||||||
if (pinFromUrl) return window.close();
|
if (pinFromUrl) return window.close();
|
||||||
|
pin.editable = true;
|
||||||
pin = renderTemplate('#pins-template', {pins: [pin]});
|
pin = renderTemplate('#pins-template', {pins: [pin]});
|
||||||
$('#pins').prepend(pin);
|
$('#pins').prepend(pin);
|
||||||
dismissModal(modal);
|
dismissModal(modal);
|
||||||
|
|||||||
@@ -44,6 +44,19 @@ $(window).load(function() {
|
|||||||
colHeights[sCol] += block.height()+(blockMargin);
|
colHeights[sCol] += block.height()+(blockMargin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Delete pin if trash icon clicked
|
||||||
|
$('.icon-trash').each(function() {
|
||||||
|
var thisPin = $(this);
|
||||||
|
$(this).click(function() {
|
||||||
|
$(this).off('click');
|
||||||
|
var promise = deletePinData($(this).data('id'));
|
||||||
|
promise.success(function() {
|
||||||
|
thisPin.parent().parent().parent().remove();
|
||||||
|
tileLayout();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
$('.spinner').css('display', 'none');
|
$('.spinner').css('display', 'none');
|
||||||
blockContainer.css('height', colHeights.sort().slice(-1)[0]);
|
blockContainer.css('height', colHeights.sort().slice(-1)[0]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,10 @@
|
|||||||
{{#if editable}}
|
{{#if editable}}
|
||||||
<div class="editable">
|
<div class="editable">
|
||||||
<div class="borderable">
|
<div class="borderable">
|
||||||
<i class="icon-white icon-pencil"></i>
|
<i class="icon-white icon-trash" data-id="{{id}}"></i>
|
||||||
|
</div>
|
||||||
|
<div class="borderable">
|
||||||
|
<i class="icon-white icon-pencil" data-id="{{id}}"></i>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|||||||
Reference in New Issue
Block a user