Permalink
Browse files

inital commit

  • Loading branch information...
schorsch committed Sep 15, 2010
0 parents commit 9794919ab0d35c02a3bc6e5012f5894768f819fa
Showing with 45 additions and 0 deletions.
  1. +4 −0 .gitignore
  2. +9 −0 README.rdoc
  3. +32 −0 jquery-dragout.js
@@ -0,0 +1,4 @@
+nbproject/*
+coverage/*
+rdoc/*
+pkg/*
@@ -0,0 +1,9 @@
+= jQuery Dragout
+
+Plugin can be used to dragout files from your webbrowser onto your desktop.
+
+Currently only works in google chrome and firefox 4 beta.
+
+stay tuned for further features
+
+Copyright (c) 2009, 2010 Georg Leciejewski, released under the MIT license
@@ -0,0 +1,32 @@
+/**
+ * Download a file by dragging it out of the browser.
+ * Currently only supported by google chrome browser
+ * @example
+ * <a class="dragout"
+ * data-downloadurl="application/pdf:saleking-invoice.pdf:http://salesking.eu"
+ * href="http://some-url.de"
+ * salesking-invoice.pdf</a>
+ *
+ * $('.downdrag').dragout();
+ *
+ * The important part:
+ * data-downloadurl="application/pdf:saleking-invoice.pdf:http://salesking.eu"
+ * data-downloadurl="mime-type:filename:file-url"
+ */
+(function($) {
+ $.fn.extend({
+
+ dragout : function () {
+ var files = this;
+ if(files.length > 0) {
+ var use_data = (typeof files[0].dataset === "undefined") ? false : true;
+ $(files).each(function() {
+ var url = use_data ? this.dataset.downloadurl : this.getAttribute("data-downloadurl");
+ this.addEventListener("dragstart",function(e){
+ e.dataTransfer.setData("DownloadURL",url);
+ },false);
+ });
+ }
+ }
+});
+})(jQuery);

0 comments on commit 9794919

Please sign in to comment.