Double click panel resizer to toggle collapse
This commit is contained in:
@@ -53,8 +53,7 @@ angular.module('app')
|
|||||||
this.loadPreferences();
|
this.loadPreferences();
|
||||||
|
|
||||||
this.onPanelResize = function(newWidth) {
|
this.onPanelResize = function(newWidth) {
|
||||||
authManager.setUserPrefValue("tagsPanelWidth", newWidth);
|
authManager.setUserPrefValue("tagsPanelWidth", newWidth, true);
|
||||||
authManager.syncUserPreferences();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.componentManager = componentManager;
|
this.componentManager = componentManager;
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ class PanelResizer {
|
|||||||
index: "=",
|
index: "=",
|
||||||
panelId: "=",
|
panelId: "=",
|
||||||
onResize: "&",
|
onResize: "&",
|
||||||
|
defaultWidth: "=",
|
||||||
onResizeFinish: "&",
|
onResizeFinish: "&",
|
||||||
control: "=",
|
control: "=",
|
||||||
alwaysVisible: "=",
|
alwaysVisible: "=",
|
||||||
@@ -44,6 +45,23 @@ class PanelResizer {
|
|||||||
var startWidth = panel.scrollWidth, startX = 0, lastDownX = 0, collapsed, lastWidth = startWidth, startLeft, lastLeft;
|
var startWidth = panel.scrollWidth, startX = 0, lastDownX = 0, collapsed, lastWidth = startWidth, startLeft, lastLeft;
|
||||||
var appFrame;
|
var appFrame;
|
||||||
|
|
||||||
|
|
||||||
|
// Handle Double Click Event
|
||||||
|
var widthBeforeLastDblClick = 0;
|
||||||
|
panel.ondblclick = () => {
|
||||||
|
var collapsed = $scope.isCollapsed();
|
||||||
|
$timeout(() => {
|
||||||
|
if(collapsed) {
|
||||||
|
$scope.setWidth(widthBeforeLastDblClick || $scope.defaultWidth);
|
||||||
|
} else {
|
||||||
|
widthBeforeLastDblClick = lastWidth;
|
||||||
|
$scope.setWidth(minWidth);
|
||||||
|
}
|
||||||
|
$scope.finishSettingWidth();
|
||||||
|
$scope.onResizeFinish()(lastWidth, lastLeft, $scope.isAtMaxWidth());
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
function getParentRect() {
|
function getParentRect() {
|
||||||
return panel.parentNode.getBoundingClientRect();
|
return panel.parentNode.getBoundingClientRect();
|
||||||
}
|
}
|
||||||
@@ -107,6 +125,14 @@ class PanelResizer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$scope.isCollapsed = function() {
|
||||||
|
return lastWidth <= minWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
$scope.isAtMaxWidth = function() {
|
||||||
|
return lastWidth == getParentRect().width;
|
||||||
|
}
|
||||||
|
|
||||||
$scope.setLeft = function(left) {
|
$scope.setLeft = function(left) {
|
||||||
panel.style.left = left + "px";
|
panel.style.left = left + "px";
|
||||||
lastLeft = left;
|
lastLeft = left;
|
||||||
@@ -117,11 +143,7 @@ class PanelResizer {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(lastWidth <= minWidth) {
|
collapsed = $scope.isCollapsed();
|
||||||
collapsed = true;
|
|
||||||
} else {
|
|
||||||
collapsed = false;
|
|
||||||
}
|
|
||||||
if(collapsed) {
|
if(collapsed) {
|
||||||
resizerColumn.classList.add("collapsed");
|
resizerColumn.classList.add("collapsed");
|
||||||
} else {
|
} else {
|
||||||
@@ -214,7 +236,7 @@ class PanelResizer {
|
|||||||
resizerColumn.classList.remove("dragging");
|
resizerColumn.classList.remove("dragging");
|
||||||
panel.classList.remove("no-selection");
|
panel.classList.remove("no-selection");
|
||||||
|
|
||||||
let isMaxWidth = lastWidth == getParentRect().width;
|
let isMaxWidth = $scope.isAtMaxWidth();
|
||||||
|
|
||||||
if($scope.onResizeFinish) {
|
if($scope.onResizeFinish) {
|
||||||
$scope.onResizeFinish()(lastWidth, lastLeft, isMaxWidth);
|
$scope.onResizeFinish()(lastWidth, lastLeft, isMaxWidth);
|
||||||
|
|||||||
@@ -67,4 +67,4 @@
|
|||||||
%span{"ng-if" => "ctrl.sortBy == 'client_updated_at'"} Modified {{note.updatedAtString() || 'Now'}}
|
%span{"ng-if" => "ctrl.sortBy == 'client_updated_at'"} Modified {{note.updatedAtString() || 'Now'}}
|
||||||
%span{"ng-if" => "ctrl.sortBy != 'client_updated_at'"} {{note.createdAtString() || 'Now'}}
|
%span{"ng-if" => "ctrl.sortBy != 'client_updated_at'"} {{note.createdAtString() || 'Now'}}
|
||||||
|
|
||||||
%panel-resizer{"panel-id" => "'notes-column'", "on-resize-finish" => "ctrl.onPanelResize", "control" => "ctrl.panelController", "hoverable" => "true", "collapsable" => "true"}
|
%panel-resizer{"panel-id" => "'notes-column'", "default-width" => 300, "on-resize-finish" => "ctrl.onPanelResize", "control" => "ctrl.panelController", "hoverable" => "true", "collapsable" => "true"}
|
||||||
|
|||||||
@@ -33,4 +33,4 @@
|
|||||||
.info
|
.info
|
||||||
%input.title{"ng-disabled" => "true", "ng-model" => "ctrl.archiveTag.title"}
|
%input.title{"ng-disabled" => "true", "ng-model" => "ctrl.archiveTag.title"}
|
||||||
|
|
||||||
%panel-resizer{"panel-id" => "'tags-column'", "on-resize-finish" => "ctrl.onPanelResize", "control" => "ctrl.panelController", "hoverable" => "true", "collapsable" => "true"}
|
%panel-resizer{"panel-id" => "'tags-column'", "default-width" => 150, "on-resize-finish" => "ctrl.onPanelResize", "control" => "ctrl.panelController", "hoverable" => "true", "collapsable" => "true"}
|
||||||
|
|||||||
Reference in New Issue
Block a user