@@ -11,17 +11,17 @@ var modal = (function() {
1111 } ;
1212 } ;
1313
14- var render = function ( options ) {
15- var defaultOptions = {
14+ var render = function ( override ) {
15+ var options = {
1616 heading : "Modal" ,
1717 content : "Body" ,
1818 action : null ,
1919 actionText : "OK" ,
2020 cancelText : "Cancel" ,
2121 size : "medium"
2222 } ;
23- if ( options ) {
24- defaultOptions = helper . applyOptions ( defaultOptions , options ) ;
23+ if ( override ) {
24+ options = helper . applyOptions ( options , override ) ;
2525 } ;
2626 var makeModal = function ( ) {
2727 var body = helper . e ( "body" ) ;
@@ -32,11 +32,11 @@ var modal = (function() {
3232 var modalWrapper = document . createElement ( "div" ) ;
3333 modalWrapper . setAttribute ( "class" , "modal-wrapper" ) ;
3434 var modal = document . createElement ( "div" ) ;
35- if ( defaultOptions . size == "large" ) {
35+ if ( options . size == "large" ) {
3636 modal . setAttribute ( "class" , "modal modal-large" ) ;
37- } else if ( defaultOptions . size == "small" ) {
37+ } else if ( options . size == "small" ) {
3838 modal . setAttribute ( "class" , "modal modal-small" ) ;
39- } else if ( defaultOptions . size ) {
39+ } else if ( options . size ) {
4040 modal . setAttribute ( "class" , "modal" ) ;
4141 } ;
4242 modal . destroy = function ( ) {
@@ -59,30 +59,30 @@ var modal = (function() {
5959 var actionButton = document . createElement ( "button" ) ;
6060 actionButton . setAttribute ( "tabindex" , "1" ) ;
6161 actionButton . setAttribute ( "class" , "button button-primary button-block" ) ;
62- actionButton . textContent = defaultOptions . actionText ;
62+ actionButton . textContent = options . actionText ;
6363 var cancelButton = document . createElement ( "button" ) ;
6464 cancelButton . setAttribute ( "tabindex" , "1" ) ;
6565 cancelButton . setAttribute ( "class" , "button button-primary button-block" ) ;
66- cancelButton . textContent = defaultOptions . cancelText ;
66+ cancelButton . textContent = options . cancelText ;
6767 modalControls . appendChild ( cancelButton ) ;
6868 modalControls . appendChild ( actionButton ) ;
69- if ( defaultOptions . heading != null ) {
69+ if ( options . heading != null ) {
7070 var modalHeading = document . createElement ( "h1" ) ;
7171 modalHeading . setAttribute ( "tabindex" , "1" ) ;
7272 modalHeading . setAttribute ( "class" , "modal-heading" ) ;
73- modalHeading . textContent = defaultOptions . heading ;
73+ modalHeading . textContent = options . heading ;
7474 modalBody . appendChild ( modalHeading ) ;
7575 } ;
76- if ( defaultOptions . content ) {
77- if ( typeof defaultOptions . content == "string" ) {
76+ if ( options . content ) {
77+ if ( typeof options . content == "string" ) {
7878 var container = document . createElement ( "div" ) ;
7979 container . setAttribute ( "class" , "container" ) ;
8080 var para = document . createElement ( "p" ) ;
81- para . textContent = defaultOptions . content ;
81+ para . textContent = options . content ;
8282 container . appendChild ( para ) ;
8383 modalBody . appendChild ( container ) ;
8484 } else {
85- modalBody . appendChild ( defaultOptions . content ) ;
85+ modalBody . appendChild ( options . content ) ;
8686 } ;
8787 } ;
8888 modalWrapper . appendChild ( modalBody ) ;
@@ -99,8 +99,8 @@ var modal = (function() {
9999 actionButton . addEventListener ( "click" , function ( event ) {
100100 this . destroy ( ) ;
101101 shade . destroy ( ) ;
102- if ( defaultOptions . action ) {
103- defaultOptions . action ( ) ;
102+ if ( options . action ) {
103+ options . action ( ) ;
104104 } ;
105105 } . bind ( modal ) , false ) ;
106106 cancelButton . addEventListener ( "click" , function ( event ) {
0 commit comments