Skip to content

- add css width 99% to .webui-popover-content > div:first-child to pr… #184

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 25, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions dist/jquery.webui-popover.css
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
/*
* webui popover plugin - v1.2.12
* 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!
* https://github.com/sandywalker/webui-popover
*
* Made by Sandy Duan
* Under MIT License
*/
.webui-popover-content {
display: none;
}
Expand Down Expand Up @@ -97,6 +89,9 @@
overflow: auto;
display: block;
}
.webui-popover .webui-popover-content > div:first-child {
width: 99%;
}
.webui-popover-inner .close {
font-family: arial;
margin: 8px 10px 0 0;
Expand Down
49 changes: 30 additions & 19 deletions dist/jquery.webui-popover.js
Original file line number Diff line number Diff line change
Expand Up @@ -412,10 +412,21 @@
targetWidth = $target[0].offsetWidth;
targetHeight = $target[0].offsetHeight;

var postionInfo = this.getTargetPositin(elementPos, placement, targetWidth, targetHeight);

var postionInfo = this.getTargetPosition(elementPos, placement, targetWidth, targetHeight);
this.$target.css(postionInfo.position).addClass(placement).addClass('in');

// fix popover if element is fixed
if(this.$element.css('position') === 'fixed') {
this.$target.css('position', 'fixed');
}

var that = this;
$(window).resize(function () {
elementPos = that.getElementPosition();
postionInfo = that.getTargetPosition(elementPos, placement, targetWidth, targetHeight);
that.$target.css(postionInfo.position).addClass(placement);
});

if (this.options.type === 'iframe') {
var $iframe = $target.find('iframe');
var iframeWidth = $target.width();
Expand Down Expand Up @@ -885,7 +896,7 @@
}
},

getTargetPositin: function(elementPos, placement, targetWidth, targetHeight) {
getTargetPosition: function(elementPos, placement, targetWidth, targetHeight) {
var pos = elementPos,
container = this.options.container,
//clientWidth = container.innerWidth(),
Expand All @@ -912,31 +923,31 @@
switch (placement) {
case 'bottom':
position = {
top: pos.top + pos.height,
left: pos.left + pos.width / 2 - targetWidth / 2
top: pos.top + pos.height - scrollTop,
left: pos.left + pos.width / 2 - targetWidth / 2 > 20 ? pos.left + pos.width / 2 - targetWidth / 2 : 20
};
break;
case 'top':
position = {
top: pos.top - targetHeight,
left: pos.left + pos.width / 2 - targetWidth / 2
top: pos.top - targetHeight - scrollTop,
left: pos.left + pos.width / 2 - targetWidth / 2 > 20 ? pos.left + pos.width / 2 - targetWidth / 2 : 20
};
break;
case 'left':
position = {
top: pos.top + pos.height / 2 - targetHeight / 2,
left: pos.left - targetWidth
top: pos.top + pos.height / 2 - targetHeight / 2 - scrollTop,
left: pos.left - targetWidth > 20 ? pos.left - targetWidth : 20
};
break;
case 'right':
position = {
top: pos.top + pos.height / 2 - targetHeight / 2,
left: pos.left + pos.width
top: pos.top + pos.height / 2 - targetHeight / 2 - scrollTop,
left: pos.left + pos.width > 20 ? pos.left + pos.width : 20
};
break;
case 'top-right':
position = {
top: pos.top - targetHeight,
top: pos.top - targetHeight - scrollTop,
left: validLeft ? pos.left - fixedW : padding
};
arrowOffset = {
Expand All @@ -946,7 +957,7 @@
case 'top-left':
refix = validRight ? fixedW : -padding;
position = {
top: pos.top - targetHeight,
top: pos.top - targetHeight - scrollTop,
left: pos.left - targetWidth + pos.width + refix
};
arrowOffset = {
Expand All @@ -955,7 +966,7 @@
break;
case 'bottom-right':
position = {
top: pos.top + pos.height,
top: pos.top + pos.height - scrollTop,
left: validLeft ? pos.left - fixedW : padding
};
arrowOffset = {
Expand All @@ -965,7 +976,7 @@
case 'bottom-left':
refix = validRight ? fixedW : -padding;
position = {
top: pos.top + pos.height,
top: pos.top + pos.height - scrollTop,
left: pos.left - targetWidth + pos.width + refix
};
arrowOffset = {
Expand All @@ -975,7 +986,7 @@
case 'right-top':
refix = validBottom ? fixedH : -padding;
position = {
top: pos.top - targetHeight + pos.height + refix,
top: pos.top - targetHeight + pos.height + refix - scrollTop,
left: pos.left + pos.width
};
arrowOffset = {
Expand All @@ -984,7 +995,7 @@
break;
case 'right-bottom':
position = {
top: validTop ? pos.top - fixedH : padding,
top: validTop ? pos.top - fixedH - scrollTop : padding - scrollTop,
left: pos.left + pos.width
};
arrowOffset = {
Expand All @@ -994,7 +1005,7 @@
case 'left-top':
refix = validBottom ? fixedH : -padding;
position = {
top: pos.top - targetHeight + pos.height + refix,
top: pos.top - targetHeight + pos.height + refix - scrollTop,
left: pos.left - targetWidth
};
arrowOffset = {
Expand All @@ -1003,7 +1014,7 @@
break;
case 'left-bottom':
position = {
top: validTop ? pos.top - fixedH : padding,
top: validTop ? pos.top - fixedH - scrollTop : padding - scrollTop,
left: pos.left - targetWidth
};
arrowOffset = {
Expand Down
Loading