function showFadePopup(pUrl, pWidth, pHeight,pCallback, pTop, pLeft){ //try to find or create popup element var p = document.getElementById('popup') if(!p){ var p = document.createElement('div'); p.setAttribute('id','popup'); //document.getElementsByTagName('body')[0].insertBefore(p, document.getElementsByTagName('body')[0].firstChild); document.getElementsByTagName('body')[0].appendChild(p); } //modify popup element p.style.height = pHeight + 'px'; p.style.width = pWidth + 'px'; p.style.top = (!pTop)?((getWindowHeight() - pHeight) / 2) + 'px':pTop + 'px'; p.style.left = (!pLeft)?((getWindowWidth() - pWidth) / 2) + 'px':pLeft + 'px'; //try to find and create background carpet element if(! document.getElementById('carpet')){ var c = document.createElement('div'); c.setAttribute('id','carpet'); //document.getElementsByTagName('body')[0].insertBefore(c, document.getElementsByTagName('body')[0].firstChild); document.getElementsByTagName('body')[0].appendChild(c); } //load content for popup Spry.Utils.setInnerHTML('popup',''); Spry.Utils.updateContent('popup',pUrl,pCallback,{preventScripts:true}); //start fading var efCarpet = new Spry.Effect.Fade('carpet',{from:0,to:80, setup:setupPopup}); var efPopup = new Spry.Effect.Fade('popup',{from:0,to:100, setup:setupPopup}); efCarpet.start(); efPopup.start(); } function hideFadePopup(){ var efPopupClose = new Spry.Effect.Fade('popup',{from:100,to:0,finish:closePopup}); var efCarpetClose = new Spry.Effect.Fade('carpet',{from:80,to:0,finish:closePopup}); efCarpetClose.start(); efPopupClose.start(); } function setupPopup(e,fe){ e.style.diplay = "block"; } function closePopup(e,fe){ e.style.display = "none"; } function getWindowWidth(){ if(document.all){ return document.body.offsetWidth; } else { return window.innerWidth; } } function getWindowHeight(){ if(document.all){ return document.body.offsetHeight; } else { return window.innerHeight; } } function filterByName(ds){ var tf = Spry.$('user_search'); var regExp = new RegExp(tf.value, "i"); var userFilterFunc = function(dataSet, row, rowNumber){ var str = row["givenname"] + ' ' + row["surname"]; if (str && str.search(regExp) != -1){ return row; } return null; } ds.filter(userFilterFunc); } function resizeTo(pElem,pWidth,pHeight,pLeft,pTop){ pElem.style.height = pHeight + 'px'; pElem.style.width = pWidth + 'px'; pElem.style.top = (!pTop)?((getWindowHeight() - pHeight) / 2) + 'px':pTop; pElem.style.left = (!pLeft)?((getWindowWidth() - pWidth) / 2) + 'px':pLeft; } function responseController(req){ //Spry.Utils.setInnerHTML('popup','');return; var context = new ExprContext(req.xhRequest.responseXML); var action = xpathEval("//response/@action", context).stringValue(); var state = xpathEval("//response/@state", context).stringValue(); var editId = xpathEval("//response/@id", context).stringValue(); var message = xpathEval("//response", context).stringValue(); if(state == "error"){ alert(message); //Spry.Utils.updateContent('popup','dialogError.html?message='+message); } else{ //alert(action +':'+message); switch(action){ case 'create': lastEditedId = editId; Spry.Utils.updateContent('popup','dialogSuccess.html?message='+message); resizeTo(Spry.$('popup'),350,200); showInactivePositions(); break; case 'save': lastEditedId = editId; Spry.Utils.updateContent('popup','dialogSuccess.html?message='+message); resizeTo(Spry.$('popup'),350,200); break; case 'delete': Spry.Utils.updateContent('popup','dialogSuccess.html?message='+message); resizeTo(Spry.$('popup'),350,200); break; case 'activate': Spry.Utils.updateContent('popup','dialogSuccess.html?message='+message); resizeTo(Spry.$('popup'),350,200); break; case 'send2friend': Spry.Utils.updateContent('popup','mailSuccess.html?message='+message); resizeTo(Spry.$('popup'),350,200); dsVacancies.loadData(); break; default: break; } dsVacancies.loadData(); } } /*=== Set Object ===========================================================*/ var Palaimon = {}; Palaimon.Set = function(){ this.IDs = new Array(); } Palaimon.Set.prototype.add = function(ele){ this.IDs.push(ele); } Palaimon.Set.prototype.remove = function(ele){ for (var i in this.IDs){ if (this.IDs[i] == ele){ //this.IDs = this.IDs.slice(0,i).concat(this.IDs.slice(i+1,this.IDs.length-1)); this.IDs.splice(i,1); break; } } } Palaimon.Set.prototype.toString = function(){ return this.IDs.join(','); } Palaimon.Set.prototype.getMax = function(){ function Numsort (a, b) { return a - b; } this.IDs.sort(Numsort); return this.IDs.length > 0 ? this.IDs[this.IDs.length -1]:0; } Palaimon.Set.prototype.clear = function(){ this.IDs = new Array(); } var targetIDs = new Palaimon.Set(); /** * prepends a string to another */ function prepend(s, prefix){ return prefix + s; } function findSelection(select, value){ for (var i = 0; i < select.options.length;i++){ if (select.options[i].value == value){ return i; } } } /** * Creates a clone of targetPrototype within targets area * * @param {Object} pid * Optional to create a target with a given ID, used for existing targets */ function createPublicationTarget(pid){ var p = Spry.$('targetPrototype').getElementsByTagName('div')[0].cloneNode(true); var currentNumber = !isNaN(pid)?pid:(targetIDs.getMax() + 1); //elements to change the name attribute on var prepends = new Array( p.getElementsByTagName('select')[0], p.getElementsByTagName('input')[0], p.getElementsByTagName('input')[1] ); for (var e in prepends){ prepends[e].name = prepend(prepends[e].name,'target'+currentNumber+'_'); prepends[e].id = prepends[e].name; } p.id = currentNumber; Spry.$('targets').appendChild(p); targetIDs.add(currentNumber); iStart = p.getElementsByTagName('input')[0]; iEnd = p.getElementsByTagName('input')[1]; var cal = new dhtmlxCalendarObject(iStart.id, true, {isYearEditable: true,isMonthEditable: true}); dhtmlCalendars['start' + p.id] = cal; cal.setSkin('simplegrey'); cal.setDateFormat('%d.%m.%Y'); cal = new dhtmlxCalendarObject(iEnd.id, true, {isYearEditable: true,isMonthEditable: true}); dhtmlCalendars['end' + p.id] = cal; cal.setSkin('simplegrey'); cal.setDateFormat('%d.%m.%Y'); //alert(targetIDs.toString()); return p; } /** * Calls createPublicationTarget with given ID and sets values as given as parameters * * @param {Object} id * target ID from database * @param {Object} target * name of publication target for selection in dropdownbox * @param {Object} validFrom * start of publication from database * @param {Object} validTo * end of publication from database */ function createExistingPublicationTarget(id,target,validFrom,validTo){ p = createPublicationTarget(id); p.getElementsByTagName('select')[0].selectedIndex = findSelection(p.getElementsByTagName('select')[0],target); p.getElementsByTagName('input')[0].value=validFrom; p.getElementsByTagName('input')[1].value=validTo; } /** * Deletes the target from the DOM tree and removes ID from targetIDs list * @param {Object} caller * calling element, should be the button or link inside the div */ function removePublicationTarget(caller){ dhtmlCalendars['start'+caller.parentNode.id].close(); dhtmlCalendars['end'+caller.parentNode.id].close(); dhtmlCalendars['start'+caller.parentNode.id] = null; dhtmlCalendars['end'+caller.parentNode.id] = null; targetIDs.remove(caller.parentNode.id); Spry.$('targets').removeChild(caller.parentNode); } /** * callback function to display an appropriate message * @param {Object} req */ function updateResponseDiv(req){ Spry.Utils.setInnerHTML('submitResponse', req.xhRequest.responseText); } /** * sets value of targetIDs from Set and submits form via XHR */ function submitTargetForm(pForm, pURL){ tinyMCE.triggerSave(); Spry.$('targetIDs').value = targetIDs.toString(); if(Spry.$('ioletAction').value == 'GetAdminPreview'){ return true; } else{ return Spry.Utils.submitForm(pForm, responseController, {url:pURL}); } } function resetTargetIDs(){ targetIDs.clear(); } function showInactivePositions(){ dsVacancies.setXPath('/stellenboerse/array-list/position[description/active!=\'true\']'); Spry.$('showActive').style.display = 'block'; Spry.$('showInactive').style.display = 'none'; Spry.$$('.bannerHeadline')[0].firstChild.replaceData(22,25,'- Inaktive Stellen/Archiv'); } function showActivePositions(){ dsVacancies.setXPath('/stelleboerse/array-list/position[description/active=\'true\']'); Spry.$('showActive').style.display = 'none'; Spry.$('showInactive').style.display = 'block'; Spry.$$('.bannerHeadline')[0].firstChild.replaceData(22,25,'- Aktive Stellen'); } function cleanupEditDialogClose(){ for (c in dhtmlCalendars){ if (dhtmlCalendars[c]) dhtmlCalendars[c].close(); } } var lastEditedId; var templateMapping = ['tpl_proactiv','tpl_pbv','tpl_civ']; var dhtmlCalendars = new Array();