Changeset 552 for trunk/js/Msg.js


Ignore:
Timestamp:
Nov 25, 2015 7:29:35 PM (8 years ago)
Author:
anonymous
Message:

Updated js.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/js/Msg.js

    r551 r552  
    4545---------------------------------------------------------------------
    4646*/
    47 Strangecode.Msg = function(options) {
     47Strangecode.Msg = function (options) {
    4848    // Merge options with defaults
    4949    this.o = $.extend({
    50         container: '#sc-msg:last',
     50        container: '.sc-msg:last',
    5151        above_msg: '',
    5252        gotohash: true
     
    6464* @since    18 Mar 2014 23:24:15
    6565*/
    66 Strangecode.Msg.prototype.raise = function(message, msg_class) {
     66Strangecode.Msg.prototype.raise = function (message, msg_class) {
    6767    // If an "above msg" is provided, and one doesn't already exist, add it to the message box.
    6868    if (this.o.above_msg.length && !$(this.o.container).find('.sc-above').length) {
     
    7373    // Append this raised message to the sc-msg stack, if it doesn't exist already.
    7474    if (!$(this.o.container).find(':contains("' + message + '")').length) {
    75         $(this.o.container).append($('<div class="sc-js-msg ' + msg_class + '"></div>').text(message)).show();
    76         // $(this.o.container).append($('<div data-alert class="alert-box sc-js-msg ' + msg_class + '"></div>').hide().text(message).append('<a href="#" class="close">×</a>'));
    77         // $('.sc-js-msg').slideDown('fast');
     75        $(this.o.container).append($('<div data-alert class="alert-box sc-js-msg ' + msg_class + '"></div>').hide().html(message).append('<a href="#" class="close">×</a>'));
     76        $('.sc-js-msg').slideDown('fast');
     77        if ($.fn.foundation) {
     78            $(document).foundation('reflow');
     79        }
    7880    }
    7981
     
    8688
    8789/*
    88 * Removes all messages previously created by Msg.raise.
     90* Removes all previously raised messages. By default, only messages raised by this JS class
     91* are cleared (matching class="sc-js-msg"), but you can clear *all* messages by assigning a more general
     92* class (e.g., "sc-msg-error").
    8993*
    9094* @access   public
    9195* @param    string message  The message to display.
    92 * @param    string class    The class to apply to the message div (when using codebase CSS, it is useful to use one of: sc-msg-success, sc-msg-notice, sc-msg-warning, sc-msg-error)
     96* @param    string class    Remove message divs matching this class (default: sc-js-msg; or use one of: sc-msg-success, sc-msg-notice, sc-msg-warning, sc-msg-error)
    9397* @author   Quinn Comendant <quinn@strangecode.com>
    94 * @version  1.0
     98* @version  1.1
    9599* @since    18 Mar 2014 23:24:15
    96100*/
    97 Strangecode.Msg.prototype.clear = function() {
    98     // Append this raised message to the sc-msg stack.
    99     var msg_class = (typeof msg_class === 'undefined') ? 'sc-msg-error' : msg_class;
    100     $(this.o.container).find('.sc-js-msg').remove();
     101Strangecode.Msg.prototype.clear = function (msg_class) {
     102    var msg_class = (typeof msg_class === 'undefined') ? 'sc-js-msg' : msg_class;
     103    $(this.o.container).find('.' + msg_class).remove();
    101104};
Note: See TracChangeset for help on using the changeset viewer.