This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/views/history.js.es6

37 lines
1.2 KiB
JavaScript

import ModalBodyView from "discourse/views/modal-body";
import ClickTrack from 'discourse/lib/click-track';
import { selectedText } from 'discourse/lib/utilities';
export default ModalBodyView.extend({
templateName: 'modal/history',
title: I18n.t('history'),
resizeModal: function(){
const viewPortHeight = $(window).height();
this.$(".modal-body").css("max-height", Math.floor(0.8 * viewPortHeight) + "px");
}.on("didInsertElement"),
_inserted: function() {
this.$().on('mouseup.discourse-redirect', '#revisions a', function(e) {
// bypass if we are selecting stuff
const selection = window.getSelection && window.getSelection();
if (selection.type === "Range" || selection.rangeCount > 0) {
if (selectedText() !== "") {
return true;
}
}
const $target = $(e.target);
if ($target.hasClass('mention') || $target.parents('.expanded-embed').length) { return false; }
return ClickTrack.trackClick(e);
});
}.on('didInsertElement'),
// This view is being removed. Shut down operations
_destroyed: function() {
this.$().off('mouseup.discourse-redirect', '#revisions a');
}.on('willDestroyElement')
});