It's possible to switch different message implementations and use the same interface.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | $( '#method' ).change( function () { switch ($( '#method' ).val()) { case 'jquery-toastmessage' : flash.setting.method = toastmessage; break ; case 'default' : default : flash.setting.method = flash.defaultMethod; break ; } }); var typeMap = { danger: 'error' , info: 'notice' , alert: 'warning' }; var toastmessage = function (message, options) { flash.formatOptions(options); options.text = message; options.stayTime = options.time; options.type = typeMap[options.type] || options.type; $().toastmessage( 'showToast' , options); }; |