1$(document).ready(function () { 2 TranslateMultiLingualControls(); 3}); 4 5//Ticket SCM7-4052: Date format and Metric system dynamic configuration Start 6function getCurrencyText() { 7 var currencySymbol = $('#hdnMetricCurrencySymbol').val(); 8 var currencyText = ''; 9 switch (currencySymbol) { 10 case '$': 11 currencyText = 'Dollar'; 12 break; 13 case 'â¹': 14 currencyText = 'Rupees'; 15 break; 16 case '£': 17 currencyText = 'Pound'; 18 break; 19 case 'â¬': 20 currencyText = 'Euro'; 21 break; 22 case 'Â¥': 23 currencyText = 'Yen'; 24 break; 25 } 26 return currencyText; 27 28} 29function TranslateMultiLingualControls() { 30 31 try { 32 var glbList = $('[globalize]'); 33 34 if (glbList.length <= 0) return; //No Need to move forward if have nothing to do: Sachin 35 36 var mandatoryLst = $('[mandatory]'); // list of all keys which are mandatory=1 37 var placeHolderToReplace = []; 38 39 if (mandatoryLst.length > 0) { 40 mandatoryLst.each(function (i) { 41 if (mandatoryLst[i].attributes['globalize'] != undefined && mandatoryLst[i].attributes['mandatory'].value == '1' && (mandatoryLst[i].type == "text" || mandatoryLst[i].type == "textarea" || mandatoryLst[i].type == "number" || mandatoryLst[i].type == "password")) { 42 //contains the control ids whose controlplaceholder values are to be replaced by text 'Mandatory'. 43 placeHolderToReplace.push($('[mandatory]')[i].attributes['globalize'].value); 44 } 45 }); 46 } 47 48 var controlIdList = ""; 49 glbList.each(function (i) { 50 controlIdList += glbList[i].attributes['globalize'].value + "|"; 51 }); 52 53 glbList.each(function (i) { 54 55 var ctrlId = glbList[i].attributes['globalize'].value; 56 //var ctrlData = translatedControls[ctrlId]; 57 58 var ctrlData = window.ApplicationLabels[ctrlId]; 59 if (ctrlData == null) return true;// By passing calls if no data found for control. 60 61 var locText = ctrlData.ControlText == null ? ctrlData.ControlTitle : ctrlData.ControlText; 62 var locTitle = ctrlData.AltTitle == null ? locText : ctrlData.AltTitle; 63 64 //Ticket SCM7-4052: Date format and Metric system dynamic configuration Start 65 if (ctrlId == 'ML_DASHBOARD_Anchor_Dol' || ctrlId == 'ML_Compare_dollar' || ctrlId == 'ML_POWERWATER_btn_$') 66 locTitle = locTitle.replace(/{(.*?)}/, getCurrencyText()); 67 //locTitle = locTitle.replace(/{(.*?)}/, $('#hdnMetricCurrencySymbol').val()); 68 69 var locPlaceHolder = ctrlData.ControlPlaceHolder; 70 var locErrorMessage = ctrlData.ErrorMessage; 71 var controlType = ctrlData.Controltype; 72 73 74 var intatt = document.createAttribute("InputType"); 75 intatt.value = (controlType != null && controlType.trim().length > 0) ? controlType : ""; 76 glbList[i].setAttributeNode(intatt); 77 78 var att = document.createAttribute("ValidateMessage"); 79 if (locErrorMessage != null && locErrorMessage.trim().length > 0) { 80 att.value = locErrorMessage; 81 } 82 else if (locPlaceHolder != null && locPlaceHolder.trim().length > 0) { 83 att.value = locPlaceHolder; 84 } 85 else if (locText != null && locText.trim().length > 0) { //Validation message and place holder not available 86 switch (glbList[i].type) { 87 case "textarea": 88 case "text": 89 case "number": 90 case "password": 91 att.value = 'Please enter ' + locText; 92 //handleControl(); 93 break; 94 case "select": 95 case "div": 96 att.value = 'Please select ' + locText; 97 break; 98 } 99 } 100 101 glbList[i].setAttributeNode(att); 102 if (glbList[i].previousSibling != null) { 103 if (glbList[i].previousSibling.localName === "img" && locTitle != null && locTitle.trim().length > 0) { 104 glbList[i].previousSibling.title = locTitle; 105 } 106 } 107 108 if (locTitle != null && locTitle.trim().length > 0) { 109 //************************************ 110 switch (glbList[i].tagName) { 111 case "LABEL": 112 case "div": 113 case "DIV": 114 case "undefined": 115 case "H1": 116 case "H2": 117 case "H3": 118 case "H4":
119 case "H5": 120 case "H6": 121 case "": 122 break; 123 default: 124 glbList[i].title = locTitle; 125 } 126 } 127 //Inner function to call from above case. 128 if (glbList[i].type === "textarea" || glbList[i].type === "text" || glbList[i].type === "number" || glbList[i].type === "password") { 129 var attpalceholder = document.createAttribute("placeholder"); 130 var flag = 0; 131 //below code replaces the controlplaceholder text as 'Mandatory' for mandatory controls. 132 for (var k = 0; k < placeHolderToReplace.length; k++) { 133 //if (glbList[i].attributes['globalize'].value == placeHolderToReplace[k]) //Commented by pawan gupta 134 if (glbList[i].attributes['globalize'].value === placeHolderToReplace[k] && 135 glbList[i].attributes['mandatory'] != undefined) { 136 flag = glbList[i].attributes['mandatory'].value; 137 break; 138 } else { 139 flag = 0; 140 } 141 142 } 143 if (flag === 0) { 144 attpalceholder.value = (controlType === "Search") ? locPlaceHolder : "";//Non-mandatory text and textareas will now have blank placeholders. 145 } 146 glbList[i].setAttributeNode(attpalceholder);//Placeholder will only appear in case of mandatory field 147 } 148 }); 149 } 150 catch (e) { 151 console.log(e.message); 152 } 153} 154 155//for translate header text in multilingual feature for w2ui grid header 156function w2UiTranslateGridHeaders(grid) { 157 158 //Loading All Columns 159 var column = grid.columns; 160 var controlIdList = ""; 161 162 var i; 163 for (i = 0; i < grid.columns.length; i++) { 164 controlIdList += grid.columns[i].classname + "|"; 165 } 166 167 168 for (i = 0; i < grid.columns.length; i++) { 169 grid.columns[i].caption = window.ApplicationLabels[grid.columns[i].classname].ControlText; 170 } 171 for (i = 0; i < grid.searches.length; i++) { 172 grid.searches[i].caption = window.ApplicationLabels[grid.searches[i].classname].ControlText; 173 } 174 175}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.