Range.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650
  1. /*
  2. *+------------------------------------------------------------------------+
  3. *| Licensed Materials - Property of IBM
  4. *| BI and PM: prmt
  5. *| (C) Copyright IBM Corp. 2002, 2017
  6. *|
  7. *| US Government Users Restricted Rights - Use, duplication or
  8. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  9. *|
  10. *+------------------------------------------------------------------------+
  11. */
  12. /**
  13. This script is used to provide interactivity for the
  14. range versions of each of the prompt controls.
  15. @class
  16. @private
  17. */
  18. cognos.Prompt.Control.Range = cognos.Prompt.Control.f_extend({
  19. f_initialize: function( v_oProps, v_oPM ) {
  20. this.f_parent( v_oProps );
  21. this.m_oProps = v_oProps;
  22. this.m_oPM = v_oPM;
  23. this.m_bSkipAdornments = true;
  24. this.f_draw();
  25. },
  26. checkData: function() {
  27. // We keep a reference to the parent function
  28. // Calling this.m_oFrom functions seems to have a side effect on this.f_parent().
  29. var v_fnParent = this.f_parent;
  30. if (!this.isMulti()) {
  31. if (this.isRequired()) {
  32. if ((typeof this[K_PRMT_RANGE_FORCE_BOUNDRANGE] != K_PRMT_sUNDEFINED) && this[K_PRMT_RANGE_FORCE_BOUNDRANGE] === true) {
  33. this.m_bValid = this.m_oFrom.hasValue() && this.m_oTo.hasValue();
  34. }
  35. else {
  36. this.m_bValid = this.m_oFrom.hasValue() || this.m_oTo.hasValue();
  37. }
  38. var v_oFrom = this.m_oFrom;
  39. var v_oTo = this.m_oTo;
  40. if (v_oFrom._type_ == "cognos.Prompt.Control.Text") {
  41. setTimeout(function(){
  42. // set From: as valid if there is a valid value in To: and From: is empty
  43. if (v_oFrom.m_bValid || (v_oTo.m_bValid && v_oFrom.getValue() === ""))
  44. v_oFrom.checkPass();
  45. else
  46. v_oFrom.checkFail();
  47. // set To: as valid if there is a valid value in From: and To: is empty
  48. if (v_oTo.m_bValid || (v_oFrom.m_bValid && v_oTo.getValue() === ""))
  49. v_oTo.checkPass();
  50. else
  51. v_oTo.checkFail();
  52. }, 1);
  53. }
  54. }
  55. else {
  56. var bFromValid = (this.m_rdFrom && this.m_rdFrom.checked ? this.m_oFrom.hasValue() : true);
  57. var bToValid = (this.m_rdTo && this.m_rdTo.checked ? this.m_oTo.hasValue() : true);
  58. this.m_bValid = bFromValid && bToValid;
  59. }
  60. } else {
  61. this.m_bValid = this.m_oChoices.f_getValid();
  62. }
  63. this.f_parent = v_fnParent; // call parent's checkData using saved reference.
  64. this.f_parent(); // call parent's checkData using saved reference.
  65. return this.m_bValid;
  66. },
  67. clearValues: function()
  68. {
  69. this.f_parent();
  70. this.m_oFrom.clearValues();
  71. this.m_oTo.clearValues();
  72. },
  73. f_drawCompleted: function() {
  74. // We keep a reference to the parent function
  75. // Calling this.m_oFrom.f_drawCompleted seems to have a side effect on this.f_parent().
  76. var v_fnParent = this.f_parent;
  77. var v_oFrom = this.m_oFrom;
  78. var v_oTo = this.m_oTo;
  79. if ( this["n"] == "selectValue" )
  80. {
  81. // replace/clone select boxes
  82. var v_elPrompt = $( this.f_getId(K_PRMT_sSV_PREFIX) );
  83. if (v_elPrompt)
  84. {
  85. var v_sFromId = this.f_getId(K_PRMT_sRANGE_FROM_PREFIX);
  86. var v_sToId = this.f_getId(K_PRMT_sRANGE_TO_PREFIX);
  87. var v_elFrom = $( v_sFromId );
  88. var v_elTo = $( v_sToId );
  89. if ( v_elFrom )
  90. {
  91. v_elPrompt.setAttribute( "id", v_oFrom.f_getId(K_PRMT_sSV_PREFIX) );
  92. v_oFrom.f_moveInContainer( v_elFrom, v_elPrompt );
  93. }
  94. if ( v_elTo )
  95. {
  96. var v_elPromptClone = v_elPrompt.cloneNode(true);
  97. v_elPromptClone.setAttribute( "id", v_oTo.f_getId(K_PRMT_sSV_PREFIX) );
  98. v_oTo.f_moveInContainer( v_elTo, v_elPromptClone );
  99. }
  100. }
  101. }
  102. v_oFrom.f_drawCompleted();
  103. v_oTo.f_drawCompleted();
  104. // For DateTime controls, set the TO's time to latest value for the visible fields, for all: 23:59:59.999
  105. if ( v_oTo && (v_oTo.m_oTime && v_oTo.m_oTime.f_setTime) || v_oTo.f_setTime ) {
  106. var v_defaultSeconds = ( this["@showSeconds"]? "59" : "00" );
  107. var v_defaultMilliSeconds = ( this["@showMilliseconds"]? "999" : "000" );
  108. var v_defaultToTime = "23:59:" + v_defaultSeconds + "." + v_defaultMilliSeconds;
  109. if ( v_oTo && v_oTo.m_oTime && v_oTo.m_oTime.f_setTime ) {
  110. v_oTo.m_oTime.f_setTime( v_defaultToTime );
  111. } else if ( v_oTo && v_oTo.f_setTime ) {
  112. v_oTo.f_setTime( v_defaultToTime );
  113. }
  114. }
  115. if ( !this[K_PRMT_sATTR_DISABLED] )
  116. {
  117. var tmp = this.f_setRangeEvents( K_PRMT_sRANGE_FROM_PREFIX );
  118. this.m_rdFrom = tmp[0];
  119. this.m_rdFromDefault = tmp[1];
  120. tmp = this.f_setRangeEvents( K_PRMT_sRANGE_TO_PREFIX );
  121. this.m_rdTo = tmp[0];
  122. this.m_rdToDefault = tmp[1];
  123. }
  124. this.f_parent = v_fnParent; // call parent's f_drawCompleted using saved reference.
  125. this.f_parent(); // call parent's f_drawCompleted using saved reference.
  126. }
  127. });
  128. /**
  129. See {@link cognos.Prompt.Control.addValues} for more info.
  130. @param {cognos.Value[]}
  131. @return {void}
  132. */
  133. cognos.Prompt.Control.Range.prototype.addValues = function( v_aValues )
  134. {
  135. for (var v_idx = 0; v_idx < v_aValues.length; v_idx++)
  136. {
  137. var v_oValue = v_aValues[v_idx];
  138. if (v_oValue.start) {
  139. if (this.m_rdFrom) {
  140. this.m_rdFrom.checked = true;
  141. }
  142. this.m_oFrom.addValues( [v_oValue.start] );
  143. } else {
  144. if (this.m_rdFrom) {
  145. this.m_rdFrom.checked = false;
  146. this.m_rdFromDefault.checked = true;
  147. }
  148. this.m_oFrom.clearValues();
  149. }
  150. if (v_oValue.end) {
  151. if (this.m_rdTo) {
  152. this.m_rdTo.checked = true;
  153. }
  154. this.m_oTo.addValues( [v_oValue.end] );
  155. } else {
  156. if (this.m_rdTo) {
  157. this.m_rdTo.checked = false;
  158. this.m_rdToDefault.checked = true;
  159. }
  160. this.m_oTo.clearValues();
  161. }
  162. if ( this.m_oChoices ) {
  163. this.m_oChoices.F_Insert();
  164. var v_oFrom = this.m_oFrom;
  165. var v_oTo = this.m_oTo;
  166. setTimeout(function() {
  167. v_oFrom.clearValues();
  168. v_oTo.clearValues();
  169. },0);
  170. }
  171. }
  172. PRMTUtils.f_updateRadioButtons(this.m_rdFrom);
  173. PRMTUtils.f_updateRadioButtons(this.m_rdTo);
  174. };
  175. /**
  176. @private
  177. @return {void}
  178. */
  179. cognos.Prompt.Control.Range.prototype.f_checkRadioCheckData = function()
  180. {
  181. this.m_radio.checked = true;
  182. this.m_oPrompt.checkData();
  183. PRMTUtils.f_updateRadioButtons(this.m_radio);
  184. };
  185. /**
  186. Sets the JavaScript references used by custom scripts based on generated code from Blaring and before.
  187. (Custom Scripts Workaround)
  188. @private
  189. */
  190. cognos.Prompt.Control.Range.prototype.f_CSW_init = function()
  191. {
  192. var aRadios = document.getElementsByName( this.f_getId("pFrom_") );
  193. this.f_CSW_createJSObject( "fromValue", aRadios );
  194. aRadios = document.getElementsByName( this.f_getId("pTo_") );
  195. this.f_CSW_createJSObject( "toValue", aRadios );
  196. };
  197. /**
  198. @private
  199. @param {C_PromptElement} v_el Container.
  200. @return {void}
  201. */
  202. cognos.Prompt.Control.Range.prototype.f_drawInput = function( v_el )
  203. {
  204. var oFrom = Object.f_extend( {}, this.m_oProps );
  205. oFrom["@range"] = false;
  206. oFrom["@multiSelect"] = false;
  207. oFrom.m_oRangeControl = this;
  208. oFrom.m_bIsAComponent = true;
  209. var oTo = Object.f_extend( {}, oFrom );
  210. oFrom._id_ = this.f_getId( K_PRMT_sRANGE_FROM_PREFIX );
  211. oFrom.m_sCSW_rangeSuffix = "range_from";
  212. oTo._id_ = this.f_getId( K_PRMT_sRANGE_TO_PREFIX );
  213. oTo.m_sCSW_rangeSuffix = "range_to";
  214. var v_oFrom = this.f_getPM().f_create( oFrom );
  215. var v_oTo = this.f_getPM().f_create( oTo );
  216. v_oTo.m_bIsRangeEndControl = true;
  217. v_oTo.m_elRangeContainer = v_oFrom.m_elRangeContainer = $( this.f_getId(this.m_sDivPrefix) );
  218. var v_tdRange = v_el;
  219. v_tdRange["vAlign"] = "top";
  220. var v_tbl = $CE( "table", {
  221. "border": K_PRMT_DEBUG_TABLEBORDER,
  222. "cellPadding": 0,
  223. "cellSpacing": 0,
  224. "role":K_PRMT_ARIA_ROLE_PRESENTATION
  225. }, v_tdRange );
  226. var v_tbd = $CE( "tbody", {}, v_tbl );
  227. this.f_drawRangeControl( v_oFrom, v_tbd, this[K_PRMT_LABEL_RANGE_FROM], v_oFrom[K_PRMT_LABEL_RANGE_LOWEST], "pFrom_" );
  228. var v_trSpacer = $CE( "tr", {}, v_tbd );
  229. var v_tdSpacer = $CE( "td", {"height": 10}, v_trSpacer );
  230. $CE("img", {"src": this.m_sSkin + "/prompting/images/spacer.gif", "width": 1, "height": 1, "border": 0, "alt":""}, v_tdSpacer);
  231. this.f_drawRangeControl( v_oTo, v_tbd, this[K_PRMT_LABEL_RANGE_TO], v_oFrom[K_PRMT_LABEL_RANGE_HIGHEST], "pTo_" );
  232. this.m_oFrom = v_oFrom;
  233. this.m_oTo = v_oTo;
  234. return this;
  235. };
  236. /**
  237. Render input control for a range.
  238. @private
  239. @param {cognos.Prompt.Control} v_oPrompt.
  240. @param {C_PromptElement} v_el Container.
  241. @param {String} v_sLabel From/To label
  242. @param {String} v_sText From/To text
  243. @param {String} v_sPrefix Prefix for this control.
  244. @return {void}
  245. */
  246. cognos.Prompt.Control.Range.prototype.f_drawRangeControl = function( v_oPrompt, v_el, v_sLabel, v_sText, v_sPrefix )
  247. {
  248. var v_bUseRadioButtons = ( !this.isRequired() || this.isMulti() );
  249. var v_tr = $CE( "tr", {}, v_el );
  250. var v_inputId = this.f_getId( v_sPrefix );
  251. var v_labelInputId = null;
  252. if (!v_bUseRadioButtons && v_oPrompt && v_oPrompt.f_getRangeInputId) {
  253. v_labelInputId = v_oPrompt.f_getRangeInputId();
  254. }
  255. //v_oPrompt.
  256. // draw the label (From || To)
  257. var v_td = $CE( "td", {"class": "clsControlLabel pc", "noWrap": "nowrap"}, v_tr );
  258. var v_labelId = this.f_getId( v_sPrefix + "label" );
  259. var v_labelAttr = { "id": v_labelId };
  260. if(!v_bUseRadioButtons && v_labelInputId) {
  261. v_labelAttr["for"] = v_labelInputId;
  262. }
  263. var v_captionLabel = $CE( "label", v_labelAttr, v_td );
  264. v_captionLabel.f_appendText( v_sLabel );
  265. v_tr = $CE( "tr", {}, v_el );
  266. v_td = $CE( "td", {"vAlign": "top"}, v_tr );
  267. // creating a table to hold the range Control (From || To )
  268. var v_groupAttr = {"vAlign": "top", "border": "0","cellPadding": 0, "cellSpacing": 0};
  269. if(v_bUseRadioButtons) {
  270. v_groupAttr["role"] = "radiogroup";
  271. } else {
  272. v_groupAttr["role"] = "group";
  273. }
  274. if (!v_labelInputId) {
  275. v_groupAttr["aria-labelledby"] = v_labelId;
  276. }
  277. v_table = $CE( "table", v_groupAttr, v_td );
  278. v_tr = $CE( "tr", {"id": v_oPrompt.f_getId(K_PRMT_sRANGE_ROW_INPUT_PREFIX)}, v_table );
  279. var v_radioCellWidth = (PRMTUtils.f_isHighContrast() && window.ie?"25px":"15:px");
  280. // first column cell
  281. v_td = $CE( "td", {"vAlign": "middle", "width": v_radioCellWidth}, v_tr );
  282. var v_sName = this.f_getId( v_sPrefix );
  283. var radioButtonAttrib = {
  284. "type": "radio",
  285. "name": v_sName,
  286. "id": v_inputId,
  287. "class": "dijitCheckBoxInput",
  288. style: "margin:0",
  289. "onFocus": "PRMTUtils.f_RangeRadioOnFocus(this)",
  290. "onBlur": "PRMTUtils.f_RangeRadioOnBlur(this)"
  291. };
  292. if ( v_bUseRadioButtons )
  293. {
  294. var v_radioDiv = $CE( "div", {"class": K_PRMT_CSS_RADIOBUTTON}, v_td );
  295. // associating the label ( From | To ) with the first radio button
  296. var v_input = $CE( "input", radioButtonAttrib, v_radioDiv );
  297. if ( this[K_PRMT_sATTR_DISABLED] )
  298. {
  299. v_input.f_setProperty( "disabled", "true" );
  300. }
  301. v_oPrompt["@title"] = v_sLabel;
  302. }
  303. else{
  304. $CE("img", {"src": this.m_sSkin + "/prompting/images/spacer.gif", "width": 10, "height": 1, "border": 0, "alt":""}, v_td);
  305. }
  306. if ( this.isMulti() )
  307. {
  308. v_oPrompt["@required"] = false;
  309. }
  310. if ( v_oPrompt.n != "selectInterval" )
  311. {
  312. v_oPrompt["@hideAdornments"] = true;
  313. }
  314. // draw input
  315. v_td = $CE( "td", {"id": v_oPrompt._id_}, v_tr );
  316. if ( cssParser( this["@style"], "width" ) )
  317. {
  318. v_td.f_setProperty( "width", "100%" );
  319. }
  320. var v_oInput = v_oPrompt.f_drawInput( v_td );
  321. // second radio button
  322. v_inputId = this.f_getId( v_sPrefix + "2_" );
  323. if ( !this.isRequired() || this.isMulti() )
  324. {
  325. v_tr = $CE( "tr", {"id": v_oPrompt.f_getId(K_PRMT_sRANGE_ROW_DEFAULT_PREFIX)}, v_table );
  326. v_td = $CE( "td", {"vAlign": "middle", "width": v_radioCellWidth}, v_tr );
  327. radioButtonAttrib.id = v_inputId;
  328. radioButtonAttrib.checked = true;
  329. var v_radioDiv = $CE( "div", {"class": K_PRMT_CSS_RADIOBUTTON_CHECKED}, v_td );
  330. var v_input = $CE( "input", radioButtonAttrib, v_radioDiv );
  331. if ( this[K_PRMT_sATTR_DISABLED] )
  332. {
  333. v_input.f_setProperty( "disabled", "true" );
  334. }
  335. var v_oLabelTDAttrib = {
  336. "vAlign": "middle",
  337. "height": "20px",
  338. "class": "clsReadOnlyText pe"
  339. };
  340. if ( v_oPrompt.n == "selectInterval" ) {
  341. v_oLabelTDAttrib["style"] = "padding-left:12px;";
  342. }
  343. v_td = $CE( "td", v_oLabelTDAttrib, v_tr );
  344. v_captionLabel = $CE( "label", { "for": v_inputId }, v_td );
  345. v_captionLabel.f_appendText( v_sText )
  346. }
  347. return v_oInput;
  348. };
  349. /**
  350. @private
  351. @return {void}
  352. */
  353. cognos.Prompt.Control.Range.prototype.f_getPM = function()
  354. {
  355. return (this.m_oPM);
  356. };
  357. /**
  358. Return all values for this control.
  359. @private
  360. @param {boolean} [bSkipType] Skip setting the promptType as part of the values returned. Used by Control.getValues().
  361. @return {cognos.Value[]}
  362. */
  363. cognos.Prompt.Control.Range.prototype.f_getPV = function(bSkipType)
  364. {
  365. var v_oStart = null;
  366. var v_oEnd = null;
  367. var v_oPV = null;
  368. if ( (!this.m_rdFrom || this.m_rdFrom.checked) && this.m_oFrom.hasValue() )
  369. {
  370. var tmpSave = this.m_oFrom.m_bisGetValuesCall;
  371. if (this.m_bisGetValuesCall) {
  372. this.m_oFrom.m_bisGetValuesCall = true;
  373. }
  374. v_oStart = this.m_oFrom.f_getPV();
  375. this.m_oFrom.m_bisGetValuesCall = tmpSave;
  376. }
  377. if ( (!this.m_rdTo || this.m_rdTo.checked) && this.m_oTo.hasValue() )
  378. {
  379. var tmpSave = this.m_oTo.m_bisGetValuesCall;
  380. if (this.m_bisGetValuesCall) {
  381. this.m_oTo.m_bisGetValuesCall = true;
  382. }
  383. v_oEnd = this.m_oTo.f_getPV();
  384. this.m_oTo.m_bisGetValuesCall = tmpSave;
  385. }
  386. if ( v_oStart && v_oEnd )
  387. {
  388. var v_iCompare = this.m_oTo.f_compare(this.m_oFrom);
  389. if ( v_iCompare == -1 )
  390. {
  391. // switch start and end
  392. var v_oTemp = v_oEnd;
  393. v_oEnd = v_oStart;
  394. v_oStart = v_oTemp;
  395. if (this.n == "selectDate" && this["@DateTime"])
  396. {
  397. // need to fix the time values for date controls using dateTime format.
  398. v_oStart["use"] = v_oStart["use"].replace( K_PRMT_reTIMEPART, K_PRMT_sTIME_MIN );
  399. v_oEnd["use"] = v_oEnd["use"].replace( K_PRMT_reTIMEPART, K_PRMT_sTIME_MAX );
  400. }
  401. }
  402. else if ( v_iCompare == 0 && !(this.n == "selectDate" && this["@DateTime"]) )
  403. {
  404. // start and end are the same, just use a plain value then
  405. v_oPV = this.m_oFrom.getValues()[0];
  406. v_oStart = v_oEnd = null;
  407. }
  408. }
  409. if ( v_oStart || v_oEnd )
  410. {
  411. v_oPV = {};
  412. if ( v_oStart )
  413. {
  414. v_oPV["start"] = (v_oStart.length && v_oStart.length == 1 ? v_oStart[0] : v_oStart);
  415. }
  416. if ( v_oEnd )
  417. {
  418. v_oPV["end"] = (v_oEnd.length && v_oEnd.length == 1 ? v_oEnd[0] : v_oEnd);
  419. }
  420. }
  421. if (v_oPV && bSkipType !== true)
  422. {
  423. v_oPV.promptType = this.m_oFrom._type_;
  424. }
  425. return v_oPV;
  426. };
  427. /**
  428. @private
  429. @param {event} evt
  430. @return {void}
  431. */
  432. cognos.Prompt.Control.Range.prototype.f_keyDown = function(evt)
  433. {
  434. var evt = ( arguments && arguments.length ? arguments[arguments.length-1] : null );
  435. var v_oEvt = (evt ? evt : (typeof event != K_PRMT_sUNDEFINED ? event : null ));
  436. if ( v_oEvt )
  437. {
  438. switch( v_oEvt.which || v_oEvt.keyCode )
  439. {
  440. case 9: //tab
  441. case 16: // shift
  442. case 17: // ctrl
  443. case 18: // alt
  444. // skip
  445. break;
  446. default:
  447. this.m_radio.checked = true;
  448. PRMTUtils.f_updateRadioButtons(this.m_radio);
  449. };
  450. }
  451. this.m_oPrompt.checkData();
  452. };
  453. /**
  454. @private
  455. @param {cognos.Value} v_oPV
  456. @return {void}
  457. */
  458. cognos.Prompt.Control.Range.prototype.f_setPV = function ( v_oPV )
  459. {
  460. if ( v_oPV.start || v_oPV.end )
  461. {
  462. if ( v_oPV.start )
  463. {
  464. this.m_oFrom.f_setPV( v_oPV.start );
  465. if (this.m_rdFrom)
  466. {
  467. this.m_rdFrom.checked = true;
  468. }
  469. }
  470. if ( v_oPV.end )
  471. {
  472. this.m_oTo.f_setPV( v_oPV.end );
  473. if (this.m_rdTo)
  474. {
  475. this.m_rdTo.checked = true;
  476. }
  477. }
  478. }
  479. else
  480. {
  481. this.m_oFrom.f_setPV( v_oPV );
  482. if ( this.m_rdFrom && (v_oPV.use || v_oPV.display) )
  483. {
  484. this.m_rdFrom.checked = true;
  485. }
  486. this.m_oTo.f_setPV( v_oPV );
  487. if ( this.m_rdTo && (v_oPV.use || v_oPV.display) )
  488. {
  489. this.m_rdTo.checked = true;
  490. }
  491. }
  492. PRMTUtils.f_updateRadioButtons(this.m_rdFrom);
  493. PRMTUtils.f_updateRadioButtons(this.m_rdTo);
  494. };
  495. /**
  496. @private
  497. @param {String} v_sId
  498. @return {[DOMElement,DOMElement]} Array containing the two radio buttons.
  499. */
  500. cognos.Prompt.Control.Range.prototype.f_setRangeEvents = function( v_sId )
  501. {
  502. var v_result = [null, null];
  503. var v_rd = null;
  504. // Lowest/Highest radio buttons
  505. var v_sTrId = this.f_getId( K_PRMT_sRANGE_ROW_DEFAULT_PREFIX + v_sId );
  506. var v_tr = $( v_sTrId );
  507. if ( v_tr )
  508. {
  509. v_tr.m_oPrompt = this;
  510. // tr > td > div > input
  511. v_rd = v_tr.firstChild.firstChild.firstChild;
  512. if ( v_rd && (typeof v_rd.type == K_PRMT_sSTRING) && v_rd.type.match(/radio/i) )
  513. {
  514. v_tr.m_radio = v_rd;
  515. v_tr.m_oPrompt = this;
  516. PRMTUtils.f_addEvent( v_tr, "click", this.f_checkRadioCheckData.bind(v_tr) );
  517. }
  518. else
  519. {
  520. v_rd = null;
  521. }
  522. v_result[1] = v_rd;
  523. }
  524. // Radio button for input field
  525. v_sTrId = this.f_getId( K_PRMT_sRANGE_ROW_INPUT_PREFIX + v_sId );
  526. v_tr = $( v_sTrId );
  527. if ( v_tr )
  528. {
  529. v_tr.m_oPrompt = this;
  530. // tr > td > div > input
  531. v_rd = v_tr.firstChild.firstChild.firstChild;
  532. if ( v_rd && (typeof v_rd.type == K_PRMT_sSTRING) && v_rd.type.match(/radio/i) )
  533. {
  534. v_tr.m_radio = v_rd;
  535. v_tr.m_oPrompt = this;
  536. PRMTUtils.f_addEvent( v_tr, "click", this.f_checkRadioCheckData.bind(v_tr) );
  537. PRMTUtils.f_addEvent( v_tr, "keydown", this.f_keyDown.bind(v_tr) );
  538. }
  539. else
  540. {
  541. v_rd = null;
  542. }
  543. v_result[0] = v_rd;
  544. }
  545. return v_result;
  546. };
  547. /**
  548. @private
  549. @return {boolean}
  550. */
  551. cognos.Prompt.Control.Range.prototype.hasValue = function()
  552. {
  553. var v_bHasValue = false;
  554. if ( this.m_rdFrom && this.m_rdTo )
  555. {
  556. v_bHasValue = ( (this.m_rdFrom.checked && this.m_oFrom.hasValue()) || (this.m_rdTo.checked && this.m_oTo.hasValue()) ? true : false );
  557. }
  558. else
  559. {
  560. v_bHasValue = ( this.m_oFrom.hasValue() || this.m_oTo.hasValue() ? true : false );
  561. }
  562. return v_bHasValue;
  563. };
  564. /**
  565. * By default, returns true if the control does not return any value.
  566. *
  567. * @private
  568. * @return {boolean}
  569. */
  570. cognos.Prompt.Control.Range.prototype.isEmpty = function()
  571. {
  572. var v_bResult = ( this.m_oFrom.isEmpty() && this.m_oTo.isEmpty() ? true : false );
  573. return v_bResult;
  574. };
  575. var C_Range = cognos.Prompt.Control.Range; // Keep old reference for backward compatibility with custom scripts.