Changeset 552 for trunk/js/Msg.js
- Timestamp:
- Nov 25, 2015 7:29:35 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/js/Msg.js
r551 r552 45 45 --------------------------------------------------------------------- 46 46 */ 47 Strangecode.Msg = function (options) {47 Strangecode.Msg = function (options) { 48 48 // Merge options with defaults 49 49 this.o = $.extend({ 50 container: ' #sc-msg:last',50 container: '.sc-msg:last', 51 51 above_msg: '', 52 52 gotohash: true … … 64 64 * @since 18 Mar 2014 23:24:15 65 65 */ 66 Strangecode.Msg.prototype.raise = function (message, msg_class) {66 Strangecode.Msg.prototype.raise = function (message, msg_class) { 67 67 // If an "above msg" is provided, and one doesn't already exist, add it to the message box. 68 68 if (this.o.above_msg.length && !$(this.o.container).find('.sc-above').length) { … … 73 73 // Append this raised message to the sc-msg stack, if it doesn't exist already. 74 74 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 } 78 80 } 79 81 … … 86 88 87 89 /* 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"). 89 93 * 90 94 * @access public 91 95 * @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 touse 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) 93 97 * @author Quinn Comendant <quinn@strangecode.com> 94 * @version 1. 098 * @version 1.1 95 99 * @since 18 Mar 2014 23:24:15 96 100 */ 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(); 101 Strangecode.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(); 101 104 };
Note: See TracChangeset
for help on using the changeset viewer.