diff --git a/CHANGELOG.md b/CHANGELOG.md index 8cd33e986..610195474 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ All notable changes to AET will be documented in this file. **List of changes that are finished but not yet released in any final version.** - [PR-226](https://github.com/Cognifide/aet/pull/226) Side panel follows the currently opened report while navigating them using keyboard shortcuts. The unused mCustomScrollbar plugin was removed. +- [PR-225](https://github.com/Cognifide/aet/pull/225) Added sidebar resize functionality for report app - [PR-221](https://github.com/Cognifide/aet/pull/221) Added crosshair buttons for scrolling Side Panel to currently opened url/test. - [PR-209](https://github.com/Cognifide/aet/pull/209) Selenium upgraded to 3.8.1. Guava upgraded to 23.6-jre diff --git a/report/src/main/webapp/app/app.config.js b/report/src/main/webapp/app/app.config.js index 4d433c72a..668a8ab5f 100644 --- a/report/src/main/webapp/app/app.config.js +++ b/report/src/main/webapp/app/app.config.js @@ -54,7 +54,7 @@ require.config({ //toolbarBottom 'toolbarBottomController': 'layout/toolbar/toolbarBottom.controller', //sidepanel - 'sidepanelToggleDirective': 'layout/sidepanel/sidepanelToggle.directive', + 'sidepanelDirective': 'layout/sidepanel/sidepanel.directive', 'sidepanelStatusFilterDirective': 'layout/sidepanel/sidepanelStatusFilter.directive', 'sidepanelSearchDirective': 'layout/sidepanel/sidepanelSearch.directive', 'sidepanelToggleLinkDirective': 'layout/sidepanel/toggleLink.directive', diff --git a/report/src/main/webapp/app/app.module.js b/report/src/main/webapp/app/app.module.js index c8ed47075..86ae1f15f 100644 --- a/report/src/main/webapp/app/app.module.js +++ b/report/src/main/webapp/app/app.module.js @@ -49,7 +49,7 @@ define(['angularAMD', 'viewModeService', // sidepanel - 'sidepanelToggleDirective', + 'sidepanelDirective', 'sidepanelStatusFilterDirective', 'sidepanelSearchDirective', 'sidepanelToggleLinkDirective', @@ -93,12 +93,8 @@ define(['angularAMD', $rootScope.fullSourceVisible = userSettingsService.isFullSourceVisible(); }]); - app.config(['$stateProvider', '$urlRouterProvider', '$locationProvider', - '$compileProvider', - function ($stateProvider, $urlRouterProvider, $locationProvider, - $compileProvider) { - $compileProvider.debugInfoEnabled(false); - + app.config(['$stateProvider', '$urlRouterProvider', + function ($stateProvider, $urlRouterProvider) { $stateProvider .state('root', angularAMD.route({ views: { diff --git a/report/src/main/webapp/app/layout/sidepanel/sidepanel.directive.js b/report/src/main/webapp/app/layout/sidepanel/sidepanel.directive.js new file mode 100644 index 000000000..03011d0c5 --- /dev/null +++ b/report/src/main/webapp/app/layout/sidepanel/sidepanel.directive.js @@ -0,0 +1,128 @@ +/* + * AET + * + * Copyright (C) 2013 Cognifide Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +define(['angularAMD'], function (angularAMD) { + 'use strict'; + // custom prefix for custom directive 'aet' see: http://bit.ly/29U2YFf + angularAMD.directive('aetSidepanel', + ['$rootScope', 'localStorageService', SidepanelDirective]); + + function SidepanelDirective($rootScope, localStorageService) { + var EXPANDED_SIDEBAR_KEY_NAME = 'aet:expandedSidepanel'; + var INIT_SIDEPANEL_WIDTH = 350; + var $sidepanel; + var $content; + var $toggleIcon; + + var onWindowResizeThrottled = _.throttle(onWindowResize, 100); + + return { + restrict: 'AE', + link: linkFunc + }; + + function linkFunc($scope, $element) { + var newWidth = INIT_SIDEPANEL_WIDTH; + var isSidepanelResized = false; + + $scope.sidebarExpanded = true; + + $rootScope.$on('$stateChangeSuccess', function() { + $content = $element.find('.main'); + $sidepanel = $element.find('.aside'); + $toggleIcon = $element.find('.toolbar-toggle i'); + }); + + $scope.$watch('sidebarExpanded', function(newValue, oldValue) { + if (newValue !== oldValue) { + toggleSidepanel(); + } + }); + + $element.on('mousedown', '.aside-resizer', function (e) { + isSidepanelResized = true; + + e.preventDefault(); + }); + + $element.on('mousemove', _.throttle(function (e) { + if (isSidepanelResized) { + newWidth = limitSidepanelSize(e.pageX); + updateWidth(newWidth); + e.preventDefault(); + } + }, 10)); + + $element.on('mouseup', function () { + isSidepanelResized = false; + }); + + $element.on('click', '.toolbar-toggle', function () { + $scope.sidebarExpanded = !$scope.sidebarExpanded; + $scope.$apply(); + }); + + $(window).on('resize', onWindowResizeThrottled); + } + + function isExpanded() { + return localStorageService.get(EXPANDED_SIDEBAR_KEY_NAME); + } + + function toggleSidepanel() { + if (isExpanded()) { + close(); + } else { + expand(); + } + } + + function onWindowResize() { + updateWidth(limitSidepanelSize($sidepanel.outerWidth())); + } + + function expand() { + $content.css('left', $sidepanel.outerWidth()); + $content.css('width', document.body.clientWidth - $sidepanel.outerWidth()); + $sidepanel.css('left', 0); + + $(window).on('resize', onWindowResizeThrottled); + localStorageService.put(EXPANDED_SIDEBAR_KEY_NAME, true); + } + + function close() { + $content.css('left', 0); + $content.css('width', ''); + $sidepanel.css('left', -$sidepanel.outerWidth()); + + $(window).off('resize', onWindowResizeThrottled); + localStorageService.put(EXPANDED_SIDEBAR_KEY_NAME, false); + } + + function updateWidth(newWidth) { + var newContentWidth = document.body.clientWidth - newWidth; + + $content.css('left', newWidth); + $content.css('width', newContentWidth); + $sidepanel.css('width', newWidth); + } + + function limitSidepanelSize(xPos) { + return Math.min(Math.max(INIT_SIDEPANEL_WIDTH, xPos), document.body.clientWidth/2); + } + } +}); diff --git a/report/src/main/webapp/app/layout/sidepanel/sidepanel.view.html b/report/src/main/webapp/app/layout/sidepanel/sidepanel.view.html index a2039df2d..6dc4a2e10 100644 --- a/report/src/main/webapp/app/layout/sidepanel/sidepanel.view.html +++ b/report/src/main/webapp/app/layout/sidepanel/sidepanel.view.html @@ -17,7 +17,7 @@ limitations under the License. --> -