uview.xslt 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  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, 2018
  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" xmlns:xts="http://developer.cognos.com/schemas/xts/" xmlns:nav="http://developer.cognos.com/schemas/cps/navigation/1/" xmlns:encodingUtils="com.cognos.portal.utils.EncodingUtils" exclude-result-prefixes="nav xts encodingUtils">
  13. <xsl:output method="html" version="1.0" encoding="UTF-8" indent="no"/>
  14. <xsl:template match="/">
  15. <xsl:variable name="customs" select="/root/customs/param"/>
  16. <xsl:variable name="interactions" select="/root/interactions/param"/>
  17. <xsl:variable name="transients" select="/root/transients/param"/>
  18. <xsl:variable name="controllerParams" select="/root/controllerParams/param"/>
  19. <xsl:variable name="configuration" select="/root/input[@name='configurationResponse']/config/param"/>
  20. <xsl:variable name="selectionId">
  21. <xsl:choose>
  22. <xsl:when test="$transients[@name='display_id'] and $transients[@name = 'display_id'] != ''">
  23. <xsl:value-of select="$transients[@name='display_id']"/>
  24. </xsl:when>
  25. <xsl:otherwise>
  26. <xsl:value-of select="$customs[@name='navSelectionId']"/>
  27. </xsl:otherwise>
  28. </xsl:choose>
  29. </xsl:variable>
  30. <xsl:variable name="channel">
  31. <xsl:value-of select="$customs[@name='channel']"/>
  32. </xsl:variable>
  33. <xsl:variable name="titleOptions">
  34. <xsl:value-of select="$customs[@name='viewerTitleOptions']"/>
  35. </xsl:variable>
  36. <xsl:variable name="sub-fragment-id">
  37. <xsl:text>frame1</xsl:text>
  38. <xsl:value-of select="$selectionId"/>
  39. </xsl:variable>
  40. <xsl:variable name="fragmentHeight">
  41. <xsl:if test="$customs[@name='viewerFragmentHeight']">
  42. <xsl:value-of select="$customs[@name='viewerFragmentHeight']"/>
  43. </xsl:if>
  44. </xsl:variable>
  45. <xsl:variable name="fragWindowState" select="/root/controllerParams/param[@name='frag-windowState']"/>
  46. <xsl:variable name="delayExecution" select="$customs[@name='delayExecution']='true' and not($interactions[@name='getContent'])"/>
  47. <script type="text/javascript">
  48. <xsl:choose>
  49. <xsl:when test="$channel != ''">
  50. _THIS_.channel = '<xsl:value-of select="encodingUtils:javascriptencode(string($channel))"/>';
  51. </xsl:when>
  52. <xsl:otherwise>
  53. if (_THIS_.channel == '') {
  54. delete _THIS_.channel;
  55. }
  56. </xsl:otherwise>
  57. </xsl:choose>
  58. _THIS_.removeFragChildren = function() {
  59. var uvChildren = _THIS_.getChildren();
  60. if (uvChildren) {
  61. for (var i=0; i &lt; uvChildren.length; i++) {
  62. uvChildren[i].destroy();
  63. }
  64. }
  65. };
  66. function _THIS_uviewTitleChangeCaptureHandler(evt) {
  67. <xsl:choose>
  68. <xsl:when test="$titleOptions = 'entryName'">
  69. <xsl:text>var useEntry = true;</xsl:text>
  70. </xsl:when>
  71. <xsl:otherwise>
  72. <xsl:text>var useEntry = false;</xsl:text>
  73. </xsl:otherwise>
  74. </xsl:choose>
  75. if (!useEntry) {
  76. if ((evt.eventPhase == evt.AT_TARGET) &amp;&amp;($(this.id + "caption"))) {
  77. this.title = evt.payload.newTitle;
  78. $(this.id + "caption").innerHTML = evt.payload.newTitle;
  79. } else {
  80. evt.stopPropagation();
  81. }
  82. }
  83. }
  84. function _THIS_uviewTitleChangeBubbleHandler(evt) {
  85. <xsl:choose>
  86. <xsl:when test="$titleOptions = 'entryName'">
  87. <xsl:text>var useEntry = true;</xsl:text>
  88. </xsl:when>
  89. <xsl:otherwise>
  90. <xsl:text>var useEntry = false;</xsl:text>
  91. </xsl:otherwise>
  92. </xsl:choose>
  93. if ((useEntry) &amp;&amp;(evt.eventPhase == evt.BUBBLING_PHASE)) {
  94. evt.stopPropagation();
  95. this.raiseEvent(evt.name, evt.payload, evt.type);
  96. }
  97. }
  98. function _THIS_uviewUnloadHandler(evt) {
  99. if (evt.eventPhase == evt.AT_TARGET) {
  100. this.removeEventListener("*", fragment.prototype.proxyEvent, false);
  101. }
  102. }
  103. function _THIS_uviewShowBusy(evt) {
  104. if (!_THIS_hasBusyIcon($("_THIS_container"))) {
  105. $("_THIS_busy").style.display="block";
  106. $("_THIS_busy").style.top = $("_THIS_container").scrollTop;
  107. $("_THIS_busy").style.left = $("_THIS_container").scrollLeft;
  108. }
  109. }
  110. function _THIS_uviewHideBusy(evt) {
  111. $("_THIS_busy").style.display="none";
  112. }
  113. function _THIS_hasBusyIcon(element) {
  114. var isBusyIcon = false;
  115. if (element.id &amp;&amp; element.id.indexOf &amp;&amp; element.id.indexOf("CVWaitTable") != -1) {
  116. isBusyIcon = true;
  117. } else {
  118. if (element.childNodes) {
  119. var i, length = element.childNodes.length;
  120. for (i =0; i &lt; length; i++) {
  121. if (_THIS_hasBusyIcon(element.childNodes[i])) {
  122. isBusyIcon = true;
  123. break;
  124. }
  125. }
  126. }
  127. }
  128. return isBusyIcon;
  129. }
  130. <xsl:variable name="object-type">
  131. <xsl:choose>
  132. <xsl:when test="/root/init/objectResponse/nav:getItemResponse/nav:shortcut">
  133. <xsl:value-of select="/root/init/objectResponse/nav:getItemResponse/nav:shortcut/*/nav:type"/>
  134. </xsl:when>
  135. <xsl:otherwise>
  136. <xsl:value-of select="/root/init/objectResponse/nav:getItemResponse/*/nav:type"/>
  137. </xsl:otherwise>
  138. </xsl:choose>
  139. </xsl:variable>
  140. var _THIS_objectType = "<xsl:value-of select="encodingUtils:javascriptencode(string($object-type))"/>";
  141. var _THIS_heightSetting = "<xsl:value-of select="encodingUtils:javascriptencode(string($fragmentHeight))"/>";
  142. // Handle window resize event
  143. function _THIS_windowResizeHanlder(){
  144. if ("maximized" == _THIS_.windowState){
  145. _THIS_maximize();
  146. } else {
  147. // We resized.. we need to adjust the height for special content (some content might produce unecessary scrollbars. This call will fix it)
  148. ui_resizeHelper.adjustHeightForFragmentContent(_THIS_, $("_THIS_container"), _THIS_objectType, _THIS_heightSetting);
  149. }
  150. }
  151. // Handle fragment events
  152. function _THIS_uviewEventsHandler(evt) {
  153. if (evt.eventPhase == evt.AT_TARGET) {
  154. // Handle event targetted for the Universal viewer.
  155. _THIS_handleUVEvents(evt);
  156. }else if ( evt.eventPhase == evt.CAPTURING_PHASE) {
  157. // Handle events targetted for the sub-fragments
  158. // The capture phase will make sure we get notified of the sub-fragment fragment.load event
  159. _THIS_handleSubfragmentEvents(evt);
  160. }
  161. }
  162. // Handles all events targetted to the UV
  163. function _THIS_handleUVEvents(evt){
  164. var isPageMaximized = "fragment.load" == evt.name &amp;&amp; "maximized" == _THIS_.windowState;
  165. var isModeChangedToMaximized = "fragment.windowstate.change" == evt.name &amp;&amp; evt.payload.newWindowState == "maximized";
  166. if (isPageMaximized || isModeChangedToMaximized){
  167. // Use setTimeout to make sure that at the time we calculate the height, all other fragments are hidden. Otherwise, the calculated height will not be correct
  168. _THIS_maximize(100);
  169. } else if ("fragment.windowstate.change" == evt.name) {
  170. _THIS_restoreSize();
  171. }
  172. }
  173. // Handles the events targetted for sub-fragments.
  174. function _THIS_handleSubfragmentEvents(evt){
  175. if ("fragment.load" == evt.name){
  176. // Reset the scroll position
  177. $("_THIS_container").scrollTop = 0;
  178. if ("maximized" != _THIS_.windowState){
  179. // When the sub-fragment is loaded, fix the height of the content if we are not in maximized mode.
  180. ui_resizeHelper.adjustHeightForFragmentContent(_THIS_, $("_THIS_container"), _THIS_objectType, _THIS_heightSetting);
  181. }
  182. }
  183. }
  184. function _THIS_maximize(){
  185. if(arguments.length > 0 &amp;&amp; arguments[0]){
  186. setTimeout("_THIS_maximize()", arguments[0]);
  187. return;
  188. }
  189. if (_THIS_.initialHeight === undefined || _THIS_.initialHeight == null) {
  190. _THIS_.initialHeight = $("_THIS_container").style.height;
  191. _THIS_.initialOverflowY = $("_THIS_container").style.overflowY;
  192. }
  193. $("_THIS_container").style.height = (xClientHeight() - ui_calcAvailableHeight($("_THIS_container"),document.body,false) - 5) + "px";
  194. $("_THIS_container").style.overflowY = "auto";
  195. }
  196. function _THIS_restoreSize(){
  197. if (_THIS_.initialHeight !== undefined &amp;&amp; _THIS_.initialHeight != null) {
  198. // restore the height of the UV
  199. $("_THIS_container").style.height = _THIS_.initialHeight;
  200. $("_THIS_container").style.overflowY = _THIS_.initialOverflowY;
  201. _THIS_.initialHeight = null;
  202. // Adjust the height for special content
  203. ui_resizeHelper.adjustHeightForFragmentContent(_THIS_, $("_THIS_container"), _THIS_objectType, _THIS_heightSetting);
  204. }
  205. }
  206. _THIS_.addEventListener("fragment.retrieve.before", "_THIS_uviewShowBusy", false);
  207. _THIS_.addEventListener("fragment.retrieve.after", "_THIS_uviewHideBusy", false);
  208. _THIS_.addEventListener("fragment.windowstate.change", "_THIS_uviewEventsHandler", false);
  209. _THIS_.addEventListener("fragment.load", "_THIS_uviewEventsHandler", true);
  210. xAddEventListener(window, "resize", "_THIS_windowResizeHanlder");
  211. function _THIS_uviewTransientUpdateHandler(evt)
  212. {
  213. if (evt.eventPhase == evt.AT_TARGET) {
  214. // clean the children
  215. _THIS_.removeFragChildren();
  216. }
  217. }
  218. _THIS_.addEventListener("fragment.transientUpdate", "_THIS_uviewTransientUpdateHandler", false);
  219. <!--
  220. Add this fragment to the list of fragments that listen to the old WSRP communication, in case we need to clear the state. (e.g. clicking on an item in the navigator)
  221. CQCOGCQ00815120
  222. -->
  223. <xsl:if test="not($delayExecution)">
  224. if (window._F_WSRP){
  225. window._F_WSRP.setDestroyStateForTransient(_THIS_, 'display_id', '<xsl:value-of select="encodingUtils:javascriptencode(string($channel))"/>');
  226. }
  227. </xsl:if>
  228. _THIS_.addEventListener("fragment.unload", "_THIS_uviewUnloadHandler", false);
  229. _THIS_.addEventListener("fragment.title.change", "_THIS_uviewTitleChangeCaptureHandler", true);
  230. _THIS_.addEventListener("fragment.title.change", "_THIS_uviewTitleChangeBubbleHandler", false);
  231. _THIS_.addEventListener("*", fragment.prototype.proxyEvent, false);
  232. _THIS_.addEventListener("cognos.viewer.authoredDrillEvent", "_THIS_viewerAuthoredDrill", false);
  233. function _THIS_viewerAuthoredDrill(){
  234. $("_THIS_backToDefault").style.display = "";
  235. }
  236. </script>
  237. <div class="portlet-font" id="_THIS_backToDefault">
  238. <xsl:if test="not(string($transients[@name='display_id']))">
  239. <xsl:attribute name="style">display:none;</xsl:attribute>
  240. </xsl:if>
  241. <a href="javascript:_F_Config.emptyFunction()" onclick="_THIS_.removeFragChildren();_THIS_.retrieve('sessionTransient=display_id&amp;transientValue=');return false;"><xts:string id="IDS_NAV_VEW_BACK_TO_DEFAULT"/></a><br/>
  242. <br/>
  243. </div>
  244. <!-- All containers under the div _THIS_container need to have there height set to be 100% this is to preserve to make sure the height of iframes or embeds in subfragments render properly -->
  245. <div id="_THIS_container">
  246. <xsl:variable name="content-style">
  247. <xsl:text>width:100%;position:relative;</xsl:text>
  248. <xsl:choose>
  249. <xsl:when test="string($fragmentHeight) != ''">
  250. <xsl:text>height:</xsl:text>
  251. <xsl:variable name="numericHeight">
  252. <xsl:value-of select="translate($fragmentHeight,translate($fragmentHeight, '0123456789.', ''),'')"/>
  253. </xsl:variable>
  254. <xsl:value-of select="$fragmentHeight"/>
  255. <xsl:if test="$numericHeight = $fragmentHeight">
  256. <xsl:value-of select="'px'"/>
  257. </xsl:if>
  258. <xsl:text>;overflow:auto;</xsl:text>
  259. </xsl:when>
  260. <xsl:when test="$selectionId = ''">
  261. <!-- default height when there is not report selected -->
  262. <xsl:text>height:100px;</xsl:text>
  263. </xsl:when>
  264. </xsl:choose>
  265. </xsl:variable>
  266. <xsl:if test="string($content-style) != ''">
  267. <xsl:attribute name="style"><xsl:value-of select="$content-style"/></xsl:attribute>
  268. </xsl:if>
  269. <div id="_THIS_busy" style="position:absolute; margin-top:15px; margin-left:15px; display:none; border:1px solid black; padding:5px ; background-color:#F3F3F3">
  270. <img src="_THIS?frag-resource=/fragments/common/images/loading_timed.gif/THIS_" align="top"/>
  271. <xts:string id="IDS_BV_WAIT"/>
  272. </div>
  273. <xsl:choose>
  274. <xsl:when test="$selectionId = ''">
  275. <table id="_THIS_noselection" border="0" cellspacing="0" cellpadding="0" width="100%" height="100%">
  276. <tr>
  277. <td class="portlet-font" align="center" valign="middle">
  278. <xsl:choose>
  279. <xsl:when test="$channel != ''">
  280. <xts:string id="IDS_VEW_READY_FOR_REQUESTS"/>
  281. </xsl:when>
  282. <xsl:otherwise>
  283. <xts:string id="IDS_VEW_CUSTOMIZE"/>
  284. </xsl:otherwise>
  285. </xsl:choose>
  286. </td>
  287. </tr>
  288. </table>
  289. </xsl:when>
  290. <xsl:otherwise>
  291. <!-- sub-fragment div-->
  292. <div id="_THIS_{$sub-fragment-id}content" style="height:100%">
  293. <xsl:choose>
  294. <xsl:when test="$delayExecution">
  295. <div style="height:50px"/>
  296. <script type="text/javascript">
  297. <!--
  298. Special case for CC mode. We need to clear the inactive fragemnts state once we retieve the content in the "delayed execution" mode
  299. -->
  300. var _THIS_clearInactiveStateHandler = function(){
  301. _THIS_.removeEventListener("fragment.retrieve.after", "_THIS_clearInactiveStateHandler", false);
  302. if (_THIS_.clearInactiveFragments)
  303. _THIS_.clearInactiveFragments();
  304. }
  305. var _THIS_getContent = function(){
  306. _THIS_.addEventListener("fragment.retrieve.after", "_THIS_clearInactiveStateHandler", false);
  307. _THIS_.retrieve("getContent=true");
  308. }
  309. var _THIS_getContentHandler = function(){
  310. _THIS_.removeEventListener("fragment.load", "_THIS_getContentHandler", false);
  311. // settimeout will make sure that we processed the full fragment response before we refresh to get the content
  312. setTimeout(_THIS_getContent, 1);
  313. }
  314. _THIS_.addEventListener("fragment.load", "_THIS_getContentHandler", false);
  315. </script>
  316. </xsl:when>
  317. <xsl:otherwise>
  318. <xsl:text>_THIS?frag-subfragment=</xsl:text>
  319. <xsl:value-of select="$sub-fragment-id"/>
  320. <xsl:text>&amp;frag-id=</xsl:text>
  321. <xsl:value-of select="$sub-fragment-id"/>
  322. <xsl:text>/THIS_</xsl:text>
  323. </xsl:otherwise>
  324. </xsl:choose>
  325. </div>
  326. </xsl:otherwise>
  327. </xsl:choose>
  328. </div>
  329. </xsl:template>
  330. </xsl:stylesheet>