2018-08-16 19:04:42 +08:00
|
|
|
(function() {
|
|
|
|
'use strict';
|
|
|
|
|
2018-08-21 17:11:25 +08:00
|
|
|
$.init_popover_v2 = function() {
|
|
|
|
if ($(document.body).data("popover_v2_enabled")===true || $(document.body).data("popover_v2_enabled")== null ){
|
2018-08-20 19:03:30 +08:00
|
|
|
var popovers_array = [];
|
2018-08-21 17:11:25 +08:00
|
|
|
$('.popover_open').remove() // Destroy all (if any) old open popovers
|
2018-08-20 19:03:30 +08:00
|
|
|
$('.popover_v2').each(function(i,obj) {
|
|
|
|
var popover_object = obj;
|
|
|
|
popovers_array.push(popover_object);
|
|
|
|
});
|
2018-08-17 17:52:10 +08:00
|
|
|
$('.popover_v2').each(function(i,obj) {
|
2018-08-17 22:03:49 +08:00
|
|
|
var link = $(obj).data('popoverlink')
|
2018-08-20 19:03:30 +08:00
|
|
|
var text_data = $(obj).data('popovercontent')
|
|
|
|
|
2018-08-17 17:52:10 +08:00
|
|
|
$(obj).popover({
|
|
|
|
html: true,
|
|
|
|
container: 'body',
|
|
|
|
placement: 'auto right',
|
|
|
|
trigger: 'manual',
|
2018-08-20 19:45:43 +08:00
|
|
|
content: 'popovers will not display if empty',
|
2018-08-21 17:11:25 +08:00
|
|
|
template: '<div class="popover popover_'+i+'_window popover_open" role="tooltip" style="background-color:#F0F0F0;font-family:Lato;font-size:14px;" color="#000000" >' +
|
2018-08-20 19:03:30 +08:00
|
|
|
'<div class="popover-body" >' + text_data + '</div>' +
|
|
|
|
'<br><br><br>' +
|
|
|
|
'<div class="popover-footer" style="position:absolute;bottom:5px;right:5px;background-color:#E8E8E8;border-radius: 3px;">' +
|
|
|
|
'<a style="color:grey;" class="btn btn-link text-nowrap" href="'+link+'" target="_blank" rel="noopener noreferrer" ">' +
|
|
|
|
'Read more <i class="fas fa-external-link-alt"></i>' +
|
|
|
|
'</a>' +
|
|
|
|
'</div>' +
|
|
|
|
'</div>'
|
2018-08-17 17:52:10 +08:00
|
|
|
}).on("mouseenter", function () {
|
|
|
|
setTimeout(function () {
|
|
|
|
if ($(obj).hover().length) {
|
|
|
|
$(obj).popover("show")
|
|
|
|
var top = $(obj).offset().top;
|
|
|
|
$('.popover_'+i+'_window').css({
|
|
|
|
top: (top) + 'px'
|
|
|
|
});
|
|
|
|
$(".popover_"+i+"_window").on("mouseleave", function () {
|
2018-08-20 19:03:30 +08:00
|
|
|
$(obj).popover('hide');
|
2018-08-17 17:52:10 +08:00
|
|
|
$(".popover_"+i+"_window").css("background-color","#F0F0F0");
|
|
|
|
});
|
|
|
|
$(".popover_"+i+"_window").on("mouseenter", function () {
|
2018-08-20 19:03:30 +08:00
|
|
|
$(".popover_"+i+"_window").css("background-color","#DADADA");
|
2018-08-17 17:52:10 +08:00
|
|
|
});
|
2018-08-20 19:45:43 +08:00
|
|
|
|
2018-08-16 22:10:19 +08:00
|
|
|
}
|
2018-08-17 17:52:10 +08:00
|
|
|
}, 1000);
|
|
|
|
}).on("mouseleave", function () {
|
|
|
|
setTimeout(function () {
|
|
|
|
if (!$(".popover_"+i+"_window:hover").length) {
|
|
|
|
$(obj).popover("hide")
|
|
|
|
}
|
2018-08-21 17:11:25 +08:00
|
|
|
}, 300);
|
2018-08-20 19:03:30 +08:00
|
|
|
}).on("shown.bs.popover", function(){
|
2018-08-17 22:03:49 +08:00
|
|
|
// hide all other popovers
|
2018-08-20 19:03:30 +08:00
|
|
|
popovers_array.forEach(function (arrayItem) {
|
|
|
|
if(obj !== arrayItem){
|
|
|
|
$(arrayItem).popover("hide")
|
|
|
|
}
|
|
|
|
});
|
2018-08-17 17:52:10 +08:00
|
|
|
});
|
|
|
|
})
|
2018-08-21 17:11:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$(document).ready(function() {
|
|
|
|
$.init_popover_v2();
|
2018-08-16 19:04:42 +08:00
|
|
|
});
|
2018-08-21 17:11:25 +08:00
|
|
|
|
2018-08-16 19:04:42 +08:00
|
|
|
}());
|
2018-08-17 17:52:10 +08:00
|
|
|
|
|
|
|
/* copy and paste shortcut
|
2018-08-17 22:03:49 +08:00
|
|
|
<button class="btn btn-default popover_v2" data-popoverlink="<%= I18n.t('popover_test.link.') %>" data-popovercontent="<%= I18n.t('popover_test.text.') %>">
|
2018-08-17 17:52:10 +08:00
|
|
|
*/
|