diff options
author | Stas Vilchik <vilchiks@gmail.com> | 2015-09-29 15:22:40 +0200 |
---|---|---|
committer | Stas Vilchik <vilchiks@gmail.com> | 2015-09-29 15:22:40 +0200 |
commit | b8a80269e55fee3e0590c925a5c37f8d18c5c932 (patch) | |
tree | dd1efe864cd73986f4894797f28f5fd3c1f7319b /server/sonar-web/src/main/js/components/workspace/views/viewer-header-view.js | |
parent | be7978644b590068fe21fe047ccb75b3c0b8f326 (diff) | |
download | sonarqube-b8a80269e55fee3e0590c925a5c37f8d18c5c932.tar.gz sonarqube-b8a80269e55fee3e0590c925a5c37f8d18c5c932.zip |
migrate js components to es2015 modules
Diffstat (limited to 'server/sonar-web/src/main/js/components/workspace/views/viewer-header-view.js')
-rw-r--r-- | server/sonar-web/src/main/js/components/workspace/views/viewer-header-view.js | 187 |
1 files changed, 93 insertions, 94 deletions
diff --git a/server/sonar-web/src/main/js/components/workspace/views/viewer-header-view.js b/server/sonar-web/src/main/js/components/workspace/views/viewer-header-view.js index 15f79a27636..b0c03b77edd 100644 --- a/server/sonar-web/src/main/js/components/workspace/views/viewer-header-view.js +++ b/server/sonar-web/src/main/js/components/workspace/views/viewer-header-view.js @@ -1,95 +1,94 @@ -define([ - '../templates' -], function () { - - var $ = jQuery; - - return Marionette.ItemView.extend({ - template: Templates['workspace-viewer-header'], - - 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); - } - }); - +import $ from 'jquery'; +import _ from 'underscore'; +import Marionette from 'backbone.marionette'; +import '../templates'; + +export default Marionette.ItemView.extend({ + template: Templates['workspace-viewer-header'], + + 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); + } }); + + |