Files
Facilitor/APPL/Localscripts/resultset_table_v2.js
Maykel Geerdink 7499594c28 AAIT#30722: Opmerkingen naar aanleiding van AAIT#29901 (Maint. proces).
svn path=/Website/trunk/; revision=23590
2014-12-08 13:43:30 +00:00

274 lines
8.8 KiB
JavaScript
Raw Blame History

/*
$Revision$
$Id$
File: resultset_table_v2.js
Description: Javascript code voor de resultsettable. Voegt post formulier aan body toe.
Parameters:
Globals:
Context: Wordt gebruikt door de resultset_table_v2.inc
Note:
*/
// post formulier voor printen aan de body toevoegen
// <form> printform is nodig bij printen reserveringen i.v.m. POST formulier
// maar <form> mag niet binnen een ander <form> voorkomen en moet eigenlijk wel binnen body staan
// Formulier als tekstring samenstellen en m.b.v. $(document).ready(function(){}) binnen de body zetten
$(document).ready(function() {
if (typeof(postformHTML)!="undefined") $("body").append(postformHTML);
});
function resizeWhenInIFrame()
{
FcltMgr.resized();
}
function largerWhenInIFrame()
{
FcltMgr.resized(window, { largerOnly: true });
}
function hideInlineDetails(thisTR)
{
$(thisTR).find(".inlinedetails").toggleClass("closed");
$(thisTR).find(".inlinedetails").html(L("lcl_shared_inlinecolumnclosed"));
var thisTABLE = thisTR.parentNode;
if (thisTABLE.nodeName == "TBODY")
thisTABLE = thisTABLE.parentNode; // Indien de tabel een <tbody> heeft dan de parent <table> pakken.
thisTABLE.deleteRow(thisTR.rowIndex + 1); // De volgende rij verwijderen.
thisTR.inlineVisible = false;
return false;
}
function hideAllInlineDetails(ID)
{
$("#" + ID).find("tr[inlineVisible=true]").each(function (i) { hideInlineDetails(this)});
resizeWhenInIFrame();
}
function showInlineDetails(thisTD, strfnURL, position)
{
var thisTR = thisTD.parentNode;
var thisTRid = thisTR.id;
var thisRowkey = thisTR.getAttribute("ROWKEY");
if (thisTR.inlineVisible)
return hideInlineDetails(thisTR);
$(thisTR).find(".inlinedetails").toggleClass("closed");
$(thisTR).find(".inlinedetails").html(L("lcl_shared_inlinecolumnopen"));
thisTR.inlineVisible = true;
var thisTABLE = thisTR.parentNode; // Parent node kan ook <tbody> zijn
if (thisTABLE.nodeName == "TBODY")
thisTABLE = thisTABLE.parentNode; // Indien de tabel een <tbody> heeft dan de parent <table> pakken.
var newRow = thisTABLE.insertRow(thisTR.rowIndex + 1); // De nieuwe rij erna toevoegen.
newRow.id = thisTRid + "inline"
newRow.insertCell(0);
var theCell = newRow.insertCell(1);
theCell.innerHTML = L("lcl_shared_loading");
theCell.colSpan=thisTR.children.length - 2;
if (position == null) position = 3;
for (var i = 0; i < position - 2; i++)
newRow.insertCell(1);
var xurl = eval(strfnURL).call(null, thisTR);
$.ajaxSetup({ cache: true });
theCell.id = "tdinline";
$(theCell).load(xurl, largerWhenInIFrame);
return false;
}
function loadInlineDetails(url)
{
$("#tdinline").load(url, largerWhenInIFrame);
}
// forTouch doen we geen mouseover's. Die maken dat je veel te veel moet klikken
function initActions(tableID, isTouch)
{
$(function () {
$("#" + tableID)
.on('click', 'tr', defaultAction)
.on('click', '.multiselect', FcltMgr.stopPropagation );
if (!isTouch)
{
$("#" + tableID)
.on('mouseover', 'tr', showActions)
.on('mouseout', 'tr', hideActions);
$("#allactions_" + tableID +".allactions")
.on('mouseover', function (evt) { evt.stopPropagation() } )
.on('mouseout', function (evt) { evt.stopPropagation() } )
}
});
}
function $currentActionsDiv()
{
var tbl = $(window.activerow).closest("table.rstable");
if (!tbl.length)
return $();
return $("#allactions_" + tbl[0].id +".allactions");
}
function defaultAction(event)
{
var key = this.getAttribute("ROWKEY");
window.activerow = this;
var $actiondiv = $currentActionsDiv();
if (!key)
{
$actiondiv.hide();
return;
}
var bits = String(this.getAttribute('ACTIONBITS'));
$actiondiv.find("span.ia2").each(function (i)
{
if (bits.substr(i,1) == 1 && this.getAttribute("isdefault") == 1)
$(this).trigger('click');
});
}
function hideActions(event)
{
if (window.activerow != this) // voorkom hide als je muis boven de buttons beweegt
$currentActionsDiv().hide();
event.stopPropagation();
}
window.activerow = null;
function showActions(event) // event op de mouseover van resultsettable
{
var key = this.getAttribute("ROWKEY");
if (!key)
{
hideActions(event)
return;
}
var mustHide = ( window.activerow != this );
window.activerow = this;
var $actiondiv = $currentActionsDiv();
if (mustHide)
$actiondiv.stop().hide();
$actiondiv.delay(100).fadeIn('fast');
event.stopPropagation();
var bits = String(this.getAttribute('ACTIONBITS'));
// Zet alle actions aan die enabled zijn
window.ww = 0;
var anyShow = false;
$actiondiv.find("span.ia2").each(function (i)
{
if (bits.substr(i,1) == 1 && this.getAttribute("isdefault") == 1)
$(window.activerow).css("cursor", "pointer");
var show = bits.substr(i,1) == 1 && this.getAttribute("isdefault") != 1;
$(this).toggle(show)
if (show)
{
window.ww += $(this).outerWidth();
anyShow = true;
}
});
$actiondiv.css('top', $(this).position().top + $(this).outerHeight() - $actiondiv.outerHeight() + "px");
if (!anyShow)
{
$actiondiv.hide();
return;
}
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");
}
}
//actions[i].multiOnce
function doA(evt, thisSPAN, theAction)
{
//$(thisSPAN).css('visibility', 'hidden'); // Verwijder de actie direct zodat dubbelklikken geen tweede aanroep kan veroorzaken.
FcltMgr.stopPropagation(evt);
eval(theAction).call(null, window.activerow);
return false;
}
// Als doA maar dan voor actions die ook multiOnce kunnen: geef een rowArray (met <20><>n element) door ipv row
function doAm(evt, thisSPAN, theAction)
{
FcltMgr.stopPropagation(evt);
var rowArray = [ window.activerow ];
eval(theAction).call(null, rowArray);
return false;
}
function getKeyString(rowArray)
{
var key;
var keyString = [];
for (var i = 0; i < rowArray.length; i++)
{
key = rowArray[i].getAttribute("ROWKEY");
keyString.push(key);
}
return keyString.join(",");
}
function doMulti(thisID)
{
var actionSelect = document.getElementById("multiaction");
if (actionSelect[actionSelect.selectedIndex].value == '') return;
var regels = $("#" + thisID + " .multiselect:checked");
if (regels.length > 0 &&
confirm(L("lcl_shared_doaction").format(actionSelect[actionSelect.selectedIndex].text, regels.length)))
{
// Als multiOnce is gedefinieerd dan wordt de actie 1 keer aangeroepen waarbij een string met keys wordt meegegeven aan de actiefunctie
// anders wordt voor elke aangevinkte regel de actie aangeroepen waarbij elke keer een key wordt meegegeven aan de actiefunctie
var multiOnce = false;
var multiOnceArray = new Array();
var teller = 0;
$("#" + thisID + " .multiselect:checked").each(function()
{
teller++;
var rowData = eval('(' + this.parentNode.parentNode.getAttribute("ROWDATA") + ')');
multiOnce = actionSelect[actionSelect.selectedIndex].getAttribute("multiOnce");
if (multiOnce)
multiOnceArray.push(this.parentNode.parentNode);
else
eval(actionSelect[actionSelect.selectedIndex].value).call(null, this.parentNode.parentNode, true); // true voor noconfirm i.g.v. multi actie
});
if (multiOnce)
eval(actionSelect[actionSelect.selectedIndex].value).call(null, multiOnceArray, true); // true voor noconfirm i.g.v. multi actie
}
}
function checkAll(thisID, zelf)
{
$("#"+thisID+" .multiselect").each(function()
{
this.checked = zelf.checked;
});
}
function RSdefaultAction(thisID, defaultAction)
{
var row = $("#"+thisID)[0].getFirstSelectedRow();
$("#"+thisID)[0].clearSelection();
eval(defaultAction).call(null, row);
}
// Als op ...meer geklikt bij afgekapte tekst
function expandTruncate(evt, elm)
{
if (!evt) evt = window.event;
elm.innerHTML=elm.getAttribute("resttxt").replace(/\n/ig,"<br>");
elm.className = "";
FcltMgr.stopPropagation(evt);
FcltMgr.resized();
return false;
}