//this is a .html file instead of a .js so that FBT will serve the page with substr for all SUBS var onLoadDefaultsDone = false; var iOS = /^(iPhone|iPad|iPod)/.test(navigator.platform); if(typeof(mmUrlAddNoContext)=="undefined")mmUrlAddNoContext=""; if(typeof(mmContext)=="undefined")mmContext=""; if(typeof(mmRand)=="undefined")mmRand=""; 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 = ""; var FIT_CK = ""; function checkValidRtfContent(text) { var lines = text.split("\n"); for (i=0; i 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= 0) { var rtfActive = false; var text = ""; if (typeof(tinyMCE) != "undefined") { var rtfObj = tinyMCE.get(input.name); if (rtfObj) { // could have been turned off text = rtfObj.getContent(); rtfActive=true; } } else if (typeof(CKEDITOR) != "undefined") { if (CKEDITOR.instances[input.name]) { text = CKEDITOR.instances[input.name].getData(); rtfActive = true; } } var div = document.createElement("div"); div.innerHTML = text; text = div.textContent || div.innerText || ""; text = text.trim(); if (rtfActive && 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(); //viewport = document.querySelector("meta[name=viewport]"); //viewport.setAttribute('content', 'width=768, initial-scale=1.0, maximum-scale=1.0, xuser-scalable=0'); //viewport.setAttribute('content', 'user-scalable=0.8'); jQuery("#"+firstMissingId ).after("
: " + missingLabels + "
"); if (iOS) { jQuery(window).scrollLeft(0); jQuery(window).scrollTop(0); } jQuery( "#dialog" ).dialog({ modal: true, open: function () { //var scrollLeft = jQuery('html, body').scrollLeft(); if (iOS) { jQuery('.ui-dialog').css("left","100px"); jQuery('.ui-dialog').css("top","200px"); } }, close: function(event, ui) { // this is the line I changed for bug 4953 if (!isElementVisible(jQuery("#"+firstMissingId)[0])) { 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); } } }); //alert(); //jQuery("#dialog").dialog('option', 'position', 'center'); 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; } } // TinyMceConfig had code checking img links if(ret && typeof (window.rtfCheckLinks) == 'function') { if (rtfCheckLinks()==false) { ret = false; } } // check for dangerous text in rtf if (rtfSubmitCheck()==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(window.event, {html: "You have a subwindow open and might be editing a relationship above or below.\nPlease close that window before saving!"}); ret = false; } } catch (err) { console.log(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? \n\n\nTraceback Details:\n"+err.stack); } return ret; } function otherFitSubmitChecks() { //this function is overridden elsewhere return true; } function getRtfLabel(rtfname) { var obj = jQuery("[name='"+rtfname+"']"); if (obj) { var labelObj = obj.closest("td").siblings().first(); var label = labelObj.text(); label = label.replace(":","").trim(); return label; } return "fieldId:"+rtfname; } function rtfSubmitCheck() { if (typeof CKEDITOR !== 'undefined') { for (var name in CKEDITOR.instances) { var instance = CKEDITOR.instances[name]; if (instance.mode!="wysiwyg") { alert("RTF editor must be in normal mode before saving for security reasons.\nCheck if you are in source mode for ["+getRtfLabel(name)+"]?"); return false; } var data = instance.getData(); if (data.indexOf("")>=0) { alert("You have a tag in the source for rtf editor ["+getRtfLabel(name)+"].\nPlease modify as this can be dangerous to other users."); return false; } // testing for Noirlab if (data.indexOf("__LanguageMenu_popup")>0) { alert("You have __LanguageMenu_popup in your ["+getRtfLabel(name)+"] RTF editor.\nPlease check the source for that field as this has caused problems before.\nIt is possible some kind of translator plugin is altering this field?"); return false; } } } 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; ta = getFitForm()[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; ta = getFitForm()[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 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 = getFitForm(); var list = eval(form.name+'.mNotifyList'+specific); var select = eval(form.name+'.notifySelect'+specific); //if (select.length<=2 && collapse==false) return; // no need to resize if (list.rowsb)return 1; if(a 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) { if (checkUnsavedChanges()==true) { alert(""); } 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 (typeof mmBugId != 'undefined') { if (id<0 ) { 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; } var relatedTableView = 0; function setRelatedTableView() {} 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) { if (link.indexOf("URIEncoded=1")<=0) { 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=0;--c) { updateSelect.options[c] = null; } } function updateField(fieldname,newVals,newLabels) { var updateSelect = getFitForm()[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;c0 && currExists==false && onLoadDefaultsDone==false && "" != "com.other.NewBug" && "".indexOf("com.other.FieldHierarchy")<0 ) // init fieldHierarchy examples properly { 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); //resetSelectize($(updateSelect)); if ($(updateSelect).hasClass("fit-combobox")) { if (jQuery("#"+updateSelect.id+" option").length==0) { jQuery("#"+updateSelect.id).append(""); // no way to select without second option } jQuery("#"+updateSelect.id).append(""); } } function enableCombobox(sel) { //alert("enableCombobox"); var id = sel[0].id; if (jQuery("#"+id+" option").length==0) { jQuery("#"+id).append(""); // no way to select without second option } jQuery("#"+id).append(""); jQuery("#"+id).change(function() { var val = jQuery("#"+id+" option:selected").text(); if (val=="") { addDropdownOption(null,id); } }); } function resetSelectize(sel) { sel.selectize()[0].selectize.destroy(); enableSelectize(sel); } function enableSelectize(sel){ var allowEmpty = false; if (sel[0].options.length>0 && ("" == sel[0].options[0].value)) { allowEmpty = true; } //alert("enableSelectize"); sel.selectize({ create: true, //allowEmptyOption: allowEmpty, //sortField: 'text' onInitialize: function(value) { if (this.$input[0].value=="") { this.clear(); } }, onChange: function(value) { if (value=="") { this.clear(); //$(".selectize-input input[placeholder]").attr('placeholder','Select an Architecture (Optional)'); //setValue("something",false); } var obj = $(this)[0]; //alert("selectize "+obj.$input["0"].id+" changed to "+value); changeField(obj); } }); } 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 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 = getFitForm()[parentName]; if (addedParents[parentName] != 1) { parents.push(parent); addedParents[parentName] = 1; } } } } for (i=0;i" == "com.other.NewBug") { field.selectedIndex = 0; } } } if (field.value == "" && field.options[0].value == selectStr) { //if a blank val is selected, highlight "Select..." instead 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 = getFitForm()[parentName]; if (addedParents[parentName] != 1) { parents.push(parent); addedParents[parentName] = 1; } } } } for (i=0;i