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