confirm.xslt 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. IBM Cognos Products: ps
  5. (C) Copyright IBM Corp. 2005, 2011
  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. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  13. xmlns:xts="http://developer.cognos.com/schemas/xts/"
  14. xmlns:dc="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/dialog/confirm/1/"
  15. xmlns:out="dummy-uri" >
  16. <xsl:output method="xml" encoding="UTF-8" indent="no"/>
  17. <xsl:namespace-alias stylesheet-prefix="out" result-prefix="xsl"/>
  18. <xsl:template match="xsl:stylesheet">
  19. <xsl:copy>
  20. <xsl:copy-of select="@*"/>
  21. <out:variable name="dc-confirm-cancel">if (window.confirmCancel) { var cancon = confirmCancel(); if( cancon == true &amp;&amp; window.resetPageState) {resetPageState();}return cancon; } else { if (window.resetPageState) {resetPageState();} return true; }</out:variable>
  22. <xsl:apply-templates/>
  23. </xsl:copy>
  24. </xsl:template>
  25. <!--
  26. ===============================================================================================
  27. dc:confirm-cancel - adds the javascript function that is called by the cancel button
  28. when it is clicked.
  29. ===============================================================================================
  30. -->
  31. <xsl:template match="dc:confirm-cancel">
  32. <script language="JavaScript">
  33. function confirmCancel()
  34. {
  35. var confirmationRequired = false;
  36. var form = document.pform;
  37. for (var i = 0; i &lt; form.length; i++)
  38. {
  39. if (form.elements[i] &amp;&amp; form.elements[i].name &amp;&amp; form.elements[i].name.indexOf(&apos;changed_&apos;) == 0 &amp;&amp; form.elements[i].value &amp;&amp; form.elements[i].value == &apos;1&apos;)
  40. {
  41. confirmationRequired = true;
  42. break;
  43. }
  44. }
  45. if (confirmationRequired == true)
  46. {
  47. return window.confirm("<xts:string id="IDS_PROP_CANCEL_CONFIRM" encode="javascript"/>");
  48. }
  49. else
  50. {
  51. return true;
  52. }
  53. }
  54. </script>
  55. </xsl:template>
  56. <!--
  57. ===============================================================================================
  58. The main engine
  59. ===============================================================================================
  60. -->
  61. <xsl:template match="*">
  62. <xsl:copy>
  63. <xsl:copy-of select="@*"/>
  64. <xsl:apply-templates/>
  65. </xsl:copy>
  66. </xsl:template>
  67. </xsl:stylesheet>