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.7 to 1.2.8

demo/test-auto-bottom.html

2

bower.json
{
"name": "webui-popover",
"version": "1.2.6",
"version": "1.2.8",
"authors": [

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

/*
* webui popover plugin - v1.2.6
* webui popover plugin - v1.2.8
* 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!

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

type: 'html',
direction: '', // ltr,rtl
animation: null,

@@ -83,3 +84,3 @@ template: '<div class="webui-popover">' +

var rtlClass = pluginClass + '-rtl';
var _srcElements = [];

@@ -288,3 +289,3 @@ var backdrop = $('<div class="webui-popover-backdrop"></div>');

}
// use cache by default, if not cache setted , reInit the contents
// use cache by default, if not cache setted , reInit the contents
if (!this.getCache() || !this._poped || this.content === '') {

@@ -358,2 +359,7 @@ this.content = '';

//check rtl
if (this.options.direction === 'rtl' && !$targetContent.hasClass(rtlClass)) {
$targetContent.addClass(rtlClass);
}
//init the popover and insert into the document body

@@ -535,2 +541,6 @@ if (!this.options.arrow) {

if (title) {
//check rtl
if (this.options.direction === 'rtl' && !$titleEl.hasClass(rtlClass)) {
$titleEl.addClass(rtlClass);
}
$titleEl.html(title);

@@ -838,6 +848,14 @@ } else {

getElementPosition: function() {
return $.extend({}, this.$element.offset(), {
width: this.$element[0].offsetWidth,
height: this.$element[0].offsetHeight
});
// If the container is the body, cancels the margin.
var containerRect = (this.options.container.is(document.body)) ? {
top: 0,
left: 0
} : 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
};
},

@@ -848,4 +866,4 @@

container = this.options.container,
clientWidth = container.innerWidth(),
clientHeight = container.innerHeight(),
//clientWidth = container.innerWidth(),
//clientHeight = container.innerHeight(),
elementW = this.$element.outerWidth(),

@@ -862,7 +880,5 @@ elementH = this.$element.outerHeight(),

refix = 0,
pageH = clientHeight + scrollTop,
pageW = clientWidth + scrollLeft;
pageH = document.documentElement.clientHeight + scrollTop,
pageW = document.documentElement.clientWidth + scrollLeft;
var validLeft = pos.left + pos.width / 2 - fixedW > 0;

@@ -869,0 +885,0 @@ var validRight = pos.left + pos.width / 2 + fixedW < pageW;

/*
* webui popover plugin - v1.2.6
* webui popover plugin - v1.2.8
* 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(),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);
!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(){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&&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 a=this.options.container.is(b.body)?{top:0,left:0}:this.options.container[0].getBoundingClientRect(),c=this.$element[0].getBoundingClientRect();return{top:c.top-a.top+this.options.container.scrollTop(),left:c.left-a.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,12 @@

### 1.2.8
* fix and optimize the scroll placement bug
* add rtl direction support
* fix arrow hide bug when placement is set to auto or auto-buttom
* fix the LESS variable collision
### 1.2.7
* fix the scroll placement bug
### 1.2.6

@@ -18,6 +28,6 @@ * fix the hidden bug on mobile device when trigger is set to 'hover'

* fix the bug which cause the popover hide by click when multi popovers in same page.
* optimize event handling for performance
* optimize event handling for performance
### 1.2.2
*
*
* optimize code and clean debug info

@@ -38,2 +48,1 @@

* update the demo page adapt for mobile device.

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

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

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

WebUI-Popover
=============
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!
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!

@@ -206,8 +206,9 @@

arrow:true,//show arrow or not
title:'',//the popover title ,if title is set to empty string,title bar will auto hide
title:'',//the popover title, if title is set to empty string,title bar will auto hide
content:'',//content of the popover,content can be function
closeable:false,//display close button or not
direction:'', // direction of the popover content default is ltr ,values:'rtl';
padding:true,//content padding
type:'html',//content type, values:'html','iframe','async'
url:'',//if type equals 'html' , value should be jQuery selecor. if type equels 'async' the plugin will load content by url.
url:'',//if type equals 'html', value should be jQuery selecor. if type equels 'async' the plugin will load content by url.
backdrop:false,//if backdrop is set to true, popover will use backdrop on open

@@ -214,0 +215,0 @@ dismissible:true, // if popover can be dismissed by outside click or escape key

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

type: 'html',
direction: '', // ltr,rtl
animation: null,

@@ -75,3 +76,3 @@ template: '<div class="webui-popover">' +

var rtlClass = pluginClass + '-rtl';
var _srcElements = [];

@@ -280,3 +281,3 @@ var backdrop = $('<div class="webui-popover-backdrop"></div>');

}
// use cache by default, if not cache setted , reInit the contents
// use cache by default, if not cache setted , reInit the contents
if (!this.getCache() || !this._poped || this.content === '') {

@@ -350,2 +351,7 @@ this.content = '';

//check rtl
if (this.options.direction === 'rtl' && !$targetContent.hasClass(rtlClass)) {
$targetContent.addClass(rtlClass);
}
//init the popover and insert into the document body

@@ -527,2 +533,6 @@ if (!this.options.arrow) {

if (title) {
//check rtl
if (this.options.direction === 'rtl' && !$titleEl.hasClass(rtlClass)) {
$titleEl.addClass(rtlClass);
}
$titleEl.html(title);

@@ -830,6 +840,14 @@ } else {

getElementPosition: function() {
return $.extend({}, this.$element.offset(), {
width: this.$element[0].offsetWidth,
height: this.$element[0].offsetHeight
});
// If the container is the body, cancels the margin.
var containerRect = (this.options.container.is(document.body)) ? {
top: 0,
left: 0
} : 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
};
},

@@ -840,4 +858,4 @@

container = this.options.container,
clientWidth = container.innerWidth(),
clientHeight = container.innerHeight(),
//clientWidth = container.innerWidth(),
//clientHeight = container.innerHeight(),
elementW = this.$element.outerWidth(),

@@ -854,7 +872,5 @@ elementH = this.$element.outerHeight(),

refix = 0,
pageH = clientHeight + scrollTop,
pageW = clientWidth + scrollLeft;
pageH = document.documentElement.clientHeight + scrollTop,
pageW = document.documentElement.clientWidth + scrollLeft;
var validLeft = pos.left + pos.width / 2 - fixedW > 0;

@@ -861,0 +877,0 @@ var validRight = pos.left + pos.width / 2 + fixedW < pageW;

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

],
"version":"1.2.6",
"version":"1.2.8",
"author": {

@@ -30,4 +30,4 @@ "name": "Sandy Duan",

"dependencies": {
"jquery": ">=1.6.0"
"jquery": ">=1.6.0"
}
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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