//this is a .html file instead of a .js so that FBT will serve the page with substr for all SUBS var onLoadDefaultsDone = false; if(typeof(mmUrlAddNoContext)=="undefined")mmUrlAddNoContext=""; if (!String.prototype.trim) { // no trim() prior to IE9 String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g, '');}; } // older browsers (IE8) do not have this function // also added com/other/ddr-ecma5-1.2.1-min.js with more similar functions (if needed) if (!Array.prototype.indexOf) { Array.prototype.indexOf = function(obj, start) { for (var i = (start || 0), j = this.length; i < j; i++) { if (this[i] === obj) { return i; } } return -1; } } var FIT_TINY = ""; function checkValidRtfContent(text) { var lines = text.split("\n"); for (i=0; i<lines.length; i++) { if ((lines[i]!=FIT_TINY) && (lines[i]!="<p> </p>" )) { return true; } } return false; } function checkRtfMandatory(name) { if (tinyMCE) { var inst = tinyMCE.get(name); if (inst) { return checkValidRtfContent(inst.getContent()); } } return true; } function contains(a, obj) { var i = a.length; while (i--) { if (a[i] === obj) { return true; } } return false; } function mandatoryCheck() { var missingLabels = ""; var myForm = document.entry_form; var firstMissingId=""; var alreadyChecked = []; for(i=0;i<myForm.elements.length;i++) { var input = myForm.elements[i]; if (input.name.length > 0 && contains(alreadyChecked,input.name)) { continue; } alreadyChecked[alreadyChecked.length] = input.name; var pos = -1; if (input) { pos = mandFields.indexOf(input.name); if (pos>-1) { var rtfBlank = false; var multipleEmpty = false; if ((input.type == 'checkbox' || input.type == 'radio') && document.getElementsByName(input.name).length > 1) { var checkboxes = document.getElementsByName(input.name) multipleEmpty = true; //alert(input.name); for (var c=0;c<checkboxes.length;c++) { if (checkboxes[c].checked) { multipleEmpty = false; break; } } } if (input.type == 'select-multiple') { var options = input.options; multipleEmpty = true; for(d=0;d<options.length;++d) { if (options[d].selected) { multipleEmpty = false; } } } else if (rtfDefaultFields.indexOf(input.name) >= 0) { var rtfObj = tinyMCE.get(input.name); if (rtfObj) { // could have been turned off var text = rtfObj.getContent(); var div = document.createElement("div"); div.innerHTML = text; text = div.textContent || div.innerText || ""; text = text.trim(); if (text.length == 0) { rtfBlank = true; } } } if (rtfBlank || multipleEmpty || (input.options && input.selectedIndex>=0 && input.options[input.selectedIndex].text== "") || // select now allows blanks (!input.options && input.value == "") || !checkRtfMandatory(input.name) || // RTF enabled (input.selectize && input.selectize.getValue()=="") ) // combobox { if (missingLabels.length > 0) { missingLabels += ", "; } if (firstMissingId.length==0) { firstMissingId=input.name; } missingLabels += mandFieldLabels[pos]; var obj = $("#"+input.name); if (jQuery("#"+input.name+"-selectized").length) { // combobox obj = jQuery("#"+input.name+"-selectized").parent(); } else if (!obj.is(":visible")) { obj = obj.parent(); } obj.css("border", "2px red dashed"); } else { var obj = $("#"+input.name); if (jQuery("#"+input.name+"-selectized").length) { // combobox obj = jQuery("#"+input.name+"-selectized").parent(); } else if (!obj.is(":visible")) { obj = obj.parent(); } obj.css("border", "none"); } } } } if (missingLabels.length > 0) { draggableFix(); jQuery("#"+firstMissingId ).after("
: " + missingLabels + "
"); jQuery( "#dialog" ).dialog({ modal: true, close: function(event, ui) { // this is the line I changed for bug 4953 var scrollPos = jQuery("#"+firstMissingId ).offset().top - 10; // if scrolling to field, never going to need to worry about - fixedHeaderHeight if (document.body.scrollTop==0) { scrollPos -= totalHeaderHeight; } else { scrollPos -= fixedHeaderHeight; } jQuery(window).scrollTop(scrollPos); } }); return false; } return true; } function fitSubmitCheck() { try { var ret = true; if (typeof mandFields!='undefined' && mandatoryCheck()==false) { ret = false; } //stale data check if(ret && typeof (window.ajaxCheckForStaleData) == 'function') { // ModifyBug case if (ajaxCheckForStaleData()==false) { ret = false; } } //stale data check if(ret && typeof (window.rtfCheckLinks) == 'function') { // tinymce stuff if (rtfCheckLinks()==false) { ret = false; } } if (!otherFitSubmitChecks(ret)) { ret = false; } // check for sv_iframe windows (ie: editing relationships) var obj = jQuery("#sv_iframe"); if (obj && obj.is(":visible")) { fitDialog("You have a subwindow open and might be editing a relationship.Please close that window before saving!"); ret = false; } } catch (err) { return confirm ("There appears to be a problem with the fitSubmitCheck code:\n" + err.message + "\nPlease have someone address this. Do you wish to submit anyways?"); } return ret; } function otherFitSubmitChecks() { //this function is overridden elsewhere return true; } // there may be an input at the top or the bottom function synchronizeSuppress(input) { var value = input.checked; var suppress = document.getElementById("suppress"); if (suppress) { suppress.checked = value; } var bottomSuppress = document.getElementById("bottomSuppress"); if (bottomSuppress) { bottomSuppress.checked = value; } } function editorWin(name){ var win = window.open(mmUrlAddNoContext+"&CONTEXT="+mmContext+"&page=com.other.Editor","blank","toolbar=no,width=500,height=300"); //alert("win:"+win); //win.edited.value='xxx'; } // expand / collapse textareas var minsize = ; var maxsize = ; function initTA(taName) { if (minsize == -1) return; var ta; if (typeof document.entry_form == "undefined") { ta = eval('document.BulkForm.'+taName); } else { ta = eval('document.entry_form.'+taName); } if (ta != null) { ta.rows = minsize; ta.scrollTop=0; } } function isdefined( variable) { return (typeof(window[variable]) == "undefined") ? false: true; } function expColTA(event,taName) { if (isdefined("tinyMCE") && tinyMCE.get(taName)) { //if (tinyMCE.getInstanceById(taName)) { // tinyMCE.get(taName).execCommand('mceFullScreen'); //} fitInfo(event,""); return; } if (minsize == -1) return; var ta; if (typeof document.entry_form == "undefined") { ta = eval('document.BulkForm.'+taName); } else { ta = eval('document.entry_form.'+taName); } if (ta != null) { if (ta.rows==minsize) { ta.rows = maxsize; // maximize if minimized } else if (ta.rows > minsize) { ta.rows = minsize; // if not minimized, minimize } else { resizeTA(event,ta); // otherwise, fit existing text } } } // resize TextArea to fit text function resizeTA(event,t) { if (minsize == -1) return; a = t.value.split('\n'); b = a.length; for (i=0; i<a.length; i++) { m = parseInt(a[i].length / 80) ; if (m > 0) { b+=m; } } if (b > t.rows) { t.rows = b; } } var notifyMax = 10; var notifyMin = 4; function expColNotify(collapse,specific) { if (minsize == -1) return; var form; if (typeof document.entry_form == "undefined") { form = eval('document.BulkForm'); } else { form = eval('document.entry_form'); } var list = eval('form.mNotifyList'+specific); var select = eval('form.notifySelect'+specific); //if (select.length<=2 && collapse==false) return; // no need to resize if (list.rows<notifyMax) { list.rows=notifyMax; select.size=notifyMax-2; } else if (collapse==true) { list.rows=notifyMin; select.size=notifyMin; } } function sortNotify(specific){ var form; if(typeof document.entry_form=="undefined"){ form=eval('document.BulkForm'); }else{ form=eval('document.entry_form'); } if(form){ var list=eval('form.mNotifyList'+specific); if(list&&list.value){ var re=new RegExp('[,\r\n]+',"g"); if(re){ var arr=list.value.split(re); arr.sort(function(x,y){ var a=String(x).toLowerCase(); var b=String(y).toLowerCase(); if(a>b)return 1; if(a<b)return -1; return 0;}); list.value=arr.join("\n"); } } } } var tagsFirst = "<SUB TAGSFIRST>"; function addNotify(specific) { var form; if (typeof document.entry_form == "undefined") { form = eval('document.BulkForm'); } else { form = eval('document.entry_form'); } var append = ""; var operationObj = eval('form.notifyOperation'+specific); var operation = operationObj.selectedIndex; operationObj.selectedIndex = 0; var list = eval('form.mNotifyList'+specific); var select = eval('form.notifySelect'+specific); //clear if (operation==operationObj.options.length-1) { list.value=""; return false; } //add From notifySelect for(i=0; i<select.length; i++) { if (select[i].selected == true) { if(append.length > 0 || list.value.length > 0) { append += '\n'; } var val = select[i].value; if (tagsFirst!="1") { val = select.options[i].text; } if (operation==1&&operationObj.options.length>2) { if (tagsFirst=="1") { val += "*"; } else { var index = select[i].value.lastIndexOf("["); if (index>0) { val = val.substring(0,index-1) + " *" + val.substring(index); } else { val += "*"; } } } val = val.replace(","," "); //tagsNoComma append += val; } } list.value+=append; //sortNotify(specific); return false; } var HIGHLIGHTCLASS = "highlight"; // functions for rolling over and highlighting main menu items function rollOnAll(evt,rowId) { // check for children for(var c=1; c<10; c++) { var child = document.getElementById(rowId+"-CHILD"+c); if (!child) { break; } rollOnAll(evt,rowId+"-CHILD"+c); } var index = rowId.indexOf("-RC"); if (index<0) index = rowId.indexOf("-EL"); if (index<0) index = rowId.indexOf("-SPACER"); if (index>-1) { // in case row field, then start with parent of group of tr rollOn(evt,rowId.substr(0,index)); return; } var row = document.getElementById(rowId); if (row.className.indexOf(HIGHLIGHTCLASS)>-1) { // in case highlight is never turned off for some reason return; } if ( row.className == "" ) { row.className = HIGHLIGHTCLASS; } else { row.className = HIGHLIGHTCLASS + " " + row.className; } // possible there is a spacer var spacer = document.getElementById(rowId+"-SPACER"); if (spacer) { spacer.className = HIGHLIGHTCLASS + " " + spacer.className; } // do all row fields for (c=1;c<10;++c) { var child = document.getElementById(rowId+"-RC"+c); if (child == undefined) { break; } child.className = HIGHLIGHTCLASS + " " + child.className; } // do all ExtraLine fields for (c=1;c<10;++c) { var child = document.getElementById(rowId+"-EL"+c); if (child == undefined) { break; } child.className = HIGHLIGHTCLASS + " " + child.className; } } function rollOffAll(rowId) { // check for children for(var c=1; c<10; c++) { var child = document.getElementById(rowId+"-CHILD"+c); if (!child) { break; } rollOffAll(rowId+"-CHILD"+c); } var index = rowId.indexOf("-RC"); if (index<0) index = rowId.indexOf("-EL"); if (index<0) index = rowId.indexOf("-SPACER"); if (index>-1) { // in case row field, then start with parent of group of tr rollOffAll(rowId.substr(0,index)); return; } var row = document.getElementById(rowId); row.className = row.className.replace(HIGHLIGHTCLASS,""); row.className = row.className.replace(/^\s+|\s+$/g,''); // possible there is a spacer var spacer = document.getElementById(rowId+"-SPACER"); if (spacer) { spacer.className = spacer.className.replace(HIGHLIGHTCLASS,""); spacer.className = spacer.className.replace(/^\s+|\s+$/g,''); } // do all row fields for (c=1;c<10;++c) { var child = document.getElementById(rowId+"-RC"+c); if (child == undefined) { break; } child.className = child.className.replace(HIGHLIGHTCLASS,""); child.className = child.className.replace(/^\s+|\s+$/g,''); } // do all ExtraLine fields for (c=1;c<10;++c) { var child = document.getElementById(rowId+"-EL"+c); if (child == undefined) { break; } child.className = child.className.replace(HIGHLIGHTCLASS,""); child.className = child.className.replace(/^\s+|\s+$/g,''); } } function rollOn(evt, rowId) { var e = (window.event) ? window.event : evt; var targ; if (e.target) { targ = e.target; } else if (e.srcElement) { targ = e.srcElement; } if (targ.id.indexOf("idCol")!=0 && targ.id.indexOf("user")!=0) { targ.style.cursor="pointer"; } var row = document.getElementById(rowId); row.onmouseout = new Function("rollOffAll('"+rowId+"');"); rollOnAll(evt,rowId); } var LASTSV = "-1"; var SVSTARTUP; var svVisible=false; var ie = document.all?1:0; var svid="SimpleView_DIV"; var sv="-1"; var sv_html = "
"; // allow user to press escape to close calendar window/popup function sv_escape(evt) { var e = (window.event) ? window.event : evt; if (e.keyCode == 27) { sv_hide(); } } function toggle_sv(context,rowId) { if (svVisible==true) { sv_hide(); } else { var link = mmUrlAddNoContext+"&CONTEXT="+context+"&page=&bugId="+rowId; sv_show(rowId,link); } } var updateRelationship = -1; function toggle_svNew(bugId,fieldId,otherContext,otherFieldId) { var moreVars = ""; if (typeof additionalRelationshipOverride == 'function') { moreVars = additionalRelationshipOverride(fieldId,otherContext); } if (svVisible==true) { sv_hide(); } else { updateRelationship = fieldId; if (otherFieldId>0 && moreVars.indexOf("moreVarsSTOP")<0) { var id = bugId; if (id<0 && typeof mmBugId != null) { id = mmBugId; } moreVars += "&field"+otherFieldId+"="+id; } var link = mmUrlAddNoContext+"&CONTEXT="+otherContext+"&page=com.other.SimpleNewBug"+moreVars+"&fromNewRelButton="+otherFieldId; sv_show((new Date()).getTime(),link); } } function searchStringFocus() { jQuery("#searchString").focus(); } function sv_startup() { if (sv != "-1") { // close the current one sv.style.visibility = "hidden"; } sv = setupSV(); sv.innerHTML=sv_html; document.body.appendChild(sv); //sv.className='templatetitle'; //sv.style.backgroundColor='#006699'; //sv.style.padding='10px'; //these should not be modified sv.style.position="absolute"; sv.style.visibility="hidden"; sv.style.width="400px"; //sv.style.height="100000px"; // make it big so there is no second scrollbar sv.style.zIndex="1000"; sv_closer_startup(); } function setOpacityOff() { var mainMenuTable = document.getElementById("mainMenuTable"); if (mainMenuTable!=undefined) { //dashboard mainMenuTable.style.opacity = 1; mainMenuTable.style.filter = ''; var menu = document.getElementById("FBT_MENU"); if (menu!=undefined) { menu.style.opacity = 1; menu.style.filter = ''; } } } function setOpacity(value) { var mainMenuTable = document.getElementById("mainMenuTable"); if (mainMenuTable!=undefined) { mainMenuTable.style.opacity = value/10; mainMenuTable.style.filter = 'alpha(opacity=' + value*10 + ')'; var menu = document.getElementById("FBT_MENU"); if (menu!=undefined) { // older styles menu.style.opacity = value/10; menu.style.display = 'inline'; menu.style.filter = 'alpha(opacity=' + value*10 + ')'; } } } function sv_hide(hideId) { if (svVisible) window.scrollTo(0,sv.offsetTop-totalHeaderHeight); // back to where we started from svVisible=false; var current_sv = document.getElementById(hideId); if (!current_sv) { current_sv = sv; } current_sv.innerHTML = "
empty
"; // stop ajax updates to FIT current_sv.style.visibility = "hidden"; setOpacityOff(); extraStepsOnQuickViewClose(); return false; } function extraStepsOnQuickViewClose() {} var fixedHeaderHeight = 0; var totalHeaderHeight = 0; var VIEW = 1; var EDIT = 2; var SCROLLWIDTH = 25; // so scroll is not hidden var svOffset = 200; function sv_show(distinct,link) { link = encodeURI(link); if(typeof (window.sv_customshow) == 'function') { sv_customshow(distinct,link); return false; } LASTSV=distinct; if (SVSTARTUP==undefined) { sv_startup(); SVSTARTUP=1; } var myWidth; var myHeight; if( typeof( window.innerWidth ) == 'number' ) { //Non-IE myWidth = window.innerWidth; myHeight = window.innerHeight; } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) { //IE 6+ in 'standards compliant mode' myWidth = document.documentElement.clientWidth; myHeight = document.documentElement.clientHeight; } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) { //IE 4 compatible myWidth = document.body.clientWidth; myHeight = document.body.clientHeight; } setOpacity(4); var xpos=svOffset; var xOffset=ie?document.documentElement.scrollLeft:window.pageXOffset; var yOffset=ie?document.documentElement.scrollTop:window.pageYOffset; var ypos=yOffset; ypos += totalHeaderHeight; var iPADDING = 10; // padding of table around iframe var xdiff = (myWidth<800) ? 800 : myWidth-xpos-iPADDING; if (distinct=="Trial" && xdiff<1000) xdiff = 1000; if (link.substring(0,5)=="html:") { sv_html = link.substring(5); } else { sv_html = "

