-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Drag-n-drop support in file upload form
- Loading branch information
Showing
6 changed files
with
93 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
server/webapp/src/main/scala/com/karasiq/shadowcloud/webapp/components/common/Dropzone.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.karasiq.shadowcloud.webapp.components.common | ||
|
||
import com.karasiq.bootstrap.Bootstrap.default._ | ||
import org.scalajs.dom | ||
import scalaTags._ | ||
|
||
import scala.scalajs.js | ||
import scala.scalajs.js.annotation.JSGlobal | ||
|
||
@js.native | ||
@JSGlobal("Dropzone") | ||
class Dropzone(element: js.Any, options: js.Object) extends js.Object { | ||
def on[T <: js.Any](event: String, f: js.Function1[T, Unit]): Unit = js.native | ||
def removeAllFiles(): Unit = js.native | ||
} | ||
|
||
object Dropzone { | ||
def apply(process: dom.File => Unit): Modifier = { e: dom.Element => | ||
val dropzone = new Dropzone(e, js.Dynamic.literal(url = "/", autoProcessQueue = false).asInstanceOf[js.Object]) | ||
dropzone.on("addedfile", { f: dom.File => | ||
process(f) | ||
dropzone.removeAllFiles() | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters