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