Skip to content

Commit

Permalink
Add drag to resize panel widths. Closes #329
Browse files Browse the repository at this point in the history
  • Loading branch information
Rashid Khan committed Apr 24, 2014
1 parent 34a3590 commit 50ba841
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/app/directives/all.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ define([
'./tip',
'./confirmClick',
'./esVersion',
'./configModal'
'./configModal',
'./resizable'
], function () {});
35 changes: 35 additions & 0 deletions src/app/directives/resizable.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
define([
'angular',
],
function (angular) {
'use strict';

angular
.module('kibana.directives')
.directive('resizable', function() {
return {
restrict: 'A',
link: function(scope, elem) {
console.log('linked');

var getOpts = function() {
return {
maxWidth: elem.parent().width(),
grid: elem.parent().width()/12
};
};

// Re-render if the window is resized
angular.element(window).bind('resize', function(){
elem.resizable(getOpts());
});

elem.resizable(getOpts());
elem.resize(function (event, ui) {
scope.panel.span = Math.round(((ui.size.width / elem.parent().width()) * 100) * 1.2) / 10;
scope.$apply();
});
}
};
});
});
2 changes: 1 addition & 1 deletion src/app/partials/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<div style="padding-top:0px" ng-if="!row.collapse">

<!-- Panels -->
<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}">
<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}">

<!-- Content Panel -->
<div style="position:relative">
Expand Down
2 changes: 1 addition & 1 deletion src/css/bootstrap.dark.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/css/bootstrap.light.min.css

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions src/vendor/bootstrap/less/overrides.less
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,18 @@ code, pre {
border: 1px solid @blue;
}

.ui-resizable { position: relative;}
.ui-resizable-handle { position: absolute;font-size: 0.1px; display: block; }
.ui-resizable-disabled .ui-resizable-handle, .ui-resizable-autohide .ui-resizable-handle { display: none; }
//.ui-resizable-n { cursor: n-resize; height: 7px; width: 100%; top: -5px; left: 0; }
//.ui-resizable-s { cursor: s-resize; height: 7px; width: 100%; bottom: -5px; left: 0; }
.ui-resizable-e { cursor: e-resize; width: 7px; right: 3px; top: 0; height: 100%; }
.ui-resizable-w { cursor: w-resize; width: 7px; left: 3px; top: 0; height: 100%; }
//.ui-resizable-se { cursor: se-resize; width: 12px; height: 12px; right: 1px; bottom: 1px; }
//.ui-resizable-sw { cursor: sw-resize; width: 9px; height: 9px; left: -5px; bottom: -5px; }
//.ui-resizable-nw { cursor: nw-resize; width: 9px; height: 9px; left: -5px; top: -5px; }
//.ui-resizable-ne { cursor: ne-resize; width: 9px; height: 9px; right: -5px; top: -5px;}

// ---------------------------

.row-add-button {
Expand Down

0 comments on commit 50ba841

Please sign in to comment.