Remove deletion toast after deletion
This commit is contained in:
parent
696c08200b
commit
6214e1373c
@ -153,7 +153,7 @@ weechat.factory('imgur', ['$rootScope', 'settings', function($rootScope, setting
|
|||||||
xhttp.onload = function() {
|
xhttp.onload = function() {
|
||||||
// Check state and response status
|
// Check state and response status
|
||||||
if(xhttp.status === 200) {
|
if(xhttp.status === 200) {
|
||||||
callback();
|
callback(deletehash);
|
||||||
} else {
|
} else {
|
||||||
showErrorMsg();
|
showErrorMsg();
|
||||||
}
|
}
|
||||||
|
@ -280,12 +280,20 @@ weechat.directive('inputBar', function() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var deleteCallback = function () {
|
var deleteCallback = function (deleteHash) {
|
||||||
// Image got sucessfully deleted.
|
// Image got sucessfully deleted.
|
||||||
// Show toast with delete link
|
// Show toast with delete link
|
||||||
var toastDeleted = $compile('<div class="toast toast-short">Successfully deleted.</div>')($scope)[0];
|
var toastDeleted = $compile('<div class="toast toast-short">Successfully deleted.</div>')($scope)[0];
|
||||||
document.body.appendChild(toastDeleted);
|
document.body.appendChild(toastDeleted);
|
||||||
setTimeout(function() { document.body.removeChild(toastDeleted); }, 5000);
|
setTimeout(function() { document.body.removeChild(toastDeleted); }, 5000);
|
||||||
|
|
||||||
|
// Try to remove the toast with the deletion link (it stays 15s
|
||||||
|
// instead of the 5 of the deletion notification, so it could
|
||||||
|
// come back beneath it, which would be confusing)
|
||||||
|
var pasteToast = document.querySelector("[data-imgur-deletehash='" + deleteHash + "']");
|
||||||
|
if (!!pasteToast) {
|
||||||
|
document.body.removeChild(pasteToast);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope.imgurDelete = function (deleteHash) {
|
$scope.imgurDelete = function (deleteHash) {
|
||||||
@ -774,7 +782,7 @@ weechat.directive('inputBar', function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Show toast with delete link
|
// Show toast with delete link
|
||||||
var toastImgur = $compile('<div class="toast toast-long">Image uploaded to Imgur. <a id="deleteImgur" ng-click="imgurDelete(\'' + deleteHash + '\')" href="">Delete?</a></div>')($scope)[0];
|
var toastImgur = $compile('<div class="toast toast-long" data-imgur-deletehash=\'' + deleteHash + '\'>Image uploaded to Imgur. <a id="deleteImgur" ng-click="imgurDelete(\'' + deleteHash + '\')" href="">Delete?</a></div>')($scope)[0];
|
||||||
document.body.appendChild(toastImgur);
|
document.body.appendChild(toastImgur);
|
||||||
setTimeout(function() { document.body.removeChild(toastImgur); }, 15000);
|
setTimeout(function() { document.body.removeChild(toastImgur); }, 15000);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user