[Update for 1.0 PR] Super Drag and Go
-
- Posts: 207
- Joined: November 10th, 2003, 2:27 pm
Possible bug found for 0.9
I found in 0.9, with "Super Drag and Go" installed, I cannot to move selected text around in the text box/frame (e.g. edit frame for this forum). And I did a quick test on 0.8 and found it doesn't effect 0.8. Any other users can confirm this bug?
Anyone coming up ideas why this problem occurs and how to solve it, please post your idea in this thread. Thanks!
Anyone coming up ideas why this problem occurs and how to solve it, please post your idea in this thread. Thanks!
-
- Posts: 209
- Joined: March 15th, 2004, 3:50 am
Morphis:
Since the abiltiy of saving an image when dragged is very important for me, I implemented a very simple such funtion for me: if Ctrl key is holded when dropping an image, the image is automatically saved to your default download directory.
The coded added to your extension is posted here. I you wish, please use it as an reference. I just hope you can add such function to your extension.
1. The following is added to the onDrag function
2. The following is two functions added to the superDrag object:
Since the abiltiy of saving an image when dragged is very important for me, I implemented a very simple such funtion for me: if Ctrl key is holded when dropping an image, the image is automatically saved to your default download directory.
The coded added to your extension is posted here. I you wish, please use it as an reference. I just hope you can add such function to your extension.
1. The following is added to the onDrag function
Code: Select all
if (aEvent.ctrlKey && aDragSession.sourceNode.nodeName == 'IMG')
{
superDrag.saveImage(aDragSession.sourceNode.src);
document.getElementById('statusbar-display').label = "The image is being saved.";
return;
}
2. The following is two functions added to the superDrag object:
Code: Select all
getDownloadsFolder: function() {
var pref = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch("browser.download.");
if (!pref.prefHasUserValue("dir"))
{
var fileLocator = Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties);
var dir = fileLocator.get("DeskV", Components.interfaces.nsILocalFile);
return dir.path;
}
else
return pref.getCharPref("dir");
},
saveImage: function(src)
{
var fileName = src.substring(src.lastIndexOf('/')+1, src.length);
var fileSaving = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
var path = superDrag.getDownloadsFolder() + "\\";
fileSaving.initWithPath(path);
if (!fileSaving.exists())
{
alert("The download folder does not exist!");
return;
}
fileSaving.initWithPath(path + fileName);
var i = 1;
while (fileSaving.exists())
{
if (fileName.indexOf('.') != -1)
{
var ext = fileName.substring(fileName.lastIndexOf('.'), fileName.length);
var file = fileName.substring(0, fileName.length - ext.length);
var newFileName = file + "-" + i + ext;
fileSaving.initWithPath(path + newFileName);
}
else
fileSaving.initWithPath(path + fileName + i);
i++;
}
var cacheKey = Components.classes['@mozilla.org/supports-string;1'].createInstance(Components.interfaces.nsISupportsString);
cacheKey.data = src;
var urifix = Components.classes['@mozilla.org/docshell/urifixup;1'].getService(Components.interfaces.nsIURIFixup);
var uri = urifix.createFixupURI(src, 0);
var hosturi = null;
if (uri.host.length > 0) {
hosturi = urifix.createFixupURI(uri.host, 0);
}
var persist = Components.classes['@mozilla.org/embedding/browser/nsWebBrowserPersist;1'].createInstance(Components.interfaces.nsIWebBrowserPersist);
persist.persistFlags = Components.interfaces.nsIWebBrowserPersist.PERSIST_FLAGS_FROM_CACHE | Components.interfaces.nsIWebBrowserPersist.PERSIST_FLAGS_CLEANUP_ON_FAILURE;
persist.saveURI(uri, cacheKey, hosturi, null, null, fileSaving);
},
Last edited by NetOne on July 3rd, 2004, 1:56 am, edited 1 time in total.
- Rowne Mastaile
- Posts: 1434
- Joined: December 21st, 2003, 3:05 pm
- Location: Housed in a swirling neosma of scintillating thought and turgid ideas.
- Contact:
Ooh, that's neat!
For those interested, I have a modified XPinstaller of this here [link].
I will, of course, remove it if Morphis says so, however.
This is wonderfully functional but there is one caveat.
If you don't use the 'Save all files to this folder' it can lock out mouse access. That's okay because one can still use the tab key but I thought I'd point that out.
For those interested, I have a modified XPinstaller of this here [link].
I will, of course, remove it if Morphis says so, however.
This is wonderfully functional but there is one caveat.
If you don't use the 'Save all files to this folder' it can lock out mouse access. That's okay because one can still use the tab key but I thought I'd point that out.
-
- Posts: 209
- Joined: March 15th, 2004, 3:50 am
I've tried as what you said, but there is no such problem. :)
And I've change the code a little to make it saving the image frome cache and to change the statusbar text to indicate the operation has been submitted. You can modidy your link if you wish. (Please note that the parameter name for saveImage function is changed.) Thanks!
BTW, those code are based on the code in the "Image toolbar" extension. Thanks to the authors of "Image toolbar".
And I've change the code a little to make it saving the image frome cache and to change the statusbar text to indicate the operation has been submitted. You can modidy your link if you wish. (Please note that the parameter name for saveImage function is changed.) Thanks!
BTW, those code are based on the code in the "Image toolbar" extension. Thanks to the authors of "Image toolbar".
- Rowne Mastaile
- Posts: 1434
- Joined: December 21st, 2003, 3:05 pm
- Location: Housed in a swirling neosma of scintillating thought and turgid ideas.
- Contact:
I find there is but maybe it's just me.
If you hold Ctrl and drag an image without the default set, it'll bring up a dialog but the browser will believe you're still dragging in the background of the dialog and the background (behind the dialog) has the focus. Perhaps I implimented your code incorrectly...
The mouse can still move and it works perfectly fine but clicking Save or Cancel in the dialog has no effect, one has to tab to them.
If you hold Ctrl and drag an image without the default set, it'll bring up a dialog but the browser will believe you're still dragging in the background of the dialog and the background (behind the dialog) has the focus. Perhaps I implimented your code incorrectly...
The mouse can still move and it works perfectly fine but clicking Save or Cancel in the dialog has no effect, one has to tab to them.
- Rowne Mastaile
- Posts: 1434
- Joined: December 21st, 2003, 3:05 pm
- Location: Housed in a swirling neosma of scintillating thought and turgid ideas.
- Contact:
Allow me to take back what I said earlier. Your code is perfect.
My problem was DownloadSort, apparently. I discovered this when I was trying to sort out why GMailCompose doesn't work.
With DownloadSort disabled, your extension addition has the desired effect. Very well done. Sorry about the irrelevant bug report and that.
At least now though if anyone else has this problem, they'll know it's DownloadSort.
-Edit-
I'm curious, let's say I wanted to change this to another folder other than my default download folder, what would I change? So it would always download there instead of the default.
My problem was DownloadSort, apparently. I discovered this when I was trying to sort out why GMailCompose doesn't work.
With DownloadSort disabled, your extension addition has the desired effect. Very well done. Sorry about the irrelevant bug report and that.
At least now though if anyone else has this problem, they'll know it's DownloadSort.
-Edit-
I'm curious, let's say I wanted to change this to another folder other than my default download folder, what would I change? So it would always download there instead of the default.
-
- Posts: 207
- Joined: November 10th, 2003, 2:27 pm
-Netone
I intergrate part of code into release 0.2.1 to make the "drag image to download" feature avaible. I didn't use your function "saveImage",
instead, I use the system function "saveUrl" which invokes the download manager to handle the download. See below "simplified" code section:
Thanks for your, including Roan Foofitush's , help.
I intergrate part of code into release 0.2.1 to make the "drag image to download" feature avaible. I didn't use your function "saveImage",
instead, I use the system function "saveUrl" which invokes the download manager to handle the download. See below "simplified" code section:
Code: Select all
if (aEvent.ctrlKey && aDragSession.sourceNode.nodeName == 'IMG')
{
// superDrag.saveImage(aDragSession.sourceNode.src);
==> saveUrl(DragSession.sourceNode.src, ...);
document.getElementById('statusbar-display').label = "The image is being saved.";
return;
}
Thanks for your, including Roan Foofitush's , help.
-
- Posts: 209
- Joined: March 15th, 2004, 3:50 am
I'm very glad to hear about this. It's my hornor to be helpful. :)
In the code I initially posted here the system function saveUrl is used. But I changed it to the saveImage function later because I'm not sure if saveUrl can save the image frome cache. I can't find any document about the saveUrl function.
In the code I initially posted here the system function saveUrl is used. But I changed it to the saveImage function later because I'm not sure if saveUrl can save the image frome cache. I can't find any document about the saveUrl function.
morphis wrote:-Netone
I intergrate part of code into release 0.2.1 to make the "drag image to download" feature avaible. I didn't use your function "saveImage",
instead, I use the system function "saveUrl" which invokes the download manager to handle the download. See below "simplified" code section:Code: Select all
if (aEvent.ctrlKey && aDragSession.sourceNode.nodeName == 'IMG')
{
// superDrag.saveImage(aDragSession.sourceNode.src);
==> saveUrl(DragSession.sourceNode.src, ...);
document.getElementById('statusbar-display').label = "The image is being saved.";
return;
}
Thanks for your, including Roan Foofitush's , help.
Last edited by NetOne on July 4th, 2004, 12:00 am, edited 1 time in total.
- soccer_dude182
- Posts: 720
- Joined: July 11th, 2003, 10:50 pm
- Location: Waco, TX