nav-ui.xslt 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. IBM Cognos Products: cpscrn
  5. (C) Copyright IBM Corp. 2005, 2013
  6. US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. -->
  8. <!--
  9. Copyright (C) 2008 Cognos ULC, an IBM Company. All rights reserved.
  10. Cognos (R) is a trademark of Cognos ULC, (formerly Cognos Incorporated).
  11. -->
  12. <!-- $Header: //cpscrn/main/templates/cps4/portlets/nav/logicsheets/nav-ui.xslt#1 $ -->
  13. <!-- $DateTime: 2008/10/22 11:12:04 $ -->
  14. <!-- $Change: 25109 $ -->
  15. <xsl:stylesheet version="1.0"
  16. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  17. xmlns:out="dummy-uri"
  18. xmlns:xts="http://developer.cognos.com/schemas/xts/"
  19. xmlns:nui="http://developer.cognos.com/schemas/cps/logic/nav/ui/1/">
  20. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  21. <xsl:namespace-alias stylesheet-prefix="out" result-prefix="xsl"/>
  22. <xsl:template match="xsl:stylesheet" priority="1">
  23. <xsl:copy>
  24. <xsl:apply-templates select="@*"/>
  25. <out:attribute-set name="anchor">
  26. <out:attribute name="class">cognos-anchor</out:attribute>
  27. <out:attribute name="onmouseover">window.status='';return true;</out:attribute>
  28. <out:attribute name="onmouseout">window.status='';return true;</out:attribute>
  29. </out:attribute-set>
  30. <xsl:apply-templates select="*|text()|processing-instruction()"/>
  31. </xsl:copy>
  32. </xsl:template>
  33. <xsl:template match="nui:wsrp_rewrite_channel_set" priority="1">
  34. function wsrp_rewrite_channel_set(id) {
  35. if (wsrp_rewrite_validate()) {
  36. <!--
  37. Get the list of all the fragment that read the 'display_id' and destory them so we can clear the state before we communicate the value
  38. CQCOGCQ00815120
  39. -->
  40. if (window._F_WSRP){
  41. window._F_WSRP.destroyTransientState('display_id', '<out:value-of select="xtsext:javascriptencode(string($channel))"/>');
  42. }
  43. document.wsrp_rewrite_form.display_id.value = id;
  44. document.wsrp_rewrite_form.action='wsrp_rewrite?wsrp-urlType=blockingAction&amp;wsrp-interactionState=set:<out:value-of select="$channel"/>&amp;wsrp-windowState=<out:value-of select="$ui-window-state"/>/wsrp_rewrite';
  45. document.wsrp_rewrite_form.submit();
  46. }
  47. }
  48. </xsl:template>
  49. <xsl:template match="nui:script-validate-range" priority="1">
  50. <out:variable name="min-range">
  51. <xsl:choose>
  52. <xsl:when test="@minRange"><out:value-of select="{@minRange}"/></xsl:when>
  53. <xsl:otherwise>0</xsl:otherwise>
  54. </xsl:choose>
  55. </out:variable>
  56. <out:variable name="max-range">
  57. <xsl:choose>
  58. <xsl:when test="@maxRange"><out:value-of select="{@maxRange}"/></xsl:when>
  59. <xsl:otherwise>2147483646</xsl:otherwise>
  60. </xsl:choose>
  61. </out:variable>
  62. <out:variable name="max-objects">
  63. <xsl:choose>
  64. <xsl:when test="@maxObjects"><out:value-of select="{@maxObjects}"/></xsl:when>
  65. <xsl:otherwise>10</xsl:otherwise>
  66. </xsl:choose>
  67. </out:variable>
  68. <out:variable name="from">
  69. <xsl:choose>
  70. <xsl:when test="@from"><out:value-of select="{@from}"/></xsl:when>
  71. <xsl:otherwise>from</xsl:otherwise>
  72. </xsl:choose>
  73. </out:variable>
  74. <out:variable name="to">
  75. <xsl:choose>
  76. <xsl:when test="@to"><out:value-of select="{@to}"/></xsl:when>
  77. <xsl:otherwise>to</xsl:otherwise>
  78. </xsl:choose>
  79. </out:variable>
  80. <script language="javascript">
  81. var wsrp_rewrite_errmsg1 = "<xts:string id="IDS_NAV_ERR_FIRST_TOO_SMALL" encode="javascript"><xts:param name="low"><out:value-of select="$min-range"/></xts:param></xts:string>";
  82. var wsrp_rewrite_errmsg2 = "<xts:string id="IDS_NAV_ERR_FIRST_TOO_BIG" encode="javascript"><xts:param name="high"><out:value-of select="$max-range"/></xts:param></xts:string>";
  83. var wsrp_rewrite_errmsg3 = "<xts:string id="IDS_NAV_ERR_SECOND_TOO_SMALL" encode="javascript"><xts:param name="low"><out:value-of select="$min-range"/></xts:param></xts:string>";
  84. var wsrp_rewrite_errmsg4 = "<xts:string id="IDS_NAV_ERR_SECOND_TOO_BIG" encode="javascript"><xts:param name="high"><out:value-of select="$max-range"/></xts:param></xts:string>";
  85. var wsrp_rewrite_errmsg5 = "<xts:string id="IDS_NAV_ERR_FIRST_BIGGER_SECOND" encode="javascript"/>";
  86. var wsrp_rewrite_errmsg6 = "<xts:string id="IDS_NAV_ERR_GOTO_VALUE_MISSING" encode="javascript"/>";
  87. function wsrp_rewrite_validateRange(allowBlank)
  88. {
  89. var cForm = document.wsrp_rewrite_form;
  90. var fromField = cForm.<out:value-of select="$from"/>;
  91. var toField = cForm.<out:value-of select="$to"/>;
  92. var maxObjects = <out:value-of select="$max-objects"/> ;
  93. if (fromField != null &amp;&amp; toField != null) {
  94. // Make sure that not both fields are empty
  95. if (allowBlank == null || allowBlank !=true){
  96. if ( fromField.value == "" &amp;&amp; toField.value == "" ) {
  97. window.alert(wsrp_rewrite_errmsg6);
  98. fromField.focus();
  99. return false;
  100. }
  101. }
  102. // validate the first field
  103. if (!wsrp_rewrite_validateValue( fromField , wsrp_rewrite_errmsg1, wsrp_rewrite_errmsg2)) {
  104. return false;
  105. }
  106. // validate the second field
  107. if (!wsrp_rewrite_validateValue( toField, wsrp_rewrite_errmsg3, wsrp_rewrite_errmsg4)) {
  108. return false;
  109. }
  110. // If one of the fields if empty fill it with the right value
  111. var fromValue = new Number(fromField.value);
  112. var toValue = new Number(toField.value);
  113. if ( fromField.value != "" &amp;&amp; toField.value == "" ) {
  114. toValue = fromValue + maxObjects - 1;
  115. toField.value = toValue ;
  116. }
  117. else
  118. if ( fromField.value == "" &amp;&amp; toField.value != "" ) {
  119. fromValue = toValue - maxObjects + 1;
  120. if (fromValue &lt; 1){
  121. fromValue=1;
  122. }
  123. fromField.value = fromValue;
  124. }
  125. // Make sure the first value is less than the second value
  126. if (fromValue &gt; toValue){
  127. window.alert(wsrp_rewrite_errmsg5);
  128. fromField.focus();
  129. return false;
  130. }
  131. }
  132. return true;
  133. }
  134. function wsrp_rewrite_validateValue(field, min_error, max_error)
  135. {
  136. var minRange = <out:value-of select="$min-range"/>;
  137. var maxRange = <out:value-of select="$max-range"/>;
  138. var value = field.value;
  139. if (value != "") {
  140. // validate that the entry is a number
  141. var n = new Number(value);
  142. if (Math.round(n.valueOf()) != value) {
  143. window.alert(min_error);
  144. field.focus();
  145. return false;
  146. }
  147. // validate that the entry is in the necessary range
  148. if ( n &lt;= minRange ) {
  149. window.alert(min_error);
  150. field.focus();
  151. return false;
  152. }
  153. if ( n &gt;=maxRange ) {
  154. window.alert(max_error);
  155. field.focus();
  156. return false;
  157. }
  158. }
  159. return true;
  160. }
  161. </script>
  162. </xsl:template>
  163. <xsl:template match="nui:*" priority="0">
  164. <xsl:call-template name="nui-compile-error">
  165. <xsl:with-param name="errno">0100</xsl:with-param>
  166. <xsl:with-param name="errmsg">Unsupported logicsheet tag: <xsl:value-of select="local-name(.)"/></xsl:with-param>
  167. </xsl:call-template>
  168. </xsl:template>
  169. <xsl:template name="nui-compile-error">
  170. <xsl:param name="errno"/>
  171. <xsl:param name="errmsg"/>
  172. <xsl:message>
  173. <xsl:text>CPS-ERR-</xsl:text>
  174. <xsl:value-of select="$errno"/>
  175. <xsl:text>: </xsl:text>
  176. <xsl:value-of select="$errmsg"/>
  177. <xsl:text>.</xsl:text>
  178. </xsl:message>
  179. <xsl:message terminate="yes">
  180. <xsl:text> ...at: </xsl:text>
  181. <xsl:for-each select="ancestor-or-self::node()[name()!='']">
  182. <xsl:text>/</xsl:text>
  183. <xsl:value-of select="name()"/>
  184. </xsl:for-each>
  185. </xsl:message>
  186. </xsl:template>
  187. <xsl:template match="*|@*|text()|processing-instruction()" priority="-1">
  188. <xsl:copy>
  189. <xsl:apply-templates select="*|@*|text()|processing-instruction()"/>
  190. </xsl:copy>
  191. </xsl:template>
  192. </xsl:stylesheet>