<commit_before>goog.provide 'wzk.ui.FlashMessage'

goog.require 'goog.fx.Transition.EventType'
goog.require 'goog.fx.dom.FadeOutAndHide'
goog.require 'wzk.ui.CloseIcon'
goog.require 'wzk.ui.Component'
goog.require 'wzk.ui.FlashMessageRenderer'
goog.require 'goog.dom.classes'

class wzk.ui.FlashMessage extends wzk.ui.Component

  @DISwzkEAR_TIME = 10000

  ###*
    @constructor
    @extends {wzk.ui.Component}
    @param {Object} params
      msg: {string}
      severity: {string}
      fadeOut: {boolean} default true
      closable: {boolean} default true if true renders a close icon
      renderer: {@link wzk.ui.FlashMessageRenderer}
  ###
  constructor: (params) ->
    params.renderer ?= wzk.ui.FlashMessageRenderer.getInstance()
    super params
    {@msg, @severity, @fadeOut, @closable} = params
    @fadeout ?= true
    @closable ?= true
    @addClass 'flash'
    if @severity?
      @addClass @severity

  ###*
    @override
  ###
  createDom: ->
    super()
    @decorateInternal @getElement()

  ###*
    @override
  ###
  canDecorate: (el) ->
    el? and goog.dom.classes.has el, 'flash'

  ###*
    @override
  ###
  decorateInternal: (el) ->
    super el

    if @closable
      icon = new wzk.ui.CloseIcon dom: @dom
      icon.listen goog.ui.Component.EventType.ACTION, =>
        @destroy()
      icon.createDom()
      @getElement().appendChild icon.getElement()
      icon.enterDocument()

    if @fadeOut
      @setDiswzkearTrigger()

  ###*
    @protected
  ###
  setDiswzkearTrigger: ->
    trigger = =>
      anim = new goog.fx.dom.FadeOutAndHide @getElement(), 1000
      anim.listen goog.fx.Transition.EventType.END, =>
        @destroy()
      anim.play()

    setTimeout trigger, wzk.ui.FlashMessage.DISwzkEAR_TIME<commit_msg>Fixed typo #50 in FlashMessage<commit_after>goog.provide 'wzk.ui.FlashMessage'

goog.require 'goog.fx.Transition.EventType'
goog.require 'goog.fx.dom.FadeOutAndHide'
goog.require 'wzk.ui.CloseIcon'
goog.require 'wzk.ui.Component'
goog.require 'wzk.ui.FlashMessageRenderer'
goog.require 'goog.dom.classes'

class wzk.ui.FlashMessage extends wzk.ui.Component

  @DISAPPEAR_TIME = 10000

  ###*
    @constructor
    @extends {wzk.ui.Component}
    @param {Object} params
      msg: {string}
      severity: {string}
      fadeOut: {boolean} default true
      closable: {boolean} default true if true renders a close icon
      renderer: {@link wzk.ui.FlashMessageRenderer}
  ###
  constructor: (params) ->
    params.renderer ?= wzk.ui.FlashMessageRenderer.getInstance()
    super params
    {@msg, @severity, @fadeOut, @closable} = params
    @fadeout ?= true
    @closable ?= true
    @addClass 'flash'
    if @severity?
      @addClass @severity

  ###*
    @override
  ###
  createDom: ->
    super()
    @decorateInternal @getElement()

  ###*
    @override
  ###
  canDecorate: (el) ->
    el? and goog.dom.classes.has el, 'flash'

  ###*
    @override
  ###
  decorateInternal: (el) ->
    super el

    if @closable
      icon = new wzk.ui.CloseIcon dom: @dom
      icon.listen goog.ui.Component.EventType.ACTION, =>
        @destroy()
      icon.createDom()
      @getElement().appendChild icon.getElement()
      icon.enterDocument()

    if @fadeOut
      @setDiswzkearTrigger()

  ###*
    @protected
  ###
  setDiswzkearTrigger: ->
    trigger = =>
      anim = new goog.fx.dom.FadeOutAndHide @getElement(), 1000
      anim.listen goog.fx.Transition.EventType.END, =>
        @destroy()
      anim.play()

    setTimeout trigger, wzk.ui.FlashMessage.DISAPPEAR_TIME
{'fraction_non_alphanumeric': 0.13614491933201245, 'fraction_numerical': 0.005660911406736484, 'mean_word_length': 2.939799331103679, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '487957', 'n_tokens_mistral': 1249, 'n_tokens_neox': 1169, 'n_words': 239}