From 89802cff662a028c977ea993a2408593fa863e89 Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Thu, 10 Apr 2014 17:45:29 +0600 Subject: [PATCH] SONAR-5168 Left column on search pages should be resizeable --- .../src/main/coffee/coding-rules/app.coffee | 2 + .../main/coffee/coding-rules/layout.coffee | 47 ++++++++++++++++- .../hbs/coding-rules/coding-rules-layout.hbs | 1 + sonar-server/src/main/js/issues/app.js | 48 ++++++++++++++++-- sonar-server/src/main/less/icons.less | 5 ++ .../src/main/less/navigator/base.less | 40 ++++++++++----- .../src/main/less/navigator/filters.less | 2 +- sonar-server/src/main/less/ui.less | 2 +- sonar-server/src/main/less/variables.less | 8 +++ .../WEB-INF/app/views/issues/search.html.erb | 1 + sonar-server/src/main/webapp/fonts/sonar.eot | Bin 15172 -> 15356 bytes sonar-server/src/main/webapp/fonts/sonar.svg | 1 + sonar-server/src/main/webapp/fonts/sonar.ttf | Bin 15016 -> 15200 bytes sonar-server/src/main/webapp/fonts/sonar.woff | Bin 14936 -> 15176 bytes 14 files changed, 136 insertions(+), 21 deletions(-) diff --git a/sonar-server/src/main/coffee/coding-rules/app.coffee b/sonar-server/src/main/coffee/coding-rules/app.coffee index e9bc853cd8a..9d1393c46b2 100644 --- a/sonar-server/src/main/coffee/coding-rules/app.coffee +++ b/sonar-server/src/main/coffee/coding-rules/app.coffee @@ -150,6 +150,8 @@ requirejs [ collection: new Backbone.Collection r.facets @layout.facetsRegion.show @codingRulesFacetsView + @layout.onResize() + App.fetchFirstPage = (fromFacets = false) -> diff --git a/sonar-server/src/main/coffee/coding-rules/layout.coffee b/sonar-server/src/main/coffee/coding-rules/layout.coffee index 48b4e68444c..4f243a478e8 100644 --- a/sonar-server/src/main/coffee/coding-rules/layout.coffee +++ b/sonar-server/src/main/coffee/coding-rules/layout.coffee @@ -10,6 +10,7 @@ define [ className: 'navigator coding-rules-navigator' template: Templates['coding-rules-layout'] spinner: '' + storageKey: 'codingRulesResultsWidth' regions: @@ -21,20 +22,40 @@ define [ facetsRegion: '.navigator-facets' + ui: + side: '.navigator-side' + results: '.navigator-results' + details: '.navigator-details' + resizer: '.navigator-resizer' + + initialize: -> jQuery(window).on 'resize', => @onResize() + @isResize = false + jQuery('body').on 'mousemove', (e) => @processResize(e) + jQuery('body').on 'mouseup', => @stopResize() + + + onRender: -> + @ui.resizer.on 'mousedown', (e) => @startResize(e) + + resultsWidth = localStorage.getItem @storageKey + if resultsWidth + @$(@resultsRegion.el).width +resultsWidth + @ui.side.width +resultsWidth + 20 + onResize: -> footerEl = jQuery('#footer') footerHeight = footerEl.outerHeight true - resultsEl = jQuery('.navigator-results') + resultsEl = @ui.results resultsHeight = jQuery(window).height() - resultsEl.offset().top - parseInt(resultsEl.css('margin-bottom'), 10) - footerHeight resultsEl.height resultsHeight - detailsEl = jQuery('.navigator-details') + detailsEl = @ui.details detailsWidth = jQuery(window).width() - detailsEl.offset().left - parseInt(detailsEl.css('margin-right'), 10) detailsHeight = jQuery(window).height() - detailsEl.offset().top - @@ -44,3 +65,25 @@ define [ showSpinner: (region) -> @$(@[region].el).html @spinner + + + startResize: (e) -> + @isResize = true + @originalWidth = @ui.results.width() + @x = e.clientX + jQuery('html').attr('unselectable', 'on').css('user-select', 'none').on('selectstart', false) + + + processResize: (e) -> + if @isResize + delta = e.clientX - @x + @$(@resultsRegion.el).width @originalWidth + delta + @ui.side.width @originalWidth + 20 + delta + localStorage.setItem @storageKey, @ui.results.width() + @onResize() + + + stopResize: -> + if @isResize + jQuery('html').attr('unselectable', 'off').css('user-select', 'all').off('selectstart') + @isResize = false diff --git a/sonar-server/src/main/hbs/coding-rules/coding-rules-layout.hbs b/sonar-server/src/main/hbs/coding-rules/coding-rules-layout.hbs index 4f23b5d2820..9180c4090ac 100644 --- a/sonar-server/src/main/hbs/coding-rules/coding-rules-layout.hbs +++ b/sonar-server/src/main/hbs/coding-rules/coding-rules-layout.hbs @@ -6,6 +6,7 @@