Skip to content

Commit

Permalink
Add Bootstrap Modal Web Views
Browse files Browse the repository at this point in the history
  • Loading branch information
gcotelli committed Apr 10, 2017
1 parent 0b49dc5 commit a1df903
Show file tree
Hide file tree
Showing 53 changed files with 458 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
A BootstrapModalFooterTest is a test class for testing the behavior of BootstrapModalFooterWebView
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
private
acceptButton

^ AsynchronicButtonWebView
labeled: 'Accept'
applying:
(ComponentClassificationCommand
toStyleWithAll:
{BootstrapCssStyles button.
BootstrapCssStyles buttonPrimary})
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
tests
testOnTrigger

| footer html |

footer := BootstrapModalFooterWebView
with: self acceptButton
andCloseButtonLabeled: 'Close'
applying: (ComponentClassificationCommand toStyleWith: BootstrapCssStyles buttonLink).

footer onTrigger disable.

html := self render: footer.

self
assert: html
equals:
'<div class="modal-footer"><button class="btn btn-link" data-dismiss="modal" type="button">Close</button><button id="button-id1" class="btn btn-primary" type="button">Accept</button></div><script type="text/javascript">$("#button-id1").click(function(){$(this).prop("disabled",true)});</script>'
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
tests
testRenderContentOn

| footer html |

footer := BootstrapModalFooterWebView
withCloseButtonLabeled: 'Close'
applying: (ComponentClassificationCommand toStyleWith: BootstrapCssStyles buttonLink).

html := self render: footer.

self assert: html equals: '<div class="modal-footer"><button class="btn btn-link" data-dismiss="modal" type="button">Close</button></div>'
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
tests
testRenderContentOnWithAdditionalButtons

| footer html |

footer := BootstrapModalFooterWebView
with: self acceptButton
andCloseButtonLabeled: 'Close'
applying: (ComponentClassificationCommand toStyleWith: BootstrapCssStyles buttonLink).

html := self render: footer.

self
assert: html
equals:
'<div class="modal-footer"><button class="btn btn-link" data-dismiss="modal" type="button">Close</button><button class="btn btn-primary" type="button">Accept</button></div>'
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"instance" : {
"testRenderContentOnWithAdditionalButtons" : "GabrielOmarCotelli 4/10/2017 10:22",
"testOnTrigger" : "GabrielOmarCotelli 4/10/2017 10:22",
"acceptButton" : "GabrielOmarCotelli 4/10/2017 09:55",
"testRenderContentOn" : "GabrielOmarCotelli 4/10/2017 10:22"
},
"class" : { }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"commentStamp" : "GabrielOmarCotelli 4/10/2017 10:23",
"super" : "WillowTestCase",
"category" : "Willow-Bootstrap-Tests-WebViews",
"classinstvars" : [ ],
"pools" : [ ],
"classvars" : [ ],
"instvars" : [ ],
"name" : "BootstrapModalFooterWebViewTest",
"type" : "normal"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
A BootstrapModalHeaderTest is a test class for testing the behavior of BootstrapModalHeaderWebView
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
tests
testRenderContentOn

| header html |

header := BootstrapModalHeaderWebView titled: 'Welcome!'.
html := self render: header.

self assert: html equals: '<div class="modal-header"><h4 class="modal-title">Welcome!</h4></div>'
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
tests
testRenderContentOnWithComplexTitle

| header html |

header := BootstrapModalHeaderWebView
titled: [ :canvas |
canvas
render: (BootstrapIconWebView representing: Glyphicons menuUp);
render: 'Up!' ].
html := self render: header.

self
assert: html
equals: '<div class="modal-header"><h4 class="modal-title"><span class="glyphicon glyphicon-menu-up"></span>Up!</h4></div>'
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
tests
testRenderContentOnWithDismissButton

| header html |

header := BootstrapModalHeaderWebView dismissableTitled: 'Welcome!'.
html := self render: header.

