1
1
Fork 0

Merge pull request #2538 from rabuzarus/2805_frio_mobile

frio: open hovercard on click if device is a mobile device
This commit is contained in:
Michael Vogel 2016-05-28 13:49:05 +02:00
commit db99ce9512
2 changed files with 24 additions and 5 deletions

View file

@ -47,6 +47,14 @@ $(document).ready(function(){
var title = targetElement.attr("title"); var title = targetElement.attr("title");
targetElement.attr({"data-orig-title": title, title: ""}); targetElement.attr({"data-orig-title": title, title: ""});
// if the device is a mobile open the hover card by click and not by hover
if(typeof is_mobile != "undefined") {
targetElement[0].removeAttribute("href");
var hctrigger = 'click';
} else {
var hctrigger = 'manual';
};
// Timeoute until the hover-card does appear // Timeoute until the hover-card does appear
setTimeout(function(){ setTimeout(function(){
if(targetElement.is(":hover") && parseInt(targetElement.attr('data-awaiting-hover-card'),10) == timeNow) { if(targetElement.is(":hover") && parseInt(targetElement.attr('data-awaiting-hover-card'),10) == timeNow) {
@ -69,7 +77,7 @@ $(document).ready(function(){
} }
return "top"; return "top";
}, },
trigger: 'manual', trigger: hctrigger,
template: '<div class="popover hovercard" data-card-created="' + timeNow + '"><div class="arrow"></div><div class="popover-content hovercard-content"></div></div>', template: '<div class="popover hovercard" data-card-created="' + timeNow + '"><div class="arrow"></div><div class="popover-content hovercard-content"></div></div>',
content: data content: data
}).popover('show'); }).popover('show');
@ -90,8 +98,12 @@ $(document).ready(function(){
// hover cards should be removed very easily, e.g. when any of these events happen // hover cards should be removed very easily, e.g. when any of these events happen
$('body').on("mouseleave touchstart scroll click dblclick mousedown mouseup submit keydown keypress keyup", function(e){ $('body').on("mouseleave touchstart scroll click dblclick mousedown mouseup submit keydown keypress keyup", function(e){
var timeNow = new Date().getTime(); // remove hover card only for desktiop user, since on mobile we openen the hovercards
removeAllhoverCards(e,timeNow); // by click event insteadof hover
if(typeof is_mobile == "undefined") {
var timeNow = new Date().getTime();
removeAllhoverCards(e,timeNow);
};
}); });
// if we're hovering a hover card, give it a class, so we don't remove it // if we're hovering a hover card, give it a class, so we don't remove it

View file

@ -21,9 +21,16 @@ function frio_init(&$a) {
$frio = "view/theme/frio"; $frio = "view/theme/frio";
global $frio; global $frio;
// if the device is a mobile device set js is_mobile
// variable so the js scripts can use this information
if($a->is_mobile || $a->is_tablet) {
$a->page["htmlhead"] .= <<< EOT
<script>
var is_mobile = 1;
</script>
EOT;
}
if ($style == "") if ($style == "")
$style = get_config('frio', 'style'); $style = get_config('frio', 'style');