UNPKG

@progress/kendo-ui

Version:

This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.

1 lines 6.27 kB
module.exports=function(t){function e(i){if(o[i])return o[i].exports;var s=o[i]={exports:{},id:i,loaded:!1};return t[i].call(s.exports,s,s.exports,e),s.loaded=!0,s.exports}var o={};return e.m=t,e.c=o,e.p="",e(0)}({0:function(t,e,o){o(927),t.exports=o(927)},3:function(t,e){t.exports=function(){throw Error("define cannot be used indirect")}},920:function(t,e){t.exports=require("./kendo-drawing")},927:function(t,e,o){var i,s,n;!function(h,define){s=[o(928),o(920)],i=h,n="function"==typeof i?i.apply(e,s):i,!(void 0!==n&&(t.exports=n))}(function(){!function(t){var e=".kendo",o=window.kendo,i=o.deepExtend,s=o.drawing.util,n=s.defined,h=s.limitValue,r=s.eventCoordinates,p=o._outerWidth,u=o._outerHeight,a=t.proxy,l='<div class="k-tooltip"><div class="k-tooltip-content"></div></div>',c='<div class="k-tooltip-button"><a href="\\#" class="k-icon k-i-close">close</a></div>',d=o.Class.extend({init:function(e,o){this.element=t(l),this.content=this.element.children(".k-tooltip-content"),o=o||{},this.options=i({},this.options,this._tooltipOptions(o)),this.popupOptions={appendTo:o.appendTo,animation:o.animation,copyAnchorStyles:!1,collision:"fit fit"},this._openPopupHandler=t.proxy(this._openPopup,this),this.surface=e,this._bindEvents()},options:{position:"top",showOn:"mouseenter",offset:7,autoHide:!0,hideDelay:0,showAfter:100},_bindEvents:function(){this._showHandler=a(this._showEvent,this),this._surfaceLeaveHandler=a(this._surfaceLeave,this),this._mouseleaveHandler=a(this._mouseleave,this),this._mousemoveHandler=a(this._mousemove,this),this.surface.bind("click",this._showHandler),this.surface.bind("mouseenter",this._showHandler),this.surface.bind("mouseleave",this._mouseleaveHandler),this.surface.bind("mousemove",this._mousemoveHandler),this.surface.element.on("mouseleave"+e,this._surfaceLeaveHandler),this.element.on("click"+e,".k-tooltip-button",a(this._hideClick,this)),this.element.on("mouseleave"+e,a(this._tooltipLeave,this))},getPopup:function(){return this.popup||(this.popup=new o.ui.Popup(this.element,this.popupOptions)),this.popup},destroy:function(){var t=this.popup;this.surface.unbind("click",this._showHandler),this.surface.unbind("mouseenter",this._showHandler),this.surface.unbind("mouseleave",this._mouseleaveHandler),this.surface.unbind("mousemove",this._mousemoveHandler),this.surface.element.off("mouseleave"+e,this._surfaceLeaveHandler),this.element.off("click"+e),this.element.off("mouseleave"+e),t&&(t.destroy(),delete this.popup),delete this.popupOptions,clearTimeout(this._timeout),delete this.element,delete this.content,delete this.surface},_tooltipOptions:function(t){return t=t||{},{position:t.position,showOn:t.showOn,offset:t.offset,autoHide:t.autoHide,width:t.width,height:t.height,content:t.content,shared:t.shared,hideDelay:t.hideDelay,showAfter:t.showAfter}},_tooltipShape:function(t){for(;t&&!t.options.tooltip;)t=t.parent;return t},_updateContent:function(t,e,i){var s=i.content;if(o.isFunction(s)&&(s=s({element:e,target:t})),s)return this.content.html(s),!0},_position:function(t,e,o,i){var s,n=e.position,p=e.offset||0,u=this.surface,a=u._instance._elementOffset(),l=u.getSize(),c=u._instance._offset,d=t.bbox(),f=o.width,m=o.height,_=0,v=0;return d.origin.translate(a.left,a.top),c&&d.origin.translate(-c.x,-c.y),"cursor"==n&&i?(s=r(i),_=s.x-f/2,v=s.y-m-p):"left"==n?(_=d.origin.x-f-p,v=d.center().y-m/2):"right"==n?(_=d.bottomRight().x+p,v=d.center().y-m/2):"bottom"==n?(_=d.center().x-f/2,v=d.bottomRight().y+p):(_=d.center().x-f/2,v=d.origin.y-m-p),{left:h(_,a.left,a.left+l.width),top:h(v,a.top,a.top+l.height)}},show:function(t,e){this._show(t,t,i({},this.options,this._tooltipOptions(t.options.tooltip),e))},hide:function(){var t=this.popup,e=this._current;delete this._current,clearTimeout(this._showTimeout),t&&t.visible()&&e&&!this.surface.trigger("tooltipClose",{element:e.shape,target:e.target,popup:t})&&t.close()},_hideClick:function(t){t.preventDefault(),this.hide()},_show:function(t,e,o,i,s){var n,h,r=this._current;clearTimeout(this._timeout),r&&(r.shape===e&&o.shared||r.target===t)||(clearTimeout(this._showTimeout),n=this.getPopup(),!this.surface.trigger("tooltipOpen",{element:e,target:t,popup:n})&&this._updateContent(t,e,o)&&(this._autoHide(o),h=this._measure(o),n.visible()&&n.close(!0),this._current={options:o,elementSize:h,shape:e,target:t,position:this._position(o.shared?e:t,o,h,i)},s?this._showTimeout=setTimeout(this._openPopupHandler,o.showAfter||0):this._openPopup()))},_openPopup:function(){var t=this._current,e=t.position;this.getPopup().open(e.left,e.top)},_autoHide:function(e){e.autoHide&&this._closeButton&&(this.element.removeClass("k-tooltip-closable"),this._closeButton.remove(),delete this._closeButton),e.autoHide||this._closeButton||(this.element.addClass("k-tooltip-closable"),this._closeButton=t(c).prependTo(this.element))},_showEvent:function(t){var e,o=this._tooltipShape(t.element);o&&(e=i({},this.options,this._tooltipOptions(o.options.tooltip)),e&&e.showOn==t.type&&this._show(t.element,o,e,t.originalEvent,!0))},_measure:function(t){var e,o,i,s=this.getPopup();return this.element.css({width:"auto",height:"auto"}),i=s.visible(),i||s.wrapper.show(),this.element.css({width:n(t.width)?t.width:"auto",height:n(t.height)?t.height:"auto"}),e=p(this.element),o=u(this.element),i||s.wrapper.hide(),{width:e,height:o}},_mouseleave:function(t){var e,o;this.popup&&!this._popupRelatedTarget(t.originalEvent)&&(e=this,o=e._current,o&&o.options.autoHide&&(e._timeout=setTimeout(function(){clearTimeout(e._showTimeout),e.hide()},o.options.hideDelay||0)))},_mousemove:function(t){var e,o,i=this._current;i&&t.element&&(e=i.options,"cursor"==e.position&&(o=this._position(t.element,e,i.elementSize,t.originalEvent),i.position=o,this.getPopup().wrapper.css({left:o.left,top:o.top})))},_surfaceLeave:function(t){this.popup&&!this._popupRelatedTarget(t)&&(clearTimeout(this._showTimeout),this.hide())},_popupRelatedTarget:function(e){return e.relatedTarget&&t(e.relatedTarget).closest(this.popup.wrapper).length},_tooltipLeave:function(){var t=this,e=t._current;e&&e.options.autoHide&&(t._timeout=setTimeout(function(){t.hide()},e.options.hideDelay||0))}});o.drawing.SurfaceTooltip=d}(window.kendo.jQuery)},o(3))},928:function(t,e){t.exports=require("../kendo.popup")}});