1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
/*
* SonarQube :: Web
* Copyright (C) 2009-2016 SonarSource SA
* mailto:contact AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import $ from 'jquery';
import _ from 'underscore';
import Marionette from 'backbone.marionette';
import Template from '../templates/workspace-viewer-header.hbs';
export default Marionette.ItemView.extend({
template: Template,
modelEvents: {
'change': 'render'
},
events: {
'mousedown .js-resize': 'onResizeClick',
'click .js-minimize': 'onMinimizeClick',
'click .js-full-screen': 'onFullScreenClick',
'click .js-normal-size': 'onNormalSizeClick',
'click .js-close': 'onCloseClick'
},
onRender: function () {
this.$('[data-toggle="tooltip"]').tooltip({ container: 'body' });
this.$('.js-normal-size').addClass('hidden');
},
onDestroy: function () {
this.$('[data-toggle="tooltip"]').tooltip('destroy');
$('.tooltip').remove();
},
onResizeClick: function (e) {
e.preventDefault();
this.startResizing(e);
},
onMinimizeClick: function (e) {
e.preventDefault();
this.trigger('viewerMinimize');
},
onFullScreenClick: function (e) {
e.preventDefault();
this.toFullScreen();
},
onNormalSizeClick: function (e) {
e.preventDefault();
this.toNormalSize();
},
onCloseClick: function (e) {
e.preventDefault();
this.trigger('viewerClose');
},
startResizing: function (e) {
this.initialResizePosition = e.clientY;
this.initialResizeHeight = $('.workspace-viewer-container').height();
var processResizing = _.bind(this.processResizing, this),
stopResizing = _.bind(this.stopResizing, this);
$('body')
.on('mousemove.workspace', processResizing)
.on('mouseup.workspace', stopResizing);
},
processResizing: function (e) {
var currentResizePosition = e.clientY,
resizeDelta = this.initialResizePosition - currentResizePosition,
height = this.initialResizeHeight + resizeDelta;
$('.workspace-viewer-container').height(height);
},
stopResizing: function () {
$('body')
.off('mousemove.workspace')
.off('mouseup.workspace');
},
toFullScreen: function () {
this.$('.js-normal-size').removeClass('hidden');
this.$('.js-full-screen').addClass('hidden');
this.initialResizeHeight = $('.workspace-viewer-container').height();
$('.workspace-viewer-container').height('9999px');
},
toNormalSize: function () {
this.$('.js-normal-size').addClass('hidden');
this.$('.js-full-screen').removeClass('hidden');
$('.workspace-viewer-container').height(this.initialResizeHeight);
}
});
|