-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
141 additions
and
39 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,4 +18,4 @@ doc/api/ | |
# project includes source files written in JavaScript. | ||
*.js_ | ||
*.js.deps | ||
*.js.map | ||
*.js.map |
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,57 @@ | ||
library dialog.modal; | ||
|
||
import "dart:async"; | ||
import "dart:html"; | ||
import "../src/dialog_class.dart"; | ||
|
||
Future<dynamic> modal( | ||
[String title = "Modal", | ||
List<Node> content = const [], | ||
String successText, | ||
String cancelText, | ||
dynamic onSuccess, | ||
dynamic onCancel, | ||
bool cancellable, | ||
Element whatToFocus]) async { | ||
Completer c = Completer(); | ||
|
||
Dialog modalDialog = Dialog(title, content, cancellable, successText, | ||
cancelText, onSuccess, onCancel); | ||
|
||
whatToFocus ??= modalDialog.okButton; | ||
|
||
modalDialog.showDialog(); | ||
whatToFocus.focus(); | ||
|
||
whatToReturn(bool howClosed) { | ||
if (howClosed == true) { | ||
c.complete(onSuccess); | ||
} else if (howClosed == false) { | ||
c.complete(onCancel); | ||
} | ||
} | ||
|
||
modalDialog.dialogBackdrop.onClick.first.then((_) { | ||
whatToReturn(false); | ||
modalDialog.closeDialog(); | ||
}); | ||
|
||
querySelectorAll(".modal button").forEach((Element buttons) { | ||
buttons.onClick.first.then((e) { | ||
if (e.target == modalDialog.okButton) { | ||
whatToReturn(true); | ||
} else { | ||
whatToReturn(false); | ||
} | ||
modalDialog.closeDialog(); | ||
}); | ||
buttons.onKeyDown.listen((e) { | ||
if (e.keyCode == KeyCode.ESC) { | ||
whatToReturn(false); | ||
modalDialog.closeDialog(); | ||
} | ||
}); | ||
}); | ||
|
||
return c.future; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
name: dialog | ||
version: 0.6.2 | ||
description: Modern alert, confirm and prompt dialog implementation | ||
version: 0.7.0 | ||
description: Modern modal dialog implementation containing remakes of alert & confirm dialogs supplemented by prompt & custom modal dialogs | ||
author: Pavel Dvořák <[email protected]> | ||
homepage: https://github.com/dvorapa/dialog-dart | ||
documentation: | ||
environment: | ||
sdk: ">=2.0.0 <3.0.0" | ||
dev_dependencies: | ||
build_runner: ^0.10.0 | ||
build_web_compilers: ^0.4.0 | ||
build_web_compilers: ^0.4.0 |