mirror of
https://github.com/processwire/processwire.git
synced 2025-08-13 10:15:28 +02:00
Some updates to touch support per issue #84, plus a few other minor things that got bundled in
This commit is contained in:
@@ -274,15 +274,35 @@ var ProcessWireAdmin = {
|
||||
|
||||
}
|
||||
|
||||
function touchClick() {
|
||||
var touchCnt = $(this).attr('data-touchCnt');
|
||||
var $lastTouchClickItem = null;
|
||||
|
||||
function touchClick(e) {
|
||||
var $item = $(this);
|
||||
var touchCnt = $item.attr('data-touchCnt');
|
||||
if($lastTouchClickItem && $item.attr('id') != $lastTouchClickItem.attr('id')) {
|
||||
$lastTouchClickItem.attr('data-touchCnt', 0);
|
||||
}
|
||||
$lastTouchClickItem = $item;
|
||||
if(!touchCnt) touchCnt = 0;
|
||||
touchCnt++;
|
||||
$(this).attr('data-touchCnt', touchCnt);
|
||||
if(touchCnt == 2) {
|
||||
$(this).mouseleave();
|
||||
$item.attr('data-touchCnt', touchCnt);
|
||||
|
||||
if(touchCnt == 2 || ($item.hasClass('pw-has-ajax-items') && !$item.closest('ul').hasClass('topnav'))) {
|
||||
var href = $item.attr('href');
|
||||
$item.attr('data-touchCnt', 0);
|
||||
if(typeof href != "undefined" && href.length > 1) {
|
||||
return true;
|
||||
} else {
|
||||
$item.mouseleave();
|
||||
}
|
||||
} else {
|
||||
$(this).mouseenter();
|
||||
var datafrom = $item.attr('data-from');
|
||||
if(typeof datafrom == "undefined") var datafrom = '';
|
||||
if(datafrom.indexOf('topnav') > -1) {
|
||||
var from = datafrom.replace('topnav-', '') + '-';
|
||||
$("a.pw-dropdown-toggle.hover:not('." + from + "')").attr('data-touchCnt', 0).mouseleave();
|
||||
}
|
||||
$item.mouseenter();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -290,7 +310,7 @@ var ProcessWireAdmin = {
|
||||
function init() {
|
||||
|
||||
if($("body").hasClass('touch-device')) {
|
||||
$('#topnav').on("click", "a.pw-dropdown-toggle, a.pw-has-items", touchClick);
|
||||
$(document).on("touchstart", "a.pw-dropdown-toggle, a.pw-has-items", touchClick);
|
||||
}
|
||||
|
||||
$(".pw-dropdown-menu").on("click", "a:not(.pw-modal)", function(e) {
|
||||
|
2
wire/templates-admin/scripts/main.min.js
vendored
2
wire/templates-admin/scripts/main.min.js
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user