demo20230512/Scripts/kendo/2014.2.716/kendo.notification.min.js
2023-05-12 10:20:28 +08:00

16 lines
5.5 KiB
JavaScript

/**
* Copyright 2014 Telerik AD
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
!function(e,define){define(["./kendo.core.min","./kendo.popup.min"],e)}(function(){return function(e,t){var n=window.kendo,i=n.ui.Widget,r=e.proxy,o=e.extend,a=window.setTimeout,s="click",l="show",u="hide",d="k-notification",c=".k-notification-wrap .k-i-close",f="info",h="success",p="warning",g="error",m="top",v="left",_="bottom",y="right",b="up",w=".kendoNotification",x='<div class="k-widget k-notification"></div>',k='<div class="k-notification-wrap"><span class="k-icon k-i-note">#=typeIcon#</span>#=content#<span class="k-icon k-i-close">Hide</span></div>',T=i.extend({init:function(t,r){var o=this;i.fn.init.call(o,t,r),r=o.options,r.appendTo&&e(r.appendTo).is(t)||o.element.hide(),o._compileTemplates(r.templates),o._guid="_"+n.guid(),o._isRtl=n.support.isRtl(t),o._compileStacking(r.stacking,r.position.top),n.notify(o)},events:[l,u],options:{name:"Notification",position:{pinned:!0,top:null,left:null,bottom:20,right:20},stacking:"default",hideOnClick:!0,button:!1,allowHideAfter:0,autoHideAfter:5e3,appendTo:null,width:null,height:null,templates:[],animation:{open:{effects:"fade:in",duration:300},close:{effects:"fade:out",duration:600,hide:!0}}},_compileTemplates:function(t){var i=this,r=n.template;i._compiled={},e.each(t,function(t,n){i._compiled[n.type]=r(n.template||e("#"+n.templateId).html())}),i._defaultCompiled=r(k)},_getCompiled:function(e){var t=this,n=t._defaultCompiled;return e?t._compiled[e]||n:n},_compileStacking:function(e,t){var n,i,r=this,o={paddingTop:0,paddingRight:0,paddingBottom:0,paddingLeft:0};switch(e){case"down":n=_+" "+v,i=m+" "+v,delete o.paddingBottom;break;case y:n=m+" "+y,i=m+" "+v,delete o.paddingRight;break;case v:n=m+" "+v,i=m+" "+y,delete o.paddingLeft;break;case b:n=m+" "+v,i=_+" "+v,delete o.paddingTop;break;default:null!==t?(n=_+" "+v,i=m+" "+v,delete o.paddingBottom):(n=m+" "+v,i=_+" "+v,delete o.paddingTop)}r._popupOrigin=n,r._popupPosition=i,r._popupPaddings=o},_attachPopupEvents:function(e,t){function n(e){e.on(s+w,function(){t.close()})}var i,r=e.allowHideAfter,o=!isNaN(r)&&r>0;e.hideOnClick?t.bind("activate",function(){o?a(function(){n(t.element)},r):n(t.element)}):e.button&&(i=t.element.find(c),o?a(function(){n(i)},r):n(i))},_showPopup:function(t,i){var r,s,l=this,d=i.autoHideAfter,f=i.position.left,h=i.position.top;s=e("."+l._guid).last(),r=new n.ui.Popup(t,{anchor:s[0]?s:document.body,origin:l._popupOrigin,position:l._popupPosition,animation:i.animation,modal:!0,collision:"",isRtl:l._isRtl,close:function(){l.trigger(u,{element:this.element})},deactivate:function(e){e.sender.element.off(w),e.sender.element.find(c).off(w),e.sender.destroy()}}),l._attachPopupEvents(i,r),s[0]?r.open():(null===f&&(f=e(window).width()-t.width()-i.position.right),null===h&&(h=e(window).height()-t.height()-i.position.bottom),r.open(f,h)),r.wrapper.addClass(l._guid).css(o({margin:0},l._popupPaddings)),i.position.pinned?(r.wrapper.css("position","fixed"),s[0]&&l._togglePin(r.wrapper,!0)):s[0]||l._togglePin(r.wrapper,!1),d>0&&a(function(){r.close()},d)},_togglePin:function(t,n){var i=e(window),r=n?-1:1;t.css({top:parseInt(t.css(m),10)+r*i.scrollTop(),left:parseInt(t.css(v),10)+r*i.scrollLeft()})},_attachStaticEvents:function(e,t){function n(e){e.on(s+w,r(i._hideStatic,i,t))}var i=this,o=e.allowHideAfter,l=!isNaN(o)&&o>0;e.hideOnClick?l?a(function(){n(t)},o):n(t):e.button&&(l?a(function(){n(t.find(c))},o):n(t.find(c)))},_showStatic:function(e,t){var n=this,i=t.autoHideAfter,r=t.animation,o=t.stacking==b||t.stacking==v?"prependTo":"appendTo";e.addClass(n._guid)[o](t.appendTo).hide().kendoAnimate(r.open),n._attachStaticEvents(t,e),i>0&&a(function(){n._hideStatic(e)},i)},_hideStatic:function(e){e.kendoAnimate(o(this.options.animation.close,{complete:function(){e.off(w).find(c).off(w),e.remove()}})),this.trigger(u,{element:e})},show:function(i,r){var a,s,u=this,c=u.options,h=e(x);return r||(r=f),null!==i&&i!==t&&""!==i&&(n.isFunction(i)&&(i=i()),s={typeIcon:r,content:""},a=e.isPlainObject(i)?o(s,i):o(s,{content:i}),h.addClass(d+"-"+r).toggleClass(d+"-button",c.button).attr("data-role","alert").css({width:c.width,height:c.height}).append(u._getCompiled(r)(a)),e(c.appendTo)[0]?u._showStatic(h,c):u._showPopup(h,c),u.trigger(l,{element:h})),u},info:function(e){return this.show(e,f)},success:function(e){return this.show(e,h)},warning:function(e){return this.show(e,p)},error:function(e){return this.show(e,g)},hide:function(){var t=this,n=t.getNotifications();return n.each(t.options.appendTo?function(n,i){t._hideStatic(e(i))}:function(t,n){var i=e(n).data("kendoPopup");i&&i.close()}),t},getNotifications:function(){var t=this,n=e("."+t._guid);return t.options.appendTo?n:n.children("."+d)},setOptions:function(e){var n,r=this;i.fn.setOptions.call(r,e),n=r.options,e.templates!==t&&r._compileTemplates(n.templates),(e.stacking!==t||e.position!==t)&&r._compileStacking(n.stacking,n.position.top)},destroy:function(){i.fn.destroy.call(this),this.getNotifications().off(w).find(c).off(w)}});n.ui.plugin(T)}(window.kendo.jQuery),window.kendo},"function"==typeof define&&define.amd?define:function(e,t){t()});