Skip to content

Commit efd1ea4

Browse files
author
Rashid Khan
committed
Merge pull request #1177 from rashidkpc/master
Add drag-to-resize panel widths
2 parents 34a3590 + ab61a3d commit efd1ea4

File tree

6 files changed

+45
-4
lines changed

6 files changed

+45
-4
lines changed

src/app/directives/all.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ define([
99
'./tip',
1010
'./confirmClick',
1111
'./esVersion',
12-
'./configModal'
12+
'./configModal',
13+
'./resizable'
1314
], function () {});

src/app/directives/resizable.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
define([
2+
'angular',
3+
],
4+
function (angular) {
5+
'use strict';
6+
7+
angular
8+
.module('kibana.directives')
9+
.directive('resizable', function() {
10+
return {
11+
restrict: 'A',
12+
link: function(scope, elem) {
13+
console.log('linked');
14+
15+
var getOpts = function() {
16+
return {
17+
maxWidth: elem.parent().width(),
18+
grid: elem.parent().width()/12
19+
};
20+
};
21+
22+
// Re-render if the window is resized
23+
angular.element(window).bind('resize', function(){
24+
elem.resizable(getOpts());
25+
});
26+
27+
elem.resizable(getOpts());
28+
elem.resize(function (event, ui) {
29+
scope.panel.span = Math.round(((ui.size.width / elem.parent().width()) * 100) * 1.2) / 10;
30+
scope.$apply();
31+
});
32+
}
33+
};
34+
});
35+
});

src/app/partials/dashboard.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
<div style="padding-top:0px" ng-if="!row.collapse">
5050

5151
<!-- Panels -->
52-
<div ng-repeat="(name, panel) in row.panels|filter:isPanel" ng-hide="panel.hide" class="panel nospace" ng-style="{'width':!panel.span?'100%':((panel.span/1.2)*10)+'%'}" data-drop="true" ng-model="row.panels" data-jqyoui-options jqyoui-droppable="{index:$index,mutate:false,onDrop:'panelMoveDrop',onOver:'panelMoveOver(true)',onOut:'panelMoveOut'}" ng-class="{'dragInProgress':dashboard.panelDragging}">
52+
<div resizable ng-repeat="(name, panel) in row.panels|filter:isPanel" ng-hide="panel.hide" class="panel nospace" ng-style="{'width':!panel.span?'100%':((panel.span/1.2)*10)+'%'}" data-drop="true" ng-model="row.panels" data-jqyoui-options jqyoui-droppable="{index:$index,mutate:false,onDrop:'panelMoveDrop',onOver:'panelMoveOver(true)',onOut:'panelMoveOut'}" ng-class="{'dragInProgress':dashboard.panelDragging}">
5353

5454
<!-- Content Panel -->
5555
<div style="position:relative">

src/css/bootstrap.dark.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/css/bootstrap.light.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/vendor/bootstrap/less/overrides.less

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,11 @@ code, pre {
139139
border: 1px solid @blue;
140140
}
141141

142+
.ui-resizable { position: relative;}
143+
.ui-resizable-handle { position: absolute;font-size: 0.1px; display: block; }
144+
.ui-resizable-disabled .ui-resizable-handle, .ui-resizable-autohide .ui-resizable-handle { display: none; }
145+
.ui-resizable-e { cursor: e-resize; width: 7px; right: 3px; top: 0; height: 100%; }
146+
.ui-resizable-w { cursor: w-resize; width: 7px; left: 3px; top: 0; height: 100%; }
142147
// ---------------------------
143148

144149
.row-add-button {

0 commit comments

Comments
 (0)