self
assert: html
equals:
'<div class="modal-header"><button class="close" data-dismiss="modal" aria-label="Close" type="button"><span aria-hidden="true">×</span></button><h4 class="modal-title">Welcome!</h4></div>'
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"instance" : {
"testRenderContentOnWithDismissButton" : "GabrielOmarCotelli 4/10/2017 10:22",
"testRenderContentOnWithComplexTitle" : "GabrielOmarCotelli 4/10/2017 10:22",
"testRenderContentOn" : "GabrielOmarCotelli 4/10/2017 10:22"
},
"class" : { }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"commentStamp" : "GabrielOmarCotelli 4/10/2017 10:23",
"super" : "WillowTestCase",
"category" : "Willow-Bootstrap-Tests-WebViews",
"classinstvars" : [ ],
"pools" : [ ],
"classvars" : [ ],
"instvars" : [ ],
"name" : "BootstrapModalHeaderWebViewTest",
"type" : "normal"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
A BootstrapModalWebViewTest is a test class for testing the behavior of BootstrapModalWebView
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
private
agreeButton

^ AsynchronicButtonWebView
labeled: 'Agree'
applying:
(ComponentClassificationCommand
toStyleWithAll:
{BootstrapCssStyles button.
BootstrapCssStyles buttonDefault})
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
private
takeMySoulButton

^ AsynchronicButtonWebView
labeled: 'Just take my soul'
applying:
(ComponentClassificationCommand
toStyleWithAll:
{BootstrapCssStyles button.
BootstrapCssStyles buttonPrimary})
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
tests
testOnTrigger

| html footer header dialog |

footer := BootstrapModalFooterWebView withCloseButtonLabeled: 'Ok' applying: (ComponentClassificationCommand toStyleWith: BootstrapCssStyles buttonLink).
header := BootstrapModalHeaderWebView titled: 'Terms and Conditions'.
dialog := BootstrapModalWebView withHeader: header containing: 'Some very large legal stuff. ;)' footer: footer.

dialog onTrigger disable.

html := self render: dialog.

"The only button is the close one, so no need to generate javascript."
self assert: html equals: '<div class="modal" tabindex="-1" role="dialog"><div class="modal-dialog" role="document"><div class="modal-content"><div class="modal-header"><h4 class="modal-title">Terms and Conditions</h4></div><div class="modal-body">Some very large legal stuff. ;)</div><div class="modal-footer"><button class="btn btn-link" data-dismiss="modal" type="button">Ok</button></div></div></div></div>'
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
tests
testOnTriggerWithButtons

| html footer header dialog |

footer := BootstrapModalFooterWebView
containing:
{self agreeButton.
self takeMySoulButton}
andCloseButton:
(BootstrapModalFooterWebView
closeButtonLabeled: 'Disagree'
applying: (ComponentClassificationCommand toStyleWith: BootstrapCssStyles buttonLink)).
header := BootstrapModalHeaderWebView titled: 'Terms and Conditions'.
dialog := BootstrapModalWebView withHeader: header containing: 'Some very large legal stuff. ;)' footer: footer.

dialog onTrigger disable.

html := self render: dialog.

self
assert: html
equals:
'<div class="modal" tabindex="-1" role="dialog"><div class="modal-dialog" role="document"><div class="modal-content"><div class="modal-header"><h4 class="modal-title">Terms and Conditions</h4></div><div class="modal-body">Some very large legal stuff. ;)</div><div class="modal-footer"><button class="btn btn-link" data-dismiss="modal" type="button">Disagree</button><button id="button-id1" class="btn btn-default" type="button">Agree</button><button id="button-id2" class="btn btn-primary" type="button">Just take my soul</button></div></div></div></div><script type="text/javascript">$("#button-id1").click(function(){$(this).prop("disabled",true)});$("#button-id2").click(function(){$(this).prop("disabled",true)});</script>'
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
tests
testRenderContentOn

| html footer header dialog |

footer := BootstrapModalFooterWebView withCloseButtonLabeled: 'Ok' applying: (ComponentClassificationCommand toStyleWith: BootstrapCssStyles buttonLink).
header := BootstrapModalHeaderWebView titled: 'Terms and Conditions'.

dialog := BootstrapModalWebView withHeader: header containing: 'Some very large legal stuff. ;)' footer: footer.

html := self render: dialog.

self assert: html equals: '<div class="modal" tabindex="-1" role="dialog"><div class="modal-dialog" role="document"><div class="modal-content"><div class="modal-header"><h4 class="modal-title">Terms and Conditions</h4></div><div class="modal-body">Some very large legal stuff. ;)</div><div class="modal-footer"><button class="btn btn-link" data-dismiss="modal" type="button">Ok</button></div></div></div></div>'
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
tests
testRenderContentOnWithCommands

| html footer header dialog |

