|
|
@ -14,10 +14,11 @@ weechat.directive('inputBar', function() { |
|
|
|
command: '=command' |
|
|
|
command: '=command' |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
controller: ['$rootScope', '$scope', '$element', '$log', 'connection', 'imgur', 'models', 'IrcUtils', 'settings', 'utils', function($rootScope, |
|
|
|
controller: ['$rootScope', '$scope', '$element', '$log', '$compile', 'connection', 'imgur', 'models', 'IrcUtils', 'settings', 'utils', function($rootScope, |
|
|
|
$scope, |
|
|
|
$scope, |
|
|
|
$element, //XXX do we need this? don't seem to be using it
|
|
|
|
$element, //XXX do we need this? don't seem to be using it
|
|
|
|
$log, |
|
|
|
$log, |
|
|
|
|
|
|
|
$compile, |
|
|
|
connection, //XXX we should eliminate this dependency and use signals instead
|
|
|
|
connection, //XXX we should eliminate this dependency and use signals instead
|
|
|
|
imgur, |
|
|
|
imgur, |
|
|
|
models, |
|
|
|
models, |
|
|
@ -263,8 +264,8 @@ weechat.directive('inputBar', function() { |
|
|
|
|
|
|
|
|
|
|
|
$scope.uploadImage = function($event, files) { |
|
|
|
$scope.uploadImage = function($event, files) { |
|
|
|
// Send image url after upload
|
|
|
|
// Send image url after upload
|
|
|
|
var sendImageUrl = function(imageUrl) { |
|
|
|
var sendImageUrl = function(imageUrl, deleteHash) { |
|
|
|
// Send image
|
|
|
|
// Put link in input box
|
|
|
|
if(imageUrl !== undefined && imageUrl !== '') { |
|
|
|
if(imageUrl !== undefined && imageUrl !== '') { |
|
|
|
$rootScope.insertAtCaret(String(imageUrl)); |
|
|
|
$rootScope.insertAtCaret(String(imageUrl)); |
|
|
|
} |
|
|
|
} |
|
|
@ -276,8 +277,27 @@ weechat.directive('inputBar', function() { |
|
|
|
// Process image
|
|
|
|
// Process image
|
|
|
|
imgur.process(files[i], sendImageUrl); |
|
|
|
imgur.process(files[i], sendImageUrl); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var deleteCallback = function (deleteHash) { |
|
|
|
|
|
|
|
// Image got sucessfully deleted.
|
|
|
|
|
|
|
|
// Show toast with delete link
|
|
|
|
|
|
|
|
var toastDeleted = $compile('<div class="toast toast-short">Successfully deleted.</div>')($scope)[0]; |
|
|
|
|
|
|
|
document.body.appendChild(toastDeleted); |
|
|
|
|
|
|
|
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) { |
|
|
|
|
|
|
|
imgur.deleteImage( deleteHash, deleteCallback ); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// Send the message to the websocket
|
|
|
|
// Send the message to the websocket
|
|
|
@ -351,7 +371,7 @@ weechat.directive('inputBar', function() { |
|
|
|
if (buffer.type === 'channel' && !is_online) { |
|
|
|
if (buffer.type === 'channel' && !is_online) { |
|
|
|
// show a toast that the user left
|
|
|
|
// show a toast that the user left
|
|
|
|
var toast = document.createElement('div'); |
|
|
|
var toast = document.createElement('div'); |
|
|
|
toast.id = "toast"; |
|
|
|
toast.className = "toast toast-short"; |
|
|
|
toast.innerHTML = nick + " has left the room"; |
|
|
|
toast.innerHTML = nick + " has left the room"; |
|
|
|
document.body.appendChild(toast); |
|
|
|
document.body.appendChild(toast); |
|
|
|
setTimeout(function() { document.body.removeChild(toast); }, 5000); |
|
|
|
setTimeout(function() { document.body.removeChild(toast); }, 5000); |
|
|
@ -750,15 +770,24 @@ weechat.directive('inputBar', function() { |
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
return true; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
$scope.inputPasted = function(e) { |
|
|
|
$scope.inputPasted = function(e) { |
|
|
|
if (e.clipboardData && e.clipboardData.files && e.clipboardData.files.length) { |
|
|
|
if (e.clipboardData && e.clipboardData.files && e.clipboardData.files.length) { |
|
|
|
e.stopPropagation(); |
|
|
|
e.stopPropagation(); |
|
|
|
e.preventDefault(); |
|
|
|
e.preventDefault(); |
|
|
|
|
|
|
|
|
|
|
|
var sendImageUrl = function(imageUrl) { |
|
|
|
var sendImageUrl = function(imageUrl, deleteHash) { |
|
|
|
if(imageUrl !== undefined && imageUrl !== '') { |
|
|
|
if(imageUrl !== undefined && imageUrl !== '') { |
|
|
|
$rootScope.insertAtCaret(String(imageUrl)); |
|
|
|
$rootScope.insertAtCaret(String(imageUrl)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Show toast with delete link
|
|
|
|
|
|
|
|
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); |
|
|
|
|
|
|
|
setTimeout(function() { document.body.removeChild(toastImgur); }, 15000); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Log the delete hash to the console in case the toast was missed.
|
|
|
|
|
|
|
|
console.log('An image was uploaded to imgur, delete it with $scope.imgurDelete(\'' + deleteHash + '\')'); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
for (var i = 0; i < e.clipboardData.files.length; i++) { |
|
|
|
for (var i = 0; i < e.clipboardData.files.length; i++) { |
|
|
|