<% /* $Revision$ $Id$ File: iface.inc Description: generic interface functions for buttons and maybe more */ %> <% if (JSON_Result) __SafeLog("JSON_Result staat aan, dan is iface.inc includen erg onlogisch."); FCLTHeader.Requires({ plugins: ["jQuery"], js: ["iface.js"]}) var isPrinting = getQParamInt("print", 0) == 1; function CreateButton(tekst, onClick, btn, params) //akey, id, params) { btn = btn || {}; params = params || {}; // voor alle buttons var hasIcon = (params.showIcons || btn.showIcon) && btn.icon; var cls = (params.isDialog? "dialog ": "") + (hasIcon? "hasIcon ": "") + (btn.xclass ? btn.xclass : ""); if (!params.isDialog && tekst) { if (!btn.tooltip) // Alles voor de eerste \n komt in de button, alles erna in de tooltip { var arr = tekst.split("\n"); tekst = arr[0]; // In de tooltip hoeven we de tekst niet (ook) nog een keer te tonen // Let wel: Omdat we ooit responsive op een klein scherm de teksten // onderdrukken dan moet de tooltip toch blijven //arr.shift(); // eerste er af btn.tooltip = arr.join("\n"); } } var display = params.display || 'block'; %>
  • class='<%= cls %>' <%=(btn.tooltip?' title="' + safe.htmlattr(btn.tooltip) + '"' : "")%> <%=(btn.singlepress?" singlepress=1":"")%> onClick="iface.button.click(event, this)" fcltClick="<%=onClick%>" <%= btn.id != null ?'id="' + btn.id + '"' : '' %>><% if (hasIcon) { Response.Write(I(btn.icon) + " "); if (params.isDialog && btn.tooltip) { %>
    <%= btn.tooltip %>
    <% } else { if (tekst) Response.write(""+safe.html(tekst)+""); } } else { Response.write(safe.html(tekst)); } %>
  • <% } // Buttons is een hash // Velden: title, action en id // params: { showIcons : false boolean om (alleen) de icons te tonen en niet de teksten // showText : true boolean om de tekst te doen // vertical : false // autoshowOnly: false // autoshow : false // } var HAMBUTTONS = S("buttons_in_hamburger"); function CreateButtons(buttons, params) { params = params || {}; if (typeof params.showText == "undefined") params.showText = true; if (buttons) { %>
    <% } } // to group fields within an edit page var __blockactive__ = false; function BLOCK_START(id, title, params) { params = params || {}; if (__blockactive__) ERROR_NESTED_BLOCK_START_DETECTED; __blockactive__ = true; if (!params.ishtmlsafe && title && title != " ") var safe_title = safe.html(title); %> <% } /* optional params: { title: "Titel", initHeight: "400px", // grove instelling initHide : true, refreshOnClose: true, // zet oorspronkelijk src terug na FcltClose van child FcltClose: function aan te roepen na FcltClose van child } */ function IFRAMER(id, url, params) { params = params||{}; var cls = "fcltframe"; if ("tabframe" in params && !params.tabframe) cls += " notabframe"; %>
    <% if (params.buttons) CreateButtons(params.buttons) if (params.initHide && !S("fac_tabframes")) url+="&collapsed=1"; %>
    <% } function IFRAMER_HEADER(titel, buttons, params) { var iscoll = getQParamInt("collapsed",0)==1; %>
    > <%=titel %> <% if (buttons) { %>
    <% CreateButtons(buttons, { showIcons: true }) %>
    <% } %>
    <% } // Bij leeg label krijg je helemaal geen 's function AFIELD(pclass, plabel, phref, pvalue, params) { params = params||{}; if ((pvalue == null || pvalue == "") && params.suppressEmpty) return; // snel klaar if (plabel) { %> <% } %> href="<%=safe.htmlattr(phref)%>" <%=params && params.onclick? ' onclick=\"' + safe.jsstring(params.onclick) + '\"' : ''%> <%=(params.html? " " + params.html + " " : "")%>><%=safe.html(pvalue)%> <%=((params.rating && params.rating.score) ? rating.stars(params.rating.score, params) : "")%> <% if (plabel) { %> <% } } function AFIELDTR(pclass, plabel, phref, pvalue, params) { params = params||{}; if ((pvalue == null || pvalue == "") && params.suppressEmpty) return; // snel klaar %>> <% if (!plabel) { %><% } %> <%AFIELD(pclass, plabel, phref, pvalue, params)%> <% if (!plabel) { %><% } %> <% } // Bij leeg label krijg je helemaal geen 's function ROFIELD(pclass, plabel, pvalue, params) { params = params||{}; if ((pvalue == null || pvalue == "") && params.suppressEmpty) return; // snel klaar // Vanuit API2 model if (pvalue != null && typeof pvalue == "object" && "name" in pvalue) pvalue = pvalue["name"]; if (plabel) { %> <% } var input = " 0) prot_url = protectQS.create(params.infoPointer.Url); else prot_url = params.infoPointer.Url; if (params.infoPointer.NewWindow) { var fnclick = "FcltMgr.windowopen(\"" + safe.jsstring(prot_url) + "\")"; } else if (params.infoPointer.Modal) { fnclick = "FcltMgr.openModalDetail(\"" + safe.jsstring(prot_url) + "\"" + ", { titel: \"" + safe.jsstring(params.infoPointer.Title||"") + "\" })"; } else { fnclick = "FcltMgr.openDetail(\"" + safe.jsstring(prot_url) + "\"" + ", { reuse: true, titel: \"" + safe.jsstring(params.infoPointer.Title||"") + "\" })"; } input += " onclick='" + safe.htmlattr(fnclick) + "'"; } if (params.secret) input += " title='{0}' onclick='this.innerText=this.title;this.onclick=null'>".format(safe.htmlattr(pvalue)) + ""; else input += ">" + safe.html(pvalue) + ""; Response.Write(input); if (params.selector) { FCLTselector(params.selector.fieldName, params.selector.sql, params.selector.params); } if (plabel) { %> <% } } function ROFIELDTR(pclass, plabel, pvalue, params) { params = params||{}; if ((pvalue == null || pvalue == "") && params.suppressEmpty) return; // snel klaar if (plabel && params.translate && S("multi_language_option")) { var fn = "iface.translate('"+params.translate.fld+"', "+params.translate.key+", this.innerText, '"+safe.jsstring(pvalue)+"', 'input')" if (params.org_lcl) var fn = "iface.overrule('"+safe.jsstring(params.org_lcl)+"')" plabel = "" + plabel + ""; } %>> <% if (!plabel) { %><% } %> <%ROFIELD(pclass, plabel, pvalue, params)%> <% if (!plabel) { %><% } %> <% } function ROTEXTAREATR(pclass, plabel, pvalue, params) { params = params||{}; if ((pvalue == null || pvalue == "") && params.suppressEmpty) return; // snel klaar if (plabel && params.translate && S("multi_language_option")) { var fn = "iface.translate('"+params.translate.fld+"', "+params.translate.key+", this.innerText, '"+safe.jsstring(pvalue)+"', 'textarea')" if (params.org_lcl) var fn = "iface.overrule('"+safe.jsstring(params.org_lcl)+"')" plabel = "" + plabel + ""; } %>> <%if (plabel) {%><% } %> >
    <%=params && params.id? ' id=\"' + params.id + '\"' : ''%>><%=safe.fclthtml(pvalue, params.mldlink)%>
    <% } // params.html wordt er ook tussen geplakt (onclick bijvoorbeeld) function RWFIELD(pname, pclass, plabel, pvalue, params) { pvalue = safe.nvl(pvalue); params = params||{}; if (plabel) { %> <% } if (params.fronttext) { %><%=params.fronttext%> <% } var lclass = pclass; if (params.infoPointer) lclass += " details"; if (params.extraclass) lclass += " " + params.extraclass; if (!params.readonly && params.required) lclass += " required"; if (!params.readonly && params.requiredor0) lclass += " required required0isoke"; var inputtype = (isBadInput()? " type='text'" : " type='number'"); var lstep=""; switch (params.datatype) { case "number" : lclass += " number"; break; case "float" : lclass += " float"; break; case "currency" : lclass += " currency"; lstep= " step='0.01'"; break; case "text" : inputtype = " type='text'"; break; case "button" : inputtype = " type='button'"; break; default : inputtype = ""; break; } %> <%=lstep%> name="<%=pname%>" id="<%=pname%>" value="<%=Server.HTMLEncode(pvalue)%>" <%=(params.maxlength? " maxlength="+params.maxlength : "")%> <%=(params.readonly? " readonly " : "")%> <%=(params.html? " " + params.html + " " : "")%> <% if (params.infoPointer) { // Hebben we anno 2015.1 nog wel ergens een RWFIELD met infopointer? %> onclick="FcltMgr.openDetail('<%=safe.jsstring(params.infoPointer.Url)%>', { reuse: true, titel: '<%=safe.jsstring(params.infoPointer.Title||"")%>' })"<% } %>><% if (params.selector) { FCLTselector(params.selector.fieldName, params.selector.sql, params.selector.params); } if (params.extrabutton) { %>   <% } if (params.reartext) { %><%=params.reartext%> <%} if (params.endicon) { var iconClick = ""; if (params.iconClick) { if (params.iconClick == "inherit" && params.datatype == "button") iconClick = " onClick='this.previousSibling.click()'"; else iconClick = " onClick='" + safe.htmlattr(params.iconClick) + "'"; } %>> <%} if (plabel) { %> <% } } // Sommige browsers ondersteunen het input type='number' en dan gaat het fout als wij // er iets met een komma instoppen. function isBadInput() { var agent = "" + Request.ServerVariables("HTTP_USER_AGENT"); if (agent.indexOf("Chrome")>=0) return true; if (agent.indexOf("Firefox")>=0) return true; if (agent.indexOf("Safari")>=0) return true; return false; } function RWFIELDTR(pname, pclass, plabel, pvalue, params) { params = params||{}; if ((pvalue == null || pvalue == "") && params.suppressEmpty && params.readonly) return; // snel klaar %> <%=params.trclass?"class='"+params.trclass+"'":""%>> <% if (!plabel) { %><% } %> <%RWFIELD(pname, pclass, plabel, pvalue, params)%> <% if (!plabel) { %><% } %> <% } function RWTEXTAREATR(pname, pclass, plabel, pvalue, params) { params = params||{}; if ((pvalue == null || pvalue == "") && params.suppressEmpty && params.readonly) return; // snel klaar %>> <%if (plabel) {%><% } %> > <% } // Zie save2db.inc type "check": we voegen een hidden field has_xxxx toe // params.html wordt er ook tussen geplakt (onclick bijvoorbeeld) // DEPRECATED function CHECKBOX(pclass, pid, pvalue, params) { params = params||{}; %> > <%=params.hidden?"style=\"visibility:hidden\"" : ""%> <%=params.readonly? " disabled" : ""%> <%=params.html? params.html : ""%>> <% } function RWCHECKBOXTR(pname, pclass, plabel, pvalue, params) { params = params||{}; if ((pvalue == null || pvalue == "") && params.suppressEmpty && params.readonly) return; // snel klaar %> > <% if (!params.boxfirst) { if (plabel) { %><% } else { %><% } CHECKBOX(pclass, pname, pvalue, params) if (params.posthtml) Response.Write(params.posthtml); if (plabel) { %><% } } else { %><% CHECKBOX(pclass, pname, pvalue, params) %><% if (plabel) { %><% } else { %><% } } %><% } function CHECKBOXTR(plabel, pclass, pid, pvalue, params) // DEPCRECATED, backward compatible { RWCHECKBOXTR(pid, pclass, plabel, pvalue, params); }; function ROCHECKBOXTR(pclass, plabel, pvalue, params) { params = params||{}; if ((pvalue == null || pvalue == "") && params.suppressEmpty) return; // snel klaar if ((pvalue == 0) && params.suppressNo) return; // snel klaar if ((pvalue) && params.suppressYes) return; // snel klaar pvalue = (pvalue?L("lcl_Yes"):L("lcl_No")); ROFIELDTR(pclass, plabel, pvalue, params) } // Functie t.b.v. tijd velden // altijd :-syntax // serverside versie function decimalToHour(val) { if (!val || val == 0) return ""; var mintime = Math.abs(val) != val; // is tijd negatief of positief var hh = Math.floor(Math.abs(val) + 0.5 / 60); // reken met positief tijd var mm = Math.floor((Math.abs(val) - hh) * 60 + 0.5); var timestr = String(hh) + ":" + String((mm < 10? "0" : "") + mm); return (mintime ? "-" + timestr : timestr); // voeg eventueel weer min-teken toe } // Kopie in ../shared/iface.inc IFACE = { FORM_END: function() { protectRequest.inputToken(); } } function I(icon) { if (icon in ICONS) icon = ICONS[icon]; if (icon.match(/^fa-/)) return "".format(icon); else return "".format(rooturl, icon); } %>