Make dropdown menu's hidden by clicking away & cursor pointer for rstables
svn path=/Website/trunk/; revision=31453
This commit is contained in:
@@ -16,7 +16,8 @@
|
||||
// Formulier als tekststring samenstellen en m.b.v. $(document).ready(function(){}) binnen de body zetten
|
||||
var timerID=null;
|
||||
var showingInlineDetails = false;
|
||||
var touch = null;
|
||||
var hasHamburger = null;
|
||||
// var useHamb = S("inline_actions_hamburger");
|
||||
var currentRowKey = null;
|
||||
|
||||
function delayed(delay, fn)
|
||||
@@ -150,31 +151,45 @@ function loadInlineDetails(url)
|
||||
}
|
||||
|
||||
// forTouch doen we geen mouseover's. Die maken dat je veel te veel moet klikken
|
||||
function initActions(tableID, isTouch)
|
||||
function initActions(tableID, useHamb)
|
||||
{
|
||||
$(function () {
|
||||
$("#" + tableID)
|
||||
.on('click', 'tr', defaultAction)
|
||||
.on('click', '.multiselect', FcltMgr.stopPropagation );
|
||||
if (!isTouch)
|
||||
.on('click', '.multiselect', FcltMgr.stopPropagation);
|
||||
if (useHamb)
|
||||
{
|
||||
$(document).add(parent.document).add(parent.parent.document).click(defaultHamburgerAction);
|
||||
$("#" + tableID)
|
||||
.on('click', 'tr', defaultHamburgerAction)
|
||||
.on('click', '.hamburger', showHamburgerActions)
|
||||
.on('click', '.hamburger', FcltMgr.stopPropagation)
|
||||
.on('mouseover', 'tr', hambSetCursor);
|
||||
hasHamburger = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#" + tableID)
|
||||
.on('click', 'tr', defaultAction)
|
||||
.on('mouseover', 'tr', showActions)
|
||||
.on('mouseout', 'tr', hideActions);
|
||||
$("#allactions_" + tableID +".allactions")
|
||||
.on('mouseover', function (evt) { evt.stopPropagation() } )
|
||||
.on('mouseout', function (evt) { evt.stopPropagation() } );
|
||||
touch = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#" + tableID)
|
||||
.on('click', ".hamburger", showHamburgerActions)
|
||||
.on('click', '.hamburger', FcltMgr.stopPropagation );
|
||||
touch = true;
|
||||
hasHamburger = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function defaultHamburgerAction(event)
|
||||
{
|
||||
var thisTR = $(this).closest('tr')[0];
|
||||
|
||||
if (!$('li.byHamburger').hasClass('hidden'))
|
||||
$('li.byHamburger').toggleClass('hidden');
|
||||
else if (showingInlineDetails)
|
||||
hideActions.apply(thisTR, [event]);
|
||||
else if (!!$(event.currentTarget).attr("ROWKEY"))
|
||||
defaultAction.apply(thisTR, [event]);
|
||||
}
|
||||
|
||||
function $currentActionsDiv()
|
||||
@@ -201,20 +216,45 @@ function defaultAction(event)
|
||||
$actiondiv.find("span.ia2").each(function (i)
|
||||
{
|
||||
if (bits.substr(i,1) == 1 && this.getAttribute("isdefault") == 1)
|
||||
{
|
||||
$(this).trigger('click');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function hideActions(event)
|
||||
{
|
||||
if ((!touch && window.activerow != this) || (touch && showingInlineDetails)) // voorkom hide als je muis boven de buttons beweegt
|
||||
if ((!hasHamburger && window.activerow != this) || (hasHamburger && showingInlineDetails)) // voorkom hide als je muis boven de buttons beweegt
|
||||
{
|
||||
$currentActionsDiv().hide();
|
||||
if (touch) showingInlineDetails = false;
|
||||
if (hasHamburger) showingInlineDetails = false;
|
||||
}
|
||||
event.stopPropagation();
|
||||
}
|
||||
|
||||
function inlineHambOff()
|
||||
{
|
||||
if (showingInlineDetails)
|
||||
{
|
||||
$currentActionsDiv().hide();
|
||||
if (hasHamburger) showingInlineDetails = false;
|
||||
}
|
||||
}
|
||||
|
||||
function hambSetCursor(event)
|
||||
{
|
||||
window.activerow = this;
|
||||
var $actiondiv = $currentActionsDiv();
|
||||
event.stopPropagation();
|
||||
|
||||
var bits = String(this.getAttribute('ACTIONBITS'));
|
||||
$actiondiv.find("span.ia2").each(function (i)
|
||||
{
|
||||
if (bits.substr(i,1) == 1 && this.getAttribute("isdefault") == 1)
|
||||
$(window.activerow).css("cursor", "pointer");
|
||||
});
|
||||
}
|
||||
|
||||
function showHamburgerActions(event)
|
||||
{
|
||||
var thisTR = $(this).closest('tr')[0];
|
||||
@@ -225,16 +265,18 @@ window.activerow = null;
|
||||
function showActions(event) // event op de mouseover van resultsettable
|
||||
{
|
||||
var key = this.getAttribute("ROWKEY");
|
||||
if (!key || (touch && currentRowKey == key && showingInlineDetails))
|
||||
if (!key || (hasHamburger && currentRowKey == key && showingInlineDetails))
|
||||
{
|
||||
hideActions(event)
|
||||
return;
|
||||
}
|
||||
else if (touch)
|
||||
else if (hasHamburger)
|
||||
{
|
||||
currentRowKey = key;
|
||||
showingInlineDetails = true;
|
||||
}
|
||||
if (!$('li.byHamburger').hasClass('hidden'))
|
||||
$('li.byHamburger').toggleClass('hidden');
|
||||
var mustHide = ( window.activerow != this );
|
||||
window.activerow = this;
|
||||
var $actiondiv = $currentActionsDiv();
|
||||
@@ -259,36 +301,39 @@ function showActions(event) // event op de mouseover van resultsettable
|
||||
anyShow = true;
|
||||
}
|
||||
});
|
||||
if (touch)
|
||||
$actiondiv.css('top', $(this).offset().top);
|
||||
else
|
||||
$actiondiv.css('top', $(this).offset().top + $(this).outerHeight() - $actiondiv.outerHeight() - 5 + "px");
|
||||
|
||||
if (!anyShow)
|
||||
{
|
||||
$actiondiv.hide();
|
||||
return;
|
||||
}
|
||||
var hasActionsCol = $actiondiv.attr("hasActionsCol");
|
||||
var tdhasact = $(this).find("td")[hasActionsCol];
|
||||
var hambImg = $(this).find("div.hamburger").children()[0];
|
||||
|
||||
if (touch)
|
||||
if (hasHamburger)
|
||||
{
|
||||
$actiondiv.css('top', $(this).offset().top);
|
||||
|
||||
var hambImg = $(this).find("div.hamburger").children()[0];
|
||||
|
||||
if (hambImg)
|
||||
{
|
||||
$actiondiv.css('left', $(hambImg).position().left + $(hambImg).width() + "px");
|
||||
}
|
||||
else
|
||||
{
|
||||
// afvangen? div.hamburger niet gevonden of heeft geen children()
|
||||
}
|
||||
}
|
||||
else if (tdhasact)
|
||||
$actiondiv.css('left', $(tdhasact).position().left + "px");
|
||||
else // dan maar rechts uitlijnen?
|
||||
{ // TODO: Forceren dat het niet buiten beeld valt als er een scrollbar is?
|
||||
$actiondiv.css('left', $(this).position().left + $(this).width() - window.ww - 10 + "px");
|
||||
else
|
||||
{
|
||||
$actiondiv.css('top', $(this).offset().top + $(this).outerHeight() - $actiondiv.outerHeight() - 5 + "px");
|
||||
|
||||
var hasActionsCol = $actiondiv.attr("hasActionsCol");
|
||||
var tdhasact = $(this).find("td")[hasActionsCol];
|
||||
|
||||
if (tdhasact)
|
||||
$actiondiv.css('left', $(tdhasact).position().left + "px");
|
||||
else // dan maar rechts uitlijnen?
|
||||
{ // TODO: Forceren dat het niet buiten beeld valt als er een scrollbar is?
|
||||
$actiondiv.css('left', $(this).position().left + $(this).width() - window.ww - 10 + "px");
|
||||
}
|
||||
}
|
||||
FcltMgr.resized();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user