<commit_before>isic.views.ImagesViewSubViews = isic.views.ImagesViewSubViews || {};

// View for image details
isic.views.ImagesViewSubViews.ImageDetailsPane = isic.View.extend({
    events: {
        'click .button': 'clearSelectedImage',
        'click .openwindow': 'openwindow',
        'click .fullscreen': 'fullscreen'
    },

    initialize: function (settings) {
        this.image = settings.image;

        this.listenTo(this.image, 'changed:_id g:fetched g:error', this.render);

        this.segmentationsDisplayView = new isic.views.SegmentationsDisplayView({
            image: this.image,
            parentView: this
        });
    },

    render: function () {
        var created = null;
        var license = {
            name: null,
            url: null
        };
        var acquisitionMetadata = null;
        var clinicalMetadata = null;

        // Get image data
        if (this.image.id) {
            created = girder.formatDate(this.image.get('created'), girder.DATE_SECOND);

            // Get license, default to CC-0
            if (this.image.has('license')) {
                license.name = this.image.get('license');
            } else {
                license.name = 'CC-0';
                license.url = 'https://creativecommons.org/publicdomain/zero/1.0/';
            }

            var meta = this.image.get('meta');
            acquisitionMetadata = meta['acquisition'];
            clinicalMetadata = meta['clinical'];

            // Reformat some acquisition metadata
            acquisitionMetadata['Dimensions (pixels)'] =
                acquisitionMetadata['pixelsX'] + ' &times; ' + acquisitionMetadata['pixelsY'];
            delete acquisitionMetadata['pixelsX'];
            delete acquisitionMetadata['pixelsY'];
        }

        this.$el.html(isic.templates.imageDetailsPage({
            imgRoot: girder.staticRoot + '/built/plugins/isic_archive/extra/img',
            image: this.image,
            created: created,
            license: license,
            acquisitionMetadata: acquisitionMetadata,
            clinicalMetadata: clinicalMetadata
        }));

        this.segmentationsDisplayView.setElement(
            this.$('#isic-image-details-segmentations-display-view-container')).render();

        return this;
    },

    openwindow: function () {
      window.open('/api/v1/image/' + this.image.id + '/download?contentDisposition=inline');
    },

    fullscreen: function () {
      var img = $('.focusimage');
      var modal = $('#focusmodal');

      // Supply the image element with a new src attribute to display the image.
      var src = '/api/v1/image/' + this.image.id + '/download?contentDisposition=inline';
      img.attr('src', src);

      // Create a dummy image element so we can learn the size of the new image.
      // When the image is loaded, we can use its size to properly resize and
      // situate the modal.
      var image = new Image();
      image.onload = function () {
        // Add thirty to represent the 15px padding that comes stock with a
        // Bootstrap modal.
        var modalWidth = image.width + 30;
        var modalHeight = image.height + 30;

        // Set the CSS of the dialog so it appears vertically and horizontally
        // centered in the webpage (even with browser resizing).
        modal.find('.modal-dialog').css({
          width: modalWidth + 'px',
          position: 'absolute',
          top: '50%',
          left: '50%',
          'margin-top': (-modalHeight / 2) + 'px',
          'margin-left': (-modalWidth / 2) + 'px'
        });

        // Now that the image and CSS are ready, show the modal.
        modal.modal('show');
      };

      image.src = src;
    },

    clearSelectedImage: function () {
        this.image.clear();
    }
});<commit_msg>Dismiss lightbox on image-click<commit_after>isic.views.ImagesViewSubViews = isic.views.ImagesViewSubViews || {};

// View for image details
isic.views.ImagesViewSubViews.ImageDetailsPane = isic.View.extend({
    events: {
        'click .button': 'clearSelectedImage',
        'click .openwindow': 'openwindow',
        'click .fullscreen': 'fullscreen'
    },

    initialize: function (settings) {
        this.image = settings.image;

        this.listenTo(this.image, 'changed:_id g:fetched g:error', this.render);

        this.segmentationsDisplayView = new isic.views.SegmentationsDisplayView({
            image: this.image,
            parentView: this
        });
    },

    render: function () {
        var created = null;
        var license = {
            name: null,
            url: null
        };
        var acquisitionMetadata = null;
        var clinicalMetadata = null;

        // Get image data
        if (this.image.id) {
            created = girder.formatDate(this.image.get('created'), girder.DATE_SECOND);

            // Get license, default to CC-0
            if (this.image.has('license')) {
                license.name = this.image.get('license');
            } else {
                license.name = 'CC-0';
                license.url = 'https://creativecommons.org/publicdomain/zero/1.0/';
            }

            var meta = this.image.get('meta');
            acquisitionMetadata = meta['acquisition'];
            clinicalMetadata = meta['clinical'];

            // Reformat some acquisition metadata
            acquisitionMetadata['Dimensions (pixels)'] =
                acquisitionMetadata['pixelsX'] + ' &times; ' + acquisitionMetadata['pixelsY'];
            delete acquisitionMetadata['pixelsX'];
            delete acquisitionMetadata['pixelsY'];
        }

        this.$el.html(isic.templates.imageDetailsPage({
            imgRoot: girder.staticRoot + '/built/plugins/isic_archive/extra/img',
            image: this.image,
            created: created,
            license: license,
            acquisitionMetadata: acquisitionMetadata,
            clinicalMetadata: clinicalMetadata
        }));

        this.segmentationsDisplayView.setElement(
            this.$('#isic-image-details-segmentations-display-view-container')).render();

        return this;
    },

    openwindow: function () {
      window.open('/api/v1/image/' + this.image.id + '/download?contentDisposition=inline');
    },

    fullscreen: function () {
      var img = $('.focusimage');
      var modal = $('#focusmodal');

      // Supply the image element with a new src attribute to display the image.
      var src = '/api/v1/image/' + this.image.id + '/download?contentDisposition=inline';
      img.attr('src', src);

      // Create a dummy image element so we can learn the size of the new image.
      // When the image is loaded, we can use its size to properly resize and
      // situate the modal.
      var image = new Image();
      image.onload = function () {
        // Add thirty to represent the 15px padding that comes stock with a
        // Bootstrap modal.
        var modalWidth = image.width + 30;
        var modalHeight = image.height + 30;

        // Set the CSS of the dialog so it appears vertically and horizontally
        // centered in the webpage (even with browser resizing).
        modal.find('.modal-dialog').css({
          width: modalWidth + 'px',
          position: 'absolute',
          top: '50%',
          left: '50%',
          'margin-top': (-modalHeight / 2) + 'px',
          'margin-left': (-modalWidth / 2) + 'px'
        });

        // Now that the image and CSS are ready, show the modal.
        modal.modal('show');
      };

      // Allow clicking on the image itself to dismiss the modal.
      img.on('click.dismiss', function () {
        $('#focusmodal').modal('hide');
      });

      image.src = src;
    },

    clearSelectedImage: function () {
        this.image.clear();
    }
});
{'fraction_non_alphanumeric': 0.1246313629952558, 'fraction_numerical': 0.004615976407231696, 'mean_word_length': 2.0197444831591174, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1215025', 'n_tokens_mistral': 2114, 'n_tokens_neox': 2036, 'n_words': 536}