Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

webui-popover

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webui-popover - npm Package Compare versions

Comparing version 1.2.10 to 1.2.11

demo/test-canvas.html

2

bower.json
{
"name": "webui-popover",
"version": "1.2.9",
"version": "1.2.11",
"authors": [

@@ -5,0 +5,0 @@ "sandywalker <sanddywalker@gmail.com>"

/*
* webui popover plugin - v1.2.9
* webui popover plugin - v1.2.10
* A lightWeight popover plugin with jquery ,enchance the popover plugin of bootstrap with some awesome new features. It works well with bootstrap ,but bootstrap is not necessary!

@@ -845,6 +845,7 @@ * https://github.com/sandywalker/webui-popover

// If the container is the body or normal conatiner, just use $element.offset()
var elRect = this.$element[0].getBoundingClientRect();
if (this.options.container.is(document.body) || this.options.container.css('position') !== 'fixed') {
return $.extend({}, this.$element.offset(), {
width: this.$element[0].offsetWidth,
height: this.$element[0].offsetHeight
width: this.$element[0].offsetWidth || elRect.width,
height: this.$element[0].offsetHeight || elRect.height
});

@@ -854,8 +855,7 @@ // Else fixed container need recalculate the position

var containerRect = this.options.container[0].getBoundingClientRect();
var elementRect = this.$element[0].getBoundingClientRect();
return {
top: elementRect.top - containerRect.top + this.options.container.scrollTop(),
left: elementRect.left - containerRect.left + this.options.container.scrollLeft(),
width: elementRect.width,
height: elementRect.height
top: elRect.top - containerRect.top + this.options.container.scrollTop(),
left: elRect.left - containerRect.left + this.options.container.scrollLeft(),
width: elRect.width,
height: elRect.height
};

@@ -862,0 +862,0 @@ }

/*
* webui popover plugin - v1.2.9
* webui popover plugin - v1.2.10
* A lightWeight popover plugin with jquery ,enchance the popover plugin of bootstrap with some awesome new features. It works well with bootstrap ,but bootstrap is not necessary!

@@ -9,2 +9,2 @@ * https://github.com/sandywalker/webui-popover

*/
!function(a,b,c){"use strict";!function(b){"function"==typeof define&&define.amd?define(["jquery"],b):"object"==typeof exports?module.exports=b(require("jquery")):b(a.jQuery)}(function(a){function c(b,c){this.$element=a(b),c&&("string"===a.type(c.delay)||"number"===a.type(c.delay))&&(c.delay={show:c.delay,hide:c.delay}),this.options=a.extend({},g,c),this._defaults=g,this._name=d,this._targetclick=!1,this.init(),i.push(this.$element)}var d="webuiPopover",e="webui-popover",f="webui.popover",g={placement:"auto",container:null,width:"auto",height:"auto",trigger:"click",style:"",delay:{show:null,hide:null},async:{type:"GET",before:null,success:null,error:null},cache:!0,multi:!1,arrow:!0,title:"",content:"",closeable:!1,padding:!0,url:"",type:"html",direction:"",animation:null,template:'<div class="webui-popover"><div class="webui-arrow"></div><div class="webui-popover-inner"><a href="#" class="close"></a><h3 class="webui-popover-title"></h3><div class="webui-popover-content"><i class="icon-refresh"></i> <p>&nbsp;</p></div></div></div>',backdrop:!1,dismissible:!0,onShow:null,onHide:null,abortXHR:!0,autoHide:!1,offsetTop:0,offsetLeft:0,iframeOptions:{frameborder:"0",allowtransparency:"true",id:"",name:"",scrolling:"",onload:"",height:"",width:""}},h=e+"-rtl",i=[],j=a('<div class="webui-popover-backdrop"></div>'),k=0,l=!1,m=-2e3,n=a(b),o=function(a,b){return isNaN(a)?b||0:Number(a)},p=function(a){return a.data("plugin_"+d)},q=function(){for(var a=null,b=0;b<i.length;b++)a=p(i[b]),a&&a.hide(!0);n.trigger("hiddenAll."+f)},r="ontouchstart"in b.documentElement&&/Mobi/.test(navigator.userAgent),s=function(a){var b={x:0,y:0};if("touchstart"===a.type||"touchmove"===a.type||"touchend"===a.type||"touchcancel"===a.type){var c=a.originalEvent.touches[0]||a.originalEvent.changedTouches[0];b.x=c.pageX,b.y=c.pageY}else("mousedown"===a.type||"mouseup"===a.type||"click"===a.type)&&(b.x=a.pageX,b.y=a.pageY);return b};c.prototype={init:function(){"click"===this.getTrigger()||r?this.$element.off("click touchend").on("click touchend",a.proxy(this.toggle,this)):"hover"===this.getTrigger()&&this.$element.off("mouseenter mouseleave click").on("mouseenter",a.proxy(this.mouseenterHandler,this)).on("mouseleave",a.proxy(this.mouseleaveHandler,this)),this._poped=!1,this._inited=!0,this._opened=!1,this._idSeed=k,this.options.container=a(this.options.container||b.body).first(),this.options.backdrop&&j.appendTo(this.options.container).hide(),k++,"sticky"===this.getTrigger()&&this.show()},destroy:function(){for(var a=-1,b=0;b<i.length;b++)if(i[b]===this.$element){a=b;break}i.splice(a,1),this.hide(),this.$element.data("plugin_"+d,null),"click"===this.getTrigger()?this.$element.off("click"):"hover"===this.getTrigger()&&this.$element.off("mouseenter mouseleave"),this.$target&&this.$target.remove()},hide:function(b,c){if((b||"sticky"!==this.getTrigger())&&this._opened){c&&(c.preventDefault(),c.stopPropagation()),this.xhr&&this.options.abortXHR===!0&&(this.xhr.abort(),this.xhr=null);var d=a.Event("hide."+f);if(this.$element.trigger(d,[this.$target]),this.$target){this.$target.removeClass("in").addClass(this.getHideAnimation());var e=this;setTimeout(function(){e.$target.hide()},300)}this.options.backdrop&&j.hide(),this._opened=!1,this.$element.trigger("hidden."+f,[this.$target]),this.options.onHide&&this.options.onHide(this.$target)}},resetAutoHide:function(){var a=this,b=a.getAutoHide();b&&(a.autoHideHandler&&clearTimeout(a.autoHideHandler),a.autoHideHandler=setTimeout(function(){a.hide()},b))},toggle:function(a){a&&(a.preventDefault(),a.stopPropagation()),this[this.getTarget().hasClass("in")?"hide":"show"]()},hideAll:function(){q()},show:function(){if(!this._opened){var a=this.getTarget().removeClass().addClass(e).addClass(this._customTargetClass);this.options.multi||this.hideAll(),this.getCache()&&this._poped&&""!==this.content||(this.content="",this.setTitle(this.getTitle()),this.options.closeable||a.find(".close").off("click").remove(),this.isAsync()?this.setContentASync(this.options.content):this.setContent(this.getContent()),a.show()),this.displayContent(),this.options.onShow&&this.options.onShow(a),this.bindBodyEvents(),this.options.backdrop&&j.show(),this._opened=!0,this.resetAutoHide()}},displayContent:function(){var b=this.getElementPosition(),c=this.getTarget().removeClass().addClass(e).addClass(this._customTargetClass),d=this.getContentElement(),g=c[0].offsetWidth,i=c[0].offsetHeight,j="bottom",k=a.Event("show."+f);this.$element.trigger(k,[c]);var l=this.$element.data("width")||this.options.width;""===l&&(l=this._defaults.width),"auto"!==l&&c.width(l);var n=this.$element.data("height")||this.options.height;""===n&&(n=this._defaults.height),"auto"!==n&&d.height(n),this.options.style&&this.$target.addClass(e+"-"+this.options.style),"rtl"!==this.options.direction||d.hasClass(h)||d.addClass(h),this.options.arrow||c.find(".webui-arrow").remove(),c.detach().css({top:m,left:m,display:"block"}),this.getAnimation()&&c.addClass(this.getAnimation()),c.appendTo(this.options.container),j=this.getPlacement(b),this.$element.trigger("added."+f),this.initTargetEvents(),this.options.padding||("auto"!==this.options.height&&d.css("height",d.outerHeight()),this.$target.addClass("webui-no-padding")),g=c[0].offsetWidth,i=c[0].offsetHeight;var o=this.getTargetPositin(b,j,g,i);if(this.$target.css(o.position).addClass(j).addClass("in"),"iframe"===this.options.type){var p=c.find("iframe"),q=c.width(),r=p.parent().height();""!==this.options.iframeOptions.width&&"auto"!==this.options.iframeOptions.width&&(q=this.options.iframeOptions.width),""!==this.options.iframeOptions.height&&"auto"!==this.options.iframeOptions.height&&(r=this.options.iframeOptions.height),p.width(q).height(r)}if(this.options.arrow||this.$target.css({margin:0}),this.options.arrow){var s=this.$target.find(".webui-arrow");s.removeAttr("style"),"left"===j||"right"===j?s.css({top:this.$target.height()/2}):("top"===j||"bottom"===j)&&s.css({left:this.$target.width()/2}),o.arrowOffset&&(-1===o.arrowOffset.left||-1===o.arrowOffset.top?s.hide():s.css(o.arrowOffset))}this._poped=!0,this.$element.trigger("shown."+f,[this.$target])},isTargetLoaded:function(){return 0===this.getTarget().find("i.glyphicon-refresh").length},getTriggerElement:function(){return this.$element},getTarget:function(){if(!this.$target){var b=d+this._idSeed;this.$target=a(this.options.template).attr("id",b).data("trigger-element",this.getTriggerElement()),this._customTargetClass=this.$target.attr("class")!==e?this.$target.attr("class"):null,this.getTriggerElement().attr("data-target",b)}return this.$target},getTitleElement:function(){return this.getTarget().find("."+e+"-title")},getContentElement:function(){return this.$contentElement||(this.$contentElement=this.getTarget().find("."+e+"-content")),this.$contentElement},getTitle:function(){return this.$element.attr("data-title")||this.options.title||this.$element.attr("title")},getUrl:function(){return this.$element.attr("data-url")||this.options.url},getAutoHide:function(){return this.$element.attr("data-auto-hide")||this.options.autoHide},getOffsetTop:function(){return o(this.$element.attr("data-offset-top"))||this.options.offsetTop},getOffsetLeft:function(){return o(this.$element.attr("data-offset-left"))||this.options.offsetLeft},getCache:function(){var a=this.$element.attr("data-cache");if("undefined"!=typeof a)switch(a.toLowerCase()){case"true":case"yes":case"1":return!0;case"false":case"no":case"0":return!1}return this.options.cache},getTrigger:function(){return this.$element.attr("data-trigger")||this.options.trigger},getDelayShow:function(){var a=this.$element.attr("data-delay-show");return"undefined"!=typeof a?a:0===this.options.delay.show?0:this.options.delay.show||100},getHideDelay:function(){var a=this.$element.attr("data-delay-hide");return"undefined"!=typeof a?a:0===this.options.delay.hide?0:this.options.delay.hide||100},getAnimation:function(){var a=this.$element.attr("data-animation");return a||this.options.animation},getHideAnimation:function(){var a=this.getAnimation();return a?a+"-out":"out"},setTitle:function(a){var b=this.getTitleElement();a?("rtl"!==this.options.direction||b.hasClass(h)||b.addClass(h),b.html(a)):b.remove()},hasContent:function(){return this.getContent()},getIframe:function(){var b=a("<iframe></iframe>").attr("src",this.getUrl()),c=this;return a.each(this._defaults.iframeOptions,function(a){"undefined"!=typeof c.options.iframeOptions[a]&&b.attr(a,c.options.iframeOptions[a])}),b},getContent:function(){if(this.getUrl())switch(this.options.type){case"iframe":this.content=this.getIframe();break;case"html":try{this.content=a(this.getUrl()),this.content.is(":visible")||this.content.show()}catch(b){throw new Error("Unable to get popover content. Invalid selector specified.")}}else if(!this.content){var c="";if(c=a.isFunction(this.options.content)?this.options.content.apply(this.$element[0],[this]):this.options.content,this.content=this.$element.attr("data-content")||c,!this.content){var d=this.$element.next();d&&d.hasClass(e+"-content")&&(this.content=d)}}return this.content},setContent:function(a){var b=this.getTarget(),c=this.getContentElement();"string"==typeof a?c.html(a):a instanceof jQuery&&(c.html(""),this.options.cache?a.removeClass(e+"-content").appendTo(c):a.clone(!0,!0).removeClass(e+"-content").appendTo(c)),this.$target=b},isAsync:function(){return"async"===this.options.type},setContentASync:function(b){var c=this;this.xhr||(this.xhr=a.ajax({url:this.getUrl(),type:this.options.async.type,cache:this.getCache(),beforeSend:function(a){c.options.async.before&&c.options.async.before(c,a)},success:function(d){c.bindBodyEvents(),b&&a.isFunction(b)?c.content=b.apply(c.$element[0],[d]):c.content=d,c.setContent(c.content);var e=c.getContentElement();e.removeAttr("style"),c.displayContent(),c.options.async.success&&c.options.async.success(c,d)},complete:function(){c.xhr=null},error:function(a,b){c.options.async.error&&c.options.async.error(c,a,b)}}))},bindBodyEvents:function(){l||(this.options.dismissible&&"click"===this.getTrigger()?(n.off("keyup.webui-popover").on("keyup.webui-popover",a.proxy(this.escapeHandler,this)),n.off("click.webui-popover touchend.webui-popover").on("click.webui-popover touchend.webui-popover",a.proxy(this.bodyClickHandler,this))):"hover"===this.getTrigger()&&n.off("touchend.webui-popover").on("touchend.webui-popover",a.proxy(this.bodyClickHandler,this)))},mouseenterHandler:function(){var a=this;a._timeout&&clearTimeout(a._timeout),a._enterTimeout=setTimeout(function(){a.getTarget().is(":visible")||a.show()},this.getDelayShow())},mouseleaveHandler:function(){var a=this;clearTimeout(a._enterTimeout),a._timeout=setTimeout(function(){a.hide()},this.getHideDelay())},escapeHandler:function(a){27===a.keyCode&&this.hideAll()},bodyClickHandler:function(a){l=!0;for(var b=!0,c=0;c<i.length;c++){var d=p(i[c]);if(d&&d._opened){var e=d.getTarget().offset().left,f=d.getTarget().offset().top,g=d.getTarget().offset().left+d.getTarget().width(),h=d.getTarget().offset().top+d.getTarget().height(),j=s(a),k=j.x>=e&&j.x<=g&&j.y>=f&&j.y<=h;if(k){b=!1;break}}}b&&q()},initTargetEvents:function(){"hover"===this.getTrigger()&&this.$target.off("mouseenter mouseleave").on("mouseenter",a.proxy(this.mouseenterHandler,this)).on("mouseleave",a.proxy(this.mouseleaveHandler,this)),this.$target.find(".close").off("click").on("click",a.proxy(this.hide,this,!0))},getPlacement:function(a){var b,c=this.options.container,d=c.innerWidth(),e=c.innerHeight(),f=c.scrollTop(),g=c.scrollLeft(),h=Math.max(0,a.left-g),i=Math.max(0,a.top-f);b="function"==typeof this.options.placement?this.options.placement.call(this,this.getTarget()[0],this.$element[0]):this.$element.data("placement")||this.options.placement;var j="horizontal"===b,k="vertical"===b,l="auto"===b||j||k;return l?b=d/3>h?e/3>i?j?"right-bottom":"bottom-right":2*e/3>i?k?e/2>=i?"bottom-right":"top-right":"right":j?"right-top":"top-right":2*d/3>h?e/3>i?j?d/2>=h?"right-bottom":"left-bottom":"bottom":2*e/3>i?j?d/2>=h?"right":"left":e/2>=i?"bottom":"top":j?d/2>=h?"right-top":"left-top":"top":e/3>i?j?"left-bottom":"bottom-left":2*e/3>i?k?e/2>=i?"bottom-left":"top-left":"left":j?"left-top":"top-left":"auto-top"===b?b=d/3>h?"top-right":2*d/3>h?"top":"top-left":"auto-bottom"===b?b=d/3>h?"bottom-right":2*d/3>h?"bottom":"bottom-left":"auto-left"===b?b=e/3>i?"left-top":2*e/3>i?"left":"left-bottom":"auto-right"===b&&(b=e/3>i?"right-top":2*e/3>i?"right":"right-bottom"),b},getElementPosition:function(){if(this.options.container.is(b.body)||"fixed"!==this.options.container.css("position"))return a.extend({},this.$element.offset(),{width:this.$element[0].offsetWidth,height:this.$element[0].offsetHeight});var c=this.options.container[0].getBoundingClientRect(),d=this.$element[0].getBoundingClientRect();return{top:d.top-c.top+this.options.container.scrollTop(),left:d.left-c.left+this.options.container.scrollLeft(),width:d.width,height:d.height}},getTargetPositin:function(a,c,d,e){var f=a,g=this.options.container,h=this.$element.outerWidth(),i=this.$element.outerHeight(),j=g.scrollTop(),k=g.scrollLeft(),l={},n=null,o=this.options.arrow?20:0,p=10,q=o+p>h?o:0,r=o+p>i?o:0,s=0,t=b.documentElement.clientHeight+j,u=b.documentElement.clientWidth+k,v=f.left+f.width/2-q>0,w=f.left+f.width/2+q<u,x=f.top+f.height/2-r>0,y=f.top+f.height/2+r<t;switch(c){case"bottom":l={top:f.top+f.height,left:f.left+f.width/2-d/2};break;case"top":l={top:f.top-e,left:f.left+f.width/2-d/2};break;case"left":l={top:f.top+f.height/2-e/2,left:f.left-d};break;case"right":l={top:f.top+f.height/2-e/2,left:f.left+f.width};break;case"top-right":l={top:f.top-e,left:v?f.left-q:p},n={left:v?Math.min(h,d)/2+q:m};break;case"top-left":s=w?q:-p,l={top:f.top-e,left:f.left-d+f.width+s},n={left:w?d-Math.min(h,d)/2-q:m};break;case"bottom-right":l={top:f.top+f.height,left:v?f.left-q:p},n={left:v?Math.min(h,d)/2+q:m};break;case"bottom-left":s=w?q:-p,l={top:f.top+f.height,left:f.left-d+f.width+s},n={left:w?d-Math.min(h,d)/2-q:m};break;case"right-top":s=y?r:-p,l={top:f.top-e+f.height+s,left:f.left+f.width},n={top:y?e-Math.min(i,e)/2-r:m};break;case"right-bottom":l={top:x?f.top-r:p,left:f.left+f.width},n={top:x?Math.min(i,e)/2+r:m};break;case"left-top":s=y?r:-p,l={top:f.top-e+f.height+s,left:f.left-d},n={top:y?e-Math.min(i,e)/2-r:m};break;case"left-bottom":l={top:x?f.top-r:p,left:f.left-d},n={top:x?Math.min(i,e)/2+r:m}}return l.top+=this.getOffsetTop(),l.left+=this.getOffsetLeft(),{position:l,arrowOffset:n}}},a.fn[d]=function(b,e){var f=[],g=this.each(function(){var g=a.data(this,"plugin_"+d);g?"destroy"===b?g.destroy():"string"==typeof b&&f.push(g[b]()):(b?"string"==typeof b?"destroy"!==b&&(e||(g=new c(this,null),f.push(g[b]()))):"object"==typeof b&&(g=new c(this,b)):g=new c(this,null),a.data(this,"plugin_"+d,g))});return f.length?f:g}})}(window,document);
!function(a,b,c){"use strict";!function(b){"function"==typeof define&&define.amd?define(["jquery"],b):"object"==typeof exports?module.exports=b(require("jquery")):b(a.jQuery)}(function(a){function c(b,c){this.$element=a(b),c&&("string"===a.type(c.delay)||"number"===a.type(c.delay))&&(c.delay={show:c.delay,hide:c.delay}),this.options=a.extend({},g,c),this._defaults=g,this._name=d,this._targetclick=!1,this.init(),i.push(this.$element)}var d="webuiPopover",e="webui-popover",f="webui.popover",g={placement:"auto",container:null,width:"auto",height:"auto",trigger:"click",style:"",delay:{show:null,hide:null},async:{type:"GET",before:null,success:null,error:null},cache:!0,multi:!1,arrow:!0,title:"",content:"",closeable:!1,padding:!0,url:"",type:"html",direction:"",animation:null,template:'<div class="webui-popover"><div class="webui-arrow"></div><div class="webui-popover-inner"><a href="#" class="close"></a><h3 class="webui-popover-title"></h3><div class="webui-popover-content"><i class="icon-refresh"></i> <p>&nbsp;</p></div></div></div>',backdrop:!1,dismissible:!0,onShow:null,onHide:null,abortXHR:!0,autoHide:!1,offsetTop:0,offsetLeft:0,iframeOptions:{frameborder:"0",allowtransparency:"true",id:"",name:"",scrolling:"",onload:"",height:"",width:""}},h=e+"-rtl",i=[],j=a('<div class="webui-popover-backdrop"></div>'),k=0,l=!1,m=-2e3,n=a(b),o=function(a,b){return isNaN(a)?b||0:Number(a)},p=function(a){return a.data("plugin_"+d)},q=function(){for(var a=null,b=0;b<i.length;b++)a=p(i[b]),a&&a.hide(!0);n.trigger("hiddenAll."+f)},r="ontouchstart"in b.documentElement&&/Mobi/.test(navigator.userAgent),s=function(a){var b={x:0,y:0};if("touchstart"===a.type||"touchmove"===a.type||"touchend"===a.type||"touchcancel"===a.type){var c=a.originalEvent.touches[0]||a.originalEvent.changedTouches[0];b.x=c.pageX,b.y=c.pageY}else("mousedown"===a.type||"mouseup"===a.type||"click"===a.type)&&(b.x=a.pageX,b.y=a.pageY);return b};c.prototype={init:function(){"click"===this.getTrigger()||r?this.$element.off("click touchend").on("click touchend",a.proxy(this.toggle,this)):"hover"===this.getTrigger()&&this.$element.off("mouseenter mouseleave click").on("mouseenter",a.proxy(this.mouseenterHandler,this)).on("mouseleave",a.proxy(this.mouseleaveHandler,this)),this._poped=!1,this._inited=!0,this._opened=!1,this._idSeed=k,this.options.container=a(this.options.container||b.body).first(),this.options.backdrop&&j.appendTo(this.options.container).hide(),k++,"sticky"===this.getTrigger()&&this.show()},destroy:function(){for(var a=-1,b=0;b<i.length;b++)if(i[b]===this.$element){a=b;break}i.splice(a,1),this.hide(),this.$element.data("plugin_"+d,null),"click"===this.getTrigger()?this.$element.off("click"):"hover"===this.getTrigger()&&this.$element.off("mouseenter mouseleave"),this.$target&&this.$target.remove()},hide:function(b,c){if((b||"sticky"!==this.getTrigger())&&this._opened){c&&(c.preventDefault(),c.stopPropagation()),this.xhr&&this.options.abortXHR===!0&&(this.xhr.abort(),this.xhr=null);var d=a.Event("hide."+f);if(this.$element.trigger(d,[this.$target]),this.$target){this.$target.removeClass("in").addClass(this.getHideAnimation());var e=this;setTimeout(function(){e.$target.hide()},300)}this.options.backdrop&&j.hide(),this._opened=!1,this.$element.trigger("hidden."+f,[this.$target]),this.options.onHide&&this.options.onHide(this.$target)}},resetAutoHide:function(){var a=this,b=a.getAutoHide();b&&(a.autoHideHandler&&clearTimeout(a.autoHideHandler),a.autoHideHandler=setTimeout(function(){a.hide()},b))},toggle:function(a){a&&(a.preventDefault(),a.stopPropagation()),this[this.getTarget().hasClass("in")?"hide":"show"]()},hideAll:function(){q()},show:function(){if(!this._opened){var a=this.getTarget().removeClass().addClass(e).addClass(this._customTargetClass);this.options.multi||this.hideAll(),this.getCache()&&this._poped&&""!==this.content||(this.content="",this.setTitle(this.getTitle()),this.options.closeable||a.find(".close").off("click").remove(),this.isAsync()?this.setContentASync(this.options.content):this.setContent(this.getContent()),a.show()),this.displayContent(),this.options.onShow&&this.options.onShow(a),this.bindBodyEvents(),this.options.backdrop&&j.show(),this._opened=!0,this.resetAutoHide()}},displayContent:function(){var b=this.getElementPosition(),c=this.getTarget().removeClass().addClass(e).addClass(this._customTargetClass),d=this.getContentElement(),g=c[0].offsetWidth,i=c[0].offsetHeight,j="bottom",k=a.Event("show."+f);this.$element.trigger(k,[c]);var l=this.$element.data("width")||this.options.width;""===l&&(l=this._defaults.width),"auto"!==l&&c.width(l);var n=this.$element.data("height")||this.options.height;""===n&&(n=this._defaults.height),"auto"!==n&&d.height(n),this.options.style&&this.$target.addClass(e+"-"+this.options.style),"rtl"!==this.options.direction||d.hasClass(h)||d.addClass(h),this.options.arrow||c.find(".webui-arrow").remove(),c.detach().css({top:m,left:m,display:"block"}),this.getAnimation()&&c.addClass(this.getAnimation()),c.appendTo(this.options.container),j=this.getPlacement(b),this.$element.trigger("added."+f),this.initTargetEvents(),this.options.padding||("auto"!==this.options.height&&d.css("height",d.outerHeight()),this.$target.addClass("webui-no-padding")),g=c[0].offsetWidth,i=c[0].offsetHeight;var o=this.getTargetPositin(b,j,g,i);if(this.$target.css(o.position).addClass(j).addClass("in"),"iframe"===this.options.type){var p=c.find("iframe"),q=c.width(),r=p.parent().height();""!==this.options.iframeOptions.width&&"auto"!==this.options.iframeOptions.width&&(q=this.options.iframeOptions.width),""!==this.options.iframeOptions.height&&"auto"!==this.options.iframeOptions.height&&(r=this.options.iframeOptions.height),p.width(q).height(r)}if(this.options.arrow||this.$target.css({margin:0}),this.options.arrow){var s=this.$target.find(".webui-arrow");s.removeAttr("style"),"left"===j||"right"===j?s.css({top:this.$target.height()/2}):("top"===j||"bottom"===j)&&s.css({left:this.$target.width()/2}),o.arrowOffset&&(-1===o.arrowOffset.left||-1===o.arrowOffset.top?s.hide():s.css(o.arrowOffset))}this._poped=!0,this.$element.trigger("shown."+f,[this.$target])},isTargetLoaded:function(){return 0===this.getTarget().find("i.glyphicon-refresh").length},getTriggerElement:function(){return this.$element},getTarget:function(){if(!this.$target){var b=d+this._idSeed;this.$target=a(this.options.template).attr("id",b).data("trigger-element",this.getTriggerElement()),this._customTargetClass=this.$target.attr("class")!==e?this.$target.attr("class"):null,this.getTriggerElement().attr("data-target",b)}return this.$target},getTitleElement:function(){return this.getTarget().find("."+e+"-title")},getContentElement:function(){return this.$contentElement||(this.$contentElement=this.getTarget().find("."+e+"-content")),this.$contentElement},getTitle:function(){return this.$element.attr("data-title")||this.options.title||this.$element.attr("title")},getUrl:function(){return this.$element.attr("data-url")||this.options.url},getAutoHide:function(){return this.$element.attr("data-auto-hide")||this.options.autoHide},getOffsetTop:function(){return o(this.$element.attr("data-offset-top"))||this.options.offsetTop},getOffsetLeft:function(){return o(this.$element.attr("data-offset-left"))||this.options.offsetLeft},getCache:function(){var a=this.$element.attr("data-cache");if("undefined"!=typeof a)switch(a.toLowerCase()){case"true":case"yes":case"1":return!0;case"false":case"no":case"0":return!1}return this.options.cache},getTrigger:function(){return this.$element.attr("data-trigger")||this.options.trigger},getDelayShow:function(){var a=this.$element.attr("data-delay-show");return"undefined"!=typeof a?a:0===this.options.delay.show?0:this.options.delay.show||100},getHideDelay:function(){var a=this.$element.attr("data-delay-hide");return"undefined"!=typeof a?a:0===this.options.delay.hide?0:this.options.delay.hide||100},getAnimation:function(){var a=this.$element.attr("data-animation");return a||this.options.animation},getHideAnimation:function(){var a=this.getAnimation();return a?a+"-out":"out"},setTitle:function(a){var b=this.getTitleElement();a?("rtl"!==this.options.direction||b.hasClass(h)||b.addClass(h),b.html(a)):b.remove()},hasContent:function(){return this.getContent()},getIframe:function(){var b=a("<iframe></iframe>").attr("src",this.getUrl()),c=this;return a.each(this._defaults.iframeOptions,function(a){"undefined"!=typeof c.options.iframeOptions[a]&&b.attr(a,c.options.iframeOptions[a])}),b},getContent:function(){if(this.getUrl())switch(this.options.type){case"iframe":this.content=this.getIframe();break;case"html":try{this.content=a(this.getUrl()),this.content.is(":visible")||this.content.show()}catch(b){throw new Error("Unable to get popover content. Invalid selector specified.")}}else if(!this.content){var c="";if(c=a.isFunction(this.options.content)?this.options.content.apply(this.$element[0],[this]):this.options.content,this.content=this.$element.attr("data-content")||c,!this.content){var d=this.$element.next();d&&d.hasClass(e+"-content")&&(this.content=d)}}return this.content},setContent:function(a){var b=this.getTarget(),c=this.getContentElement();"string"==typeof a?c.html(a):a instanceof jQuery&&(c.html(""),this.options.cache?a.removeClass(e+"-content").appendTo(c):a.clone(!0,!0).removeClass(e+"-content").appendTo(c)),this.$target=b},isAsync:function(){return"async"===this.options.type},setContentASync:function(b){var c=this;this.xhr||(this.xhr=a.ajax({url:this.getUrl(),type:this.options.async.type,cache:this.getCache(),beforeSend:function(a){c.options.async.before&&c.options.async.before(c,a)},success:function(d){c.bindBodyEvents(),b&&a.isFunction(b)?c.content=b.apply(c.$element[0],[d]):c.content=d,c.setContent(c.content);var e=c.getContentElement();e.removeAttr("style"),c.displayContent(),c.options.async.success&&c.options.async.success(c,d)},complete:function(){c.xhr=null},error:function(a,b){c.options.async.error&&c.options.async.error(c,a,b)}}))},bindBodyEvents:function(){l||(this.options.dismissible&&"click"===this.getTrigger()?(n.off("keyup.webui-popover").on("keyup.webui-popover",a.proxy(this.escapeHandler,this)),n.off("click.webui-popover touchend.webui-popover").on("click.webui-popover touchend.webui-popover",a.proxy(this.bodyClickHandler,this))):"hover"===this.getTrigger()&&n.off("touchend.webui-popover").on("touchend.webui-popover",a.proxy(this.bodyClickHandler,this)))},mouseenterHandler:function(){var a=this;a._timeout&&clearTimeout(a._timeout),a._enterTimeout=setTimeout(function(){a.getTarget().is(":visible")||a.show()},this.getDelayShow())},mouseleaveHandler:function(){var a=this;clearTimeout(a._enterTimeout),a._timeout=setTimeout(function(){a.hide()},this.getHideDelay())},escapeHandler:function(a){27===a.keyCode&&this.hideAll()},bodyClickHandler:function(a){l=!0;for(var b=!0,c=0;c<i.length;c++){var d=p(i[c]);if(d&&d._opened){var e=d.getTarget().offset().left,f=d.getTarget().offset().top,g=d.getTarget().offset().left+d.getTarget().width(),h=d.getTarget().offset().top+d.getTarget().height(),j=s(a),k=j.x>=e&&j.x<=g&&j.y>=f&&j.y<=h;if(k){b=!1;break}}}b&&q()},initTargetEvents:function(){"hover"===this.getTrigger()&&this.$target.off("mouseenter mouseleave").on("mouseenter",a.proxy(this.mouseenterHandler,this)).on("mouseleave",a.proxy(this.mouseleaveHandler,this)),this.$target.find(".close").off("click").on("click",a.proxy(this.hide,this,!0))},getPlacement:function(a){var b,c=this.options.container,d=c.innerWidth(),e=c.innerHeight(),f=c.scrollTop(),g=c.scrollLeft(),h=Math.max(0,a.left-g),i=Math.max(0,a.top-f);b="function"==typeof this.options.placement?this.options.placement.call(this,this.getTarget()[0],this.$element[0]):this.$element.data("placement")||this.options.placement;var j="horizontal"===b,k="vertical"===b,l="auto"===b||j||k;return l?b=d/3>h?e/3>i?j?"right-bottom":"bottom-right":2*e/3>i?k?e/2>=i?"bottom-right":"top-right":"right":j?"right-top":"top-right":2*d/3>h?e/3>i?j?d/2>=h?"right-bottom":"left-bottom":"bottom":2*e/3>i?j?d/2>=h?"right":"left":e/2>=i?"bottom":"top":j?d/2>=h?"right-top":"left-top":"top":e/3>i?j?"left-bottom":"bottom-left":2*e/3>i?k?e/2>=i?"bottom-left":"top-left":"left":j?"left-top":"top-left":"auto-top"===b?b=d/3>h?"top-right":2*d/3>h?"top":"top-left":"auto-bottom"===b?b=d/3>h?"bottom-right":2*d/3>h?"bottom":"bottom-left":"auto-left"===b?b=e/3>i?"left-top":2*e/3>i?"left":"left-bottom":"auto-right"===b&&(b=e/3>i?"right-top":2*e/3>i?"right":"right-bottom"),b},getElementPosition:function(){var c=this.$element[0].getBoundingClientRect();if(this.options.container.is(b.body)||"fixed"!==this.options.container.css("position"))return a.extend({},this.$element.offset(),{width:this.$element[0].offsetWidth||c.width,height:this.$element[0].offsetHeight||c.height});var d=this.options.container[0].getBoundingClientRect();return{top:c.top-d.top+this.options.container.scrollTop(),left:c.left-d.left+this.options.container.scrollLeft(),width:c.width,height:c.height}},getTargetPositin:function(a,c,d,e){var f=a,g=this.options.container,h=this.$element.outerWidth(),i=this.$element.outerHeight(),j=g.scrollTop(),k=g.scrollLeft(),l={},n=null,o=this.options.arrow?20:0,p=10,q=o+p>h?o:0,r=o+p>i?o:0,s=0,t=b.documentElement.clientHeight+j,u=b.documentElement.clientWidth+k,v=f.left+f.width/2-q>0,w=f.left+f.width/2+q<u,x=f.top+f.height/2-r>0,y=f.top+f.height/2+r<t;switch(c){case"bottom":l={top:f.top+f.height,left:f.left+f.width/2-d/2};break;case"top":l={top:f.top-e,left:f.left+f.width/2-d/2};break;case"left":l={top:f.top+f.height/2-e/2,left:f.left-d};break;case"right":l={top:f.top+f.height/2-e/2,left:f.left+f.width};break;case"top-right":l={top:f.top-e,left:v?f.left-q:p},n={left:v?Math.min(h,d)/2+q:m};break;case"top-left":s=w?q:-p,l={top:f.top-e,left:f.left-d+f.width+s},n={left:w?d-Math.min(h,d)/2-q:m};break;case"bottom-right":l={top:f.top+f.height,left:v?f.left-q:p},n={left:v?Math.min(h,d)/2+q:m};break;case"bottom-left":s=w?q:-p,l={top:f.top+f.height,left:f.left-d+f.width+s},n={left:w?d-Math.min(h,d)/2-q:m};break;case"right-top":s=y?r:-p,l={top:f.top-e+f.height+s,left:f.left+f.width},n={top:y?e-Math.min(i,e)/2-r:m};break;case"right-bottom":l={top:x?f.top-r:p,left:f.left+f.width},n={top:x?Math.min(i,e)/2+r:m};break;case"left-top":s=y?r:-p,l={top:f.top-e+f.height+s,left:f.left-d},n={top:y?e-Math.min(i,e)/2-r:m};break;case"left-bottom":l={top:x?f.top-r:p,left:f.left-d},n={top:x?Math.min(i,e)/2+r:m}}return l.top+=this.getOffsetTop(),l.left+=this.getOffsetLeft(),{position:l,arrowOffset:n}}},a.fn[d]=function(b,e){var f=[],g=this.each(function(){var g=a.data(this,"plugin_"+d);g?"destroy"===b?g.destroy():"string"==typeof b&&f.push(g[b]()):(b?"string"==typeof b?"destroy"!==b&&(e||(g=new c(this,null),f.push(g[b]()))):"object"==typeof b&&(g=new c(this,b)):g=new c(this,null),a.data(this,"plugin_"+d,g))});return f.length?f:g}})}(window,document);

@@ -6,2 +6,6 @@

### 1.2.11
* fix the position bug with svg.
### 1.2.10

@@ -8,0 +12,0 @@ * fix the hidden bug in show method when trigger is set to 'manual'.

@@ -7,3 +7,3 @@ {

"homepage": "https://github.com/sandywalker/webui-popover",
"version": "1.2.10",
"version": "1.2.11",
"license": "MIT",

@@ -10,0 +10,0 @@ "devDependencies": {

@@ -837,6 +837,7 @@ (function(window, document, undefined) {

// If the container is the body or normal conatiner, just use $element.offset()
var elRect = this.$element[0].getBoundingClientRect();
if (this.options.container.is(document.body) || this.options.container.css('position') !== 'fixed') {
return $.extend({}, this.$element.offset(), {
width: this.$element[0].offsetWidth,
height: this.$element[0].offsetHeight
width: this.$element[0].offsetWidth || elRect.width,
height: this.$element[0].offsetHeight || elRect.height
});

@@ -846,8 +847,7 @@ // Else fixed container need recalculate the position

var containerRect = this.options.container[0].getBoundingClientRect();
var elementRect = this.$element[0].getBoundingClientRect();
return {
top: elementRect.top - containerRect.top + this.options.container.scrollTop(),
left: elementRect.left - containerRect.left + this.options.container.scrollLeft(),
width: elementRect.width,
height: elementRect.height
top: elRect.top - containerRect.top + this.options.container.scrollTop(),
left: elRect.left - containerRect.left + this.options.container.scrollLeft(),
width: elRect.width,
height: elRect.height
};

@@ -854,0 +854,0 @@ }

@@ -11,3 +11,3 @@ {

],
"version":"1.2.10",
"version":"1.2.11",
"author": {

@@ -14,0 +14,0 @@ "name": "Sandy Duan",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc