 
 
   ###*
-    Modal view with overlay option for Spark Framework.
+    Modal view with overlay option for Spark Framework. By default modal will be
+    appended to document body and it will have an overlay. When overlay clicked
+    the modal will be destroyed. You should pass title and content params of the
+    modal in your options. You can also customize buttons. See `@createButtons_`
+    for more information.
 
     @constructor
     @export


    if presetButtons.indexOf(buttons) > -1
      buttons.forEach (title) =>
        new spark.components.Button
          cssClass : spark.components.Modal.ButtonCssClasses[title]
          title    : title
          renderTo : @buttonsContainer

    @buttons = {}

    if options.overlay
      @setOverlay_()

    @createTitle_   options.title
    @createContent_ options.content
    @createButtons_ options.buttons


  ###*
    Creates modal content.

    @private
    @param {string} title Modal title.
  ###
  createTitle_: (title) ->
    @title = new spark.core.View
      template : title
      cssClass : 'modal-title'
      renderTo : this


  ###*
    Creates modal content.

    @private
    @param {string} content Modal content.
  ###
  createContent_: (content) ->
    @content   = new spark.core.View
      template : content
      cssClass : 'modal-content'
      renderTo : this


  ###*
    Creates modal buttons. You can use preset buttons like YES, YES_NO or you
    can pass custom array which contains button options in it. Preset buttons
    will emit `ModalButtonClicked` with button title. You can programatically
    listen that event and look for button title to understand which button is
    clicked. Custom buttons should contain its callback. No other events will be
    fired for custom buttons. All buttons will be stored in `buttons` object
    with its names.

    @private
    @param {spark.components.Modal.Buttons|Array.<Object>} buttons Preset button
    value in Buttons enum or custom buttons array.
  ###
  createButtons_: (buttons) ->
    @buttonsContainer = new spark.core.View
      cssClass : 'buttons-container'
      renderTo : this
