198 lines
7.6 KiB
Plaintext
198 lines
7.6 KiB
Plaintext
<%@language = "javascript" %>
|
|
<% /*
|
|
$Revision$
|
|
$Id$
|
|
|
|
File: phonebook_js.asp
|
|
Description: Phonebook API
|
|
Levert een JavaScript bestand op.
|
|
Parameters:
|
|
Context:
|
|
Note:
|
|
*/
|
|
|
|
DOCTYPE_Disable = 1;
|
|
FCLTEXPIRES = 8*60; // geen database interactie tenslotte
|
|
THIS_FILE = "appl/api/phonebook_js.asp";
|
|
var EXPIRED_PASSWORD_OK = true; // performance
|
|
%>
|
|
<!-- #include file="../Shared/common.inc"-->
|
|
<!-- #include file="../Shared/json2.js" -->
|
|
<!-- #include file="../api/api.inc" -->
|
|
|
|
<%
|
|
var API = new API_func();
|
|
|
|
var nojQuery = getQParam("nojQuery", 0)==1;
|
|
|
|
var transitParam = "&fac_id="+Session("customerId") + buildTransitParam(["API", "APIKEY", "charset"]);
|
|
|
|
var proto = (Request.ServerVariables("SERVER_PORT") == "443")?"https":"http";
|
|
var sitenoroot = proto + "://" + Request.ServerVariables("SERVER_NAME");
|
|
var site = sitenoroot + rooturl;
|
|
|
|
//lcl.buildClientLCL();
|
|
// LET OP: Geen FcltMgr.js en dus niet (clientside) zelflerend
|
|
%>
|
|
window.facilitor = window.facilitor || {};
|
|
|
|
window.facilitor.LCL = {};
|
|
window.facilitor.LCL["lcl_shared_suggest_hint"] = "<%=safe.jsstring(L("lcl_shared_suggest_hint"))%>";
|
|
window.facilitor.LCL["lcl_shared_suggest_huidig"] = "<%=safe.jsstring(L("lcl_shared_suggest_huidig"))%>";
|
|
|
|
facilitor.phonebook = facilitor.phonebook || {};
|
|
function L(p_lcl)
|
|
{
|
|
if (p_lcl in window.facilitor.LCL)
|
|
return window.facilitor.LCL[p_lcl];
|
|
return "??" + p_lcl + "??";
|
|
}
|
|
(function() {
|
|
|
|
function getScript(src) {
|
|
document.write('<' + 'script src="<%=site%>/' + src + '"' +
|
|
' type="text/javascript"><' + '/script>');
|
|
}
|
|
|
|
function getCSS(src) {
|
|
document.write('<' + 'link rel="stylesheet" href="<%=site%>/' + src + '"' +
|
|
' type="text/css">');
|
|
}
|
|
|
|
var loadScriptTime = (new Date).getTime();
|
|
getCSS("appl/shared/suggest/suggest.css");
|
|
getCSS("appl/api/api.css");
|
|
|
|
<% if (!nojQuery) { /* kan conflicteren */ %>
|
|
getScript("appl/localscripts/<%=_jqueryver%>.min.js");
|
|
<% } %>
|
|
getScript("appl/shared/suggest/suggest.js");
|
|
|
|
<% if (API.apidata.cust_js) { %>
|
|
getScript("<%=API.apidata.cust_js%>");
|
|
<% } %>
|
|
|
|
window.facilitor.open_phonebook = function(key, naam)
|
|
{
|
|
if (key > 0)
|
|
jQuery.ajax({ type: "GET",
|
|
url: "<%=site%>/appl/api/get_phonebook_info.asp?req_info=prs_perslid&prs_perslid_key=" + key + "<%=transitParam%>",
|
|
dataType: "jsonp",
|
|
success: window.facilitor.show_phonebook
|
|
});
|
|
else
|
|
$("#phonebookdetails").hide()
|
|
}
|
|
|
|
// De default waarden, werkt nog niet TODO
|
|
window.facilitor.phonebook_options =
|
|
{ detailWidth : 450,
|
|
toonFoto: true,
|
|
detailurl: "appl/fac/fac_user_info.asp",
|
|
deeplinkurl: "<%=site%>/?nomenu=1&noheader=1&ihatetabs=1&JumpTo=",
|
|
fields: [ { lbl: "<%=L("lcl_prs_email")%>", val: "prs_perslid_email" },
|
|
{ lbl: "<%=L("lcl_pb_phone")%>", val: "prs_perslid_telefoonnr" },
|
|
{ lbl: "<%=L("lcl_pb_mobile")%>", val: "prs_perslid_mobiel" },
|
|
{ lbl: "<%=L("lcl_pb_afdeling")%>", val: "afdeling" }
|
|
]
|
|
};
|
|
<%
|
|
// kopieer de serverside overrules naar clientside
|
|
for (opt in API.apidata.options)
|
|
{
|
|
Response.Write("\nwindow.facilitor.phonebook_options['"+opt+"'] = "
|
|
+ " eval('(" + safe.jsstring(JSON.stringify(API.apidata.options[opt])) + ")')");
|
|
|
|
}
|
|
%>
|
|
|
|
window.facilitor.show_phonebook = function(data, textStatus)
|
|
{
|
|
// Alle styling moet nog via classes
|
|
var closer = "<span onclick='$(\"#phonebookdetails\").hide()' style='float: right; cursor: hand' title='<%=L("lcl_close_window")%>'>x</span>"
|
|
if (window.facilitor.phonebook_options.detailurl)
|
|
{
|
|
var jumpto = window.facilitor.phonebook_options.detailurl;
|
|
jumpto += (jumpto.indexOf("?")>=0)?"&":"?";
|
|
jumpto += "prs_key="+data.prs_perslid_key;
|
|
var link = window.facilitor.phonebook_options.deeplinkurl + escape(jumpto) + "&fac_id=<%=Session("customerId")%>";
|
|
var ahref = "<a href='"+link+"' target='_new'>"+data.naam+"</a>"
|
|
}
|
|
else
|
|
ahref=date.naam;
|
|
|
|
var trh = "<tr><td></td><th colspan='2' class='title'>"+ahref+"</a></th><th></th></tr>"
|
|
|
|
var trs = "";
|
|
if (window.facilitor.phonebook_options.toonFoto && data.photopath)
|
|
{
|
|
trs += "<tr><td></td><td></td><td rowspan='50'><img src='<%=sitenoroot%>" + data.photopaththumb.replace(/\'/g,''').replace(/\"/g,'"') +"'></td></tr>";
|
|
}
|
|
var fld;
|
|
for (fld in window.facilitor.phonebook_options.fields)
|
|
{
|
|
var field = window.facilitor.phonebook_options.fields[fld];
|
|
if (field.val && data[field.val])
|
|
{
|
|
trs += "<tr><td class='label'>"+field.lbl+"</td>";
|
|
trs += " <td>"+data[field.val]+"</td></tr>";
|
|
}
|
|
if (field.fun)
|
|
trs += eval(field.fun + "(data)");
|
|
}
|
|
|
|
if (!document.getElementById("phonebookdetails"))
|
|
{
|
|
// Alle esthetische styling verloopt via de css
|
|
var dd = document.createElement('div');
|
|
dd.id = "phonebookdetails";
|
|
dd.style.position = "absolute";
|
|
dd.style.top = $("#sName_key_show").position().top+20 + "px";
|
|
dd.style.width = window.facilitor.phonebook_options.detailWidth + "px";
|
|
|
|
var newLeft = $("#sName_key_show").position().left;
|
|
if (newLeft + window.facilitor.phonebook_options.detailWidth > document.body.offsetWidth)
|
|
{ // Wel in beeld houden
|
|
newLeft = document.body.offsetWidth - window.facilitor.phonebook_options.detailWidth
|
|
}
|
|
dd.style.left = newLeft + "px";
|
|
document.body.appendChild(dd);
|
|
if (0)$("body").click // even niet, hij is te agressief
|
|
(
|
|
function(e)
|
|
{
|
|
if($(e.target).closest("#phonebookdetails").length==0)
|
|
{
|
|
$("#phonebookdetails").hide();
|
|
}
|
|
}
|
|
);
|
|
}
|
|
var dd = document.getElementById("phonebookdetails");
|
|
dd.innerHTML = ""+closer+"<table width='100%'>"+trh + trs+"</table>";
|
|
dd.style.display = "block";
|
|
|
|
}
|
|
|
|
window.facilitor.phonebook = function (elm, options)
|
|
{
|
|
var opt;
|
|
for (opt in options)
|
|
{
|
|
window.facilitor.phonebook_options[opt] = options[opt];
|
|
}
|
|
$(elm).append('<input id="sName_key_show" sgonChange="window.facilitor.open_phonebook" class="fldpers" value="">')
|
|
$(elm).append('<input type="hidden" id="sName_key" name="sName_key" value="-1">');
|
|
|
|
sgPerson = new Suggest({ objectName: "sgPerson",
|
|
queryField: $("#sName_key_show")[0],
|
|
queryUrl: "<%=site%>/appl/shared/suggest/SuggestPerslid.asp?filtcode=PHB<%=transitParam%>",
|
|
initKey: -1,
|
|
noJustOne: true,
|
|
keyField: $("#sName_key")[0],
|
|
JSONP: true,
|
|
embedded: true
|
|
});
|
|
};
|
|
})();
|