@progress/kendo-ui
Version:
This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.
1 lines • 6.92 kB
JavaScript
module.exports=function(e){var n={};function o(t){if(n[t])return n[t].exports;var i=n[t]={exports:{},id:t,loaded:!1};return e[t].call(i.exports,i,i.exports,o),i.loaded=!0,i.exports}return o.m=e,o.c=n,o.p="",o(0)}({0:function(t,i,e){t.exports=e(1375)},3:function(t,i){t.exports=function(){throw Error("define cannot be used indirect")}},1051:function(t,i){t.exports=require("./kendo.core")},1052:function(t,i){t.exports=require("./kendo.popup")},1375:function(t,i,e){var n;e(3),e=[e(1051),e(1052)],void 0===(i="function"==typeof(n=function(){var t={id:"notification",name:"Notification",category:"web",description:"The Notification widget displays user alerts.",depends:["core","popup"],features:[{id:"notification-fx",name:"Animation",description:"Support for animation",depends:["fx"]}]},l=window.kendo.jQuery,c=void 0,r=window.kendo,n=r.ui.Widget,f=l.extend,d=window.setTimeout,p="click",_="show",i="hide",w="k-notification",u=".k-notification-wrap .k-i-close",k="k-hiding",v="info",e="success",o="warning",a="error",h="top",g="left",b="bottom",T="right",x="up",m=".kendoNotification",P='<div role="alert" aria-live="polite" class="k-widget k-popup k-notification"></div>',s='<div class="k-notification-wrap">'+'<span class="k-icon k-i-#:typeIcon#" title="#:typeIcon#"></span>'+'<div class="k-notification-content">#=content#</div>'+'<span aria-hidden="true" class="#: closeButton ? "" : "k-hidden"# k-icon k-i-close" title="Hide"></span>'+"</div>",y=s.replace("#=content#","#:content#"),C=n.extend({init:function(t,i){var e=this;n.fn.init.call(e,t,i);i=e.options;if(!i.appendTo||!l(i.appendTo).is(t))e.element.hide();e._compileTemplates(i.templates);e._guid="_"+r.guid();e._isRtl=r.support.isRtl(t);e._compileStacking(i.stacking,i.position.top,i.position.left);r.notify(e)},events:[_,i],options:{name:"Notification",position:{pinned:true,top:null,left:null,bottom:20,right:20},stacking:"default",hideOnClick:true,button:false,allowHideAfter:0,autoHideAfter:5e3,appendTo:null,width:null,height:null,templates:[],title:null,animation:{open:{effects:"fade:in",duration:300},close:{effects:"fade:out",duration:600,hide:true}}},_compileTemplates:function(t){var e=this;var n=r.template;e._compiled={};l.each(t,function(t,i){e._compiled[i.type]=n(i.template||l("#"+i.templateId).html())});e._defaultCompiled=n(s);e._safeCompiled=n(y)},_getCompiled:function(t,i){var e=i?this._safeCompiled:this._defaultCompiled;return t?this._compiled[t]||e:e},_compileStacking:function(t,i,e){var n=this,o={paddingTop:0,paddingRight:0,paddingBottom:0,paddingLeft:0},a=e!==null?g:T,s,p;switch(t){case"down":s=b+" "+a;p=h+" "+a;delete o.paddingBottom;break;case T:s=h+" "+T;p=h+" "+g;delete o.paddingRight;break;case g:s=h+" "+g;p=h+" "+T;delete o.paddingLeft;break;case x:s=h+" "+a;p=b+" "+a;delete o.paddingTop;break;default:if(i!==null){s=b+" "+a;p=h+" "+a;delete o.paddingBottom}else{s=h+" "+a;p=b+" "+a;delete o.paddingTop}break}n._popupOrigin=s;n._popupPosition=p;n._popupPaddings=o},_attachPopupEvents:function(t,i){var e=this,n=t.allowHideAfter,o=!isNaN(n)&&n>0,a;function s(t){t.on(p+m,function(){e._hidePopup(i)})}if(t.hideOnClick)i.bind("activate",function(){if(o)d(function(){s(i.element)},n);else s(i.element)});else if(t.button){a=i.element.find(u);if(o)d(function(){s(a)},n);else s(a)}},_showPopup:function(t,i){var e=this,n=i.autoHideAfter,o=i.position.left,a=i.position.top,s,p;p=l("."+e._guid+":not(."+k+")").last();s=new r.ui.Popup(t,{anchor:p[0]?p:document.body,origin:e._popupOrigin,position:e._popupPosition,animation:i.animation,copyAnchorStyles:false,modal:true,collision:"",isRtl:e._isRtl,close:function(){e._triggerHide(this.element)},deactivate:function(t){t.sender.element.off(m);t.sender.element.find(u).off(m);t.sender.destroy()}});e._attachPopupEvents(i,s);t.removeClass("k-group k-reset");if(p[0])s.open();else{if(o===null)o=l(window).width()-t.outerWidth()-i.position.right;if(a===null)a=l(window).height()-t.outerHeight()-i.position.bottom;s.open(o,a)}s.wrapper.addClass(e._guid).css(f({margin:0,zIndex:10050},e._popupPaddings));if(i.position.pinned){s.wrapper.css("position","fixed");if(p[0])e._togglePin(s.wrapper,true)}else if(!p[0])e._togglePin(s.wrapper,false);if(n>0)d(function(){e._hidePopup(s)},n)},_hidePopup:function(t){t.wrapper.addClass(k);t.close()},_togglePin:function(t,i){var e=l(window),n=i?-1:1;t.css({top:parseInt(t.css(h),10)+n*e.scrollTop(),left:parseInt(t.css(g),10)+n*e.scrollLeft()})},_attachStaticEvents:function(t,i){var e=this,n=t.allowHideAfter,o=!isNaN(n)&&n>0;function a(t){t.on(p+m,e._hideStatic.bind(e,i))}if(t.hideOnClick)if(o)d(function(){a(i)},n);else a(i);else if(t.button)if(o)d(function(){a(i.find(u))},n);else a(i.find(u))},_showStatic:function(t,e){var n=this,o=e.autoHideAfter,i=e.animation,a=e.stacking==x||e.stacking==g?"prependTo":"appendTo",s;t.removeClass("k-popup").addClass(n._guid)[a](e.appendTo).hide().kendoAnimate(i.open||false);s=n.getNotifications();s.each(function(t,i){n._attachStaticEvents(e,l(i));if(o>0)d(function(){n._hideStatic(l(i))},o)})},_hideStatic:function(t){t.kendoAnimate(f(this.options.animation.close||false,{complete:function(){t.off(m).find(u).off(m);t.remove()}}));this._triggerHide(t)},_triggerHide:function(t){this.trigger(i,{element:t});this.angular("cleanup",function(){return{elements:t}})},show:function(t,i,e){var n=this,o=n.options,a=l(P),s=r.guid(),p,d;if(!i)i=v;a.attr("aria-label",i);if(t!==null&&t!==c&&t!==""){if(r.isFunction(t))t=t();d={typeIcon:i,content:"",closeButton:o.button};if(l.isPlainObject(t))p=f(d,t);else p=f(d,{content:t});a.addClass(w+"-"+i).toggleClass(w+"-button",o.button).toggleClass(w+"-closable",o.button).attr({"data-role":"alert",title:o.title}).css({width:o.width,height:o.height}).append(n._getCompiled(i,e)(p));a.find(".k-notification-content").attr("id",s);a.attr("aria-describedby",s);n.angular("compile",function(){return{elements:a,data:[{dataItem:p}]}});if(l(o.appendTo)[0])n._showStatic(a,o);else n._showPopup(a,o);n.trigger(_,{element:a})}return n},showText:function(t,i){this.show(t,i,true)},info:function(t){return this.show(t,v)},success:function(t){return this.show(t,e)},warning:function(t){return this.show(t,o)},error:function(t){return this.show(t,a)},hide:function(){var n=this,t=n.getNotifications();if(n.options.appendTo)t.each(function(t,i){n._hideStatic(l(i))});else t.each(function(t,i){var e=l(i).data("kendoPopup");if(e)n._hidePopup(e)});return n},getNotifications:function(){var t=this,i=l("."+t._guid+":not(."+k+")");if(t.options.appendTo)return i;else return i.children("."+w)},setOptions:function(t){var i=this,e;n.fn.setOptions.call(i,t);e=i.options;if(t.templates!==c)i._compileTemplates(e.templates);if(t.stacking!==c||t.position!==c)i._compileStacking(e.stacking,e.position.top,e.position.left)},destroy:function(){n.fn.destroy.call(this);this.getNotifications().off(m).find(u).off(m)}});return r.ui.plugin(C),window.kendo})?n.apply(i,e):n)||(t.exports=i)}});