/* $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 //
printform is nodig bij printen reserveringen i.v.m. POST formulier // maar mag niet binnen een ander voorkomen en moet eigenlijk wel binnen body staan // Formulier als tekststring samenstellen en m.b.v. $(document).ready(function(){}) binnen de body zetten var timerID=null; function delayed(delay, fn) { if (window.timerID) clearTimeout(window.timerID); window.timerID = setTimeout(fn, delay); } function doFilter(deze) { var deze = $("#autofilter"); var valThis = deze.val().toLowerCase(); $('table.rstable>tbody>tr').each(function(){ var text = $(this).text().toLowerCase(); var moretext = ($(this).find("span.rsTruncmore").attr('resttxt')||"").toLowerCase(); $(this).toggle(text.indexOf(valThis) > -1 || moretext.indexOf(valThis) > -1); }); } if (window.$) $(document).ready(function() { if (typeof(postformHTML)!="undefined") $("body").append(postformHTML); if ($('table.rstable>tbody>tr').length > 4) { // Uitsluitend als de frameheader direct voor de omsluitende collapseblock komt // Voorkomt dat het bij factuurregels of veel bezoekers bovenin het scherm komt // Die schermen hebben voor de details namelijk geen IFRAMER_HEADER var collapse = $('table.rstable').closest("#collapseblock"); collapse.prev(".fcltframeheader").find("#iframerextratitle").after(""); $("#autofilter") .click(function (e) {e.stopPropagation()}) .keyup(function(e){ if (e.which == 27) { $("#autofilter").val(""); } delayed(200, doFilter); }); }; // Bij multi-select Shift-toets gebruiken voor een range var lastChecked = null; $(document).ready(function() { var $chkboxes = $('input.multiselect'); $chkboxes.click(function(e) { if(!lastChecked) { lastChecked = this; return; } if(e.shiftKey) { var start = $chkboxes.index(this); var end = $chkboxes.index(lastChecked); $chkboxes.slice(Math.min(start,end), Math.max(start,end)+ 1).prop('checked', lastChecked.checked); } lastChecked = this; }); }); }); 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 heeft dan de parent 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 zijn if (thisTABLE.nodeName == "TBODY") thisTABLE = thisTABLE.parentNode; // Indien de tabel een heeft dan de parent
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() - 5 + "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 éé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,"
"); elm.className = ""; FcltMgr.stopPropagation(evt); FcltMgr.resized(); return false; }