C_SettingSheet.js 40 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490
  1. /*
  2. IBM Confidential
  3. OCO Source Materials
  4. IBM Cognos Products: uipe
  5. (C) Copyright IBM Corp. 2014
  6. The source code for this program is not published or otherwise divested of its trade secrets, irrespective of what has been deposited with the U.S. Copyright Office.
  7. */
  8. /**
  9. * @fileoverview Provides setting sheet capabilities.
  10. */
  11. /**
  12. * Indicates that the value is not valid. Used in validation of values entered in the setting sheet.
  13. * @final
  14. * @type Integer
  15. */
  16. C_SettingSheet.K_iNotValid = 1;
  17. /**
  18. * Indicates that the value is less then the minimum. Used in validation of values entered in the setting sheet.
  19. * @final
  20. * @type Integer
  21. */
  22. C_SettingSheet.K_iLessThanMin = 2;
  23. /**
  24. * Indicates that the value is more then the maximum. Used in validation of values entered in the setting sheet.
  25. * @final
  26. * @type Integer
  27. */
  28. C_SettingSheet.K_iGreaterThanMax = 3;
  29. /*
  30. * @constructor
  31. * @requires C_ListView
  32. * @param {DIV} v_divSettingSheet The container for the setting sheet.
  33. * @param {Node} v_nSettingSheet The settingSheet node.
  34. * @param {I_SettingSheetListener} v_oListener Listener.
  35. * @param {HTMLElement} v_elBlockerParent
  36. * @param {String} v_sClsInputBlocker
  37. */
  38. function C_SettingSheet( v_divSettingSheet, v_nSettingSheet, v_oListener )
  39. {
  40. /**
  41. * @private
  42. */
  43. G_HAL.F_VerifyDependencies( "C_ListView" );
  44. /**
  45. * @private
  46. */
  47. this.m_doc = document;
  48. /**
  49. * @private
  50. */
  51. this.m_oListener = v_oListener;
  52. /**
  53. * @private
  54. */
  55. this.m_sActiveSetting = "";
  56. /**
  57. * @private
  58. */
  59. this.m_oSettingToRow = {};
  60. /**
  61. * @private
  62. */
  63. this.m_oSettingValues = {};
  64. /**
  65. * @private
  66. */
  67. this.m_oCollapsedGroups = {};
  68. this.f_createTable( v_divSettingSheet );
  69. this.f_createTemplates();
  70. /**
  71. * @private
  72. */
  73. this.m_nSettingSheet = v_nSettingSheet;
  74. /**
  75. * @private
  76. */
  77. this.m_iIndentLength = parseInt( this.m_nSettingSheet.getAttribute( "indentLength" ) );
  78. /**
  79. * @private
  80. */
  81. this.m_sHighlightNonDefaultValues = this.m_nSettingSheet.getAttribute( "highlightNonDefaultValues" );
  82. this.Groups = [];
  83. this.m_oGroupAttributes = {};
  84. this.m_oSettingAttributes = {};
  85. this.m_oSubSettings = {};
  86. this.m_oSupportedSubSettings = {};
  87. this.m_oLabels = {};
  88. this.m_oSmallIcons = {};
  89. this.m_oExpandedSmallIcons = {};
  90. this.m_oTypes = {};
  91. this.m_oHasEmbeddedListView = {};
  92. this.m_oType = {};
  93. this.f_readSettings(U_XML.F_AppendNodeListToArray([], this.m_nSettingSheet.selectNodes(".")));
  94. };
  95. /**
  96. * @private
  97. */
  98. C_SettingSheet.prototype.f_readSettings = function(v_aGroups)
  99. {
  100. //Note: Anything cached in this method, must be removed in f_deleteSettings
  101. var v_iGroupsLength = v_aGroups.length;
  102. for ( var v_iGroup = 0; v_iGroup < v_iGroupsLength; v_iGroup++ )
  103. {
  104. var v_nGroup = v_aGroups[ v_iGroup ];
  105. var v_oGroup = {};
  106. v_oGroup.Name = v_nGroup.getAttribute( "name" );
  107. //Groups must be uniquely named
  108. this.f_readAttributes( v_nGroup, this.m_oGroupAttributes, v_oGroup.Name );
  109. this.m_oLabels[v_oGroup.Name] = this.f_getLabelString( v_nGroup );
  110. this.m_oSmallIcons[v_oGroup.Name] = v_nGroup.getAttribute( "smallIcon" );
  111. this.m_oExpandedSmallIcons[v_oGroup.Name] = v_nGroup.getAttribute( "expandedSmallIcon" );
  112. if ( this.m_bShowGroupSmallIcons && !this.m_oSmallIcons[v_oGroup.Name] )
  113. {
  114. this.m_oSmallIcons[v_oGroup.Name] = G_HAL.M_sImagePath + "tv_folder.gif";
  115. this.m_oExpandedSmallIcons[v_oGroup.Name] = G_HAL.M_sImagePath + "tv_folder_expanded.gif";
  116. }
  117. v_oGroup.Settings = [];
  118. this.Groups.push( v_oGroup );
  119. var v_nlSettings = v_nGroup.selectNodes( "setting" );
  120. var v_iSettingsLength = v_nlSettings.length;
  121. for ( var v_iProp = 0; v_iProp < v_iSettingsLength; v_iProp++ )
  122. {
  123. var v_nSetting = v_nlSettings.item( v_iProp );
  124. var v_sSettingName = v_nSetting.getAttribute( "name" );
  125. var v_sType = v_nSetting.getAttribute( "dataType" );
  126. this.m_oType[v_sSettingName] = v_sType;
  127. this.m_oTypes[v_sSettingName] = v_sType;
  128. this.m_oLabels[v_sSettingName] = this.f_getLabelString( v_nSetting );
  129. this.m_oSmallIcons[v_sSettingName] = v_nSetting.getAttribute( "smallIcon" );
  130. v_oGroup.Settings.push( v_sSettingName );
  131. this.f_readAttributes( v_nSetting, this.m_oSettingAttributes, v_sSettingName );
  132. }
  133. }
  134. };
  135. C_SettingSheet.prototype.F_GetUpdatedSettings = function()
  136. {
  137. var v_oUpdatedSettings = {};
  138. for ( var i = 0; i < this.Groups[0].Settings.length; i++ )
  139. {
  140. var v_sName = this.Groups[0].Settings[i];
  141. var v_sValue = this.m_oSettingValues[v_sName];
  142. if ( v_sValue != this.F_GetSettingAttribute( v_sName, "defaultValue" ) )
  143. {
  144. v_oUpdatedSettings[v_sName] = v_sValue;
  145. }
  146. }
  147. return v_oUpdatedSettings;
  148. };
  149. /**
  150. * @private
  151. */
  152. C_SettingSheet.prototype.f_getLabelString = function( n )
  153. {
  154. var v_sIdsLabel = n.getAttribute( "idsLabel" );
  155. if ( v_sIdsLabel )
  156. {
  157. var v_sLabel = G_ResManager.F_GetOptionalString( v_sIdsLabel );
  158. if ( !v_sLabel )
  159. {
  160. return n.getAttribute( "name" );
  161. }
  162. else
  163. {
  164. return v_sLabel;
  165. }
  166. }
  167. return n.getAttribute( "label" );
  168. };
  169. /**
  170. * @private
  171. */
  172. C_SettingSheet.prototype.f_readAttributes = function( n, v_oAttributes, v_sName )
  173. {
  174. v_oAttributes[v_sName] = {};
  175. var o = v_oAttributes[v_sName];
  176. var nl = n.attributes;
  177. var v_iLength = nl.length;
  178. for ( var i = 0; i < v_iLength; i++ )
  179. {
  180. var v_nAttr = nl.item( i );
  181. o[v_nAttr.name] = v_nAttr.value;
  182. }
  183. };
  184. /**
  185. * Gets an attribute of a setting.
  186. * @param {String} v_sSettingName The setting name.
  187. * @param {String} v_sAttributeName The attribute name.
  188. * @type String
  189. * @returns The attribute value for the setting.
  190. */
  191. C_SettingSheet.prototype.F_GetSettingAttribute = function( v_sSettingName, v_sAttributeName )
  192. {
  193. var o = this.m_oSettingAttributes[v_sSettingName];
  194. if ( o )
  195. {
  196. return o[v_sAttributeName];
  197. }
  198. };
  199. /**
  200. * Set whether {@link C_SettingSheet#F_Show} will create or update the UI.
  201. * @param {Boolean} b Whether or not to enable updating of the setting sheet.
  202. * @type void
  203. */
  204. C_SettingSheet.prototype.F_SetUpdate = function( b )
  205. {
  206. this.m_bUpdate = b;
  207. if ( !b )
  208. {
  209. this.F_Clear();
  210. }
  211. };
  212. /**
  213. * Returns the setting value.
  214. * @type String
  215. */
  216. C_SettingSheet.prototype.F_GetSettingValue = function( v_sName )
  217. {
  218. return this.m_oSettingValues[v_sName];
  219. };
  220. /**
  221. * Set locale to text container for language specific content
  222. * @param {String} v_sName The setting name.
  223. * @param {String} v_sLocale The locale value
  224. * @type void
  225. */
  226. C_SettingSheet.prototype.F_SetLocale = function( v_sName, v_sLocale )
  227. {
  228. if (v_sLocale)
  229. {
  230. this.F_GetFixedValueCell( v_sName ).setAttribute("lang", v_sLocale);
  231. }
  232. };
  233. /**
  234. * Shows a setting with an appropriate value. Ignore case is only used for settings that are drop down lists.
  235. * In that case, if ignore case is true, a case insensitive match will be used on values to find the correct list item.
  236. * @param {String} v_sName The setting name.
  237. * @param {String} v_sValue The setting value.
  238. * @type void
  239. */
  240. C_SettingSheet.prototype.F_ShowSetting = function( v_sName, v_sValue )
  241. {
  242. if ( v_sValue == null )
  243. {
  244. if ( this.m_oSettingValues[v_sName] == null )
  245. {
  246. v_sValue = this.F_GetSettingAttribute( v_sName, "defaultValue" );
  247. }
  248. else
  249. {
  250. v_sValue = this.m_oSettingValues[v_sName];
  251. }
  252. }
  253. this.m_oSettingValues[v_sName] = v_sValue;
  254. switch ( this.m_oTypes[v_sName] )
  255. {
  256. case "string":
  257. case "integer":
  258. this.f_showTextSetting( v_sName, v_sValue );
  259. break;
  260. case "boolean":
  261. this.f_showBooleanSetting( v_sName, ( typeof v_sValue == "boolean" ) ? ( v_sValue ? "true" : "false" ) : v_sValue );
  262. break;
  263. case "enum":
  264. this.f_showDropDownListSetting( v_sName, v_sValue );
  265. break;
  266. default:
  267. G_HAL.F_AlertError( "Unrecognized setting type '" + this.m_oTypes[v_sName] + "' for setting '" + v_sName + "'." );
  268. break;
  269. }
  270. if ( G_HAL.M_oLibraries["hal"]["enableAccessibility"] )
  271. {
  272. if ( !this.m_bFirstTabindexSet )
  273. {
  274. var v_tdLabel = this.m_tbl.rows.item( 0 ).cells.item( 0 );
  275. v_tdLabel.setAttribute( "tabIndex", "0" );
  276. this.m_bFirstTabindexSet = true;
  277. }
  278. // TODO: Why does this need to be called for every setting added? Doesn't the call in f_createTable take care of this?
  279. this.f_setupAccessibility();
  280. }
  281. };
  282. /**
  283. * @private
  284. */
  285. C_SettingSheet.prototype.f_showTextSetting = function( v_sName, v_sValue )
  286. {
  287. if ( this.m_bUpdate )
  288. {
  289. this.f_updateTextSetting( v_sName, v_sValue );
  290. }
  291. else
  292. {
  293. this.f_addTextSetting( v_sName, v_sValue );
  294. }
  295. };
  296. /**
  297. * @private
  298. */
  299. C_SettingSheet.prototype.f_showBooleanSetting = function( v_sName, v_sValue )
  300. {
  301. if ( this.m_bUpdate )
  302. {
  303. this.f_updateBooleanSetting( v_sName, v_sValue );
  304. }
  305. else
  306. {
  307. this.f_addBooleanSetting( v_sName, v_sValue );
  308. }
  309. };
  310. /**
  311. * @private
  312. */
  313. C_SettingSheet.prototype.f_getSettingListView = function( v_sName, v_sValue, v_bPopulate )
  314. {
  315. if ( this.m_oType[v_sName] == "boolean" )
  316. {
  317. var v_nListView = G_ResManager.F_GetResource( "HAL_BOOLEAN_LISTVIEW" );
  318. if ( v_nListView )
  319. {
  320. return v_nListView;
  321. }
  322. var d = G_ResManager.F_GetResourcesDoc();
  323. v_nListView = d.documentElement.appendChild( d.createElement( "listView" ) );
  324. v_nListView.setAttribute( "id", "HAL_BOOLEAN_LISTVIEW" );
  325. var v_nListItems = v_nListView.appendChild( d.createElement( "listItems" ) );
  326. var v_nListItem = v_nListItems.appendChild( d.createElement( "listItem" ) );
  327. v_nListItem.setAttribute( "value", "false" );
  328. v_nListItem.setAttribute( "idsLabel", "IDS_HAL_PROPVAL_FALSE" );
  329. var v_nListItem = v_nListItems.appendChild( d.createElement( "listItem" ) );
  330. v_nListItem.setAttribute( "value", "true" );
  331. v_nListItem.setAttribute( "idsLabel", "IDS_HAL_PROPVAL_TRUE" );
  332. return G_ResManager.F_GetResource( "HAL_BOOLEAN_LISTVIEW" );
  333. }
  334. var v_nListView = this.f_createListViewByEnumValues( v_sName );
  335. return v_nListView ? v_nListView.cloneNode( true ) : null;
  336. };
  337. C_SettingSheet.prototype.f_createListViewByEnumValues = function( v_sName )
  338. {
  339. var d = G_ResManager.F_GetResourcesDoc();
  340. v_nListView = d.documentElement.appendChild( d.createElement( "listView" ) );
  341. v_nListView.setAttribute( "id", v_sName + "_ListView" );
  342. var v_nListItems = v_nListView.appendChild( d.createElement( "listItems" ) );
  343. var v_nEnumValues = this.m_nSettingSheet.selectNodes( ".//setting[@name='" + v_sName + "']/enumValues/enumValue" );
  344. for( var i = 0; i < v_nEnumValues.length; i++ )
  345. {
  346. var v_nEnumValue = v_nEnumValues.item( i );
  347. var v_nListItem = v_nListItems.appendChild( d.createElement( "listItem" ) );
  348. v_nListItem.setAttribute( "value", v_nEnumValue.getAttribute( "value" ) );
  349. v_nListItem.setAttribute( "idsLabel", v_nEnumValue.getAttribute( "idsLabel" ) );
  350. }
  351. return v_nListView;
  352. };
  353. /**
  354. * @private
  355. */
  356. C_SettingSheet.prototype.f_showDropDownListSetting = function( v_sName, v_sValue )
  357. {
  358. var v_sDisplayValue = v_sValue;
  359. if ( v_sValue )
  360. {
  361. var v_nListView = this.f_getSettingListView( v_sName, v_sValue );
  362. if ( v_nListView )
  363. {
  364. var v_bIgnoreValueCase = ( this.F_GetSettingAttribute( v_sName, "ignoreValueCase" ) == "true" );
  365. var v_nListItem = C_ListView.F_FindListItem( v_nListView, "value", v_sValue, v_bIgnoreValueCase );
  366. if ( v_nListItem )
  367. {
  368. v_sDisplayValue = C_ListView.F_GetListItemLabel( v_nListItem );
  369. }
  370. }
  371. }
  372. if ( this.m_bUpdate )
  373. {
  374. this.f_updateDropDownListSetting( v_sName, v_sValue, v_sDisplayValue );
  375. }
  376. else
  377. {
  378. this.f_addDropDownListSetting( v_sName, v_sValue, v_sDisplayValue );
  379. }
  380. };
  381. /**
  382. * @private
  383. */
  384. C_SettingSheet.prototype.f_addTextSetting = function( v_sName, v_sValue )
  385. {
  386. var tr = this.f_appendSettingRow( "string", v_sName );
  387. var txt = this.F_GetFixedValueCell( v_sName ).firstChild;
  388. txt.onblur = C_SettingSheet.f_onInputBlur;
  389. txt.onfocus = C_SettingSheet.f_onInputFocus;
  390. txt.onchange = C_SettingSheet.f_onInputChange;
  391. this.f_updateTextSetting( v_sName, v_sValue );
  392. };
  393. /**
  394. * @private
  395. */
  396. C_SettingSheet.prototype.f_updateTextSetting = function( v_sName, v_sValue )
  397. {
  398. var txt = this.F_GetFixedValueCell( v_sName ).firstChild;
  399. txt.v_sDefaultValue = v_sValue;
  400. txt.value = v_sValue;
  401. this.f_highlightNonDefaultValue( v_sName, v_sValue, txt );
  402. this.f_updateSettingAriaLabel( v_sName, v_sValue );
  403. };
  404. /**
  405. * @private
  406. */
  407. C_SettingSheet.prototype.f_addBooleanSetting = function( v_sName, v_sValue )
  408. {
  409. var tr = this.f_appendSettingRow( "boolean", v_sName );
  410. this.f_updateBooleanSetting( v_sName, v_sValue );
  411. };
  412. /**
  413. * @private
  414. */
  415. C_SettingSheet.prototype.f_updateBooleanSetting = function( v_sName, v_sValue )
  416. {
  417. var td = this.F_GetFixedValueCell( v_sName );
  418. td.v_sSettingValue = v_sValue;
  419. td.innerText = G_ResManager.F_GetString( ( v_sValue == "true" ) ? "IDS_HAL_PROPVAL_TRUE" : "IDS_HAL_PROPVAL_FALSE" );
  420. this.f_highlightNonDefaultValue( v_sName, v_sValue, td );
  421. this.f_updateSettingAriaLabel( v_sName, td.innerText );
  422. };
  423. /**
  424. * @private
  425. */
  426. C_SettingSheet.prototype.f_addDropDownListSetting = function( v_sName, v_sValue, v_sDisplayValue )
  427. {
  428. var tr = this.f_appendSettingRow( "dropDownList", v_sName );
  429. this.f_updateDropDownListSetting( v_sName, v_sValue, v_sDisplayValue );
  430. };
  431. /**
  432. * @private
  433. */
  434. C_SettingSheet.prototype.f_updateDropDownListSetting = function( v_sName, v_sValue, v_sDisplayValue )
  435. {
  436. var td = this.F_GetFixedValueCell( v_sName );
  437. td.v_sSettingValue = v_sValue;
  438. td.innerText = v_sDisplayValue;
  439. this.f_highlightNonDefaultValue( v_sName, v_sValue, td );
  440. this.f_updateSettingAriaLabel( v_sName, v_sDisplayValue );
  441. };
  442. /**
  443. * @private
  444. */
  445. C_SettingSheet.prototype.f_highlightNonDefaultValue = function( v_sName, v_sValue, el )
  446. {
  447. if ( this.m_sHighlightNonDefaultValues )
  448. {
  449. var n = this.m_nSettingSheet.selectSingleNode( ".//setting[@name=" + v_sName.F_ToXPathString() + "]" );
  450. var v_sDefaultValue = n.getAttribute( "defaultValue" );
  451. if ( v_sDefaultValue !== null )
  452. {
  453. el.style.fontWeight = ( v_sDefaultValue == v_sValue ) ? "normal" : "bold";
  454. }
  455. }
  456. };
  457. /**
  458. * @private
  459. */
  460. C_SettingSheet.prototype.f_createTable = function( v_elContainer )
  461. {
  462. this.m_tbl = v_elContainer.appendChild( this.m_doc.createElement( "TABLE" ) );
  463. this.m_tbl.cellPadding = 0;
  464. this.m_tbl.cellSpacing = 0;
  465. this.m_tbl.className = "clsPropertySheet";
  466. this.m_tbl.h_oSettingSheet = this;
  467. this.m_tbl.style.tableLayout = "fixed";
  468. U_Accessibility.F_SetRoleForLayoutTable( this.m_tbl );
  469. this.f_attachEventHandlers();
  470. this.m_tbody = this.m_tbl.appendChild( this.m_doc.createElement( "TBODY" ) );
  471. this.f_setupAccessibility();
  472. };
  473. /**
  474. * @private
  475. */
  476. C_SettingSheet.prototype.f_attachEventHandlers = function()
  477. {
  478. this.m_tbl.onmousedown = function( e ) { return this.h_oSettingSheet.f_onMouseDown( e ); };
  479. this.m_tbl.ondblclick = function( e ) { return this.h_oSettingSheet.f_onDblClick( e ); };
  480. this.m_tbl.onclick = function( e ) { return this.h_oSettingSheet.f_onClick( e ); };
  481. this.m_tbl.onkeydown = function( e ) { return this.h_oSettingSheet.F_OnKeyDown( e ); };
  482. this.f_setupAccessibilityEventHandler( true );
  483. };
  484. /**
  485. * @private
  486. */
  487. C_SettingSheet.prototype.f_createTemplates = function()
  488. {
  489. this.m_oTemplates = {};
  490. var v_trCommon = this.m_doc.createElement( "TR" );
  491. var v_tdLabel = v_trCommon.appendChild( this.m_doc.createElement( "TD" ) );
  492. v_tdLabel.className = "clsPropertySheetLabel_inactive";
  493. v_tdLabel.style.width = "100%";
  494. v_tdLabel.style.overflow = "hidden";
  495. v_tdLabel.style.textOverflow = "ellipsis";
  496. var v_tdValue = v_trCommon.appendChild( this.m_doc.createElement( "TD" ) );
  497. v_tdValue.className = "clsPropertySheetValue";
  498. v_tdValue.style.width = "190px";
  499. var v_tblCommonValue = this.m_doc.createElement( "TABLE" );
  500. v_tblCommonValue.className = "clsDialogText";
  501. v_tblCommonValue.cellPadding = 0;
  502. v_tblCommonValue.cellSpacing = 0;
  503. v_tblCommonValue.style.tableLayout = "fixed";
  504. v_tblCommonValue.style.overflow = "hidden";
  505. v_tblCommonValue.style.width = "100%";
  506. U_Accessibility.F_SetRoleForLayoutTable( v_tblCommonValue );
  507. var tr = v_tblCommonValue.appendChild( this.m_doc.createElement( "TBODY" ) ).appendChild( this.m_doc.createElement( "TR" ) );
  508. var td = tr.appendChild( this.m_doc.createElement( "TD" ) );
  509. td.style.whiteSpace = "nowrap";
  510. td.style.overflow = "hidden";
  511. td.style.textOverflow = "ellipsis";
  512. td.style.width = "100%";
  513. var v_tdCommonActionButton = this.m_doc.createElement( "TD" );
  514. v_tdCommonActionButton.style.display = "none";
  515. v_tdCommonActionButton.style.width = "18px";
  516. var v_btnDotDotDot = v_tdCommonActionButton.appendChild( this.m_doc.createElement( "BUTTON" ) );
  517. v_btnDotDotDot.hideFocus = true;
  518. var v_imgDotDotDot = v_btnDotDotDot.appendChild( this.m_doc.createElement( "IMG" ) );
  519. //Change the dotdotdot.gif to a11y version when high contrast mode enabled.
  520. var v_sDotDotDotImageSrc = "../" + U_HighContrast.F_GetHighContrastImgIfNecessary( "hal/images/dotdotdot.gif" );
  521. v_imgDotDotDot.src = v_sDotDotDotImageSrc;
  522. if ( G_HAL.M_oLibraries["hal"]["enableAccessibility"] )
  523. {
  524. var v_sADotiraLabel = G_ResManager.F_GetString( "IDS_HAL_AC_DOTDOTDOT" );
  525. v_trCommon.setAttribute( "role", "row" );
  526. v_tdLabel.setAttribute( "tabIndex", "-1" );
  527. v_tdLabel.setAttribute( "role", "gridcell" );
  528. v_tdValue.setAttribute( "role", "gridcell" );
  529. td.setAttribute( "tabIndex", "-1" );
  530. v_btnDotDotDot.setAttribute( "tabIndex", "-1" );
  531. v_btnDotDotDot.setAttribute( "aria-label", v_sADotiraLabel );
  532. v_imgDotDotDot.setAttribute( "alt", v_sADotiraLabel );
  533. }
  534. var tr = v_trCommon.cloneNode( true );
  535. this.m_oTemplates["info"] = tr;
  536. tr.firstChild.nextSibling.appendChild( v_tblCommonValue.cloneNode( true ) );
  537. var tr = this.m_oTemplates["info"].cloneNode( true );
  538. this.m_oTemplates["string"] = tr;
  539. // TR->TD->TABLE->TBODY->TR->TD
  540. var v_elInput = tr.firstChild.nextSibling.firstChild.firstChild.firstChild.firstChild.appendChild( this.m_doc.createElement( "INPUT" ) );
  541. v_elInput.type = "text";
  542. v_elInput.style.height = "14px";
  543. v_elInput.style.width = "100%";
  544. v_elInput.style.border = "none";
  545. v_elInput.style.position = "relative";
  546. if ( G_HAL.M_oLibraries["hal"]["enableAccessibility"] )
  547. {
  548. v_elInput.setAttribute( "tabIndex", "-1" );
  549. }
  550. var tr = this.m_oTemplates["info"].cloneNode( true );
  551. this.m_oTemplates["dropDownList"] = tr;
  552. // TR->TD->TABLE->TBODY->TR
  553. var v_tdActionButton = tr.firstChild.nextSibling.firstChild.firstChild.firstChild.appendChild( v_tdCommonActionButton.cloneNode( true ) );
  554. var v_sDrowdownImageSrc = "../" + U_HighContrast.F_GetHighContrastImgIfNecessary( "hal/images/dropdown.gif" );
  555. v_tdActionButton.firstChild.style.height = "18px";
  556. v_tdActionButton.firstChild.firstChild.src = v_sDrowdownImageSrc;
  557. var v_sDropDownAriaLabel = G_ResManager.F_GetString( "IDS_HAL_AC_DROPDOWN" );
  558. if ( G_HAL.M_oLibraries["hal"]["enableAccessibility"] )
  559. {
  560. v_tdActionButton.firstChild.setAttribute( "aria-label", v_sDropDownAriaLabel );
  561. v_tdActionButton.firstChild.firstChild.setAttribute( "alt", v_sDropDownAriaLabel );
  562. }
  563. var tr = this.m_oTemplates["dropDownList"].cloneNode( true );
  564. this.m_oTemplates["boolean"] = tr;
  565. };
  566. /**
  567. * @private
  568. */
  569. C_SettingSheet.prototype.f_appendSettingRow = function( v_sType, v_sName )
  570. {
  571. var tr = this.m_tbody.appendChild( this.m_oTemplates[v_sType].cloneNode( true ) );
  572. tr.v_sSettingType = v_sType;
  573. tr.v_bIsSettingRow = true;
  574. if ( v_sType != "Last" )
  575. {
  576. tr.v_sSettingName = v_sName;
  577. var v_tdLabel = tr.cells.item( 0 );
  578. v_tdLabel.innerText = this.m_oLabels[v_sName];
  579. if ( this.m_iIndentLength )
  580. {
  581. var v_sIndentLevel = this.F_GetSettingAttribute( v_sName, "indentLevel" );
  582. if ( v_sIndentLevel )
  583. {
  584. v_tdLabel.style.paddingLeft = ( parseInt( v_sIndentLevel, 10 ) * this.m_iIndentLength ) + "px";
  585. }
  586. }
  587. var v_bIsGroup = ( v_sType == "Group" );
  588. if ( ( this.m_bShowGroupSmallIcons && v_bIsGroup ) ||
  589. ( this.m_bShowLabelSmallIcons && !v_bIsGroup ) )
  590. {
  591. var td = tr.cells.item( v_bIsGroup ? 1 : 2 );
  592. var v_sSmallIcon = this.m_oExpandedSmallIcons[v_sName] || this.m_oSmallIcons[v_sName] || ( G_HAL.M_sImagePath + "blank.gif" );
  593. var img = td.insertBefore( document.createElement( "IMG" ), td.firstChild );
  594. img.src = G_HAL.F_GetImageURL( v_sSmallIcon );
  595. var v_sHeight = this.F_GetSettingAttribute( v_sName, "smallIconHeight" );
  596. img.style.height = ( v_sHeight == null ) ? "16px" : v_sHeight;
  597. var v_sWidth = this.F_GetSettingAttribute( v_sName, "smallIconWidth" );
  598. img.style.width = ( v_sWidth == null ) ? "16px" : v_sWidth;
  599. img.style.verticalAlign = "middle";
  600. img.style.margin = "1px 3px 1px 0px";
  601. }
  602. this.m_oSettingToRow[v_sName] = tr.rowIndex;
  603. if ( this.m_bCurrentGroupCollapsed )
  604. {
  605. tr.style.display = "none";
  606. }
  607. }
  608. if ( G_HAL.M_oLibraries["hal"]["enableAccessibility"] )
  609. {
  610. var nl = tr.getElementsByTagName( "TD" );
  611. for( var i = 0 ; i < nl.length ;i++ )
  612. {
  613. var v_nTd = nl.item(i);
  614. if ( v_nTd.getAttribute( "role" ) )
  615. {
  616. v_nTd.setAttribute( "aria-label", this.m_oLabels[v_sName] || v_sName );
  617. }
  618. }
  619. }
  620. return tr;
  621. };
  622. /**
  623. * @private
  624. */
  625. C_SettingSheet.prototype.f_getSettingRow = function( v_sName )
  626. {
  627. return this.m_tbl.rows.item( this.m_oSettingToRow[v_sName] );
  628. };
  629. /**
  630. * @private
  631. */
  632. C_SettingSheet.prototype.f_getLabelCell = function( v_sName )
  633. {
  634. return this.m_tbl.rows.item( this.m_oSettingToRow[v_sName] ).cells.item( 0 );
  635. };
  636. /**
  637. * @private
  638. */
  639. C_SettingSheet.prototype.f_getValueCell = function( v_sName )
  640. {
  641. return this.m_tbl.rows.item( this.m_oSettingToRow[v_sName] ).cells.item( 1 );
  642. };
  643. /**
  644. * @private
  645. */
  646. C_SettingSheet.prototype.F_GetFixedValueCell = function( v_sName )
  647. {
  648. return this.f_getValueCell( v_sName ).firstChild.rows.item( 0 ).cells.item( 0 );
  649. };
  650. /**
  651. * @private
  652. */
  653. C_SettingSheet.f_getSettingSheetFromChild = function( el )
  654. {
  655. var v_trSettingRow = el;
  656. while ( !v_trSettingRow.v_bIsSettingRow )
  657. {
  658. v_trSettingRow = v_trSettingRow.parentNode;
  659. }
  660. // TR->TBODY->TABLE
  661. return v_trSettingRow.parentNode.parentNode.h_oSettingSheet;
  662. };
  663. /**
  664. * @private
  665. */
  666. C_SettingSheet.prototype.f_createInputBlocker = function( v_elBlockerParent, v_sClsInputBlocker )
  667. {
  668. this.m_divEventBlocker = v_elBlockerParent.appendChild( document.createElement( "DIV" ) );
  669. this.m_divEventBlocker.className = "clsBlocker" + ( v_sClsInputBlocker ? ( " " + v_sClsInputBlocker ) : "" );
  670. this.m_divEventBlocker.onmousedown = C_SettingSheet.f_blockerOnMouseDown;
  671. this.m_divEventBlocker.style.visibility = "hidden";
  672. this.m_divEventBlocker.v_sSettingSheetTableId = this.m_tbl.uniqueID;
  673. };
  674. /**
  675. * @private
  676. */
  677. C_SettingSheet.f_onInputFocus = function(e)
  678. {
  679. var v_currentInput = this;
  680. var v_oSettingSheet = C_SettingSheet.f_getSettingSheetFromChild( v_currentInput );
  681. v_oSettingSheet.m_bEditingText = true;
  682. };
  683. /**
  684. * @private
  685. */
  686. C_SettingSheet.f_onInputBlur = function(e)
  687. {
  688. var v_currentInput = this;
  689. var v_oSettingSheet = C_SettingSheet.f_getSettingSheetFromChild( v_currentInput );
  690. v_oSettingSheet.m_bEditingText = false;
  691. if ( !G_BrowserInfo.M_bIsIE )
  692. {
  693. G_Framework.F_OnTextBoxBlur(e);
  694. }
  695. };
  696. /**
  697. * @private
  698. */
  699. C_SettingSheet.f_onInputChange = function()
  700. {
  701. //G_Debug.F_Print( "f_onInputChange: " + this.value + "," + this.v_sDefaultValue );
  702. if ( this.value != this.v_sDefaultValue )
  703. {
  704. this.v_sDefaultValue = this.value;
  705. var v_trSettingRow = this;
  706. while ( !v_trSettingRow.v_bIsSettingRow )
  707. {
  708. v_trSettingRow = v_trSettingRow.parentNode;
  709. }
  710. var v_oSettingSheet = v_trSettingRow.parentNode.parentNode.h_oSettingSheet;
  711. v_oSettingSheet.f_processInput( v_trSettingRow.v_sSettingName, this.value );
  712. }
  713. };
  714. /**
  715. * @private
  716. */
  717. C_SettingSheet.prototype.f_onClick = function( e )
  718. {
  719. e = e || window.event;
  720. var v_elSrc = e.srcElement;
  721. if ( v_elSrc.tagName == "BUTTON" || (v_elSrc.tagName == "IMG" && v_elSrc.parentNode.tagName == "BUTTON"))
  722. {
  723. var v_trSettingRow = this.f_getSettingRowFromChild( v_elSrc );
  724. switch ( v_trSettingRow.v_sSettingType )
  725. {
  726. case "dropDownList":
  727. case "boolean":
  728. var v_sName = v_trSettingRow.v_sSettingName;
  729. var v_tdValueCell = this.f_getValueCell( v_sName );
  730. var v_tdFixedValueCell = this.F_GetFixedValueCell( v_sName );
  731. var v_sValue = v_tdFixedValueCell.v_sSettingValue;
  732. var v_nListView = this.f_getSettingListView( v_sName, v_sValue );
  733. this.F_ShowListView( v_sName, v_sValue, v_nListView );
  734. break;
  735. }
  736. }
  737. };
  738. /**
  739. * @private
  740. */
  741. C_SettingSheet.prototype.f_onMouseDown = function( e )
  742. {
  743. e = e || window.event;
  744. if ( G_HAL.M_oTestListener && G_HAL.M_oTestListener.F_TestListener_SettingSheetOnMouseDown )
  745. {
  746. G_HAL.M_oTestListener.F_TestListener_SettingSheetOnMouseDown( e, this );
  747. }
  748. var v_elSrc = e.srcElement;
  749. var v_trSettingRow = this.f_getSettingRowFromChild( v_elSrc );
  750. this.f_activateSetting( v_trSettingRow );
  751. e.cancelBubbble = true;
  752. };
  753. /**
  754. * @private
  755. */
  756. C_SettingSheet.prototype.f_onDblClick = function( e )
  757. {
  758. e = e || window.event;
  759. if ( G_HAL.M_oTestListener && G_HAL.M_oTestListener.F_TestListener_SettingSheetOnDblClick )
  760. {
  761. G_HAL.M_oTestListener.F_TestListener_SettingSheetOnDblClick( e, this );
  762. }
  763. var v_elSrc = e.srcElement;
  764. var v_trSettingRow = this.f_getSettingRowFromChild( v_elSrc );
  765. if ( !G_BrowserInfo.M_bIsIE && ( v_trSettingRow.v_sSettingType == "Group" ) && ( v_elSrc.tagName == "IMG" ) )
  766. {
  767. // Ingore since the second onmousedown will toggle the group
  768. return;
  769. }
  770. this.f_doDblClick( v_trSettingRow );
  771. };
  772. /**
  773. * @private
  774. */
  775. C_SettingSheet.prototype.f_doDblClick = function( v_trSettingRow )
  776. {
  777. this.f_activateSetting( v_trSettingRow );
  778. switch ( v_trSettingRow.v_sSettingType )
  779. {
  780. case "dropDownList":
  781. case "boolean":
  782. if ( this.m_oListener.F_SettingSheet_OnCycleDropDownList )
  783. {
  784. var v_sName = v_trSettingRow.v_sSettingName;
  785. if ( this.F_GetSettingAttribute( v_sName, "disableCycle" ) != "true" )
  786. {
  787. var v_sValue = this.F_GetFixedValueCell( v_sName ).v_sSettingValue;
  788. var v_nListView = this.f_getSettingListView( v_sName, v_sValue );
  789. this.m_oListener.F_SettingSheet_OnCycleDropDownList( this, v_sName, v_sValue, v_nListView );
  790. }
  791. }
  792. break;
  793. }
  794. };
  795. /**
  796. * @private
  797. */
  798. C_SettingSheet.prototype.F_OnKeyDown = function( e )
  799. {
  800. e = e || window.event;
  801. if ( G_HAL.M_oLibraries["hal"]["enableAccessibility"] )
  802. {
  803. this.f_handleAccessibilityKeyDown( e );
  804. return;
  805. }
  806. //G_Debug.F_Print( "F_OnKeyDown:" + event.keyCode )
  807. switch ( e.keyCode )
  808. {
  809. case U_DOM.K_iKeyTab:
  810. U_DOM.F_CancelEvent( e );
  811. break;
  812. case U_DOM.K_iKeyDelete:
  813. if ( !this.m_bEditingText && this.m_sActiveSetting )
  814. {
  815. this.m_oListener.F_SettingSheet_OnSettingDelete( this, this.m_sActiveSetting );
  816. }
  817. break;
  818. }
  819. };
  820. /**
  821. * @private
  822. */
  823. C_SettingSheet.prototype.F_OnKeyPress = function( e )
  824. {
  825. if ( G_HAL.M_oLibraries["hal"]["enableAccessibility"] )
  826. {
  827. //handle in keydown event
  828. return;
  829. }
  830. e = e || window.event;
  831. //G_Debug.F_Print( "F_OnKeyPress:" + event.keyCode )
  832. switch ( e.keyCode )
  833. {
  834. case U_DOM.K_iKeyEnter:
  835. //G_Debug.F_Print( "m_sActiveSetting:" + this.m_sActiveSetting )
  836. if ( this.m_sActiveSetting )
  837. {
  838. var v_trSettingRow = this.f_getSettingRow( this.m_sActiveSetting );
  839. switch ( v_trSettingRow.v_sSettingType )
  840. {
  841. case "string":
  842. this.f_deactivateSetting();
  843. break;
  844. default:
  845. this.f_doDblClick( v_trSettingRow );
  846. }
  847. }
  848. break;
  849. case U_DOM.K_iKeyEscape:
  850. this.f_deactivateSetting();
  851. break;
  852. }
  853. };
  854. /**
  855. * @private
  856. */
  857. C_SettingSheet.prototype.f_activateSetting = function( v_trSettingRow )
  858. {
  859. if ( v_trSettingRow.v_sSettingType == "Last" )
  860. {
  861. return;
  862. }
  863. if ( this.m_sActiveSetting != v_trSettingRow.v_sSettingName )
  864. {
  865. this.f_deactivateSetting();
  866. this.m_sActiveSetting = v_trSettingRow.v_sSettingName;
  867. this.f_getLabelCell( this.m_sActiveSetting ).className.replace( "clsPropertySheetLabel_inactive", "clsPropertySheetLabel_active" );
  868. switch ( v_trSettingRow.v_sSettingType )
  869. {
  870. case "string":
  871. if ( !G_HAL.M_oLibraries["hal"]["enableAccessibility"] )
  872. {
  873. // not to automatically change focus
  874. this.F_GetFixedValueCell( this.m_sActiveSetting ).firstChild.focus();
  875. }
  876. break;
  877. case "dropDownList":
  878. case "boolean":
  879. this.F_GetFixedValueCell( this.m_sActiveSetting ).nextSibling.style.display = "";
  880. if ( G_HAL.M_oLibraries["hal"]["enableAccessibility"] )
  881. {
  882. this.f_getLabelCell( this.m_sActiveSetting ).focus();
  883. }
  884. break;
  885. }
  886. if ( this.m_oListener.F_SettingSheet_OnSettingActivated )
  887. {
  888. this.m_oListener.F_SettingSheet_OnSettingActivated( this, this.m_sActiveSetting );
  889. }
  890. }
  891. };
  892. /**
  893. * @private
  894. */
  895. C_SettingSheet.prototype.f_deactivateSetting = function()
  896. {
  897. if ( this.m_sActiveSetting )
  898. {
  899. this.f_getLabelCell( this.m_sActiveSetting ).className.replace( "clsPropertySheetLabel_active", "clsPropertySheetLabel_inactive" );
  900. var v_trSettingRow = this.f_getSettingRow( this.m_sActiveSetting );
  901. switch ( v_trSettingRow.v_sSettingType )
  902. {
  903. case "string":
  904. var txt = this.F_GetFixedValueCell( this.m_sActiveSetting ).firstChild;
  905. if ( txt.value != txt.v_sDefaultValue )
  906. {
  907. txt.v_sDefaultValue = txt.value;
  908. this.f_processInput( this.m_sActiveSetting, txt.value );
  909. }
  910. txt.blur();
  911. break;
  912. case "dropDownList":
  913. case "boolean":
  914. this.F_GetFixedValueCell( this.m_sActiveSetting ).nextSibling.style.display = "none";
  915. break;
  916. }
  917. if ( this.m_oListener.F_SettingSheet_OnSettingDeactivated )
  918. {
  919. this.m_oListener.F_SettingSheet_OnSettingDeactivated( this, this.m_sActiveSetting );
  920. }
  921. this.m_sActiveSetting = "";
  922. }
  923. };
  924. /**
  925. * @private
  926. */
  927. C_SettingSheet.prototype.f_getSettingRowFromChild = function( el )
  928. {
  929. for ( ; el && ( el != this.m_tbl ); el = el.parentNode )
  930. {
  931. if ( ( el.tagName == "TR" ) && el.v_bIsSettingRow )
  932. {
  933. return el;
  934. }
  935. }
  936. };
  937. /**
  938. * @private
  939. */
  940. C_SettingSheet.prototype.f_processInput = function( v_sName, v_sValue )
  941. {
  942. var v_sDataType = this.F_GetSettingAttribute( v_sName, "dataType" );
  943. if ( v_sDataType && !( v_sValue === "" ) )
  944. {
  945. var v_sMin = this.F_GetSettingAttribute( v_sName, "min" );
  946. var v_sMax = this.F_GetSettingAttribute( v_sName, "max" );
  947. switch ( v_sDataType )
  948. {
  949. case "integer":
  950. if ( !v_sValue.match( /^-?\d+$/ ) )
  951. {
  952. this.f_onSettingFailedValidation( C_SettingSheet.K_iNotValid, v_sName, v_sValue );
  953. return;
  954. }
  955. if ( this.f_processNumericInput( v_sName, v_sValue, parseInt( v_sValue, 10 ), parseInt( v_sMin ), parseInt( v_sMax ) ) )
  956. {
  957. this.F_OnSettingChange( v_sName, v_sValue );
  958. }
  959. return;
  960. }
  961. }
  962. this.F_OnSettingChange( v_sName, v_sValue );
  963. };
  964. C_SettingSheet.prototype.f_onSettingFailedValidation = function( v_eValidationResult, v_sName, v_sValue, v_vMin, v_vMax )
  965. {
  966. switch (v_eValidationResult)
  967. {
  968. case C_SettingSheet.K_iNotValid:
  969. F_MsgBoxResLater( ( this.F_GetSettingAttribute( v_sName, "dataType" ) == "integer" ) ? "IDS_ERR_INVALID_INTEGER" : "IDS_ERR_INVALID_DECIMAL" );
  970. break;
  971. case C_SettingSheet.K_iLessThanMin:
  972. F_MsgBoxLater( G_ResManager.F_GetString( "IDS_HAL_ERR_INVALID_MIN", Number.F_ToLocalizedString( v_vMin ) ) );
  973. break;
  974. case C_SettingSheet.K_iGreaterThanMax:
  975. F_MsgBoxLater( G_ResManager.F_GetString( "IDS_HAL_ERR_INVALID_MAX", Number.F_ToLocalizedString( v_vMax ) ) );
  976. }
  977. this.f_onSettingFailedValidationChange( v_sName );
  978. };
  979. C_SettingSheet.prototype.F_OnSettingChange = function( v_sProp, v_sValue )
  980. {
  981. if( this.m_oListener && this.m_oListener.F_HighlightSettings )
  982. {
  983. this.m_oListener.F_HighlightSettings( this.F_GetFixedValueCell( v_sProp ), this.F_GetSettingAttribute( v_sProp, "defaultValue" ) != v_sValue );
  984. }
  985. this.F_SetUpdate( true );
  986. this.F_ShowSetting( v_sProp, v_sValue );
  987. };
  988. C_SettingSheet.prototype.f_onSettingFailedValidationChange = function( v_sProp, v_sValue )
  989. {
  990. this.F_SetUpdate( true );
  991. this.F_ShowSetting( v_sProp, v_sValue );
  992. };
  993. /**
  994. * @private
  995. */
  996. C_SettingSheet.prototype.f_processNumericInput = function( v_sProp, v_sValue, v_vValue, v_vMin, v_vMax )
  997. {
  998. if ( isNaN( v_vValue ) )
  999. {
  1000. this.f_onSettingFailedValidation( C_SettingSheet.K_iNotValid, v_sProp, v_sValue, v_vMin, v_vMax );
  1001. return false;
  1002. }
  1003. if ( !isNaN( v_vMin ) && ( v_vValue < v_vMin ) )
  1004. {
  1005. this.f_onSettingFailedValidation( C_SettingSheet.K_iLessThanMin, v_sProp, v_sValue, v_vMin, v_vMax );
  1006. return false;
  1007. }
  1008. if ( !isNaN( v_vMax ) && ( v_vValue > v_vMax ) )
  1009. {
  1010. this.f_onSettingFailedValidation( C_SettingSheet.K_iGreaterThanMax, v_sProp, v_sValue, v_vMin, v_vMax );
  1011. return false;
  1012. }
  1013. return true;
  1014. };
  1015. /**
  1016. * Shows the list view for a drop down or drop down list setting.
  1017. * @param {String} v_sName The setting name.
  1018. * @param {String} v_sValue The setting value.
  1019. * @param {Node} v_nListView The listView node.
  1020. * @param {Integer} v_iHeight Height of the listView.
  1021. * @param {Integer} v_iWidth Width of the listView.
  1022. * @type void
  1023. */
  1024. C_SettingSheet.prototype.F_ShowListView = function( v_sName, v_sValue, v_nListView, v_iHeight, v_iWidth, v_bAutoWidth )
  1025. {
  1026. var td = this.f_getValueCell( v_sName );
  1027. D_SettingSheetListView.F_Show( this, td, v_sName, v_sValue, v_nListView, v_iHeight, v_iWidth, true );
  1028. };
  1029. C_SettingSheet.prototype.f_setupAccessibility = function()
  1030. {
  1031. if ( !G_HAL.M_oLibraries["hal"]["enableAccessibility"] )
  1032. {
  1033. return;
  1034. }
  1035. this.m_tbl.setAttribute( "role", "treegrid" );
  1036. this.m_tbl.setAttribute( "aria-label", G_ResManager.F_GetString( "IDS_AC_SETTINGSHEET_TABLE" ) );
  1037. };
  1038. C_SettingSheet.prototype.f_updateSettingAriaLabel = function( v_sName, v_sDisplayValue )
  1039. {
  1040. if ( !G_HAL.M_oLibraries["hal"]["enableAccessibility"] )
  1041. {
  1042. return;
  1043. }
  1044. var v_tdValue = this.F_GetFixedValueCell( v_sName );
  1045. switch ( this.m_oTypes[v_sName] )
  1046. {
  1047. case "string":
  1048. var v_sAriaLabel = ( this.m_oTypes[v_sName] == "string" ) ? "IDS_HAL_AC_PROPERTY_TEXT" : "IDS_HAL_AC_PROPERTY_DROPDOWN";
  1049. v_sDisplayValue = v_sDisplayValue || G_ResManager.F_GetString( v_sAriaLabel );
  1050. v_tdValue.firstChild.setAttribute( "aria-label", v_sDisplayValue );
  1051. break;
  1052. case "boolean":
  1053. case "dropDownList":
  1054. v_tdValue.setAttribute( "aria-label", v_sDisplayValue );
  1055. break;
  1056. }
  1057. };
  1058. C_SettingSheet.prototype.f_setupAccessibilityEventHandler = function( v_bAdd )
  1059. {
  1060. if ( !G_HAL.M_oLibraries["hal"]["enableAccessibility"] || !this.m_tbl )
  1061. {
  1062. return;
  1063. }
  1064. if ( !this.m_fnOnFocusCallback )
  1065. {
  1066. this.m_fnOnFocusCallback = this.f_onFocus.F_CreateMethodCallback( this );
  1067. }
  1068. // Accessibility is only suspported on FF
  1069. if ( v_bAdd )
  1070. {
  1071. // focus and blur events don't bubble, so we have to capture it
  1072. U_Accessibility.F_AddFocusAndBlurEventListener( this.m_tbl, this.m_fnOnFocusCallback, null );
  1073. }
  1074. else
  1075. {
  1076. U_Accessibility.F_RemoveFocusAndBlurEventListener( this.m_tbl, this.m_fnOnFocusCallback, null );
  1077. }
  1078. };
  1079. C_SettingSheet.prototype.f_onFocus = function( e )
  1080. {
  1081. if ( !G_HAL.M_oLibraries["hal"]["enableAccessibility"] )
  1082. {
  1083. return;
  1084. }
  1085. e = e || window.event;
  1086. var v_elSrc = e.srcElement;
  1087. var v_trSettingRow = this.f_getSettingRowFromChild( v_elSrc );
  1088. this.f_activateSetting( v_trSettingRow );
  1089. if ( this.m_elLastFocus )
  1090. {
  1091. this.m_elLastFocus.setAttribute( "tabIndex", "-1" );
  1092. }
  1093. v_elSrc.setAttribute( "tabIndex", "0" );
  1094. this.m_elLastFocus = v_elSrc;
  1095. };
  1096. C_SettingSheet.prototype.f_clearAccessibility = function()
  1097. {
  1098. if ( !G_HAL.M_oLibraries["hal"]["enableAccessibility"] )
  1099. {
  1100. return;
  1101. }
  1102. this.m_elLastFocus = null;
  1103. };
  1104. C_SettingSheet.prototype.f_getActionButton = function( v_sName )
  1105. {
  1106. var v_elButtonTD;
  1107. var v_elValueCellTable = this.f_getValueCell( v_sName ).firstChild;
  1108. if ( v_elValueCellTable )
  1109. {
  1110. v_elButtonTD = v_elValueCellTable.rows.item( 0 ).cells.item( 1 );
  1111. }
  1112. return v_elButtonTD ? v_elButtonTD.firstChild : null;
  1113. };
  1114. /*
  1115. * @public
  1116. */
  1117. C_SettingSheet.prototype.F_GetFocusableElements = function( v_sSettingName )
  1118. {
  1119. if ( !G_HAL.M_oLibraries["hal"]["enableAccessibility"] )
  1120. {
  1121. return null;
  1122. }
  1123. var v_aFocus = [];
  1124. v_aFocus.push( this.f_getLabelCell( v_sSettingName ) );
  1125. var v_elValue;
  1126. var v_trSettingRow = this.f_getSettingRow( v_sSettingName );
  1127. switch ( v_trSettingRow.v_sSettingType )
  1128. {
  1129. case "string":
  1130. v_elValue = this.F_GetFixedValueCell( v_sSettingName ).firstChild;
  1131. break;
  1132. case "dropDownList":
  1133. case "boolean":
  1134. v_elValue = this.F_GetFixedValueCell( v_sSettingName );
  1135. break;
  1136. }
  1137. if ( v_elValue )
  1138. {
  1139. v_aFocus.push( v_elValue );
  1140. }
  1141. var v_elButton = this.f_getActionButton( v_sSettingName );
  1142. if ( v_elButton )
  1143. {
  1144. v_aFocus.push( v_elButton );
  1145. }
  1146. return v_aFocus;
  1147. };
  1148. C_SettingSheet.prototype.f_handleAccessibilityKeyDown = function( e )
  1149. {
  1150. if ( !G_HAL.M_oLibraries["hal"]["enableAccessibility"] || !this.m_sActiveSetting )
  1151. {
  1152. return;
  1153. }
  1154. var v_srcEle = e.srcElement;
  1155. switch ( e.keyCode )
  1156. {
  1157. case U_DOM.K_iKeyArrowUp:
  1158. U_DOM.F_CancelEvent( e );
  1159. var v_iRow = this.m_oSettingToRow[this.m_sActiveSetting];
  1160. var v_iNumberOfRows = this.m_tbl.rows.length;
  1161. for ( var i = v_iRow - 1; i >= 0; i-- )
  1162. {
  1163. var v_elPreviousRow = this.m_tbl.rows.item( i );
  1164. if ( v_elPreviousRow && v_elPreviousRow.style.display != "none")
  1165. {
  1166. var v_aFocus = this.F_GetFocusableElements( v_elPreviousRow.v_sSettingName );
  1167. if ( v_aFocus && v_aFocus.length > 0 )
  1168. {
  1169. v_aFocus[0].focus();
  1170. return;
  1171. }
  1172. }
  1173. }
  1174. break;
  1175. case U_DOM.K_iKeyArrowDown:
  1176. U_DOM.F_CancelEvent( e );
  1177. var v_iRow = this.m_oSettingToRow[this.m_sActiveSetting];
  1178. var v_iNumberOfRows = this.m_tbl.rows.length;
  1179. for ( var i = v_iRow + 1; i < v_iNumberOfRows; i++ )
  1180. {
  1181. var v_elNextRow = this.m_tbl.rows.item( i );
  1182. if ( v_elNextRow && v_elNextRow.style.display != "none")
  1183. {
  1184. var v_aFocus = this.F_GetFocusableElements( v_elNextRow.v_sSettingName );
  1185. if ( v_aFocus && v_aFocus.length > 0 )
  1186. {
  1187. v_aFocus[0].focus();
  1188. return;
  1189. }
  1190. }
  1191. }
  1192. break;
  1193. case U_DOM.K_iKeyArrowLeft:
  1194. U_DOM.F_CancelEvent( e );
  1195. var v_aFocus = this.F_GetFocusableElements( this.m_sActiveSetting );
  1196. for ( var i = v_aFocus.length - 1; i >= 0; i-- )
  1197. {
  1198. if ( v_aFocus[i] == v_srcEle && v_aFocus[i-1] )
  1199. {
  1200. v_aFocus[i-1].focus();
  1201. return;
  1202. }
  1203. }
  1204. break;
  1205. case U_DOM.K_iKeyArrowRight:
  1206. U_DOM.F_CancelEvent( e );
  1207. var v_aFocus = this.F_GetFocusableElements( this.m_sActiveSetting );
  1208. for ( var i = 0; i < v_aFocus.length; i++ )
  1209. {
  1210. if ( v_aFocus[i] == v_srcEle && v_aFocus[i+1] )
  1211. {
  1212. v_aFocus[i+1].focus();
  1213. return;
  1214. }
  1215. }
  1216. break;
  1217. case U_DOM.K_iKeySpace:
  1218. case U_DOM.K_iKeyEnter:
  1219. // for button, browser actually fire a onclick event
  1220. if ( this.m_sActiveSetting && v_srcEle.nodeName != "BUTTON" )
  1221. {
  1222. var v_trSettingRow = this.f_getSettingRow( this.m_sActiveSetting );
  1223. this.f_doDblClick( v_trSettingRow );
  1224. U_DOM.F_CancelEvent( e );
  1225. }
  1226. break;
  1227. case U_DOM.K_iKeyDelete:
  1228. if ( !this.m_bEditingText && this.m_sActiveSetting )
  1229. {
  1230. this.m_oListener.F_SettingSheet_OnSettingDelete( this, this.m_sActiveSetting );
  1231. U_DOM.F_CancelEvent( e );
  1232. }
  1233. break;
  1234. }
  1235. };
  1236. G_HAL.F_VerifyDependencies( "C_Dialog" );
  1237. /**
  1238. * @private
  1239. */
  1240. var D_SettingSheetListView = new C_Dialog( "D_SettingSheetListView" );
  1241. /**
  1242. * @private
  1243. */
  1244. D_SettingSheetListView.F_Show = function( v_oSettingSheet, td, v_sName, v_sValue, v_nListView, v_iHeight, v_iWidth, v_bAutoWidth )
  1245. {
  1246. if ( !this.m_divListView )
  1247. {
  1248. this.m_divListView = this.F_GetDlgItem( "divListView" );
  1249. }
  1250. this.m_oSettingSheet = v_oSettingSheet;
  1251. var doc = document;
  1252. this.m_sSettingName = v_sName;
  1253. var v_sHeight = isNaN( v_iHeight ) ? ( ( v_nListView.selectNodes( "listItems/listItem" ).length > 8 ) ? "1.2in" : "" ) : ( v_iHeight + "px" );
  1254. this.m_divListView.style.height = v_sHeight;
  1255. if ( isNaN( v_iWidth ) )
  1256. {
  1257. v_iWidth = td.offsetWidth - 1;
  1258. }
  1259. var v_sWidth = ( Math.max( 60, v_iWidth ) + "px" );
  1260. if ( G_BrowserInfo.M_bIsIE )
  1261. {
  1262. this.m_divListView.style.width = v_sWidth;
  1263. }
  1264. else
  1265. {
  1266. this.m_divListView.style.width = "auto";
  1267. this.m_divListView.style.minWidth = v_sWidth;
  1268. }
  1269. if (v_bAutoWidth)
  1270. {
  1271. this.m_divListView.style.overflow = "visible";
  1272. this.m_divListView.style.overflowY = "auto";
  1273. }
  1274. else
  1275. {
  1276. this.m_divListView.style.overflow = "";
  1277. this.m_divListView.style.overflowY = "";
  1278. }
  1279. v_nListView.setAttribute( "allowCtrlDeselect", "false" );
  1280. this.m_oListView = new C_ListView( this.m_divListView, v_nListView, this );
  1281. if ( v_sValue == null )
  1282. {
  1283. this.m_oListView.F_ClearSelections( true );
  1284. }
  1285. this.M_fnSuper_Show( td );
  1286. if ( v_sValue != null )
  1287. {
  1288. this.m_oListView.F_SelectByValue( v_sValue, true, false );
  1289. }
  1290. };
  1291. /**
  1292. * @private
  1293. */
  1294. D_SettingSheetListView.F_Dialog_OnAfterVisible = function()
  1295. {
  1296. if ( G_BrowserInfo.M_bIsIE && ( this.m_oListView.F_GetListViewNode().getAttribute( "view" ) == "report" ) )
  1297. {
  1298. this.m_divListView.style.paddingBottom = ( this.m_divListView.scrollWidth > this.m_divListView.offsetWidth ) ? "16px" : "";
  1299. }
  1300. this.F_EnsureDialogIsVisible();
  1301. this.m_divListView.focus();
  1302. };
  1303. /**
  1304. * @private
  1305. */
  1306. D_SettingSheetListView.F_Dialog_OnAfterHide = function()
  1307. {
  1308. if ( this.m_oListView )
  1309. {
  1310. this.m_oListView.F_Detach();
  1311. delete this.m_oListView;
  1312. }
  1313. delete this.m_oSettingSheet;
  1314. };
  1315. /**
  1316. * @private
  1317. */
  1318. D_SettingSheetListView.F_ListView_OnItemClick = function( v_oListView, v_nListItem, v_iMouseButton )
  1319. {
  1320. if (v_nListItem.getAttribute("selectable") == "false")
  1321. {
  1322. return;
  1323. }
  1324. setTimeout( this.F_Hide.F_CreateMethodCallback( this ), 0 );
  1325. var v_sValue = v_nListItem.getAttribute( "value" );
  1326. if ( v_sValue == null )
  1327. {
  1328. v_sValue = C_ListView.F_GetListItemLabel( v_nListItem );
  1329. }
  1330. this.m_oSettingSheet.F_OnSettingChange( this.m_sSettingName, v_sValue );
  1331. // var v_oListener = this.m_oSettingSheet.m_oListener;
  1332. // setTimeout( v_oListener.F_SettingSheet_OnSettingChange.F_CreateMethodCallback( v_oListener, this.m_oSettingSheet, this.m_sSettingName, v_sValue ), 0 );
  1333. };