Sha256: 2e105d1b0e96d5c407ef9b46721cc44fafc7ded94f5f0b47c2eedb82b78d5718
Contents?: true
Size: 845 Bytes
Versions: 8
Compression:
Stored size: 845 Bytes
Contents
module Materialize module Helpers def toaster valid_toast = ["error", "message", "success", "warning"] js_toast = "" queue = 0 flash.each do |type, message| next if message.blank? type = type.to_s case type when "alert" type = "error" when "notice" type = "success" when "info" type = "message" end next unless valid_toast.include?(type) Array(message).each do |msg| js_toast << "setTimeout(function(){ M.toast({html: '#{j(msg)}'}) }, #{queue});" end queue += 100 end flash.clear return js_toast.html_safe() end def toast jsReturn = javascript_tag(toaster) end def toast_now toaster end end end
Version data entries
8 entries across 8 versions & 1 rubygems