-
Notifications
You must be signed in to change notification settings - Fork 18
Alert and confirm #34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
asolove
wants to merge
6
commits into
montagejs:master
Choose a base branch
from
asolove:overlays
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
611567e
Add Alert
aadsm 56d3800
Add Confirm
aadsm c9ce8c7
Documentation for alert.
asolove 17ccaa0
New syntax for alert readme link.
asolove 727b57d
Documentation for confirm.
asolove 8fb43fe
Merge doc changes from master.
asolove File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,3 +1,15 @@ | ||
| var Component = require("montage/ui/component").Component; | ||
|
|
||
| exports.Main = Component.specialize({}); | ||
| exports.Main = Component.specialize({ | ||
|
|
||
| draw: { | ||
| value: function() { | ||
| // There can normally only be one overlay, absolutely-positioned, | ||
| // so we need to manually mangle the dom and style them to appear inline. | ||
| var overlays = ["alert", "alert-light", "alert-dark", "confirm", "confirm-light", "confirm-dark"]; | ||
| overlays.forEach(function(overlayName){ | ||
| this[overlayName].element.appendChild(this[overlayName]._overlay.element); | ||
| }.bind(this)); | ||
| } | ||
| } | ||
| }); | ||
This file contains hidden or 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 hidden or 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,27 @@ | ||
| var TestPageLoader = require("montage-testing/testpageloader").TestPageLoader; | ||
|
|
||
| TestPageLoader.queueTest("alert-test", function(testPage) { | ||
|
|
||
| describe("test/alert/alert-spec", function() { | ||
| it("should load", function() { | ||
| expect(testPage.loaded).toBe(true); | ||
| }); | ||
|
|
||
| describe("Alert", function() { | ||
| it("can be created", function() { | ||
| expect(testPage.test.templateObjects.alert).toBeDefined(); | ||
| }); | ||
|
|
||
| it("can be shown", function() { | ||
| var alert = testPage.test.templateObjects.alert; | ||
|
|
||
| alert.show(); | ||
|
|
||
| testPage.waitForComponentDraw(alert._overlay); | ||
| runs(function() { | ||
| expect(testPage.iframe.contentDocument.body.contains(alert._overlay.element)).toBeTruthy(); | ||
| }); | ||
| }); | ||
| }); | ||
| }); | ||
| }); |
This file contains hidden or 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,32 @@ | ||
| <!DOCTYPE html> | ||
| <html> | ||
| <head> | ||
| <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | ||
| <title>Alert Test</title> | ||
| <script type="text/javascript" src="../../node_modules/montage/montage.js" data-package="../../"></script> | ||
| <link rel="stylesheet" href="../../ui/text.reel/text.css"> | ||
| <script type="text/montage-serialization"> | ||
| { | ||
| "test": { | ||
| "prototype": "test/alert/alert-test[Test]" | ||
| }, | ||
|
|
||
| "alert": { | ||
| "prototype": "ui/alert.reel", | ||
| "properties": { | ||
| "element": {"#": "alert"}, | ||
| "title": "A Title", | ||
| "message": "A message" | ||
| } | ||
| } | ||
| } | ||
| </script> | ||
|
|
||
| </head> | ||
| <body> | ||
| <h1>Alert</h1> | ||
|
|
||
| <div data-montage-id="alert"></div> | ||
|
|
||
| </body> | ||
| </html> |
This file contains hidden or 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,4 @@ | ||
| var TestController = require("montage-testing/test-controller").TestController; | ||
|
|
||
| exports.Test = TestController.specialize({ | ||
| }); |
This file contains hidden or 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 hidden or 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,43 @@ | ||
| var TestPageLoader = require("montage-testing/testpageloader").TestPageLoader; | ||
|
|
||
| TestPageLoader.queueTest("confirm-test", function(testPage) { | ||
|
|
||
| describe("test/confirm/confirm-spec", function() { | ||
| it("should load", function() { | ||
| expect(testPage.loaded).toBe(true); | ||
| }); | ||
|
|
||
| describe("Confirm", function() { | ||
| it("can be created", function() { | ||
| expect(testPage.test.templateObjects.confirm).toBeDefined(); | ||
| }); | ||
|
|
||
| it("can be shown", function() { | ||
| var confirm = testPage.test.templateObjects.confirm; | ||
|
|
||
| confirm.show(); | ||
|
|
||
| testPage.waitForComponentDraw(confirm._overlay); | ||
| runs(function() { | ||
| expect(testPage.iframe.contentDocument.body.contains(confirm._overlay.element)).toBeTruthy(); | ||
| }); | ||
| }); | ||
|
|
||
| it("uses the configured ok label", function() { | ||
| var confirm = testPage.test.templateObjects.confirm; | ||
|
|
||
| confirm.okLabel = "Okay"; | ||
|
|
||
| expect(confirm._okButton.label).toBe("Okay"); | ||
| }); | ||
|
|
||
| it("uses the configured cancel label", function() { | ||
| var confirm = testPage.test.templateObjects.confirm; | ||
|
|
||
| confirm.cancelLabel = "Nay"; | ||
|
|
||
| expect(confirm._cancelButton.label).toBe("Nay"); | ||
| }); | ||
| }); | ||
| }); | ||
| }); |
This file contains hidden or 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,33 @@ | ||
| <!DOCTYPE html> | ||
| <html> | ||
| <head> | ||
| <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | ||
| <title>Confirm Test</title> | ||
| <script type="text/javascript" src="../../node_modules/montage/montage.js" data-package="../../"></script> | ||
| <script type="text/montage-serialization"> | ||
| { | ||
| "test": { | ||
| "prototype": "test/confirm/confirm-test[Test]" | ||
| }, | ||
|
|
||
| "confirm": { | ||
| "prototype": "ui/confirm.reel", | ||
| "properties": { | ||
| "element": {"#": "confirm"}, | ||
| "title": "A Title", | ||
| "message": "A message", | ||
| "okLabel": "Okay", | ||
| "cancelLabel": "Nay" | ||
| } | ||
| } | ||
| } | ||
| </script> | ||
|
|
||
| </head> | ||
| <body> | ||
| <h1>Confirm</h1> | ||
|
|
||
| <div data-montage-id="confirm"></div> | ||
|
|
||
| </body> | ||
| </html> |
This file contains hidden or 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,4 @@ | ||
| var TestController = require("montage-testing/test-controller").TestController; | ||
|
|
||
| exports.Test = TestController.specialize({ | ||
| }); |
This file contains hidden or 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,46 @@ | ||
| # Alert | ||
|
|
||
|  | ||
|
|
||
| The alert displays a message to the user, popping up above other content. | ||
|
|
||
| ## How to use | ||
|
|
||
| ```json | ||
| "alert": { | ||
| "prototype": "ui/alert.reel", | ||
| "properties": { | ||
| "element": {"#": "alert"}, | ||
| "title": "A Title", | ||
| "message": "A message", | ||
| "okLabel": "Ok" | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ```html | ||
| <div data-montage-id="alert"></span> | ||
| ``` | ||
|
|
||
|
|
||
|
|
||
| ## Available properties | ||
|
|
||
| * `title` - The text to appear in the title bar. | ||
| * `message` - The text to appear in the body. | ||
| * `okLabel` - The text to appear in the button to dismiss the alert. | ||
|
|
||
|
|
||
|
|
||
| ## Customizing with CSS | ||
|
|
||
| * `.digit-Alert` - The container element | ||
| * `.digit-Alert-header` - The header element | ||
| * `.digit-Alert-content` - The main content element | ||
| * `.digit-Alert-footer` - The footer element | ||
|
|
||
| ```css | ||
| .digit-Alert-header { | ||
| background: red; | ||
| } | ||
| ``` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of doing
.bind(this)you can passthisin as the last argument offorEach