{% load djblets_js %}
{% load djblets_utils %}
{% load i18n %}

{% ifuserorperm review_request.submitter "reviews.can_edit_reviewrequest" %}
<script type="text/javascript">
  $(document).ready(function() {
{%  if upload_diff_form %}
    $("#upload-diff-link").click(function() {
      $("<div/>")
        .formDlg({
          title: "{% trans "Upload Diff" %}",
          confirmLabel: "{% trans "Upload" %}",
          dataStoreObject: gReviewRequest.createDiff(),
          width: "60em",
          upload: true,
          fields: {% form_dialog_fields upload_diff_form %}
        });

      return false;
    });
{%  endif %}

    $("#upload-screenshot-link").click(function() {
      $("<div/>").formDlg({
        title: "{% trans "Upload Screenshot" %}",
        confirmLabel: "{% trans "Upload" %}",
        dataStoreObject: gReviewRequest.createScreenshot(),
        width: "50em",
        upload: true,
        fields: {% form_dialog_fields upload_screenshot_form %},
        success: function(rsp) {
            $.screenshotThumbnail(rsp.screenshot);
            gDraftBanner.show();
        }
      });

      return false;
    });
  });
</script>
{% endifuserorperm %}

{% load djblets_js %}
{% load djblets_utils %}
{% load i18n %}

{% ifuserorperm review_request.submitter "reviews.can_edit_reviewrequest" %}
<script type="text/javascript">
  $(document).ready(function() {
{%  if upload_diff_form %}
    $("#upload-diff-link").click(function() {
      $("<div/>")
        .formDlg({
          title: "{% trans "Upload Diff" %}",
          confirmLabel: "{% trans "Upload" %}",
          dataStoreObject: gReviewRequest.createDiff(),
          width: "60em",
          upload: true,
          fields: {% form_dialog_fields upload_diff_form %}
        });

      return false;
    });
{%  endif %}

    $("#upload-screenshot-link").click(function() {
      $("<div/>").formDlg({
        title: "{% trans "Upload Screenshot" %}",
        confirmLabel: "{% trans "Upload" %}",
        dataStoreObject: gReviewRequest.createScreenshot(),
        width: "50em",
        upload: true,
        fields: {% form_dialog_fields upload_screenshot_form %},
        success: function(rsp) {
            if (!$("#screenshot-thumbnails").empty()) {
                $.screenshotThumbnail(rsp.screenshot);
            }

            gDraftBanner.show();
        }
      });

      return false;
    });
  });
</script>
{% endifuserorperm %}

Fix the Upload Screenshot link on the Screenshot page.
Fix the Upload Screenshot link on the Screenshot page.

The Upload Screenshot link was assuming the existance of the screenshot
thumbnails container, which doesn't exist on the Screenshot page. This
checks to make sure the container exists before trying to add to it.