footer := BootstrapModalFooterWebView withCloseButtonLabeled: 'Ok' applying: (ComponentClassificationCommand toStyleWith: BootstrapCssStyles buttonLink).
header := BootstrapModalHeaderWebView titled: 'Terms and Conditions'.

dialog := BootstrapModalWebView
withHeader: header
containing: 'Some very large legal stuff. ;)'
footer: footer
applyingToDialog: (ComponentClassificationCommand toStyleWith: 'fade')
andToDocument: (ComponentClassificationCommand toStyleWith: BootstrapCssStyles modalLarge).

html := self render: dialog.

self
assert: html
equals: '<div class="modal fade" tabindex="-1" role="dialog"><div class="modal-dialog modal-lg" role="document"><div class="modal-content"><div class="modal-header"><h4 class="modal-title">Terms and Conditions</h4></div><div class="modal-body">Some very large legal stuff. ;)</div><div class="modal-footer"><button class="btn btn-link" data-dismiss="modal" type="button">Ok</button></div></div></div></div>'
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"instance" : {
"takeMySoulButton" : "GabrielOmarCotelli 4/10/2017 11:07",
"testOnTrigger" : "GabrielOmarCotelli 4/10/2017 11:03",
"testRenderContentOn" : "GabrielOmarCotelli 4/10/2017 10:46",
"testRenderContentOnWithCommands" : "GabrielOmarCotelli 4/10/2017 10:50",
"testOnTriggerWithButtons" : "GabrielOmarCotelli 4/10/2017 11:07",
"agreeButton" : "GabrielOmarCotelli 4/10/2017 11:07"
},
"class" : { }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"commentStamp" : "<historical>",
"super" : "WillowTestCase",
"category" : "Willow-Bootstrap-Tests-WebViews",
"classinstvars" : [ ],
"pools" : [ ],
"classvars" : [ ],
"instvars" : [ ],
"name" : "BootstrapModalWebViewTest",
"type" : "normal"
}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(name 'Willow-Bootstrap-Tests-GabrielOmarCotelli.17' message 'Add modal support.' id '95553d6c-fc08-0d00-8233-34be0f9a6dbd' date '7 April 2017' time '6:55:37.978453 pm' author 'GabrielOmarCotelli' ancestors ((name 'Willow-Bootstrap-Tests-GabrielOmarCotelli.16' message 'Add test cases' id 'ac9b9f2a-fa08-0d00-9f64-276c051ce4ae' date '7 April 2017' time '4:14:07.188075 pm' author 'GabrielOmarCotelli' ancestors ((name 'Willow-Bootstrap-Tests-GabrielOmarCotelli.15' message 'Add Collapse plugin support' id '814bc73c-f608-0d00-b4d7-2112039fb704' date '7 April 2017' time '11:32:51.909823 am' author 'GabrielOmarCotelli' ancestors ((name 'Willow-Bootstrap-Tests-GabrielOmarCotelli.14' message 'Add Bootstrap Navigation Bar support' id '70332d67-e808-0d00-af59-926405851807' date '6 April 2017' time '7:02:33.689635 pm' author 'GabrielOmarCotelli' ancestors ((name 'Willow-Bootstrap-Tests-MaximilianoTabacman.13' message 'Fixed notification section rendering.' id 'bd31953c-e008-0d00-ac33-2ec00cf493dd' date '6 April 2017' time '9:17:59.346597 am' author 'MaximilianoTabacman' ancestors ((name 'Willow-Bootstrap-Tests-MaximilianoTabacman.12' message 'Fixed notification section rendering.' id 'd69eb12d-e008-0d00-9830-fa1006c06800' date '6 April 2017' time '9:13:49.550294 am' author 'MaximilianoTabacman' ancestors ((name 'Willow-Bootstrap-Tests-MaximilianoTabacman.11' message 'Fixed notification section rendering.' id '5f01dee1-df08-0d00-9aa7-98460d42ab5d' date '6 April 2017' time '8:52:37.390687 am' author 'MaximilianoTabacman' ancestors ((name 'Willow-Bootstrap-Tests-GabrielOmarCotelli.10' message 'Updated test case.' id '48124f58-d208-0d00-8951-61d70577508c' date '5 April 2017' time '4:43:34.970116 pm' author 'GabrielOmarCotelli' ancestors ((name 'Willow-Bootstrap-Tests-GabrielOmarCotelli.9' message 'Rename utility method ' id '0be12911-ce08-0d00-993b-9d360ef8e485' date '5 April 2017' time '11:37:21.481165 am' author 'GabrielOmarCotelli' ancestors ((name 'Willow-Bootstrap-Tests-GabrielOmarCotelli.8' message 'Add WillowApplication support.' id 'f839e32c-c008-0d00-8497-8f49002954dd' date '4 April 2017' time '7:02:57.070801 pm' author 'GabrielOmarCotelli' ancestors ((name 'Willow-Bootstrap-Tests-GabrielOmarCotelli.7' message 'Add test cases' id '15e9533c-ba08-0d00-8ee5-5b5d0356d0e3' date '4 April 2017' time '11:57:46.310111 am' author 'GabrielOmarCotelli' ancestors ((name 'Willow-Bootstrap-Tests-GabrielOmarCotelli.6' message 'Add meta and doctype tests' id '7267da57-aa08-0d00-a579-6951059f230d' date '3 April 2017' time '5:00:08.632371 pm' author 'GabrielOmarCotelli' ancestors ((name 'Willow-Bootstrap-Tests-GabrielOmarCotelli.5' message 'Add test cases' id 'e835709f-a708-0d00-86c4-b79e00e2ec5f' date '3 April 2017' time '1:45:24.730536 pm' author 'GabrielOmarCotelli' ancestors ((name 'Willow-Bootstrap-Tests-GabrielOmarCotelli.4' message 'Add Bootstrap Libraries' id '31d0f4f1-a508-0d00-be3a-bfa10315a44d' date '3 April 2017' time '11:45:19.217911 am' author 'GabrielOmarCotelli' ancestors () stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())
(name 'Willow-Bootstrap-Tests-GabrielOmarCotelli.18' message 'Add Bootstrap Modal Web Views' id '8524e34a-3209-0d00-ad76-78f109d22f4e' date '10 April 2017' time '11:11:46.653504 am' author 'GabrielOmarCotelli' ancestors ((name 'Willow-Bootstrap-Tests-GabrielOmarCotelli.17' message 'Add modal support.' id '95553d6c-fc08-0d00-8233-34be0f9a6dbd' date '7 April 2017' time '6:55:37.978453 pm' author 'GabrielOmarCotelli' ancestors ((name 'Willow-Bootstrap-Tests-GabrielOmarCotelli.16' message 'Add test cases' id 'ac9b9f2a-fa08-0d00-9f64-276c051ce4ae' date '7 April 2017' time '4:14:07.188075 pm' author 'GabrielOmarCotelli' ancestors ((name 'Willow-Bootstrap-Tests-GabrielOmarCotelli.15' message 'Add Collapse plugin support' id '814bc73c-f608-0d00-b4d7-2112039fb704' date '7 April 2017' time '11:32:51.909823 am' author 'GabrielOmarCotelli' ancestors ((name 'Willow-Bootstrap-Tests-GabrielOmarCotelli.14' message 'Add Bootstrap Navigation Bar support' id '70332d67-e808-0d00-af59-926405851807' date '6 April 2017' time '7:02:33.689635 pm' author 'GabrielOmarCotelli' ancestors ((name 'Willow-Bootstrap-Tests-MaximilianoTabacman.13' message 'Fixed notification section rendering.' id 'bd31953c-e008-0d00-ac33-2ec00cf493dd' date '6 April 2017' time '9:17:59.346597 am' author 'MaximilianoTabacman' ancestors ((name 'Willow-Bootstrap-Tests-MaximilianoTabacman.12' message 'Fixed notification section rendering.' id 'd69eb12d-e008-0d00-9830-fa1006c06800' date '6 April 2017' time '9:13:49.550294 am' author 'MaximilianoTabacman' ancestors ((name 'Willow-Bootstrap-Tests-MaximilianoTabacman.11' message 'Fixed notification section rendering.' id '5f01dee1-df08-0d00-9aa7-98460d42ab5d' date '6 April 2017' time '8:52:37.390687 am' author 'MaximilianoTabacman' ancestors ((name 'Willow-Bootstrap-Tests-GabrielOmarCotelli.10' message 'Updated test case.' id '48124f58-d208-0d00-8951-61d70577508c' date '5 April 2017' time '4:43:34.970116 pm' author 'GabrielOmarCotelli' ancestors ((name 'Willow-Bootstrap-Tests-GabrielOmarCotelli.9' message 'Rename utility method ' id '0be12911-ce08-0d00-993b-9d360ef8e485' date '5 April 2017' time '11:37:21.481165 am' author 'GabrielOmarCotelli' ancestors ((name 'Willow-Bootstrap-Tests-GabrielOmarCotelli.8' message 'Add WillowApplication support.' id 'f839e32c-c008-0d00-8497-8f49002954dd' date '4 April 2017' time '7:02:57.070801 pm' author 'GabrielOmarCotelli' ancestors ((name 'Willow-Bootstrap-Tests-GabrielOmarCotelli.7' message 'Add test cases' id '15e9533c-ba08-0d00-8ee5-5b5d0356d0e3' date '4 April 2017' time '11:57:46.310111 am' author 'GabrielOmarCotelli' ancestors ((name 'Willow-Bootstrap-Tests-GabrielOmarCotelli.6' message 'Add meta and doctype tests' id '7267da57-aa08-0d00-a579-6951059f230d' date '3 April 2017' time '5:00:08.632371 pm' author 'GabrielOmarCotelli' ancestors ((name 'Willow-Bootstrap-Tests-GabrielOmarCotelli.5' message 'Add test cases' id 'e835709f-a708-0d00-86c4-b79e00e2ec5f' date '3 April 2017' time '1:45:24.730536 pm' author 'GabrielOmarCotelli' ancestors ((name 'Willow-Bootstrap-Tests-GabrielOmarCotelli.4' message 'Add Bootstrap Libraries' id '31d0f4f1-a508-0d00-be3a-bfa10315a44d' date '3 April 2017' time '11:45:19.217911 am' author 'GabrielOmarCotelli' ancestors () stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
I represent the footer in a Bootstrap modal.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Building
closeButtonLabeled: aRenderable applying: aComponentCommand

^ AsynchronicButtonWebView
labeled: aRenderable
applying:
(ComponentClassificationCommand toStyleWith: BootstrapCssStyles button)
+ (ComponentMetadataCommand toDeclare: BootstrapConstants dismiss with: BootstrapConstants modal) + aComponentCommand
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Instance Creation
containing: aButtonCollection andCloseButton: aCloseButton

^ self new initializeContaining: aButtonCollection andCloseButton: aCloseButton
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Instance Creation
with: aButtonWebView andCloseButtonLabeled: aRenderable applying: aCloseButtonCommand

^ self containing: {aButtonWebView} andCloseButton: (self closeButtonLabeled: aRenderable applying: aCloseButtonCommand)
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Instance Creation
withCloseButtonLabeled: aRenderable applying: aComponentCommand

^ self containing: #() andCloseButton: (self closeButtonLabeled: aRenderable applying: aComponentCommand)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
initialize
initializeContaining: aButtonCollection andCloseButton: aCloseButton

buttons := aButtonCollection.
closeButton := aCloseButton
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Configuring
onTrigger

^ CombinedWebInteractionInterpreter combiningInterpretersOf: buttons
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
rendering
renderContentOn: aCanvas

aCanvas div
class: BootstrapCssStyles modalFooter;
with: [ aCanvas render: closeButton.
buttons do: [ :button | aCanvas render: button ] ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"instance" : {
"renderContentOn:" : "GabrielOmarCotelli 4/10/2017 09:44",
"onTrigger" : "GabrielOmarCotelli 4/10/2017 09:56",
"initializeContaining:andCloseButton:" : "GabrielOmarCotelli 4/10/2017 09:44"
},
"class" : {
"containing:andCloseButton:" : "GabrielOmarCotelli 4/10/2017 09:45",
"withCloseButtonLabeled:applying:" : "GabrielOmarCotelli 4/10/2017 09:45",
"with:andCloseButtonLabeled:applying:" : "GabrielOmarCotelli 4/10/2017 09:52",
"closeButtonLabeled:applying:" : "GabrielOmarCotelli 4/10/2017 09:20"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"commentStamp" : "GabrielOmarCotelli 4/10/2017 09:13",
"super" : "WAPresenter",
"category" : "Willow-Bootstrap-WebViews",
"classinstvars" : [ ],
"pools" : [ ],
"classvars" : [ ],
"instvars" : [
"closeButton",
"buttons"
],
"name" : "BootstrapModalFooterWebView",
"type" : "normal"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
I represent the header in a Bootstrap modal. I can include the dismiss button or not.

0 comments on commit a1df903

Please sign in to comment.