*/
_popover: null,
+ /**
+ * popover content
+ * @var jQuery
+ */
+ _popoverContent: null,
+
+
/**
* popover horizontal offset
* @var integer
this._popoverOffset = 10;
this._selector = selector;
- this._popover = $('<div class="popover" />').hide().appendTo(document.body);
+ this._popover = $('<div class="popover"><div class="popoverContent"></div></div>').hide().appendTo(document.body);
+ this._popoverContent = this._popover.children('.popoverContent:eq(0)');
this._popover.hover($.proxy(this._overPopover, this), $.proxy(this._out, this));
this._initContainers();
// hide and reset
if (this._popover.is(':visible')) {
- this._hide();
+ this._hide(true);
}
// insert html
if (!this._data[this._activeElementID].loading && this._data[this._activeElementID].content) {
- this._popover.html(this._data[this._activeElementID].content);
+ this._popoverContent.html(this._data[this._activeElementID].content);
}
else {
- this._popover.addClass('popoverLoading');
this._data[this._activeElementID].loading = true;
}
if (this._data[this._activeElementID].loading) {
this._loadContent();
}
+ else {
+ this._popoverContent.css({ opacity: 1 });
+ }
},
/**
if (this._activeElementID === elementID) {
if (animate) {
// get current dimensions
- var $dimensions = this._popover.getDimensions();
+ var $dimensions = this._popoverContent.getDimensions();
// insert new content
- this._popover.html(this._data[elementID].content);
- var $newDimensions = this._popover.getDimensions();
+ this._popoverContent.html(this._data[elementID].content);
+ var $newDimensions = this._popoverContent.getDimensions();
// enforce current dimensions and remove HTML
- this._popover.html('').css({
+ this._popoverContent.html('').css({
height: $dimensions.height + 'px',
width: $dimensions.width + 'px'
});
// animate to new dimensons
- this._popover.animate({
+ var self = this;
+ this._popoverContent.animate({
height: $newDimensions.height + 'px',
width: $newDimensions.width + 'px'
}, 300, function() {
- var $content = $('<div style="opacity: 0;">' + content + '</div>');
- var $this = $(this);
-
- $this.html($content);
-
- $content.animate({ opacity: 1 }, 200, function() {
- $content.children().unwrap();
- $this.removeClass('popoverLoading');
- });
+ self._popoverContent.html(self._data[elementID].content).css({ opacity: 0 }).animate({ opacity: 1 }, 200);
});
}
else {
// insert new content
- this._popover.html(this._data[elementID].content);
+ this._popoverContent.html(this._data[elementID].content);
}
}
},
/**
* Hides the popover.
*/
- _hide: function() {
- this._popover.stop().removeClass('popoverLoading').wcfFadeOut(function() {
- $(this).empty().css({ height: 'auto', width: 'auto' });
- });
+ _hide: function(disableAnimation) {
+ var self = this;
+ this._popoverContent.stop();
+ this._popover.stop();
+
+ if (disableAnimation) {
+ self._popoverContent.empty().css({ height: 'auto', opacity: 0, width: 'auto' });
+ }
+ else {
+ this._popover.wcfFadeOut(function() {
+ self._popoverContent.empty().css({ height: 'auto', opacity: 0, width: 'auto' });
+ });
+ }
},
/**
// hide popover is neither element nor popover was hovered given time
if (!this._hoverElement && !this._hoverPopover) {
- this._hide();
+ this._hide(false);
}
}, this), this._delay.hide);
},
.popover {
- background-color: @wcfTooltipBackgroundColor;
+ background-color: rgba(0, 0, 0, .4);
+ background-image: url(../icon/spinner1.svg);
+ background-position: center center;
+ background-repeat: no-repeat;
+ background-size: 32px;
color: @wcfTooltipColor;
max-width: 450px;
+ min-height: 32px;
min-width: 150px;
- padding: @wcfGapTiny;
+ padding: @wcfGapSmall;
position: absolute;
vertical-align: middle;
z-index: 320;
&.top:after {
border-bottom-width: 0;
- border-top-color: @wcfTooltipBackgroundColor;
+ border-top-color: rgba(0, 0, 0, .2);
bottom: -7px;
}
&.bottom:after {
- border-bottom-color: @wcfTooltipBackgroundColor;
+ border-bottom-color: rgba(0, 0, 0, .2);
border-top-width: 0;
top: -7px;
}
&.left:after {
right: 7px;
}
+}
+
+.popoverContent {
+ background-color: @wcfContainerBackgroundColor;
+ color: @wcfColor;
+ opacity: 0;
+ padding: @wcfGapSmall;
- &.popoverLoading {
- background-image: url(../icon/spinner1.svg);
- background-position: center center;
- background-size: 32px;
- background-repeat: no-repeat;
- min-height: 32px;
- }
+ .borderRadius();
}
\ No newline at end of file