mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-04-18 06:15:49 +02:00
Allow dragging tweet links over columns to open them in detail view
Closes #167
This commit is contained in:
parent
3f5ffc9e10
commit
f17806f4e8
@ -85,6 +85,7 @@ public FormBrowser(UpdaterSettings updaterSettings){
|
|||||||
|
|
||||||
this.browser = new ChromiumWebBrowser("https://tweetdeck.twitter.com/"){
|
this.browser = new ChromiumWebBrowser("https://tweetdeck.twitter.com/"){
|
||||||
DialogHandler = new FileDialogHandler(),
|
DialogHandler = new FileDialogHandler(),
|
||||||
|
DragHandler = new DragHandlerBrowser(),
|
||||||
MenuHandler = new ContextMenuBrowser(this),
|
MenuHandler = new ContextMenuBrowser(this),
|
||||||
JsDialogHandler = new JavaScriptDialogHandler(),
|
JsDialogHandler = new JavaScriptDialogHandler(),
|
||||||
KeyboardHandler = new KeyboardHandlerBrowser(this),
|
KeyboardHandler = new KeyboardHandlerBrowser(this),
|
||||||
|
19
Core/Handling/DragHandlerBrowser.cs
Normal file
19
Core/Handling/DragHandlerBrowser.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using CefSharp;
|
||||||
|
|
||||||
|
namespace TweetDuck.Core.Handling{
|
||||||
|
sealed class DragHandlerBrowser : IDragHandler{
|
||||||
|
public bool OnDragEnter(IWebBrowser browserControl, IBrowser browser, IDragData dragData, DragOperationsMask mask){
|
||||||
|
if (dragData.IsLink){
|
||||||
|
browserControl.ExecuteScriptAsync("window.TDGF_onGlobalDragStart", "link", dragData.LinkUrl);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
browserControl.ExecuteScriptAsync("window.TDGF_onGlobalDragStart", "unknown");
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnDraggableRegionsChanged(IWebBrowser browserControl, IBrowser browser, IList<DraggableRegion> regions){}
|
||||||
|
}
|
||||||
|
}
|
@ -683,6 +683,46 @@
|
|||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Block: Allow drag & drop behavior for dropping links on columns to open their detail view.
|
||||||
|
//
|
||||||
|
(function(){
|
||||||
|
let tweetRegex = /^https?:\/\/twitter\.com\/[A-Za-z0-9_]+\/status\/(\d+)\/?$/;
|
||||||
|
let isDraggingValid = false;
|
||||||
|
|
||||||
|
window.TDGF_onGlobalDragStart = function(type, data){
|
||||||
|
isDraggingValid = type === "link" && tweetRegex.test(data);
|
||||||
|
};
|
||||||
|
|
||||||
|
app.delegate("section.js-column", {
|
||||||
|
dragover: function(e){
|
||||||
|
e.originalEvent.dataTransfer.dropEffect = isDraggingValid ? "move" : "none";
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
},
|
||||||
|
|
||||||
|
drop: function(e){
|
||||||
|
let match = tweetRegex.exec(e.originalEvent.dataTransfer.getData("URL"));
|
||||||
|
|
||||||
|
if (match.length === 2){
|
||||||
|
let column = TD.controller.columnManager.get($(this).attr("data-column"));
|
||||||
|
|
||||||
|
if (column){
|
||||||
|
TD.controller.clients.getPreferredClient().show(match[1], function(chirp){
|
||||||
|
TD.ui.updates.showDetailView(column, chirp, column.findChirp(chirp) || chirp);
|
||||||
|
$(document).trigger("uiGridClearSelection");
|
||||||
|
}, function(){
|
||||||
|
alert("error|Could not retrieve the requested tweet.");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})();
|
||||||
|
|
||||||
//
|
//
|
||||||
// Block: Fix scheduled tweets not showing up sometimes.
|
// Block: Fix scheduled tweets not showing up sometimes.
|
||||||
//
|
//
|
||||||
|
@ -88,6 +88,7 @@
|
|||||||
<SubType>Component</SubType>
|
<SubType>Component</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Core\FormManager.cs" />
|
<Compile Include="Core\FormManager.cs" />
|
||||||
|
<Compile Include="Core\Handling\DragHandlerBrowser.cs" />
|
||||||
<Compile Include="Core\Handling\General\BrowserProcessHandler.cs" />
|
<Compile Include="Core\Handling\General\BrowserProcessHandler.cs" />
|
||||||
<Compile Include="Core\Handling\ContextMenuBase.cs" />
|
<Compile Include="Core\Handling\ContextMenuBase.cs" />
|
||||||
<Compile Include="Core\Handling\ContextMenuBrowser.cs" />
|
<Compile Include="Core\Handling\ContextMenuBrowser.cs" />
|
||||||
|
Loading…
Reference in New Issue
Block a user