Sha256: c4f645f51cba9486bdc4716f5799da71354f2b8e0cbc864b57709d631c1dbee7
Contents?: true
Size: 1.62 KB
Versions: 1
Compression:
Stored size: 1.62 KB
Contents
/* * Show a flash message on dashboard UI. * * Note: To create a theme for underworld dashboard * you probably need to override this func * in your theme assets. * * @OVERRIDE */ function show_flash_message(msg, klass) { var icon = ""; if (klass == "success") { icon = "check"; } else if (klass == "error") { icon = "ban"; klass = 'danger'; } else if (klass == 'warning') { icon = 'warning'; } else if (klass == 'info') { icon = 'info'; } $("#flash-alert").removeClass().addClass("alert alert-dismissable alert-" + klass); $("#flash-icon").removeClass().addClass("fa fa-" + icon); $("#flash-msg").html(msg); $("#flash-alert").fadeIn(700).delay(5000).fadeOut(500); } /* * Hide the flash area * @OVERRIDE */ function hide_flash() { $("#flash-alert").hide(); } //TODO: Use a js template engine in here /* * Render the form errors in a flash message and * highlight the problematic form controls * * Note: This function will highligh those elements with */ function form_error(data) { $('.has-error').removeClass('has-error'); var msg = data.title + "<br/><ul>"; delete data.title; Object.keys(data, function(k, v){ msg += "<li><strong>" + k + "</strong> " + v + "</li>"; $('input[name="' + k + '"], [data-name="' + k + '"]').addClass('has-error'); }); msg += "</ul>"; error_message(msg); } function success_message(msg){ show_flash_message(msg, "success"); } function warning_message(msg){ show_flash_message(msg, "warning"); } function error_message(msg){ show_flash_message(msg, "error"); } $(function(){ $("#flash").on("click", hide_flash); });
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
underworld-1.0.0 | app/assets/javascripts/underworld/dashboard/lib/flash_message.js |