jiti-meet/libs/toastr.min.js

2 lines
5.9 KiB
JavaScript
Raw Normal View History

2015-09-14 20:50:13 +00:00
(function(define){define(["jquery"],function($){return function(){var $container;var listener;var toastId=0;var toastType={error:"error",info:"info",success:"success",warning:"warning"};var toastr={clear:clear,remove:remove,error:error,getContainer:getContainer,info:info,options:{},subscribe:subscribe,success:success,version:"2.0.3",warning:warning};return toastr;function error(message,title,optionsOverride){return notify({type:toastType.error,iconClass:getOptions().iconClasses.error,message:message,optionsOverride:optionsOverride,title:title})}function getContainer(options,create){if(!options){options=getOptions()}$container=$("#"+options.containerId);if($container.length){return $container}if(create){$container=createContainer(options)}return $container}function info(message,title,optionsOverride){return notify({type:toastType.info,iconClass:getOptions().iconClasses.info,message:message,optionsOverride:optionsOverride,title:title})}function subscribe(callback){listener=callback}function success(message,title,optionsOverride){return notify({type:toastType.success,iconClass:getOptions().iconClasses.success,message:message,optionsOverride:optionsOverride,title:title})}function warning(message,title,optionsOverride){return notify({type:toastType.warning,iconClass:getOptions().iconClasses.warning,message:message,optionsOverride:optionsOverride,title:title})}function clear($toastElement){var options=getOptions();if(!$container){getContainer(options)}if(!clearToast($toastElement,options)){clearContainer(options)}}function remove($toastElement){var options=getOptions();if(!$container){getContainer(options)}if($toastElement&&$(":focus",$toastElement).length===0){removeToast($toastElement);return}if($container.children().length){$container.remove()}}function clearContainer(options){var toastsToClear=$container.children();for(var i=toastsToClear.length-1;i>=0;i--){clearToast($(toastsToClear[i]),options)}}function clearToast($toastElement,options){if($toastElement&&$(":focus",$toastElement).length===0){$toastElement[options.hideMethod]({duration:options.hideDuration,easing:options.hideEasing,complete:function(){removeToast($toastElement)}});return true}return false}function createContainer(options){$container=$("<div/>").attr("id",options.containerId).addClass(options.positionClass).attr("aria-live","polite").attr("role","alert");$container.appendTo($(options.target));return $container}function getDefaults(){return{tapToDismiss:true,toastClass:"toast",containerId:"toast-container",debug:false,showMethod:"fadeIn",showDuration:300,showEasing:"swing",onShown:undefined,hideMethod:"fadeOut",hideDuration:1e3,hideEasing:"swing",onHidden:undefined,extendedTimeOut:1e3,iconClasses:{error:"toast-error",info:"toast-info",success:"toast-success",warning:"toast-warning"},iconClass:"toast-info",positionClass:"toast-top-right",timeOut:5e3,titleClass:"toast-title",messageClass:"toast-message",target:"body",closeHtml:"<button>&times;</button>",newestOnTop:true}}function publish(args){if(!listener){return}listener(args)}function notify(map){var options=getOptions(),iconClass=map.iconClass||options.iconClass;if(typeof map.optionsOverride!=="undefined"){options=$.extend(options,map.optionsOverride);iconClass=map.optionsOverride.iconClass||iconClass}toastId++;$container=getContainer(options,true);var intervalId=null,$toastElement=$("<div/>"),$titleElement=$("<div/>"),$messageElement=$("<div/>"),$closeElement=$(options.closeHtml),response={toastId:toastId,state:"visible",startTime:new Date,options:options,map:map};if(map.iconClass){$toastElement.addClass(options.toastClass).addClass(iconClass)}if(map.title){$titleElement.append(map.title).addClass(options.titleClass);$toastElement.append($titleElement)}if(map.message){$messageElement.append(map.message).addClass(options.messageClass);$toastElement.append($messageElement)}if(options.closeButton){$closeElement.addClass("toast-close-button").attr("role","button");$toastElement.prepend($closeElement)}if(options.reposition){options.reposition()}$toastElement.hide();if(options.newestOnTop){$container.prepend
//# sourceMappingURL=toastr.min.map