-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_bootstrap-popover-extensions.js
More file actions
72 lines (56 loc) · 2.48 KB
/
_bootstrap-popover-extensions.js
File metadata and controls
72 lines (56 loc) · 2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/****************************************************************************
bootstrap-popover-extensions.js,
(c) 2017, FCOO
https://github.com/FCOO/bootstrap-popover-extensions
https://github.com/FCOO
****************************************************************************/
(function ($, bootstrap/*, window, document, undefined*/) {
"use strict";
//MANGLER: Er det nødvendigt med nedenstående???
//Concert from all new placement to original
var truePlacement2placement = {
topleft : 'top', top : 'top', topright : 'top',
bottomleft: 'bottom', bottom: 'bottom', bottomright: 'bottom',
lefttop : 'left', left : 'left', leftbottom : 'left',
righttop : 'right', right : 'right', rightbottom: 'right'
};
//****************************************************
//Overwrite Popover.show to save and modify new positions
//*****************************************************
bootstrap.Tooltip.prototype.show = function( _show ){
return function(){
//If first time: Save 'true' placement
if (!this._config.truePlacement){
this._config.truePlacement = this._config.placement;
this._config.placement = truePlacement2placement[this._config.truePlacement];
}
//Original methods
_show.apply(this, arguments);
//Adjust popover
var $tip = $(this.tip),
arrowDim = $tip.find('.arrow').width() || 10,
arrowOffset = 6 + arrowDim,
offset = 0,
sign = 0;
switch (this._config.truePlacement){
case 'topright' :
case 'rightbottom':
case 'bottomright':
case 'leftbottom' : sign = +1; break;
case 'topleft' :
case 'righttop' :
case 'bottomleft' :
case 'lefttop' : sign = -1; break;
default : sign = 0;
}
switch (sign) {
case +1: offset = '+50%p - ' + arrowOffset + 'px'; break;
case -1: offset = '-50%p + ' + arrowOffset + 'px'; break;
default: offset = 0;
}
// VIRKER IKKE:
if (this._popper)
this._popper.modifiers[1].offset = offset;
};
}( bootstrap.Tooltip.prototype.show );
}(jQuery, this.bootstrap, this, document));