PageRenderTime 48ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/jira-project/jira-components/jira-webapp/src/main/webapp/secure/popups/attachscreenshot.jsp

https://bitbucket.org/ahmed_bilal_360factors/jira7-core
JavaServer Pages | 186 lines | 157 code | 18 blank | 11 comment | 18 complexity | 2f47fb1b81a4fc7dca406a1cd588ba42 MD5 | raw file
Possible License(s): Apache-2.0
  1. <%@ page import="com.atlassian.jira.component.ComponentAccessor" %>
  2. <%@ page import="com.opensymphony.util.TextUtils" %>
  3. <%@ taglib uri="webwork" prefix="ww" %>
  4. <%@ taglib uri="webwork" prefix="ui" %>
  5. <%@ taglib uri="webwork" prefix="aui" %>
  6. <%@ taglib prefix="webwork" uri="webwork" %>
  7. <% ComponentAccessor.getWebResourceManager().requireResource("jira.webresources:jira-global"); %>
  8. <html>
  9. <head>
  10. <%-- TODO: SEAN raised http://jira.atlassian.com/browse/JRA-25378 for the poor security check here --%>
  11. <ww:if test="/issueExists == true">
  12. <title><ww:text name="'attachscreenshot.title'"/></title>
  13. <meta name="x.ua.compatible" content="requiresActiveX=true" />
  14. </ww:if>
  15. <ww:else>
  16. <title><ww:text name="'common.words.error'"/></title>
  17. <meta name="decorator" content="message" />
  18. </ww:else>
  19. </head>
  20. <body>
  21. <ww:if test="/issueExists==true">
  22. <ui:soy moduleKey="'jira.webresources:soy-templates'" template="'JIRA.Templates.Headers.pageHeader'">
  23. <ui:param name="'mainContent'">
  24. <h1><ww:text name="'attachscreenshot.title'"/></h1>
  25. </ui:param>
  26. </ui:soy>
  27. <ui:soy moduleKey="'com.atlassian.auiplugin:aui-experimental-soy-templates'" template="'aui.page.pagePanel'">
  28. <ui:param name="'content'">
  29. <ui:soy moduleKey="'com.atlassian.auiplugin:aui-experimental-soy-templates'" template="'aui.page.pagePanelContent'">
  30. <ui:param name="'content'">
  31. <p>
  32. <ww:text name="'attachscreenshot.description.line1'"/><br>
  33. <ww:text name="'attachscreenshot.description.line2'"/>
  34. </p>
  35. <ww:if test="/hasErrorMessages == 'true'">
  36. <ul>
  37. <ww:iterator value="/flushedErrorMessages">
  38. <li><ww:property value="." /></li>
  39. </ww:iterator>
  40. </ul>
  41. </ww:if>
  42. <ul id="applet-params" style="display:none">
  43. <li id="user-agent"><%= TextUtils.htmlEncode(request.getHeader("User-Agent")) %></li>
  44. <ww:iterator value="/groupLevels" status="'paramStatus'">
  45. <li id="comment-group-name-<ww:property value="@paramStatus/index"/>"><ww:text name="./name" /></li>
  46. </ww:iterator>
  47. <ww:iterator value="/roleLevels" status="'paramStatus'">
  48. <li id="comment-role-<ww:property value="@paramStatus/index"/>"><ww:text name="./name" /></li>
  49. </ww:iterator>
  50. </ul>
  51. <script type="text/javascript" src="<%= request.getContextPath() %>/includes/deployJava.js"></script>
  52. <script type="text/javascript">
  53. var version = '1.6';
  54. var attributes = {
  55. codebase:"<%= request.getContextPath() %>/secure/",
  56. code:"com.atlassian.jira.screenshot.applet.ScreenshotApplet.class",
  57. archive:"applet/screenshot.jar",
  58. width:710,
  59. height:540
  60. };
  61. var parameters = {
  62. scriptable:"false",
  63. post:"AttachScreenshot.jspa?secureToken=<ww:property value="/newUserToken"/>",
  64. issue:<ww:property value="id" />,
  65. screenshotname:"<ww:property value="nextScreenshotName"/>",
  66. encoding:"<ww:property value="/applicationProperties/encoding" />",
  67. useragent: jQuery("#user-agent").text(),
  68. <ww:iterator value="/groupLevels" status="'paramStatus'">
  69. 'comment.group.name.<ww:property value="@paramStatus/index"/>': jQuery("#comment-group-name-<ww:property value="@paramStatus/index"/>").text().replace(/"/g, '&quot;'),
  70. </ww:iterator>
  71. <ww:iterator value="/roleLevels" status="'paramStatus'">
  72. 'comment.role.<ww:property value="@paramStatus/index"/>':"<ww:text name="./id/toString()" />|" + jQuery("#comment-role-<ww:property value="@paramStatus/index"/>").text().replace(/"/g, '&quot;'),
  73. </ww:iterator>
  74. 'paste.text':"<ww:property value="/encode(/text('attachfile.paste.label'))" />",
  75. 'filename.text':"<ww:property value="/encode(/text('attachfile.filename.label'))" />",
  76. 'errormsg.filename.text':"<ww:property value="/encode(/text('attachfile.applet.filename.error'))" />",
  77. 'comment.text':"<ww:property value="/encode(/text('attachfile.comment.update.label'))" />",
  78. 'attach.text':"<ww:property value="/encode(/text('attachfile.submitname'))" />",
  79. 'cancel.text':"<ww:property value="/encode(/text('common.words.cancel'))" />",
  80. 'badconfiguration.text':"<ww:property value="/encode(/text('attachfile.applet.configuration.error'))" />",
  81. 'comment.level.text':"<ww:property value="/encode(/text('comment.update.viewableby.label'))" />",
  82. 'allusers.text':"<ww:property value="/encode(/text('comment.constants.allusers'))" />",
  83. 'projectroles.text':"<ww:property value="/encode(/text('common.words.project.roles'))" />",
  84. 'groups.text':"<ww:property value="/encode(/text('common.words.groups'))" />",
  85. 'security.text':"<ww:property value="/encode(/text('attachfile.applet.security.problem'))" />"
  86. };
  87. //window.name will be set when we call window.open(), so we can use it here to detect if it's a popup or
  88. //if the user opened the screenshot applet in a new tab (JRADEV-3511,JRADEV-3512)
  89. var isPopup = (window.name === "screenshot");
  90. var returnUrl = "<ww:property value="returnUrl" />";
  91. var issueKey = "<ww:property value="key" />";
  92. var issueId = "<ww:property value="id" />";
  93. // JRA-27514 When the applet calls getAppletContext().showDocument() on Windows OS,
  94. // window.opener changes to be the popup window
  95. var realOpener = window.opener;
  96. function submit() {
  97. if (isPopup) {
  98. if (realOpener && !realOpener.closed) {
  99. if (realOpener.JIRA && realOpener.JIRA.Issues && realOpener.JIRA.Issues.Api && realOpener.JIRA.Issues.Api.updateIssue) {
  100. realOpener.JIRA.Issues.Api.updateIssue({ key: issueKey, id: issueId }, 'thanks_issue_attached');
  101. } else {
  102. realOpener.open(returnUrl, '_top');
  103. }
  104. }
  105. window.close();
  106. } else {
  107. window.location = returnUrl;
  108. }
  109. }
  110. function cancel() {
  111. if (isPopup) {
  112. window.close();
  113. } else {
  114. window.location = returnUrl;
  115. }
  116. }
  117. function isMetroStyle() {
  118. var result;
  119. try {
  120. new ActiveXObject("htmlfile");
  121. result = true;
  122. } catch (e) {
  123. result = false;
  124. }
  125. return !result;
  126. }
  127. var isIE10Metro = jQuery.browser.msie && jQuery.browser.version == "10.0" && isMetroStyle() ;
  128. if ( !isIE10Metro ) {
  129. //Not IE10, or IE10 in desktop mode
  130. deployJava.runApplet(attributes, parameters, version);
  131. } else {
  132. var pageAlreadyRefreshed = document.location.search.match(/redirect=1/);
  133. //IE10 metro mode
  134. if (!pageAlreadyRefreshed) {
  135. //IE10 does not ask the user to switch to desktop mode when opening a new window.
  136. //This redirect is a workaround for it until Microsoft fixes the real bug
  137. //https://connect.microsoft.com/IE/feedback/details/776564/metro-ui-ie10-requiresactivex-true-does-not-work-in-redirected-page-or-page-opened-in-a-new-window
  138. //Without the timeout,the user don't get the switch-to-desktop message. Odd.
  139. var glue = document.location.search.length?"&":"?";
  140. setTimeout(function() {
  141. document.location.assign(document.location.href + glue + "redirect=1");
  142. },0)
  143. } else {
  144. //Do nothing, the user is being asked to switch to desktop mode
  145. }
  146. }
  147. </script>
  148. <input type="submit" accesskey="<ww:text name="'common.forms.cancel.accesskey'" />" onclick="window.close();" class="hiddenButton" name="randombutton" />
  149. </ui:param>
  150. </ui:soy>
  151. </ui:param>
  152. </ui:soy>
  153. </ww:if>
  154. <ww:else>
  155. <div class="form-body">
  156. <header>
  157. <h1><ww:text name="'common.words.error'"/></h1>
  158. </header>
  159. <aui:component template="auimessage.jsp" theme="'aui'">
  160. <aui:param name="'messageType'">error</aui:param>
  161. <aui:param name="'messageHtml'">
  162. <p><ww:text name="'admin.errors.issues.current.issue.null'"/></p>
  163. </aui:param>
  164. </aui:component>
  165. </div>
  166. </ww:else>
  167. </body>
  168. </html>