From 9176ee0120c74cad1f77eb8757b91811357d16f9 Mon Sep 17 00:00:00 2001 From: Catouse Date: Mon, 22 Aug 2016 16:20:51 +0800 Subject: [PATCH] * improve messager UI: * support custom actions; * support custom CSS class; --- src/js/messager.js | 73 +++++++++++++++++++++++++++++----- src/less/modules/messager.less | 17 +++++--- 2 files changed, 74 insertions(+), 16 deletions(-) diff --git a/src/js/messager.js b/src/js/messager.js index 0db99147c..965b31fb9 100644 --- a/src/js/messager.js +++ b/src/js/messager.js @@ -6,11 +6,11 @@ * ======================================================================== */ -(function($, window) { +(function($, window, undefined) { 'use strict'; var id = 0; - var template = ''; + var template = ''; var defaultOptions = { type: 'default', placement: 'top', @@ -19,6 +19,10 @@ // clear: false, icon: null, close: true, + // actions: [{icon, name, action, title}], + // contentClass: null, + // cssClass: null, + // onAction: function, fade: true, scale: true }; @@ -31,16 +35,63 @@ that.message = (options.icon ? ' ' : '') + message; that.$ = $(template.format(options)).toggleClass('fade', options.fade).toggleClass('scale', options.scale).attr('id', 'messager-' + that.id); - if(!options.close) { - that.$.find('.close').remove(); - } else { - that.$.on('click', '.close', function() { - that.hide(); + + if(options.cssClass) that.$.addClass(options.cssClass); + + var hasCloseAction = false; + var $actions = that.$.find('.messager-actions'); + var appendAction = function(action) { + var $btn = $('