Make grid resizing work again

This commit is contained in:
Andreas Stöckel 2012-03-12 12:17:07 +00:00
parent 97080a676a
commit 162bb12d19
2 changed files with 17 additions and 30 deletions

View File

@ -17,7 +17,7 @@
et2_core_common; et2_core_common;
et2_dataview_view_grid; et2_dataview_view_grid;
// et2_dataview_view_resizeable; et2_dataview_view_resizeable;
*/ */
/** /**
@ -373,11 +373,11 @@ var et2_dataview_gridContainer = Class.extend({
// Every column but last can be resized // TODO: This won't work as the last column could be hidden // Every column but last can be resized // TODO: This won't work as the last column could be hidden
if(i < this.columns.length-1) { if(i < this.columns.length-1) {
var enc_column = self.columnMgr.getColumnById(col.id); var enc_column = self.columnMgr.getColumnById(col.id);
/* et2_dataview_makeResizeable(column, function(_w) { et2_dataview_makeResizeable(column, function(_w) {
this.set_width(_w + "px"); this.set_width(_w + "px");
self.columnMgr.updated = true; self.columnMgr.updated = true;
self.updateColumns(); self.updateColumns();
}, enc_column);*/ }, enc_column);
} }
// Store both nodes in the columnNodes array // Store both nodes in the columnNodes array

View File

@ -16,8 +16,7 @@
* This set of functions is currently only supporting resizing in ew-direction * This set of functions is currently only supporting resizing in ew-direction
*/ */
(function () (function() {
{
// Define some constants // Define some constants
var RESIZE_BORDER = 7; var RESIZE_BORDER = 7;
@ -32,9 +31,14 @@
return (ol > (_elem.outerWidth(true) - RESIZE_BORDER)); return (ol > (_elem.outerWidth(true) - RESIZE_BORDER));
} }
var helper = null;
var overlay = null;
var didResize = false;
var resizeWidth = 0;
function startResize(_outerElem, _elem, _callback) function startResize(_outerElem, _elem, _callback)
{ {
if (this.overlay == null || this.helper == null) if (overlay == null || helper == null)
{ {
// Prevent text selection // Prevent text selection
_elem[0].onselectstart = function() { _elem[0].onselectstart = function() {
@ -42,11 +46,11 @@
} }
// Reset the "didResize" flag // Reset the "didResize" flag
this.didResize = false; didResize = false;
// Create the resize helper // Create the resize helper
var left = _elem.offset().left; var left = _elem.offset().left;
this.helper = $j(document.createElement("div")) helper = $j(document.createElement("div"))
.addClass("egwResizeHelper") .addClass("egwResizeHelper")
.appendTo("body") .appendTo("body")
.css("top", _elem.offset().top + "px") .css("top", _elem.offset().top + "px")
@ -54,7 +58,7 @@
.css("height", _outerElem.outerHeight(true) + "px"); .css("height", _outerElem.outerHeight(true) + "px");
// Create the overlay which will be catching the mouse movements // Create the overlay which will be catching the mouse movements
this.overlay = $j(document.createElement("div")) overlay = $j(document.createElement("div"))
.addClass("egwResizeOverlay") .addClass("egwResizeOverlay")
.bind("mousemove", function(e) { .bind("mousemove", function(e) {
@ -65,7 +69,7 @@
}) })
.bind("mouseup", function() { .bind("mouseup", function() {
stopResize.call(); stopResize();
// Reset text selection // Reset text selection
_elem[0].onselectstart = null; _elem[0].onselectstart = null;
@ -95,19 +99,7 @@
} }
} }
/** this.et2_dataview_makeResizeable = function(_elem, _callback, _context)
* Constructor of the et2_dataview_resizeable class. et2_dataview_resizeable
* is instanciated for each dataview grid.
*/
function et2_dataview_resizeable(_body)
{
var helper = null;
var overlay = null;
var didResize = false;
var resizeWidth = 0;
}
et2_dataview_resizeable.prototype.makeResizeable = function(_elem, _callback, _context)
{ {
// Get the table surrounding the given element - this element is used to // Get the table surrounding the given element - this element is used to
// align the helper properly // align the helper properly
@ -123,7 +115,7 @@
if (inResizeRegion(e.clientX, _elem)) if (inResizeRegion(e.clientX, _elem))
{ {
// Start the resizing // Start the resizing
startResize.call(this, outerTable, _elem, function(_w) { startResize(outerTable, _elem, function(_w) {
_callback.call(_context, _w); _callback.call(_context, _w);
}); });
} }
@ -132,15 +124,10 @@
}); });
} }
et2_dataview_resizeable.prototype.resetResizeable = function(_elem) this.et2_dataview_resetResizeable = function(_elem)
{ {
// Remove all events in the ".resize" namespace from the element // Remove all events in the ".resize" namespace from the element
_elem.unbind(".resize"); _elem.unbind(".resize");
} }
// Publish the et2_dataview_resizeable class
this.et2_dataview_resizeable = et2_dataview_resizeable;
}
}).call(window); }).call(window);