Skip to content

Commit

Permalink
Merge pull request #1177 from rashidkpc/master
Browse files Browse the repository at this point in the history
Add drag-to-resize panel widths
  • Loading branch information
Rashid Khan committed Apr 24, 2014
2 parents 34a3590 + ab61a3d commit efd1ea4
Show file tree
Hide file tree
Showing 6 changed files with 45 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.

5 changes: 5 additions & 0 deletions src/vendor/bootstrap/less/overrides.less
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ 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-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%; }
// ---------------------------

.row-add-button {
Expand Down

0 comments on commit efd1ea4

Please sign in to comment.