Sha256: 17e6f01d4560d3c69e69f411892e8759dd2730757306ece64ca3046a9a1ef8eb

Contents?: true

Size: 1.8 KB

Versions: 148

Compression:

Stored size: 1.8 KB

Contents

class Alert
  @clear:(content_id) ->
    if content_id? && content_id.length > 0
      $(content_id + " .alert").hide();
    else
      $(".alert").hide();

  @show:(content_id, status) ->
    if Alert.html().length > 0
      #showing alert
      $(content_id).prepend(Alert.html(status));
      #make alert close button working by Twitter Bootstrap
      $(".alert").alert();

      # it's like flash so I will show it only one time
      Alert.set_message("")
      Alert.set_message_header("")


  @html:(status) ->
    return "" if (!Alert.message_header? || Alert.message_header.length <= 0) && (!Alert.message? || Alert.message.length <= 0)

    Alert.status = "" if !Alert.status?
    switch Alert.status
      when "ok","","success"
        return Alert.success();
      when "info"
        return Alert.info();
      when "error"
        return Alert.error();
      when "warning"
        return Alert.warning();
      else
        return Alert.success();

  @info:() ->
    return '<div class="alert alert-info">' + Alert.message_body();
  @success:() ->
    return '<div class="alert alert-success">' + Alert.message_body();
  @error:() ->
    return '<div class="alert alert-error">' + Alert.message_body();
  @warning:() ->
    return '<div class="alert alert-block">' + Alert.message_body();

  @message_body: () ->
    mes_html = '<a class="close" data-dismiss="alert" href="#">×</a>'
    mes_html += '<h4 class="alert-heading">' + Alert.message_header + '</h4>' if Alert.message_header? && Alert.message_header.length > 0
    mes_html += Alert.message if Alert.message? && Alert.message.length > 0
    mes_html += '</div>'
    return mes_html


  @set_message:(val) ->
    Alert.message = val
  @set_message_header:(val) ->
    Alert.message_header = val
  @set_status:(val) ->
    Alert.status = val




window.Alert = Alert

Version data entries

148 entries across 148 versions & 1 rubygems

Version Path
it-logica-application-backbone-0.2.29 app/assets/javascripts/backbone_js/ladas_alert.js.coffee
it-logica-application-backbone-0.2.28 app/assets/javascripts/backbone_js/ladas_alert.js.coffee
it-logica-application-backbone-0.2.27 app/assets/javascripts/backbone_js/ladas_alert.js.coffee
it-logica-application-backbone-0.2.26 app/assets/javascripts/backbone_js/ladas_alert.js.coffee
it-logica-application-backbone-0.2.25 app/assets/javascripts/backbone_js/ladas_alert.js.coffee
it-logica-application-backbone-0.2.24 app/assets/javascripts/backbone_js/ladas_alert.js.coffee
it-logica-application-backbone-0.2.23 app/assets/javascripts/backbone_js/ladas_alert.js.coffee
it-logica-application-backbone-0.2.22 app/assets/javascripts/backbone_js/ladas_alert.js.coffee