"; } sv.innerHTML = sv_html; sv.style.left=xpos+'px'; sv.style.top=ypos+'px'; sv.style.position="absolute"; sv.style.width=xdiff+"px"; //sv.style.height="100000px"; sv.style.visibility = "visible"; svVisible=true; document.onkeypress= new Function("event","sv_escape(event);"); return false; } function sv_minimize(e) { sv.style.height="50px"; if (!e) e = window.event; // works on IE, but not NS (we rely on NS passing us the event) if (e) { //if (isDrag) { var mouseX=ie?event.x:e.clientX; var mouseY=ie?event.y:e.clientY; var tx = parseInt(sv.style.left+0); var ty = parseInt(sv.style.top+0); // unknown x/y ?? // sv.style.left=tx + mouseX-x; // sv.style.top=ty + mouseY-y; //} } } function setupSV() { //created the div element for the popup var divTag = document.createElement("div"); divTag.id = svid + (new Date()).getTime(); return divTag; } var sv_closer="-1"; function sv_closer_startup() { sv_closer = setupSV(); sv_closer.innerHTML = //"

" + ""; //""; //"

"; sv_closer.id = "sv_closer"; document.body.appendChild(sv_closer); //document.onmousemove=sv_minimize; //these should not be modified sv_closer.style.position="absolute"; sv_closer.style.visibility="hidden"; sv_closer.style.zIndex="2000"; } function sv_showCloser() { if (svVisible) { var top = ie?document.documentElement.scrollTop:window.pageYOffset; if ( top < sv.offsetTop) { top = sv.offsetTop; } else { top += totalHeaderHeight; } top += ie?10:15; sv_closer.style.top = top +"px"; sv_closer.style.left = sv.offsetLeft+10+"px"; sv_closer.style.visibility="visible"; window.setTimeout("sv_showCloser()", 100); } else { sv_closer.style.visibility="hidden"; window.setTimeout("sv_showCloser()", 500); } } function arrayUnique(array) { var a = array.concat(); for(var i=0; i<a.length; ++i) { for(var j=i+1; j<a.length; ++j) { if(a[i] === a[j]) a.splice(j--, 1); } } return a; }; // hierarchy functions (requires variables on template pages - fieldVal / fieldLabel) function clearField(updateSelect) { for(c=updateSelect.options.length-1;c>=0;--c) { updateSelect.options[c] = null; } } function updateField(fieldname,newVals,newLabels) { var updateSelect = document.entry_form[fieldname]; if (updateSelect == undefined || newVals == undefined || updateSelect.options == undefined) { return; } if (addedMand) { //this keeps track of dynamically mandatory fields if (addedMand[fieldname] == "1" && (newLabels.length > 1 || newLabels[0] != "") && newLabels[0] != selectStr) { log("updateField: " + fieldname + " is mand, updating"); newLabels.unshift(selectStr); newVals.unshift(""); } else if (addedMand[fieldname] == "0" && newLabels[0] == selectStr) { log("updateField: " + fieldname + " is no longer mand, updating"); newLabels.shift(); newVals.shift(); } } var currentValue = ""; var currentLabel = ""; if (updateSelect.selectedIndex >= 0) { currentValue = updateSelect.options[updateSelect.selectedIndex].value; currentLabel = updateSelect.options[updateSelect.selectedIndex].text; } for(c=updateSelect.options.length-1;c>=0;--c) { try { updateSelect.options[c] = null; } catch (err) { log ("updateField:" + err + err.description); } } currExists = false; for(c=0;c<newVals.length;++c) { val = newVals[c]; label = newLabels[c]; if (val == currentValue || val == currentLabel) { match = true; currExists = true; } else { match = false; } updateSelect.options[c] = new Option(label,val,false,match); } // in case an old value exists... if (newVals.length>0 && currExists==false && onLoadDefaultsDone==false && "" != "com.other.NewBug") { updateSelect.options[c] = new Option(currentLabel,currentValue,false,true); } //instead of using changeField we should call onchange //incase other functions have been nested //changeField(updateSelect); updateSelect.onchange(updateSelect); } function changeTextField(parent) { /* if (parent.value != "") { removeMandIcon(parent.name); } else { addMandIcon(parent.name); } */ } var ajaxFieldHierarchy = false; function changeField(parent) { var vals = []; if (parent.selectedIndex >= 0) { //var options = parent && parent.options; var opt; for (var i=0; parent.options && i<parent.options.length; i++) { opt = parent.options[i]; if (opt.selected) { vals.push(opt.value || opt.text); } } } else { if (parent.type=="hidden") { // ReadOnly vals.push(parent.value); } } if (ajaxFieldHierarchy) { updateHierarchyField(parent, vals[0]); } else { if (FieldLabel[parent.name]) { var children = FieldLabel[parent.name]; var c = 0; for(c=0;c<children.length;++c) { var valHash = []; var labelHash = []; child = children[c]; for (var s=0; s<vals.length; s++) { var val = vals[s]; valHash=arrayUnique(valHash.concat(FieldVal[parent.name + "~" + val + "~" + child])); labelHash=arrayUnique(labelHash.concat(FieldLabel[parent.name + "~" + val + "~" + child])); } updateField(child,valHash,labelHash); } } } // hiding sections based on project if (onLoadDefaultsDone == true) { if (parent.name == "mProject") { hideSections(val); } } } //mandatory fields that were added dynamically var addedMand = new Array(); //mandatory fields that were added dynamically, then made non-mandatory var removedMand = new Array(); function addMandatory(fieldName,fieldLabel) { log("addMandatory for field: " + fieldName + " / " + fieldLabel); addedMand[fieldName] = "1"; if (removedMand[fieldName] = "1") { removedMand[fieldName] = ""; } for (var i=0;i<mandFields.length;i++) { if (mandFields[i] == fieldName) { log("addMandatory for field: " + fieldName + " / " + fieldLabel + " already MAND"); return; } } mandFields.length++; mandFieldLabels.length++; mandFields[mandFields.length-1] = fieldName; mandFieldLabels[mandFields.length-1] = fieldLabel; addMandIcon(fieldName); var field = eval("document.entry_form."+fieldName); if (field.tagName == "SELECT") { //this is a dropdown, add select... option log("addMandatory for field: " + fieldName + " / " + fieldLabel + ", it's a select field..."); addMandSelect(field); } } //when a field is made mandatory dynamically, //set to true if Select... should be selected //otherwise current value will stay selected var setMandFieldToSelect = false; var selectStr = "<SUB sSelectMandatory>"; function addMandSelect(field) { //we need to go through the array and find hierarchies //where this field is a child... var parents = new Array(); var addedParents = new Array(); try { if (field != null && field.options[0] && field.options[0].value != selectStr) { log("addMandSelect for field: " + field.getAttribute('name') + ", no "+selectStr+" yet: [" + field.options[0].value +"]"); log("FieldVal.length: " + FeldVal.length); for (i in FieldVal) { var index = i.lastIndexOf("~"+field.getAttribute('name')); if (index > 0 && i.charAt(index-1) != '~') { if (FieldVal[i][0] != selectStr) { log("addMandSelect for field: " + field.getAttribute('name') + ", adding "+selectStr+" to [" + i + "]"); FieldVal[i].unshift(selectStr); FieldLabel[i].unshift(selectStr); var parentName = i.substring(0,i.indexOf("~")); var parent = eval("document.entry_form." + parentName); if (addedParents[parentName] != 1) { parents.push(parent); addedParents[parentName] = 1; } } } } for (i=0;i<parents.length;i++) { log("addMandSelect for field: " + field.getAttribute('name') + ", changeField parent:" + parents[i].getAttribute('name')); changeField(parents[i]); } } else { log("addMandSelect for field: " + field.getAttribute('name') + ", already has Select..."); } } catch(err) { //this case is when there is no heirarchy //so we just want to add selectStr to the field itself //alert("error on adding mand select: " + err); if (field != null && field.options[0].value != selectStr) { myEle=document.createElement("option"); theText=document.createTextNode(selectStr); myEle.appendChild(theText); myEle.setAttribute("value",selectStr); field.insertBefore(myEle,field.getElementsByTagName('option')[0]); if (setMandFieldToSelect || "<SUB onPage>" == "com.other.NewBug") { field.selectedIndex = 0; } } } } function removeMandSelect(field) { //we need to go through the array and find hierarchies //where this field is a child... var parents = new Array(); var addedParents = new Array(); try { if (field != null && field.options[0] && field.options[0].value == selectStr) { log("removeMandSelect for field: " + field.getAttribute('name') + ", has "+selectStr); log("FieldVal.length: " + FeldVal.length); for (i in FieldVal) { var index = i.lastIndexOf("~"+field.getAttribute('name')); if (index > 0 && i.charAt(index-1) != '~') { if (FieldVal[i][0] == selectStr) { log("removeMandSelect for field: " + field.getAttribute('name') + ", removing "+selectStr+" from [" + i + "]"); FieldVal[i].shift(); FieldLabel[i].shift(); var parentName = i.substring(0,i.indexOf("~")); var parent = eval("document.entry_form." + parentName); if (addedParents[parentName] != 1) { parents.push(parent); addedParents[parentName] = 1; } } } } for (i=0;i<parents.length;i++) { log("removeMandSelect for field: " + field.getAttribute('name') + ", changeField parent:" + parents[i].getAttribute('name')); changeField(parents[i]); } } else { log("removeMandSelect for field: " + field.getAttribute('name') + ", no Select... to remove"); } } catch(err) { //this case is when there is no heirarchy //so we just want to remove Select... from the field itself //alert("error on adding mand select..."); if (field != null && field.options[0].value == selectStr) { field.options[0] = null; } } } function removeMandatory(fieldName) { log("removeMandatory for field: " + fieldName); addedMand[fieldName] = "0"; var remove = false; for (var i=0;i<mandFields.length;i++) { if (!remove && mandFields[i] == fieldName) { remove = true; } if (remove && i < mandFields.length-1) { mandFields[i] = mandFields[i+1]; mandFieldLabels[i] = mandFieldLabels[i+1]; } } if (remove) { mandFields.length--; mandFieldLabels.length--; } removeMandIcon(fieldName); var field = eval("document.entry_form."+fieldName); if (field.tagName == "SELECT") { //this is a dropdown, remove select... option removeMandSelect(field); } log("removeMandatory for field: " + fieldName + ", done... returning"); } function whatIsMandatory() { var ret = mandFields[0]; for (var i=1;i<mandFields.length;i++) { ret += ", " + mandFields[i]; } alert(ret); } function addMandIcon(fieldName) { var destination = document.getElementById(fieldName+"Icons"); try { if (destination.firstChild.getAttribute('name') == "dynamicMand") { //already there return; } } catch (err) {} var image = document.createElement("img"); image.src = "<SUB REVISIONPREFIX>com/other/req.gif"; image.border = "0"; image.title = "<SUB sMandatoryField>"; image.alt = "<SUB sMandatoryField>"; var image = document.createElement("img"); image.src = "<SUB REVISIONPREFIX>com/other/req.gif"; image.border = "0"; image.title = "<SUB sMandatoryField>"; image.alt = "<SUB sMandatoryField>"; image.setAttribute('name','dynamicMand'); destination.insertBefore(image,destination.firstChild); } function removeMandIcon(fieldName) { var target = document.getElementById(fieldName+"Icons"); try { if (target.firstChild.getAttribute('name') == "dynamicMand") { target.removeChild(target.firstChild); } } catch (err) {} } var debug = 0; function log(message) { if (!debug || (debug==1 && message.length==0)) { return; } else if (debug==1) { setTimeout(function() { throw new Error(message); }, 0); return; } if (!log.window_ || log.window_.closed) { var win = window.open("", null, "width=800,height=600," + "scrollbars=yes,resizable=yes,status=no," + "location=no,menubar=no,toolbar=no"); if (!win) return; var doc = win.document; doc.write("<html>" + "<bo"+"dy></bo"+"dy>"); doc.close(); log.window_ = win; } var logLine = log.window_.document.createElement("div"); logLine.appendChild(log.window_.document.createTextNode(message)); log.window_.document.body.appendChild(logLine); } //might need this //if (document.layers) { // if (document.id.display == "none"){ function toggleInnerSection(name) { var inner = document.getElementById(name+"_INNER"); var display = "none"; var img = "com/other/plus_black.gif"; //var icon = "fa-plus-circle"; var icon = "fa-chevron-circle-right"; if (inner.style.display=='none') { display = "block"; img = "com/other/minus_black.gif"; //icon = "fa-minus-circle"; icon = "fa-chevron-circle-down"; } inner.style.display = display; if (document.images && document.images[name+"_IMG"]){ document.images[name+"_IMG"].src=img; } else { //new way //jQuery("#"+name+"_ICON").removeClass("fa-plus-circle"); //jQuery("#"+name+"_ICON").removeClass("fa-minus-circle"); jQuery("#"+name+"_ICON").removeClass("fa-chevron-circle-right"); jQuery("#"+name+"_ICON").removeClass("fa-chevron-circle-down"); jQuery("#"+name+"_ICON").addClass(icon); } for(var i=0;i<document.forms.length;i+=1){ if(!document.forms[i].toggleCommands){ var toggleCommands=document.createElement("input"); if(toggleCommands){ toggleCommands.name="toggleCommands"; toggleCommands.type="hidden"; document.forms[i].appendChild(toggleCommands); if(!document.forms[i].toggleCommands){ document.forms[i].toggleCommands=toggleCommands; } } } if(document.forms[i].toggleCommands){ var re=new RegExp("\\btoggleInnerSection\\('"+name+"'\\);\\b"); if(document.forms[i].toggleCommands.value.match(re)){ document.forms[i].toggleCommands.value.replace(re,""); }else{ document.forms[i].toggleCommands.value+="toggleInnerSection('"+name+"');"; } } } } function getElementsByClass(searchClass,node,tag) { var classElements = new Array(); if ( node == null ) node = document; if ( tag == null ) tag = '*'; var els = node.getElementsByTagName(tag); var elsLen = els.length; var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)"); for (i = 0, j = 0; i < elsLen; i++) { if ( pattern.test(els[i].className) ) { classElements[j] = els[i]; j++; } } return classElements; } // Used to toggle the value of whether something is displayed by changing the attributes of it's CSS... function toggleInnerCSS(name,tagname) { var display = "none"; var img = "<SUB REVISIONPREFIX>com/other/plus_black.gif"; if (document.images){ if (document.images[name+"_IMG"].src.indexOf("plus") > 0) { display = ""; img = "com/other/minus_black.gif"; } } var elements = getElementsByClass(name+"_INNER",tagname); for(i=0;i<elements.length;++i) { elements[i].style.display = display; // alert("CHANGE!"); } if (document.images){ document.images[name+"_IMG"].src=img; } } function getCurrentSelections(selectName) { var sel = document.getElementsByName(selectName)[0]; var ret = "<P><U><B>Current Selections</B></U>:<P>"; for (i=0; i<sel.options.length; i++) { if (sel.options[i].selected) { ret += sel.options[i].value + "<BR>"; } } return ret; } function draggableFix() { // draggable has a bug in jquery if page is scrolled //var css = document.createElement("style"); //css.type = "text/css"; //css.innerHTML = ".ui-dialog {position: fixed;}"; //document.body.appendChild(css); jQuery( '
').appendTo('head'); } // info popup using jQuery (pass div) function fitDialog(e, data, big) { draggableFix(); var h = 400; var w = 400; if (big==true) { h=jQuery(window).height()*.6; w=jQuery(window).width()*.6; } if (jQuery("#dashConfigDialog").length==0) { jQuery(document.body).append('
'); } jQuery("#dashConfigDialog") //.html('
') .html(data) .dialog({ //autoOpen: true, modal: true, draggable: false, height: h, width: w, //position: ['right', 'top'], title: "Info", open: function() { jQuery(".ui-widget-overlay").css({background: "#000", opacity: 0.4}); jQuery(".ui-widget-overlay").bind('click',function(event){ jQuery("#dashConfigDialog").dialog('close'); }); }, close: function() { jQuery(".ui-widget-overlay").css({background: '', opacity: ''}); } }); } // retrive Documentation from Fit Server language file // (more detailed docs that can be created separately and no quote problems) function fitDialogFromKey(e,str) { jQuery.get( "&page=GetInfo&key="+str, function( data ) { fitDialog(e,data,true); }); } // get dialog info from a hidden div (old method) function fitDialogDiv(e, id) { fitDialog(e,jQuery(id).html(),true); } // get html to show from a url (such as com/other/docs function fitDialogUrl(e,url) { jQuery.get( url, function( data ) { fitDialog(e,data,true); }); } // info popup (override old method below) function fitInfo(e,str) { if (!e) var e = window.event; //jQuery('body').append('
'+ str.replace(/(['"])/g, "\\$1") +'
'); fitDialog(e,str); } function OLDfitInfo(e,str) { if (!e) var e = window.event; //str = str.replace(/
/i, "\r\n"); //alert(str); // open a blank window //var infoWin = window.open('', 'FitInfo', 'location=no,status=no,toolbar=no,scrollbars=yes,menubar=no,resizable=yes,toolbar=no,width=600,height=400'); //infoWin.document.write("Fit Information" + str); // use calendar stuff instead cause of popup blockers var info = "

" + "
com/other/info.gif\"> Info | com/other/close_black.gif\">
" + str + "

"; cal_show(e, "", info); } /// Calendar stuff var tipVisible=false var ie = document.all?1:0; var id="calendar" var calendar="-1"; var currentStatus = "Click to Drag"; var calendar_bgcolor = "lightgrey"; var cell_bgcolor = "lightgrey"; var cell_highlight = "#eeeeee"; var button_color = "#eeeeee"; var button_highlight = "#b0b0ff"; var today_bgcolor = "#b0b0ff"; var today_highlight = "#e0e0ff"; var close_bgcolor = "lightgrey"; var close_highlight = "#eeeeee"; var STARTUP; //for testing //var errors = window.open(); /***** * Following are variables for the * tooltip which can be customized *****/ var offsetX = -120; //horizontal offset of the tooltip //-120 var offsetY = -100; //vertical offset of the tooltip var tipWidth = 400; //width of the tooltip var tipHeight = 90; //approximate height of the tooltip months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; var calendarhtml="

"; calendarhtml+="
Default
"; calendarhtml+="

" var x,y; var isDrag=false; function getPosition(e) { e = e || window.event; var cursor = {x:0, y:0}; if (e.pageX || e.pageY) { cursor.x = e.pageX; cursor.y = e.pageY; } else { var de = document.documentElement; var b = document.body; cursor.x = e.clientX + (de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0); cursor.y = e.clientY + (de.scrollTop || b.scrollTop) - (de.clientTop || 0); } return cursor; } function cal_escape(evt) { var e = (window.event) ? window.event : evt; if (e.keyCode == 27) { cal_hide(); } } var desiredX = -1; var desiredY = -1; var clickToDrag = ''; //drag not working now 'Click to drag'; function cal_show(e, target, format) { if (STARTUP==undefined) { calendar_startup(); STARTUP==1; } var screenX= document.body.clientWidth; var screenY= document.body.clientHeight; var mouseX=0; //ie?event.x:e.clientX; var mouseY=0; //ie?event.y:e.clientY; var xpos=0; var ypos=0; if (ie) { var cursor = getPosition(event); // had problems with IE 7/8 with/without DOCTYPE mouseX=cursor.x; mouseY=cursor.y; xpos=cursor.x+offsetX; ypos=cursor.y+offsetY; } else { mouseX=e.clientX; mouseY=e.clientY; xpos=e.pageX+offsetX; ypos=e.pageY+offsetY; } //old way //var xpos=ie?event.x+offsetX+document.body.scrollLeft:e.pageX+offsetX; //var ypos=ie?event.y+offsetY+document.body.scrollTop:e.pageY+offsetY; if (!ie) { //IE dragging not working right now, //this is causing it to pop up in the //wrong spot if (offsetY < 0) { //check if hitting top of the screen if (mouseY < (-offsetY)) { //move the tip under the mouse ypos -= offsetY - 10; } } else { //check if hitting the bottom if (mouseY+offsetY+tipHeight > screenY) { //move the tip over the mouse ypos -= tipHeight + 20; } } if (mouseX + offsetX < 4) { //check the left side of the screen xpos += -(mouseX+offsetX) + 4 } else if (mouseX+offsetX+tipWidth > (screenX)) { //check the right side xpos += (screenX) - (mouseX+offsetX+tipWidth); } } //alert("T: " + target + " F: " + format + " E: " + e); if (target=="") { calendar.innerHTML = format; // simple info box. } else { getCalendar(target,format); } if (desiredX>0) { xpos = desiredX; desiredX=-1; } if (desiredY>0) { ypos = desiredY; desiredY=-1; } calendar.style.left=xpos+'px'; calendar.style.top=ypos+'px'; calendar.style.visibility = "visible"; calendar.style.width = "200px"; tipVisible=true; hideSelectBoxes(xpos,ypos); document.onkeypress= new Function("event","cal_escape(event);"); } function cal_hide() { tipVisible=false; if (calendar!="-1") { calendar.innerHTML = "
empty
"; // stop ajax updates to FIT calendar.style.visibility = "hidden"; } hideSelectBoxes(0,0); setOpacityOff(); } function cal_changeStatus(stat) { currentStatus = stat; var statusBar = document.getElementById("calendar_statusBar"); statusBar.innerHTML = currentStatus; } function cal_move(e) { if (calendar == "-1") { return true; } if (!e) e = window.event; // works on IE, but not NS (we rely on NS passing us the event) if (e) { if (isDrag) { var mouseX=ie?event.x:e.clientX; var mouseY=ie?event.y:e.clientY; var tx = parseInt(calendar.style.left+0); var ty = parseInt(calendar.style.top+0); calendar.style.left=tx + mouseX-x; calendar.style.top=ty + mouseY-y; x=mouseX; y=mouseY; hideSelectBoxes(tx + mouseX-x,ty + mouseY-y); return false; } } return true; } function cal_select(e) { var mouseX=ie?event.x:e.clientX; var mouseY=ie?event.y:e.clientY; isDrag=true; x=mouseX; y=mouseY; return false; } function cal_deselect() { isDrag=false; return false; } function populateCalendar(month, year, target, format) { var now = new Date(); var currentDate = -1; var firstDay = new Date(); firstDay.setDate(1); firstDay.setMonth(month); firstDay.setFullYear(year); var prevY = year - 1; var nextY = year + 1; var prevM = month - 1; var nextM = month + 1; var prevMY = year; var nextMY = year; if (prevM == -1) { prevM = 11; prevMY= prevY; } else if (nextM == 12) { nextM = 0; nextMY = nextY; } var todayAction = "populateCalendar("+now.getMonth()+","+now.getFullYear()+",'"+target+"','"+format+"');"; var todayText = "Jump to current date"; var targetOnChange = "if (document."+target+".onchange!=undefined) { document." + target + ".onchange(); }"; if (month == now.getMonth() && year == now.getFullYear()) { currentDate = now.getDate(); var fullYear = new String(now.getFullYear()); var fullDate = getDateFormat(currentDate,month,fullYear,year,format); todayAction = "document." + target + ".value='" + fullDate + "';cal_hide();"+targetOnChange+"return true;"; todayText = "Set date to today"; } var ret="

" + "
" + "
" + months[firstDay.getMonth()] + " " + firstDay.getFullYear() + " | X
" + "
" + "
" + "
" +"
" +"
<< | < | Today | > | >>
" + "
" + "
" + "
" + "
" + "
" + "
" + "
Sun | Mon | Tue | Wed | Thu | Fri | Sat
" + getDayGrid(firstDay,currentDate,target,format) + "
" + currentStatus + "
" + "

"; calendar.innerHTML = ret; } function getDayGrid(now,today,target,format) { var ret="
"; var fullDate; var currentDate=1; var month = now.getMonth(); var fullYear = new String(now.getFullYear()); var year = new String(fullYear.substr(2,2)); var lastDay = getLastDay(now.getMonth(),now.getFullYear()); var atLastDay=0; for(i=0;i<now.getDay();i++) { //add blank cells to beginning ret+="<td width=14% style='border:1px solid #aaa'> </td>"; } for(i=now.getDay();i<7;i++) { //rest of first week fullDate = getDateFormat(currentDate,month,fullYear,year,format); ret+=getDay(currentDate,today,fullDate,target); currentDate++; } ret+="</tr>"; for (j=1;j<6;j++) { //remaining weeks ret+="<tr>"; for(i=j*7;i<(j+1)*7;i++) { if (currentDate>lastDay) { atLastDay=1; break; } fullDate = getDateFormat(currentDate,month,fullYear,year,format); ret+=getDay(currentDate,today,fullDate,target); currentDate++; } ret+="
"; if (atLastDay) { break; } } return ret; } function getDay(currentDate,today,fullDate,target) { var background = cell_bgcolor; var highlight = cell_highlight; if (currentDate == today) { background = today_bgcolor;"#b0b0ff"; highlight = today_highlight; } var targetnodes = target.split('.'); // IE8 does not see target and causes errors here ?? var targetOnChange = "if (document."+targetnodes[0]+" && document."+target+".onchange!=undefined) { document." + target + ".onchange(); }"; return "" + "
" + currentDate +"
"; } function getCalendar(target,format) { var now = new Date(); populateCalendar(now.getMonth(),now.getFullYear(),target,format); } function getLastDay(month,year) { if (month == 1) { //Feb if ((year % 4) == 0) { if ((year % 100) == 0 && (year % 400) != 0) { return 28; } return 29; } return 28; } else if (month==0||month==2||month==4||month==6||month==7||month==9||month==11) { return 31; } return 30; } function getDateFormat(d,mon,fullYear,year,format) { var date; mon++; var day = "" + d; var month = "" + mon; if (day.length==1) { day = "0" + day; } if (month.length==1) { month = "0" + month; } switch (format) { case "MM\/dd\/yyyy" : date = month + "\/" + day + "\/" + fullYear; break; case "MM\/dd\/yy" : date = month + "\/" + day + "\/" + year; break; case "yyyy\/MM\/dd" : date = fullYear + "\/" + month + "\/" + day; break; case "dd\/MM\/yy" : date = day + "\/" + month + "\/" + year; break; case "dd\/MM\/yyyy" : date = day + "\/" + month + "\/" + fullYear; break; case "dd.MM.yyyy" : date = day + "." + month + "." + fullYear; break; case "dd-MM-yyyy" : date = day + "-" + month + "-" + fullYear; break; case "MM-dd-yyyy" : date = month + "-" + day + "-" + fullYear; break; default : date = fullYear + "\/" + month + "\/" + day; } return date; } function getAbsolute(obj) { var position = {x: obj.offsetLeft,y: obj.offsetTop}; if (obj.offsetParent) { var parent = getAbsolute(obj.offsetParent); position.x += parent.x; position.y += parent.y; } return position; }; function hideSelectBoxes(xpos,ypos) { if (!ie) return; var cal_x1 = xpos; var cal_y1 = ypos; var cal_x2 = cal_x1 + calendar.offsetWidth; var cal_y2 = cal_y1 + calendar.offsetHeight; genericHideSelectBoxes(cal_x1,cal_y1,cal_x2,cal_y2,tipVisible); } function genericHideSelectBoxes(cal_x1,cal_y1,cal_x2,cal_y2, isVisible) { if (!ie) return; var omitTags = calendar.getElementsByTagName("select"); var selectTags = document.getElementsByTagName("select"); var current = null; for (var i = 0; i < selectTags.length; i++) { current = selectTags[i]; var omit=false; for(var j=0;j<omitTags.length;j+=1){ if(current==omitTags[j]){ omit=true; break; } } if(omit){continue;} var position = getAbsolute(current); var sel_x1 = position.x; var sel_y1 = position.y; var sel_x2 = current.offsetWidth + sel_x1; var sel_y2 = current.offsetHeight + sel_y1; //errors.document.writeln("cy1:"+cal_y1+",cy2:"+cal_y2+"<br>sy1:"+sel_y1+",sy2:"+sel_y2+"
-----------
"); if (!isVisible || (cal_x1 > sel_x2) || (cal_x2 < sel_x1) || (cal_y1 > sel_y2) || (cal_y2 < sel_y1)) { //no overlap if (!current.visibility_record) { current.visibility_record = current.currentStyle.visibility; } current.style.visibility = current.visibility_record; } else { //need to hide if (!current.visibility_record) { current.visibility_record = current.currentStyle.visibility; } current.style.visibility = "hidden"; } } }; document.onmousemove=cal_move; function calendar_startup() { if (calendar != "-1") { // close the current one calendar.style.visibility = "hidden"; } calendar = setupCalendar(); calendar.innerHTML=calendarhtml; document.body.appendChild(calendar); //these should not be modified calendar.style.position="absolute"; calendar.style.visibility="hidden"; calendar.style.zIndex="1000"; } function setupCalendar() { //created the div element for the popup var divTag = document.createElement("div"); divTag.id = id; divTag.onmousedown = function (evt) { cal_select(evt || window.event); }; divTag.onmouseup = function () { cal_deselect(); }; return divTag; } //Object.extend(String.prototype, { //strip: function() { // return this.replace(/^\s+/, '').replace(/\s+$/, ''); //} //} function checkDate(e, target) { var format = ""; var dateVal = target.value; var relativeDate = false; dateVal = dateVal.trim(); if (dateVal.length!=0) { var lower = dateVal.toLowerCase(); if (lower.indexOf("+")>=0 || lower.indexOf("-")>=0 || // +/- 1 day lower.indexOf("y")>=0 || //year / yesterday lower.indexOf("m")>=0 || //month lower.indexOf("w")>=0 || //week lower.indexOf("d")>=0 || //day lower.indexOf("h")>=0 || //hour lower.indexOf("m")>=0 || //minute lower.indexOf("s")>=0 || //second lower.indexOf("t")>=0 || //tomorrow lower.indexOf("n")>=0 ) //now { // relative dates allow : Year / Month / Week / Day / Hour / MINute / Second / now / today / yesterday return true; } } if (dateVal.length!=0 && dateVal.length != format.length) { alert("Incorrect date format : " + dateVal + " ["+format+"]"); } else { // check slashes/dots/dashes are in same spots for (var i=0;i<dateVal.length;i++) { var c = dateVal.charAt(i); if (c=='/'||c=="."||c=="-") { if (format.charAt(i)!=c) { alert("Incorrect date format : " + dateVal + " ["+format+"]"); } } } } } // these functions are for updating selects on the fly function copyMenuToHelperArray(menu,helperArray){ if(menu&&menu.options&&typeof(helperArray)!="undefined"){ helperArray.length=0; for(var i=0;i<menu.options.length;i+=1){ helperArray[i]=menu.options[i]; if(helperArray[i].value==""){ helperArray[i].value=helperArray[i].text; } } } } // this function is used by the DropItemMenu in Passit // it was also copied to the Notify List code to look after selections when using search option, to reduce options // make sure options stay selected user shrinks and expands the selection list function copyMenuSelectedToHelperArray(menu,helperArray){ if(menu&&menu.options&&typeof(helperArray)!="undefined"){ // speed up page load. Most of the time people will not be searching .... if (menu.options.length == helperArray.length) return; var selectedHash = {}; var unselectedHash = {}; for(var i=0;i<menu.options.length;i+=1){ if (menu.options[i].selected==true) { selectedHash[menu.options[i].text]=1; } else { unselectedHash[menu.options[i].text]=1; } } for(var j=0;j<helperArray.length;j+=1){ if (selectedHash[helperArray[j].text]) { if (helperArray[j].selected==false) { helperArray[j].selected = true; } } else if (unselectedHash[helperArray[j].text]) { if (helperArray[j].selected==true) { helperArray[j].selected = false; } } } } } function copyHelperArraySelectedToMenu(helperArray,menu){ if(menu&&menu.options&&typeof(helperArray)!="undefined"){ for(var i=0;i<helperArray.length;i+=1){ //if(helperArray[i].selected){ // need to do unselect too for(var j=0;j<menu.options.length;j+=1){ if(helperArray[i].text==menu.options[j].text){ if (menu.options[j].selected != helperArray[j].selected) { menu.options[j].selected=helperArray[j].selected; } break; } } //} } } } function copyHelperArrayToMenu(menu,helperArray){ if(menu&&menu.options&&typeof(helperArray)!="undefined"){ menu.options.length=0; for(var i=0;i<helperArray.length;i+=1){ var optn=document.createElement("option"); optn.selected=helperArray[i].selected; optn.text=helperArray[i].text; optn.value=helperArray[i].value; optn.style.fontFamily = helperArray[i].style.fontFamily; //"monospace"; // titles for pickers optn.disabled=helperArray[i].disabled; optn.style.fontWeight = helperArray[i].style.fontWeight; // "bold"; optn.style.textDecoration = helperArray[i].style.textDecoration; // "underline"; menu.options.add(optn); } } } var helperArray=[]; var notifyGroupArray=[]; function updateMenu(specific,menu,helperArray,menuHelper,emptyMessage,startsWith){ if(menu&&menu.options&&typeof(helperArray)!="undefined"&&menuHelper){ if(helperArray.length==0&&menu.options.length>0){ copyMenuToHelperArray(menu,helperArray); } copyMenuSelectedToHelperArray(menu,helperArray); menu.options.length=0; var j=0; var help; if(startsWith===true){ help=new RegExp("^"+menuHelper.value,"i"); }else{ help=new RegExp(menuHelper.value,"i"); } for(var i=0;i<helperArray.length;i+=1){ if(helperArray[i].disabled==true || (helperArray[i].text.match(help)&&(extraCheck(specific,menu,helperArray[i].text)))) { var optn=document.createElement("option"); optn.selected=helperArray[i].selected; optn.text=helperArray[i].text; if(helperArray[i].value!=""){ optn.value=helperArray[i].value; }else{ optn.value=helperArray[i].text; } optn.style.fontFamily = helperArray[i].style.fontFamily; //"monospace"; // titles for pickers optn.disabled = helperArray[i].disabled; optn.style.fontWeight = helperArray[i].style.fontWeight; // "bold"; optn.style.textDecoration = helperArray[i].style.textDecoration; // "underline"; // these did not work : // optn.style = helperArray[i].style; // optn.css("font-family","monospace"); menu.options.add(optn); } } if(menu.options.length==0&&emptyMessage&&emptyMessage.style){ menu.style.display="none"; emptyMessage.style.display=""; }else{ menu.style.display=""; if(emptyMessage&&emptyMessage.style)emptyMessage.style.display="none"; } } } function extraCheck(specific,menu,option) { if (menu.name=='notifySelect'+specific) { var filter = eval('menu.form.notifyFilter'+specific); var groupArray = eval('notifyGroupArray'+specific); if (filter.selectedIndex==0) { // show all return true; } else { var group = false; for (i=0; i<groupArray.length; i++) { if (option==groupArray[i]) { group=true; } } if (filter.selectedIndex==1) { // show groups return group; } else { return !group; } } } else { return true; } } function submitFormOnEnter(textfield,e,button){ var keycode; if(window.event)keycode=window.event.keyCode; else if(e)keycode=e.which; else return true; if(keycode==13){ if(button&&button.click){ button.click(); return false; }else{ if(textfield&&textfield.form&&textfield.form.submit){ textfield.form.submit(); return false; }else{ return true; } } }else{ return true; } } //this function can be called from anonymous pages //to update a select field with the current list options function getFieldListOptions(trackNum, fieldId) { var mmContext = trackNum; jQuery.ajax({ type: 'GET', url: '<SUB URLADDWITHOUTCONTEXT>' + '?CONTEXT=' + trackNum + '&page=com.other.AnonAjaxUtil' + '&makeUniqueUrl=' + (new Date().valueOf()) + '&getFieldListOptions=' + fieldId, success: function(t) { try { eval(t); } catch (e) { alert("Problem retrieving list options for field "+fieldId+". Check Exception Log. " + e); } }, error: function(xhr, error) { alert("Problem retrieving list options for field "+fieldId+". Check Exception Log. " + error); } }); } function checkUniqueField(id, bugid) { var ret = true; var success = false; var fieldValue = ""; try { fieldValue = document.getElementById("field"+id).value; } catch (err) { return true; } jQuery.ajax({ type: 'GET', url: mmUrlAddNoContext + '&CONTEXT=' + mmContext + '&page=com.other.AjaxUtil' + '&checkUniqueField=' + id + '&checkUniqueFieldValue=' + fieldValue + '&checkUniqueFieldBug=' + bugid + '&makeUniqueUrl=' + (new Date().valueOf())+ '', async: false, success: function(t) { if (!success && t.length > 5) { alert(t); success = true; ret = false; } }, failure: function(t) { alert("Unique value check failed: "+t); } }); return ret; } // hello there function addRelationshipWarning() { if (""=="com.other.NewBug") { alert(""); return false; } else if (""=="com.other.ModifyBug") { return confirm(""); } return true; } function changeChart(obj,chartId) { var summaryChartImage = document.getElementById('summaryChartImage'); var link = "&page=com.other.JFreeReportChart&chartId="+chartId+"&chartType="+type; if (summaryChartImage) { var type = obj.options[obj.selectedIndex].value; summaryChartImage.src = link; } else { sv_show("Trial",link); } return true; } function showSummaryChart(obj) { var link = "&page=com.other.MainMenuSummary"; sv_show("Trial",link); return true; } var checkedHistory = new Array(); function toggleHistoryCheckbox(boxId) { if (checkedHistory[boxId]) { checkedHistory[boxId] = false; } else { checkedHistory[boxId] = true; } submitHistoryCheckboxes(); } function submitHistoryCheckboxes() { var checkedBoxes = ""; for (var i=0;i<checkedHistory.length;i++) { if (checkedHistory[i]) { checkedBoxes += " " + i; } } document.getElementById("checkedHistoryCheckboxes").value = checkedBoxes; return true; } function showHistoryCheckboxes(show) { var c = 0; var check = document.getElementById("historyCheck"+c); while (check) { if (show) { check.style.display = ""; } else { check.style.display = "none"; } c++; check = document.getElementById("historyCheck"+c); } } function showOptionsMenu(event,baseName) { //var ret = ""; var baseDiv=document.getElementById(baseName); if (baseDiv) { //log(baseName+ " : ["+ event.clientX + "," + event.clientY+"] ["+ // event.offsetLeft+ "," + event.offsetTop+"]" ); //log("target : ["+ event.target.clientX + "," + event.target.clientY+"] ["+ // event.target.offsetLeft+ "," + event.target.offsetTop+"]" ); //log("baseDiv.hideEvent: "+baseDiv.hideEvent); if(baseDiv.hideEvent!=null){ clearTimeout(baseDiv.hideEvent); } baseDiv.hideEvent=null; var e=event.target||event.srcElement; //var x=0; //var y=0; while(e!=null) { //log("showOptionsMenu " + baseDiv.id +":" +e.id||0); if (e.id) { //ret += "["+e.id+"]"; if (baseDiv.id == e.id) { //alert("returning : "+ret); return; } //log("add: "+e.id +" - "+e.offsetTop); //x+=e.offsetLeft; //y+=e.offsetTop; } e=e.offsetParent; } var scrollX = (window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft || 0); var scrollY = (window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0); baseDiv.style.left=(event.clientX+scrollX+5)+'px'; baseDiv.style.top=(event.clientY+scrollY+5)+'px'; //baseDiv.style.left=x+'px'; //baseDiv.style.top=y+'px'; baseDiv.style.display=""; } //alert(ret); } function hideOptionsMenu(evt, baseName, when) { var baseDiv=document.getElementById(baseName); if(baseDiv){ if (when!=0 && baseDiv.hideEvent==null) { var str = "hideOptionsMenu(window.event,'"+baseName+"',1000);"; baseDiv.hideEvent=setTimeout(str,when); } else { baseDiv.style.display="none"; } } } var qmenu=-1; var lastClickTime=0; function quickMenu(event,context,bsId) { if (qmenu==-1) { qmenu = new QuickMenu(event); } qmenu.setContext(context); qmenu.setBsId(bsId); //log(event.timeStamp-lastClickTime); if (event.type=="click" && event.timeStamp-lastClickTime<500) { qmenu.quickView(event); hideOptionsMenu(event,"rowOptionsMenu",0); } else { showOptionsMenu(event,"rowOptionsMenu"); } if (event.timeStamp) { lastClickTime=event.timeStamp; } //log(lastClickTime + " : " + event.type); hideOptionsMenu(event,"rowOptionsMenu",2000); // so it does not stay up forever return qmenu; } function QuickMenu(event) { var context = -1; var bsId = -1; this.setContext=function(id){this.context=id}; this.getContext=function(){return this.context}; this.setBsId=function(id){this.bsId=id}; this.getBsId=function(){return this.bsId}; var borderTopStyle=""; var html="\ <div id=rowOptionsMenu style=\"display:none;position:absolute;background:white;\" onmouseout=\"hideOptionsMenu(event,'rowOptionsMenu',500);\">"; if ("".length>0) { borderTopStyle = "style=\"border-top:none;\""; html += "\

"; } html += "\

</table</div>\

</table</div>\

</table</div>\

"; var div = document.createElement('div'); div.innerHTML = html; document.body.appendChild(div) this.quickView=function(e) { quickView(e,this.getContext(),this.getBsId(),"IFRAME","com.other.SimpleViewBug"); // sv_show } this.quickEdit=function(e) { quickView(e,this.getContext(),this.getBsId(),"IFRAME","com.other.SimpleModifyBug"); // sv_show } this.quickGrab=function(e){ desiredX=300; desiredWidth=600; desiredHeight=150; //sv_show(e,"&page=com.other.QuickGrab&CONTEXT="+this.getContext()+"&mId="+this.getBsId()); fitPopup(e,"link:&page=com.other.QuickGrab&CONTEXT="+this.getContext()+"&mId="+this.getBsId()); //jQuery().colorbox({opacity:"0.50",width:"60%",height:"60%",href:"&page=com.other.QuickGrab&CONTEXT="+this.getContext()+"&mId="+this.getBsId()}); hideOptionsMenu(event,"rowOptionsMenu",0); } this.quickAssign=function(e){ desiredX=300; desiredWidth=800; desiredHeight=500; //sv_show(e,"&page=com.other.QuickAssign&CONTEXT="+this.getContext()+"&bugId="+this.getBsId()); fitPopup(e,"link:&page=com.other.QuickAssign&CONTEXT="+this.getContext()+"&bugId="+this.getBsId()); //jQuery().colorbox({opacity:"0.50",width:"60%",height:"60%",href:"&page=com.other.QuickAssign&CONTEXT="+this.getContext()+"&bugId="+this.getBsId()}); hideOptionsMenu(event,"rowOptionsMenu",0); } this.quickChange=function(e){ //var baseDiv=document.getElementById("rowOptionsMenu"); //if(baseDiv){ // trying a different way to show the popup (vs link:) fitPopup(e,"\ \ \ \

: "+ this.bsId + "

\

: "+ "Close" + "

\

: "+ "Me" + "

\

: Some Text

\

\ \
\ \ "); hideOptionsMenu(event,"rowOptionsMenu",0); //} } return(html); } var desiredWidth = -1; var desiredHeight = -1; function fitPopup(e,str){ if(!e)e=window.event; if(e&&typeof(str)=="string"){ if (str.substring(0,5)=="link:") { str = str.substring(5); if (desiredWidth<0) { desiredWidth=600; } if (desiredHeight<0) { desiredHeight=1000; } str = "

"; desiredWidth=-1; desiredHeight=-1; } else { str = "\

\
\ "+str+"

"; } if (cal_closer=="-1") { cal_closer_startup(); } //cal_hide(); // stop AJAX on previous sv_show setOpacity(5); cal_show(e,"",str); } } // MAIN MENU Quick View // function for clicking an issue function doNav(evt, context, rowId, type) { var e = (window.event) ? window.event : evt; var targ; if (e.target) { targ = e.target; } else if (e.srcElement) { targ = e.srcElement; } //if (targ.nodeType == 3) { // defeat Safari bug // targ = targ.parentNode; //} if (targ.parentNode) { //alert("id:"+targ.id+" : "+targ.parentNode.className); if (targ.parentNode.className.indexOf("menurow")>=0) { // child of row, so regular links still work if (targ.id.indexOf("idCol")==0) { // not the id column, cause too easy to click just off it var trans = document.getElementById("transC"+context+"-"+rowId); //alert(trans.offsetLeft + ":" + e.clientX); if (trans==null || trans.offsetLeft >= e.clientX) { return; } } var index = rowId.indexOf("-"); if (index>-1) { // in case row field, then start with parent of group of tr rowId = rowId.substr(0,index); } //quickMenu(evt,context,rowId); //return; var page = ""; quickView(evt,context,rowId,type,page); //} else { //hideOptionsMenu(evt,"rowOptionsMenu",0); } } } function closeParentQuickView() { if (parent.sv=="-1") { return false; } else { parent.sv_hide(); } return true; } function quickView(evt, context, rowId, type, page) { if (type=="OPEN") { // in case modifying data which may lose changes var ret = confirm("Your selection will now take you to a new page? Choose cancel to open in quickview iframe instead!"); if (ret==false) { type = "IFRAME"; // so no data is lost } } if (type == "IFRAME") { if (sv!="-1") { sv_hide(); // stop AJAX on previous sv_show } var link = mmUrlAddNoContext+"&CONTEXT="+context+"&page="+page+"&bugId="+rowId; sv_show(rowId,link); } else if (type == "OPEN"){ page = page.replace("Simple",""); document.location = mmUrlAddNoContext+"&CONTEXT="+context+"&page="+page+"&bugId="+rowId; } } function getElement(aID) { return (document.getElementById) ? document.getElementById(aID) : document.all[aID]; } function getIFrameDocument(aID){ var rv = null; var frame=getElement(aID); // if contentDocument exists, W3C compliant (e.g. Mozilla) if (frame.contentDocument) rv = frame.contentDocument; else // bad Internet Explorer ;) rv = document.getElementById(aID).document; return rv; } function adjustMyFrameHeight() { if(typeof (window.peterTesting) == 'function') { return peterTesting(); } var frame = getElement("sv_iframe"); var frameDoc = getIFrameDocument("sv_iframe"); if (navigator.appName == "Microsoft Internet Explorer") { //make window height the minimum. IE8 showing half window when only a few issues - make at least window height var height = frameDoc.body.offsetHeight; if (height<frameDoc.body.scrollHeight) { height = frameDoc.body.scrollHeight+30; } frame.style.height = height+'px'; } else { frame.style.height = (frameDoc.body.offsetHeight+30)+'px'; } } var cal_closer="-1"; function cal_closer_startup() { cal_closer = setupSV(); cal_closer.innerHTML = //"<table style='background-color:gray;' width=100% height=50>
" + ""; //""; //"

"; document.body.appendChild(cal_closer); //document.onmousemove=cal_minimize; //these should not be modified cal_closer.style.position="absolute"; cal_closer.style.visibility="hidden"; cal_closer.style.zIndex="2000"; } function cal_showCloser() { if (calendar!="-1" && calendar.style.visibility=="visible" && calendar.innerHTML.indexOf("cal_hide()")<0 ) { var top = ie?document.documentElement.scrollTop:window.pageYOffset; if ( top < calendar.offsetTop) { top = calendar.offsetTop; } top += ie?10:15; cal_closer.style.top = top +"px"; cal_closer.style.left = calendar.offsetLeft+10+"px"; cal_closer.style.visibility="visible"; window.setTimeout("cal_showCloser()", 100); } else { cal_closer.style.visibility="hidden"; window.setTimeout("cal_showCloser()", 500); } } // allow user to press escape to close calendar window/popup function cal_escape(evt) { var e = (window.event) ? window.event : evt; if (e.keyCode == 27) { cal_hide(); } } function initializeTabs(def) { if (defaultTab) { def = defaultTab } var anchor = unescape(document.location.hash.substring(1)); if (anchor && anchor.length>0) { selectSubTab(anchor); } else { selectSubTab(def); } } function addCustomRow(prefix) { var count = document.getElementById(prefix+"RowCount").value; var max = document.getElementById(prefix+"RowMax").value; count++; displayCustomRows(prefix,count,max); document.getElementById(prefix+"RowCount").value=count; } function displayCustomRows(prefix,count,max) { for(c=1;c<=max;++c) { var element = document.getElementById(prefix+"Row"+c); if (c<=count && element.getAttribute("data-rowhidden") != "1") { element.style.display = ""; } else { element.style.display = "none"; } } if (count==max) { // one should be visible if more can be added var elementImg = document.getElementById(prefix+"AddImage"); elementImg.style.visibility = 'hidden'; } } function clearCustomRow(prefix,fields,row) { for (f=1;f<=fields;f++){ var input = document.getElementById(prefix+"Row"+row+"Cell"+f); if (input.type=="checkbox") { input.checked=false; } else { input.value=''; } } var rowObj = document.getElementById(prefix+"Row"+row); var rowCount = document.getElementById(prefix+"RowCount").value; if (rowCount>1) { rowObj.style.visibility = 'hidden'; } if (prefix=="customSale") { doSaleCalculations(prefix); } else if (prefix=="customLease") { doLeaseCalculations(prefix); } } //select related item and place value in custom row field function addValueAsCustomRow(prefix,popField,val,unique) { var count = document.getElementById(prefix+"RowCount").value; var firstBlank = -1; for (var i=1;i<=count;i++) { fieldVal = document.getElementById(prefix+"Row"+i+"Cell"+popField).value; if (unique && val == fieldVal) { return; } if (firstBlank == -1 && fieldVal.length == 0) { firstBlank = i; } } if (firstBlank == -1) { addCustomRow(prefix); firstBlank = Number(count)+1; } document.getElementById(prefix+"Row"+(firstBlank)+"Cell"+popField).value = val; } ///////// // Logic for relationship picker... ///////// function callMe(parm1,parm2,parm3,parm4) { alert("Call Me!" + parm1 + " " + parm2 + " " + parm3 + " " + parm4 + " " + parm2.id); } function getForm() { var form; if (typeof document.entry_form == "undefined") { form = document.BulkForm; } else { form = document.entry_form; } return form; } function getFormField(fieldname) { var field = getForm()[fieldname]; if (typeof(field)=='undefined') { field = document.getElementById(fieldname); } return field; } function removeRelValue(hiddenName,val) { var newValue = ""; var startValue = ""; var viewBug = false; if (typeof(getForm()[hiddenName])=='undefined') { viewBug = true; // passing as data-value in div startValue = document.getElementById(hiddenName).dataset.value; } else { startValue = getForm()[hiddenName].value; } var tokens = startValue.split(" "); for (var i=0; i<tokens.length; i++) { if (val!=tokens[i]) { if (newValue.length>0) { newValue += " "; } newValue += tokens[i]; } } if (viewBug==false) { getFormField(hiddenName).value = newValue; } return newValue; } function setRelDisplay(id,info,append) { var display = "display" + id; var innerHTML = ""; if (append==true) { //innerHTML = document.getElementById(display).innerHTML; } innerHTML += info; document.getElementById(display).innerHTML = innerHTML; } function pickRel(divName) { var element = document.getElementById(divName); element.style.display = ""; /* var fieldName = "thing"; // FROM SUGGEST... //we need to add the div to the fields first... var field = getForm()[fieldName]; field.id = fieldName; var fieldDiv = document.createElement("div"); fieldDiv.id = fieldName+"_choices"; fieldDiv.className = "autocomplete"; field.parentNode.appendChild(fieldDiv); //next we're going to add the autocomplete call... new Ajax.Autocompleter(fieldName, fieldName+"_choices", "", {parameters:'page=com.other.PickRelationship&field='+fieldName, afterUpdateElement : callMe}); */ } function closePicker(divName) { var element = document.getElementById(divName); element.style.display = "none"; } function getPickerTags(selectObj) { if (selectObj && selectObj.getAttribute('pickertags')) { return '&pickertags='+selectObj.getAttribute('pickertags'); } return ""; } function removeRel(field,id,parms) { var hiddenName = "field" + field; if (field.indexOf("m")==0) { hiddenName = field; // mParent field } var value = removeRelValue(hiddenName,id); ajaxUpdate(parms+'&selected=' + value + '&displayDiv=display' + field + getPickerTags(getForm()[hiddenName])); return false; } function updateRelValue(hiddenName,value,append) { var hObj = getForm()[hiddenName]; if (hObj.getAttribute("MULTIPLE")!=1) { hObj.value = ""; } var tokens = hObj.value.split(" "); if (tokens.indexOf(value)<0) { var newValue = ""; if (append==true) { var oldValue = hObj.value; if (oldValue.length>0) { oldValue += " "; } newValue += oldValue; } newValue += value; hObj.value = newValue; } return hObj.value; } function selectRel(selectObject,divName,displayName,hiddenName) { var value = getForm()[hiddenName].value; var setValue = selectObject.value; if (setValue.length != 0) { value = setValue; } closePicker(divName); for (x=0;x<selectObject.length;x++) { if (selectObject[x].selected) { //if (value.length>0) value += " "; value = updateRelValue(hiddenName,selectObject[x].value,true); selectObject[x].selected = false; } } ajaxUpdate('&selected=' + value + '&displayDiv=' + displayName + getPickerTags(getForm()[hiddenName])); afterSelectRel(value,hiddenName); } function afterSelectRel(selectedValue,fieldName) { //to override } function refreshRel(baseId,divName,displayName,hiddenName) { value = updateRelValue(hiddenName,"",true); ajaxUpdate('&selected=' + value + '&displayDiv=' + displayName + getPickerTags(getForm()[hiddenName])); } function updateTrackRelationship(bugId) { try { //automatically add bugId to track relationship pickerClearSearch(updateRelationship,false); var selector = document.getElementById("relPickerSelect"+updateRelationship); //selector.value = bugId; for (x=0;x<selector.length;x++) { if (selector[x].value == bugId) { selector[x].selected = true; } } selectRel(selector,'relPicker'+updateRelationship,'display'+updateRelationship,'field'+updateRelationship); } catch (err) {} } function ajaxUpdate(args) { var pickPage = '&page=com.other.PickRelationship'; if (args.indexOf("LOCAL")>=0) { pickPage = '&page=com.other.PickLocalTrack'; } jQuery.ajax({ type: 'get', url: mmUrlAddNoContext + '&CONTEXT=' + mmContext + pickPage + '&ajax=1' + '&makeUniqueUrl=' + (new Date().valueOf())+ args, success: function(t) { if (t.length > 10) { var ret = eval(t); } else { } }, failure: function(t) { } }); } function pickerSearchAll(id){ var searchOptions = document.getElementById("relPicker"+id+"SearchOptions"); searchOptions.style.display = "none"; var search = document.getElementById("relPickerSearch"+id); var searchInfo = document.getElementById("relPicker"+id+"SearchInfo"); searchInfo.innerHTML = 'Searching all s for "' + search.value + '"...'; var showClosed = ""; if (document.getElementById("relPicker"+id+"ShowClosed").checked) { showClosed = "&showClosed=on"; } ajaxPickerSearchAll('&search=' + search.value + '&field=' + id + showClosed); } function pickerClearSearch(id){ pickerClearSearch(id,true); } function pickerClearSearch(id, async){ ajaxPickerSearchAll('&field=' + id + '&clear=1', async); } function ajaxPickerSearchAll(args) { ajaxPickerSearchAll(args, true); } function ajaxPickerSearchAll(args, async) { var pickPage = '&page=com.other.PickSearchAll'; if (args.indexOf("Local")>=0 || args.indexOf("field=mParent")>=0) { pickPage = '&page=com.other.PickLocalSearchAll'; } jQuery.ajax({ type: 'GET', async: async, url: mmUrlAddNoContext + '&CONTEXT=' + mmContext + pickPage + '&ajax=1' + '&makeUniqueUrl=' + (new Date().valueOf())+ args, success: function(t) { if (t.length > 10) { var ret = eval(t); } else { } }, failure: function(t) { } }); } function updatePickerSearchOptions(id) { var search = document.getElementById("relPickerSearch"+id); var searchOptions = document.getElementById("relPicker"+id+"SearchOptions"); var clearButton = document.getElementById("relPicker"+id+"ClearButton"); if (search.value.length > 0) { searchOptions.style.display = ""; } else if (clearButton.style.display == "none") { searchOptions.style.display = "none"; } } function pickerCheckEnter(e, id){ //make sure the form isn't submitted it user presses enter in search bar e = e || event; if ((e.keyCode || e.which || e.charCode || 0) == 13) { pickerSearchAll(id); return false; } return true; } function changeThumbnailImage(bsId) { //var e = (window.event) ? window.event : evt; //alert("changeThumbnailImage : "+bsId); //var targ; //if (e.target) { // targ = e.target; //} else if (e.srcElement) { // targ = e.srcElement; //} //var bsId = targ.id; //alert("bsId:"+bsId); var tnImg = document.getElementById("thumbnailImg"+bsId); var tnSelect = document.getElementById("thumbnailSelect"+bsId); //alert("link: "+tnSelect.value); tnImg.src = tnSelect.value; } function childControl(evt, id) { var e = (window.event) ? window.event : evt; var imgObj = document.getElementById(id); var img = "com/other/img/expand.gif"; //alert(imgObj.src + " vs " + img); if (imgObj.src.indexOf(img)>=0){ img = "com/other/img/collapse.gif"; } imgObj.src = img; id = id.replace("childControl",""); //alert("looking for " + id); //var row = document.getElementById(id); //if (row) { // alert("parentPath " + row.getAttribute('parentpath')); //} //row.onmouseout = new Function("rollOffAll('"+rowId+"');"); //rollOnAll(evt,rowId); var elements = document.getElementsByTagName("tr"); for(i=0;i<elements.length;++i) { var pp = elements[i].getAttribute('parentpath'); // alert(elements[i] + " : " + pp +" vs "+id); //if (pp && pp.id) { //} if (pp!=null && pp.indexOf(id+"-")>=0) { var root = pp.substring(0,pp.lastIndexOf("-")); var disp = ""; var nodes = root.split("-"); var check = ""; for (var n=0; n<nodes.length; n++) { if (check.length>0) check += "-"; check += nodes[n]; var checkpp = document.getElementById("childControl"+check); if (checkpp && checkpp.src.indexOf("expand")>0) { disp = "none"; break; } } elements[i].style.display = disp; //alert(elements[i].id); if (elements[i].id.indexOf("-CHILD")>=0) { childControlRC(elements[i].id,disp); } } //elements[i].style.display = display; // alert("CHANGE!"); } } function childControlRC(id, disp) { // look after any row fields for(var r=1; r<2; r++) { var rc = document.getElementById(id+"-RC"+r); //alert("looking for :"+id+"-RC"+r +" - "+rc); if (!rc) { break; // if no row column, then do not keep looking } rc.style.display = disp; } } // gets rid of dropdown menu on handhelds function iPadMenuClose(obj) { while (obj && obj.className.indexOf("dropdown_")<0) { obj=obj.parentNode; } obj.className += " hide"; setTimeout(function(_this) { _this.className = _this.className.replace(" hide",""); }, 200, obj); } function showErrorMessage(error) { log(error); // $(errorMessage") is not returning the right div object in ModifyBug, had to change to getElementById var errordiv = document.getElementById("errorMessage"); if (errordiv) { if (error.length > 0) { dumpDebug("showErrorMessage: "+error); error="

"+error+"

"; } else { // only add a blank message if it is not already blank dumpDebug("showEM:["+error+"]"); if (errordiv.innerHTML.length==0) { //alert(errordiv.innerHTML.length); return; } } //error.escapeHTML(); if (error.length > 1000) { error = error.substring(0,100); } error.sub('"', 'Q'); error.sub('"', 'q'); errordiv.innerHTML = error; errordiv.style.visibility="visible"; errordiv.style.zIndex="1000"; } } // you can override this with AjaxDebugger function dumpDebug(message,e) { } // this will get the current value of a field for RO and Edit screens function fitFieldValue(str) { if (document.getElementById(str).value) { return document.getElementById(str).value; } return document.getElementById(str).innerHTML; } // document.div.name may not work function getDivByAttributeName(name) { var divs = document.getElementsByTagName("div"); for(var i=0;i<divs.length;i++){ if (divs[i].getAttribute("name") == name) { return divs[i]; } } } function findCurrentObj(form,key) { var obj = document.getElementById(key); if (!obj) { obj= eval("document."+form+"."+key); if (!obj) { obj = getDivByAttributeName(key); } } return obj; } function findCurrentValue(form,key, def) { var ret = def; var obj = document.getElementById(key); if (obj && obj.value) { ret = obj.value; } else { var obj = eval("document."+form+"."+key); if (!obj) { obj=getDivByAttributeName(key); // since name is not a proper tag } if (obj && obj.value) { ret = obj.value; } else if (obj) { ret = obj.innerHTML; ret = ret.replace(" ",""); // readonly pages } } return ret; } var filterMenu; var reportMenu; function initSkin11Menus() { initSkin11Menu("Filter",filterMenu); initSkin11Menu("Report",reportMenu); } function clearSkin11Menus() { jQuery(".ReportSubmenu").hide(); jQuery(".FilterSubmenu").hide(); } function initSkin11Menu(name,menu) { jQuery(function() { jQuery( "#"+name+"MenuLabel" ).click(function() { clearSkin11Menus(); menu = jQuery( this ).parent().next().show().position({ my: "left top", at: "left bottom", of: this }); jQuery( document ).one( "click", function() { menu.hide(); }); return false; }).parent().next().hide().menu(); }); var sub = "."+name+"Submenu"; jQuery(sub).mouseout( function(){ jQuery(sub).hide(); }); jQuery(sub).mouseover( function(){ jQuery(sub).show(); }); } function allNumeric(label, inputtxt) { var numbers = /^[0-9]+$/; if(!inputtxt.value.match(numbers)) { alert(label+': Please input numeric characters only'); inputtxt.focus(); return false; } } // Project Mask Stuff function toggleProjectMask() { jQuery("#projectMaskDiv").toggle("slide",500); return false; } function toggleProjectMaskConfig() { jQuery("#projectMaskConfigDiv").toggle("slide",500); return false; } function addToProjectMaskBase() { jQuery("#masksAvailable option:selected").each(function() { if (jQuery("#FilterMask_ProjectSelected option[value=\""+jQuery(this).val()+"\"]").length<=0) { jQuery("#FilterMask_ProjectSelected")[0].options.add( new Option( jQuery(this).text(), jQuery(this).val() ) ); } }); } function removeFromProjectMaskBase() { var selectedIndex = jQuery("#FilterMask_ProjectSelected").prop("selectedIndex"); if (selectedIndex==0) selectedIndex=1; jQuery("#FilterMask_ProjectSelected option:selected").remove(); jQuery("#FilterMask_ProjectSelected option:nth-child("+selectedIndex+")").attr("selected",true); } function clearProjectMaskBase() { jQuery('#FilterMask_ProjectSelected') .find('option') .remove(); return false; } function updateProjectMask() { var extra = ""; jQuery('#FilterMask_ProjectBase').find('option').remove(); var options=0; jQuery('#FilterMask_ProjectSelected option').each(function() { jQuery('#FilterMask_ProjectBase').append(jQuery("<option>") .attr("value",this.value) .text(this.text) .attr("selected",true)); options++; }); if (options==0) { // empty base set needs a parameter jQuery('#FilterMask_ProjectBase').append(jQuery("") .attr("value","_NONE") .text("None") .attr("selected",true)); } jQuery('#FilterMaskConfigForm').submit(); return true; } // create reverse function jQuery.fn.reverse = function() { return this.pushStack(this.get().reverse(), arguments); }; function projectBaseUp() { jQuery("#FilterMask_ProjectSelected option:selected").each(function() { jQuery(this).insertBefore(jQuery(this).prev()); }); } function projectBaseTop() { jQuery("#FilterMask_ProjectSelected option:selected").reverse().each(function() { jQuery(this).insertBefore('#FilterMask_ProjectSelected option:first-child'); }); } function projectBaseDown() { jQuery("#FilterMask_ProjectSelected option:selected").reverse().each(function() { jQuery(this).insertAfter(jQuery(this).next()); }); } function projectBaseBottom() { jQuery("#FilterMask_ProjectSelected option:selected").each(function() { jQuery(this).insertAfter("#FilterMask_ProjectSelected option:last-child"); }); } // JQUERY UI COMBOBOX Stuff (function( jQuery ) { jQuery.widget( "custom.combobox", { _create: function() { this.wrapper = jQuery( "" ) .addClass( "custom-combobox" ) .insertAfter( this.element ); this.element.hide(); this._createAutocomplete(); this._createShowAllButton(); }, _createAutocomplete: function() { var selected = this.element.children( ":selected" ), value = selected.val() ? selected.text() : ""; this.input = jQuery( "" ) .appendTo( this.wrapper ) .val( value ) .attr( "title", "" ) .addClass( "custom-combobox-input ui-widget ui-widget-content ui-state-default ui-corner-left" ) .autocomplete({ delay: 0, minLength: 0, source: jQuery.proxy( this, "_source" ) }) .tooltip({ tooltipClass: "ui-state-highlight" }); this._on( this.input, { autocompleteselect: function( event, ui ) { ui.item.option.selected = true; this._trigger( "select", event, { item: ui.item.option }); }, autocompletechange: "_removeIfInvalid" }); }, _createShowAllButton: function() { var input = this.input, wasOpen = false; jQuery( "" ) .attr( "tabIndex", -1 ) .attr( "title", "Show All Items" ) .tooltip() .appendTo( this.wrapper ) .button({ icons: { primary: "ui-icon-triangle-1-s" }, text: false }) .removeClass( "ui-corner-all" ) .addClass( "custom-combobox-toggle ui-corner-right" ) .mousedown(function() { wasOpen = input.autocomplete( "widget" ).is( ":visible" ); }) .click(function() { input.focus(); // Close if already visible if ( wasOpen ) { return; } // Pass empty string as value to search for, displaying all results input.autocomplete( "search", "" ); }); }, _source: function( request, response ) { var matcher = new RegExp( jQuery.ui.autocomplete.escapeRegex(request.term), "i" ); response( this.element.children( "option" ).map(function() { var text = jQuery( this ).text(); if ( this.value && ( !request.term || matcher.test(text) ) ) return { label: text, value: text, option: this }; }) ); }, _removeIfInvalid: function( event, ui ) { // Selected an item, nothing to do if ( ui.item ) { return; } // Search for a match (case-insensitive) var value = this.input.val(), valueLowerCase = value.toLowerCase(), valid = false; this.element.children( "option" ).each(function() { if ( jQuery( this ).text().toLowerCase() === valueLowerCase ) { this.selected = valid = true; return false; } }); // Found a match, nothing to do if ( valid ) { return; } // Remove invalid value this.input .val( "" ) .attr( "title", value + " didn't match any item" ) .tooltip( "open" ); this.element.val( "" ); this._delay(function() { this.input.tooltip( "close" ).attr( "title", "" ); }, 2500 ); this.input.autocomplete( "instance" ).term = ""; }, _destroy: function() { this.wrapper.remove(); this.element.show(); } }); })( jQuery ); var combosHash = {}; function toggleCombobox(event, id) { if (combosHash[id]==null) { jQuery( "#"+id ).combobox(); combosHash[id]=1; } else { jQuery( "#"+id ).combobox("destroy"); //jQuery( "#"+id ).parent().find("input.ui-autocomplete-input").autocomplete("option", "disabled", true).prop("disabled",true); //jQuery( "#"+id ).parent().find("a.ui-button").button("disable"); delete combosHash[id]; } } function initCombos() { // jQuery(function() { // jQuery( ".combobox" ).combobox(); // }); } /* profile preferences - code to call EditProfileAjax */ function ajaxProfilePrefs(action,fromPage) { var request = mmUrlAdd + '&page=com.other.EditProfileAjax' + '&makeUniqueUrl=' + (new Date().valueOf()) + '&fromPage='+fromPage + '&action='+action; if (typeof(editingRS) != 'undefined') { request += '&rs=' + editingRS; } jQuery.get(request,function (data) { if (data.length > 10) { //set columnWrapper to the above here //var ret = eval(data); //var wrapper = document.getElementById(action+"Wrapper"); //wrapper.innerHTML = data; jQuery("#"+action+"Wrapper").html(data); } setupColumns(); jQuery("#additionalPreferences").appendTo("#moveAdditional"); jQuery("#hedit").accordion({ collapsible: true }); // few differences on the report prefs vs column prefs if (typeof(reportPrefs) != 'undefined') { jQuery("
Save As Defaults for New Reports").insertAfter(jQuery("#fieldList_submits")); jQuery("#fieldList_submits").hide(); // submit only with rest of report //jQuery("#prefsExampleTitle").text("Example View Before Changes"); } }) .fail(function() { alert("Problem connecting to server!"); }); } function togglemIndex () { var div = document.getElementById("mIndexDiv"); if (div.style.display=='none') { div.style.display='inline'; } else { div.style.display='none'; } } //Number.prototype.getDecimals = function ( decDigCount ) { // return this.toFixed(decDigCount); //} function fixDigits(num){ var value=new String(num.toFixed(2)); if(value.indexOf(".")<0)value+=".00"; if(value.indexOf(".")==(value.length-2))value+="0"; return "$ "+value; } var vMin = 384-1; // -1 so mobile navbar interface shows var vMax = 1536; var viewportWidth = vMin; var viewportScale = 0.8; var viewportMinScale = 0.3; var viewportMaxScale = 2.0; function getSafeViewport() { if (typeof document.querySelector == 'function') { // this was not working in ie8 (ESA) return document.querySelector("meta[name=viewport]"); } else { return document.getElementById("viewport"); } } function toggleViewport ( reverse ) { var width=viewportWidth; if (reverse==false) { width=width+vMin; if (width>vMax) return; } else { width=width-vMin; if (width<vMin) return; } setViewport(width); } function setViewport(width) { viewportWidth=width; var content = 'width='+viewportWidth+ ', initial-scale='+viewportScale+', minimum-scale='+ viewportMinScale+', maximum-scale='+ viewportMaxScale; //alert(content); var viewport = getSafeViewport(); if (typeof(viewport)!="undefined" && viewport!=null) { viewport.setAttribute('content', content); } } jQuery(document).ready(function(jQuery) { if ("<SUB onPage>"=="com.other.Default" || ""=="com.other.AlceaLogin") { viewportScale=1.0; viewportWidth=vMin; } else { viewportWidth=vMin*2; } setViewport(viewportWidth); }); var holdContent = ""; function setScales(scale, minScale, maxScale) { if (viewportWidth<0) { viewportWidth = jQuery(window).width(); } //if (viewportWidth>1500) { // viewportWidth = 1500; // viewportScale = 0.4; // //} viewportScale = scale; viewportMaxScale = maxScale; viewportMinScale = minScale; var content = 'width='+viewportWidth+ ', initial-scale='+viewportScale+', minimum-scale='+ viewportMinScale+', maximum-scale='+ viewportMaxScale; //alert(content); //holdContent = content; //$(".navbar-collapse").collapse('hide'); //jQuery('.dropdown.open .dropdown-toggle').dropdown('toggle'); //jQuery(document.body).click(); //jQuery('.dropdown.open .dropdown-toggle').fade('slow'); //window.setTimeout("testit()", 1000); var viewport = getSafeViewport(); if (typeof(viewport)!="undefined" && viewport!=null) { viewport.setAttribute('content', content); } } //(function($){ //$(document).ready(function() { //$('.dropdown-toggle[href="#"]').dropdown(); //}); //})(jQuery); function testit() { var viewport = getSafeViewport(); if (typeof(viewport)!="undefined" && viewport!=null) { viewport.setAttribute('content', holdContent); } } function clearViewport() { var viewport = getSafeViewport(); if (typeof(viewport)!="undefined" && viewport!=null) { viewport.setAttribute('content', ''); } //viewport.remove(); } /* experimenting jQuery(document).ready(function(jQuery) { if (""=="com.other.Default" || ""=="com.other.AlceaLogin") { viewportScale=1.0; viewportWidth=vMin; } else if (jQuery(window).width()<600) { viewportWidth=vMin*2; viewportScale=0.5; } else { viewportWidth=jQuery(window).width(); // let's start it so they have the buttons viewportScale=1.0; } alert(jQuery(window).width()); setViewport(viewportWidth); }); */ var rowFieldToggle = true; function toggleRowFields() { if (rowFieldToggle==true) { jQuery(".menurowfield").hide(); //jQuery(".menurowfield").prop("visibility","hidden"); rowFieldToggle = false; } else { jQuery(".menurowfield").show(); //jQuery(".menurowfield").prop("visibility","visible"); rowFieldToggle = true; } jQuery("#mainMenuFunctionSelect").prop("selectedIndex","0"); } function reportTargetControl() { var display = jQuery("#display").val(); if (display=="noheader" || display=="printFormat" || display=="email") { jQuery("#reportDropOptions").attr("target", "_blank"); } else { jQuery("#reportDropOptions").attr("target", ""); } return true; }