-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/sidepanel resize #225
Merged
Merged
Changes from 10 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
ce5ad7b
Work in progress
b5101d4
Sidepanel resize functionality added
0de2faf
Added CHANGELOG entry
e31359c
Moved toggling and resizing to a single directive
f2d4f57
Merge
198810a
Tidying up after removing sidepanel-resizer directive
a008a0a
Forgot to remove one thing
d67280a
Tidying
d191edb
Changing class toggling. Removing disabling debug info
28e5ab9
Fixing bugs found during testing (content width not resizing on windo…
972faef
Changing syntax in ng-class for sidepanel toggle
ab9ece5
CR fixes - removed width instead of setting it to 100%. Added throttles
db34df5
Merge
d931860
Fixed issue where window resize callback wouldn't be detached
18888eb
Fix
e3f839e
Added separate variable for throttled resize function
4f94fc6
Fixed issue with hiding sidepanel
5e500ad
Fix
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
128 changes: 128 additions & 0 deletions
128
report/src/main/webapp/app/layout/sidepanel/sidepanel.directive.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
|
||
return { | ||
restrict: 'AE', | ||
link: linkFunc | ||
}; | ||
|
||
function linkFunc($scope, $element) { | ||
var newWidth = INIT_SIDEPANEL_WIDTH; | ||
var isSidepanelResized = false; | ||
|
||
$rootScope.$on('$stateChangeSuccess', function() { | ||
$content = $element.find('.main'); | ||
$sidepanel = $element.find('.aside'); | ||
$toggleIcon = $element.find('.toolbar-toggle i'); | ||
|
||
if (!$scope.sidebarExpanded) { | ||
expand(); | ||
} | ||
|
||
$scope.sidebarExpanded = isExpanded(); | ||
|
||
$scope.$watch('sidebarExpanded', function(newValue, oldValue) { | ||
if (newValue !== oldValue) { | ||
toggleSidepanel(); | ||
} | ||
}); | ||
}); | ||
|
||
$element.on('mousedown', '.aside-resizer', function (e) { | ||
isSidepanelResized = true; | ||
|
||
e.preventDefault(); | ||
}); | ||
|
||
$element.on('mousemove', function (e) { | ||
if (isSidepanelResized) { | ||
newWidth = limitSidepanelSize(e.pageX); | ||
updateWidth(newWidth); | ||
e.preventDefault(); | ||
} | ||
}); | ||
|
||
$element.on('mouseup', function () { | ||
isSidepanelResized = false; | ||
}); | ||
|
||
$element.on('click', '.toolbar-toggle', function () { | ||
$scope.sidebarExpanded = !$scope.sidebarExpanded; | ||
$scope.$apply(); | ||
}); | ||
} | ||
|
||
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', onWindowResize); | ||
localStorageService.put(EXPANDED_SIDEBAR_KEY_NAME, true); | ||
} | ||
|
||
function close() { | ||
$content.css('left', 0); | ||
$content.css('width', '100%'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can't we just remove width then? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yup, removed width inline style instead |
||
$sidepanel.css('left', -$sidepanel.outerWidth()); | ||
|
||
$(window).off('resize', onWindowResize); | ||
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); | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 0 additions & 80 deletions
80
report/src/main/webapp/app/layout/sidepanel/sidepanelToggle.directive.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add throttle here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done