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.6 to 1.2.7

demo/test-container-scroll.html

37

dist/jquery.webui-popover.js
/*
* webui popover plugin - v1.2.5
* webui popover plugin - v1.2.6
* 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!

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

placement: 'auto',
container: null,
width: 'auto',

@@ -172,4 +173,7 @@ height: 'auto',

this._idSeed = _globalIdSeed;
// normalize container
this.options.container = $(this.options.container || document.body).first();
if (this.options.backdrop) {
backdrop.appendTo(document.body).hide();
backdrop.appendTo(this.options.container).hide();
}

@@ -284,3 +288,2 @@ _globalIdSeed++;

}
// use cache by default, if not cache setted , reInit the contents

@@ -368,3 +371,3 @@ if (!this.getCache() || !this._poped || this.content === '') {

}
$target.appendTo(document.body);
$target.appendTo(this.options.container);

@@ -432,3 +435,3 @@

if (postionInfo.arrowOffset) {
//hide the arrow if offset is negative
//hide the arrow if offset is negative
if (postionInfo.arrowOffset.left === -1 || postionInfo.arrowOffset.top === -1) {

@@ -594,3 +597,3 @@ $arrow.hide();

$ct.html('');
//Don't want to clone too many times.
//Don't want to clone too many times.
if (!this.options.cache) {

@@ -732,8 +735,7 @@ content.clone(true, true).removeClass(pluginClass + '-content').appendTo($ct);

placement,
de = document.documentElement,
db = document.body,
clientWidth = de.clientWidth,
clientHeight = de.clientHeight,
scrollTop = Math.max(db.scrollTop, de.scrollTop),
scrollLeft = Math.max(db.scrollLeft, de.scrollLeft),
container = this.options.container,
clientWidth = container.innerWidth(),
clientHeight = container.innerHeight(),
scrollTop = container.scrollTop(),
scrollLeft = container.scrollLeft(),
pageX = Math.max(0, pos.left - scrollLeft),

@@ -846,10 +848,9 @@ pageY = Math.max(0, pos.top - scrollTop);

var pos = elementPos,
de = document.documentElement,
db = document.body,
clientWidth = de.clientWidth,
clientHeight = de.clientHeight,
container = this.options.container,
clientWidth = container.innerWidth(),
clientHeight = container.innerHeight(),
elementW = this.$element.outerWidth(),
elementH = this.$element.outerHeight(),
scrollTop = Math.max(db.scrollTop, de.scrollTop),
scrollLeft = Math.max(db.scrollLeft, de.scrollLeft),
scrollTop = container.scrollTop(),
scrollLeft = container.scrollLeft(),
position = {},

@@ -856,0 +857,0 @@ arrowOffset = null,

/*
* webui popover plugin - v1.2.5
* webui popover plugin - v1.2.6
* 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){"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(),h.push(this.$element)}var d="webuiPopover",e="webui-popover",f="webui.popover",g={placement:"auto",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",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=[],i=a('<div class="webui-popover-backdrop"></div>'),j=0,k=!1,l=-2e3,m=a(b),n=function(a,b){return isNaN(a)?b||0:Number(a)},o=function(a){return a.data("plugin_"+d)},p=function(){for(var a=null,b=0;b<h.length;b++)a=o(h[b]),a&&a.hide(!0);m.trigger("hiddenAll."+f)},q="ontouchstart"in b.documentElement&&/Mobi/.test(navigator.userAgent),r=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()||q?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=j,this.options.backdrop&&i.appendTo(b.body).hide(),j++,"sticky"===this.getTrigger()&&this.show()},destroy:function(){for(var a=-1,b=0;b<h.length;b++)if(h[b]===this.$element){a=b;break}h.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&&i.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(){p()},show:function(){var a=this.getTarget().removeClass().addClass(e).addClass(this._customTargetClass);this.options.multi||this.hideAll(),this._opened||(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&&i.show(),this._opened=!0,this.resetAutoHide())},displayContent:function(){var c=this.getElementPosition(),d=this.getTarget().removeClass().addClass(e).addClass(this._customTargetClass),g=this.getContentElement(),h=d[0].offsetWidth,i=d[0].offsetHeight,j="bottom",k=a.Event("show."+f);this.$element.trigger(k,[d]);var m=this.$element.data("width")||this.options.width;""===m&&(m=this._defaults.width),"auto"!==m&&d.width(m);var n=this.$element.data("height")||this.options.height;""===n&&(n=this._defaults.height),"auto"!==n&&g.height(n),this.options.style&&this.$target.addClass(e+"-"+this.options.style),this.options.arrow||d.find(".webui-arrow").remove(),d.detach().css({top:l,left:l,display:"block"}),this.getAnimation()&&d.addClass(this.getAnimation()),d.appendTo(b.body),j=this.getPlacement(c),this.$element.trigger("added."+f),this.initTargetEvents(),this.options.padding||("auto"!==this.options.height&&g.css("height",g.outerHeight()),this.$target.addClass("webui-no-padding")),h=d[0].offsetWidth,i=d[0].offsetHeight;var o=this.getTargetPositin(c,j,h,i);if(this.$target.css(o.position).addClass(j).addClass("in"),"iframe"===this.options.type){var p=d.find("iframe"),q=d.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 n(this.$element.attr("data-offset-top"))||this.options.offsetTop},getOffsetLeft:function(){return n(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?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(),c.content=b&&a.isFunction(b)?b.apply(c.$element[0],[d]):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(){k||(this.options.dismissible&&"click"===this.getTrigger()?(m.off("keyup.webui-popover").on("keyup.webui-popover",a.proxy(this.escapeHandler,this)),m.off("click.webui-popover touchend.webui-popover").on("click.webui-popover touchend.webui-popover",a.proxy(this.bodyClickHandler,this))):"hover"===this.getTrigger()&&m.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){k=!0;for(var b=!0,c=0;c<h.length;c++){var d=o(h[c]);if(d&&d._opened){var e=d.getTarget().offset().left,f=d.getTarget().offset().top,g=d.getTarget().offset().left+d.getTarget().width(),i=d.getTarget().offset().top+d.getTarget().height(),j=r(a),l=j.x>=e&&j.x<=g&&j.y>=f&&j.y<=i;if(l){b=!1;break}}}b&&p()},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 c,d=b.documentElement,e=b.body,f=d.clientWidth,g=d.clientHeight,h=Math.max(e.scrollTop,d.scrollTop),i=Math.max(e.scrollLeft,d.scrollLeft),j=Math.max(0,a.left-i),k=Math.max(0,a.top-h);c="function"==typeof this.options.placement?this.options.placement.call(this,this.getTarget()[0],this.$element[0]):this.$element.data("placement")||this.options.placement;var l="horizontal"===c,m="vertical"===c,n="auto"===c||l||m;return n?c=f/3>j?g/3>k?l?"right-bottom":"bottom-right":2*g/3>k?m?g/2>=k?"bottom-right":"top-right":"right":l?"right-top":"top-right":2*f/3>j?g/3>k?l?f/2>=j?"right-bottom":"left-bottom":"bottom":2*g/3>k?l?f/2>=j?"right":"left":g/2>=k?"bottom":"top":l?f/2>=j?"right-top":"left-top":"top":g/3>k?l?"left-bottom":"bottom-left":2*g/3>k?m?g/2>=k?"bottom-left":"top-left":"left":l?"left-top":"top-left":"auto-top"===c?c=f/3>j?"top-right":2*f/3>j?"top":"top-left":"auto-bottom"===c?c=f/3>j?"bottom-right":2*f/3>j?"bottom":"bottom-left":"auto-left"===c?c=g/3>k?"left-top":2*g/3>k?"left":"left-bottom":"auto-right"===c&&(c=g/3>k?"right-top":2*g/3>k?"right":"right-bottom"),c},getElementPosition:function(){return a.extend({},this.$element.offset(),{width:this.$element[0].offsetWidth,height:this.$element[0].offsetHeight})},getTargetPositin:function(a,c,d,e){var f=a,g=b.documentElement,h=b.body,i=g.clientWidth,j=g.clientHeight,k=this.$element.outerWidth(),m=this.$element.outerHeight(),n=Math.max(h.scrollTop,g.scrollTop),o=Math.max(h.scrollLeft,g.scrollLeft),p={},q=null,r=this.options.arrow?20:0,s=10,t=r+s>k?r:0,u=r+s>m?r:0,v=0,w=j+n,x=i+o,y=f.left+f.width/2-t>0,z=f.left+f.width/2+t<x,A=f.top+f.height/2-u>0,B=f.top+f.height/2+u<w;switch(c){case"bottom":p={top:f.top+f.height,left:f.left+f.width/2-d/2};break;case"top":p={top:f.top-e,left:f.left+f.width/2-d/2};break;case"left":p={top:f.top+f.height/2-e/2,left:f.left-d};break;case"right":p={top:f.top+f.height/2-e/2,left:f.left+f.width};break;case"top-right":p={top:f.top-e,left:y?f.left-t:s},q={left:y?Math.min(k,d)/2+t:l};break;case"top-left":v=z?t:-s,p={top:f.top-e,left:f.left-d+f.width+v},q={left:z?d-Math.min(k,d)/2-t:l};break;case"bottom-right":p={top:f.top+f.height,left:y?f.left-t:s},q={left:y?Math.min(k,d)/2+t:l};break;case"bottom-left":v=z?t:-s,p={top:f.top+f.height,left:f.left-d+f.width+v},q={left:z?d-Math.min(k,d)/2-t:l};break;case"right-top":v=B?u:-s,p={top:f.top-e+f.height+v,left:f.left+f.width},q={top:B?e-Math.min(m,e)/2-u:l};break;case"right-bottom":p={top:A?f.top-u:s,left:f.left+f.width},q={top:A?Math.min(m,e)/2+u:l};break;case"left-top":v=B?u:-s,p={top:f.top-e+f.height+v,left:f.left-d},q={top:B?e-Math.min(m,e)/2-u:l};break;case"left-bottom":p={top:A?f.top-u:s,left:f.left-d},q={top:A?Math.min(m,e)/2+u:l}}return p.top+=this.getOffsetTop(),p.left+=this.getOffsetLeft(),{position:p,arrowOffset:q}}},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(),h.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",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=[],i=a('<div class="webui-popover-backdrop"></div>'),j=0,k=!1,l=-2e3,m=a(b),n=function(a,b){return isNaN(a)?b||0:Number(a)},o=function(a){return a.data("plugin_"+d)},p=function(){for(var a=null,b=0;b<h.length;b++)a=o(h[b]),a&&a.hide(!0);m.trigger("hiddenAll."+f)},q="ontouchstart"in b.documentElement&&/Mobi/.test(navigator.userAgent),r=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()||q?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=j,this.options.container=a(this.options.container||b.body).first(),this.options.backdrop&&i.appendTo(this.options.container).hide(),j++,"sticky"===this.getTrigger()&&this.show()},destroy:function(){for(var a=-1,b=0;b<h.length;b++)if(h[b]===this.$element){a=b;break}h.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&&i.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(){p()},show:function(){var a=this.getTarget().removeClass().addClass(e).addClass(this._customTargetClass);this.options.multi||this.hideAll(),this._opened||(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&&i.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,h=c[0].offsetHeight,i="bottom",j=a.Event("show."+f);this.$element.trigger(j,[c]);var k=this.$element.data("width")||this.options.width;""===k&&(k=this._defaults.width),"auto"!==k&&c.width(k);var m=this.$element.data("height")||this.options.height;""===m&&(m=this._defaults.height),"auto"!==m&&d.height(m),this.options.style&&this.$target.addClass(e+"-"+this.options.style),this.options.arrow||c.find(".webui-arrow").remove(),c.detach().css({top:l,left:l,display:"block"}),this.getAnimation()&&c.addClass(this.getAnimation()),c.appendTo(this.options.container),i=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,h=c[0].offsetHeight;var n=this.getTargetPositin(b,i,g,h);if(this.$target.css(n.position).addClass(i).addClass("in"),"iframe"===this.options.type){var o=c.find("iframe"),p=c.width(),q=o.parent().height();""!==this.options.iframeOptions.width&&"auto"!==this.options.iframeOptions.width&&(p=this.options.iframeOptions.width),""!==this.options.iframeOptions.height&&"auto"!==this.options.iframeOptions.height&&(q=this.options.iframeOptions.height),o.width(p).height(q)}if(this.options.arrow||this.$target.css({margin:0}),this.options.arrow){var r=this.$target.find(".webui-arrow");r.removeAttr("style"),"left"===i||"right"===i?r.css({top:this.$target.height()/2}):("top"===i||"bottom"===i)&&r.css({left:this.$target.width()/2}),n.arrowOffset&&(-1===n.arrowOffset.left||-1===n.arrowOffset.top?r.hide():r.css(n.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 n(this.$element.attr("data-offset-top"))||this.options.offsetTop},getOffsetLeft:function(){return n(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?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(){k||(this.options.dismissible&&"click"===this.getTrigger()?(m.off("keyup.webui-popover").on("keyup.webui-popover",a.proxy(this.escapeHandler,this)),m.off("click.webui-popover touchend.webui-popover").on("click.webui-popover touchend.webui-popover",a.proxy(this.bodyClickHandler,this))):"hover"===this.getTrigger()&&m.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){k=!0;for(var b=!0,c=0;c<h.length;c++){var d=o(h[c]);if(d&&d._opened){var e=d.getTarget().offset().left,f=d.getTarget().offset().top,g=d.getTarget().offset().left+d.getTarget().width(),i=d.getTarget().offset().top+d.getTarget().height(),j=r(a),l=j.x>=e&&j.x<=g&&j.y>=f&&j.y<=i;if(l){b=!1;break}}}b&&p()},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(){return a.extend({},this.$element.offset(),{width:this.$element[0].offsetWidth,height:this.$element[0].offsetHeight})},getTargetPositin:function(a,b,c,d){var e=a,f=this.options.container,g=f.innerWidth(),h=f.innerHeight(),i=this.$element.outerWidth(),j=this.$element.outerHeight(),k=f.scrollTop(),m=f.scrollLeft(),n={},o=null,p=this.options.arrow?20:0,q=10,r=p+q>i?p:0,s=p+q>j?p:0,t=0,u=h+k,v=g+m,w=e.left+e.width/2-r>0,x=e.left+e.width/2+r<v,y=e.top+e.height/2-s>0,z=e.top+e.height/2+s<u;switch(b){case"bottom":n={top:e.top+e.height,left:e.left+e.width/2-c/2};break;case"top":n={top:e.top-d,left:e.left+e.width/2-c/2};break;case"left":n={top:e.top+e.height/2-d/2,left:e.left-c};break;case"right":n={top:e.top+e.height/2-d/2,left:e.left+e.width};break;case"top-right":n={top:e.top-d,left:w?e.left-r:q},o={left:w?Math.min(i,c)/2+r:l};break;case"top-left":t=x?r:-q,n={top:e.top-d,left:e.left-c+e.width+t},o={left:x?c-Math.min(i,c)/2-r:l};break;case"bottom-right":n={top:e.top+e.height,left:w?e.left-r:q},o={left:w?Math.min(i,c)/2+r:l};break;case"bottom-left":t=x?r:-q,n={top:e.top+e.height,left:e.left-c+e.width+t},o={left:x?c-Math.min(i,c)/2-r:l};break;case"right-top":t=z?s:-q,n={top:e.top-d+e.height+t,left:e.left+e.width},o={top:z?d-Math.min(j,d)/2-s:l};break;case"right-bottom":n={top:y?e.top-s:q,left:e.left+e.width},o={top:y?Math.min(j,d)/2+s:l};break;case"left-top":t=z?s:-q,n={top:e.top-d+e.height+t,left:e.left-c},o={top:z?d-Math.min(j,d)/2-s:l};break;case"left-bottom":n={top:y?e.top-s:q,left:e.left-c},o={top:y?Math.min(j,d)/2+s:l}}return n.top+=this.getOffsetTop(),n.left+=this.getOffsetLeft(),{position:n,arrowOffset:o}}},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);

@@ -7,4 +7,4 @@ {

"homepage": "https://github.com/sandywalker/webui-popover",
"version": "1.2.6",
"license":"MIT",
"version": "1.2.7",
"license": "MIT",
"devDependencies": {

@@ -31,3 +31,2 @@ "grunt": "~0.4.1",

],
"license": "MIT",
"scripts": {

@@ -34,0 +33,0 @@ "test": "grunt travis --verbose"

@@ -23,3 +23,3 @@ WebUI-Popover

* different animations
* support backdrop
* support backdrop

@@ -53,3 +53,3 @@

```
Or CDN
Or CDN

@@ -136,3 +136,3 @@ ```html

Animate the Popover
Animate the Popover
```javascript

@@ -150,3 +150,3 @@ $('a').webuiPopover({title:'Title',content:'Content',animation:'pop'});

```javascript
$('a').webuiPopover({
$('a').webuiPopover({
type:'async',

@@ -159,3 +159,3 @@ url:'https://api.github.com/',

return html;
}
}
});

@@ -174,6 +174,6 @@ ```

```javascript
//Initailize
//Initailize
$('a').webuiPopover({trigger:'manual'});
...
//Show it

@@ -193,2 +193,3 @@ $('a').webuiPopover('show');

placement:'auto',//values: auto,top,right,bottom,left,top-right,top-left,bottom-right,bottom-left,auto-top,auto-right,auto-bottom,auto-left,horizontal,vertical
container: document.body,// The container in which the popover will be added (i.e. The parent scrolling area). May be a jquery object, a selector string or a HTML element. See https://jsfiddle.net/1x21rj9e/1/
width:'auto',//can be set with number

@@ -229,6 +230,1 @@ height:'auto',//can be set with number

Welcome to visit my github page: [http://sandywalker.github.io/]

@@ -21,2 +21,3 @@ (function(window, document, undefined) {

placement: 'auto',
container: null,
width: 'auto',

@@ -164,4 +165,7 @@ height: 'auto',

this._idSeed = _globalIdSeed;
// normalize container
this.options.container = $(this.options.container || document.body).first();
if (this.options.backdrop) {
backdrop.appendTo(document.body).hide();
backdrop.appendTo(this.options.container).hide();
}

@@ -276,3 +280,2 @@ _globalIdSeed++;

}
// use cache by default, if not cache setted , reInit the contents

@@ -360,3 +363,3 @@ if (!this.getCache() || !this._poped || this.content === '') {

}
$target.appendTo(document.body);
$target.appendTo(this.options.container);

@@ -424,3 +427,3 @@

if (postionInfo.arrowOffset) {
//hide the arrow if offset is negative
//hide the arrow if offset is negative
if (postionInfo.arrowOffset.left === -1 || postionInfo.arrowOffset.top === -1) {

@@ -586,3 +589,3 @@ $arrow.hide();

$ct.html('');
//Don't want to clone too many times.
//Don't want to clone too many times.
if (!this.options.cache) {

@@ -724,8 +727,7 @@ content.clone(true, true).removeClass(pluginClass + '-content').appendTo($ct);

placement,
de = document.documentElement,
db = document.body,
clientWidth = de.clientWidth,
clientHeight = de.clientHeight,
scrollTop = Math.max(db.scrollTop, de.scrollTop),
scrollLeft = Math.max(db.scrollLeft, de.scrollLeft),
container = this.options.container,
clientWidth = container.innerWidth(),
clientHeight = container.innerHeight(),
scrollTop = container.scrollTop(),
scrollLeft = container.scrollLeft(),
pageX = Math.max(0, pos.left - scrollLeft),

@@ -838,10 +840,9 @@ pageY = Math.max(0, pos.top - scrollTop);

var pos = elementPos,
de = document.documentElement,
db = document.body,
clientWidth = de.clientWidth,
clientHeight = de.clientHeight,
container = this.options.container,
clientWidth = container.innerWidth(),
clientHeight = container.innerHeight(),
elementW = this.$element.outerWidth(),
elementH = this.$element.outerHeight(),
scrollTop = Math.max(db.scrollTop, de.scrollTop),
scrollLeft = Math.max(db.scrollLeft, de.scrollLeft),
scrollTop = container.scrollTop(),
scrollLeft = container.scrollLeft(),
position = {},

@@ -848,0 +849,0 @@ arrowOffset = null,

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