From 162bb12d192cbdb53240822fe011e7da37e0969b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20St=C3=B6ckel?= Date: Mon, 12 Mar 2012 12:17:07 +0000 Subject: [PATCH] Make grid resizing work again --- .../js/et2_dataview_view_gridContainer.js | 6 +-- etemplate/js/et2_dataview_view_resizeable.js | 41 +++++++------------ 2 files changed, 17 insertions(+), 30 deletions(-) diff --git a/etemplate/js/et2_dataview_view_gridContainer.js b/etemplate/js/et2_dataview_view_gridContainer.js index 3609df8623..ec89040174 100644 --- a/etemplate/js/et2_dataview_view_gridContainer.js +++ b/etemplate/js/et2_dataview_view_gridContainer.js @@ -17,7 +17,7 @@ et2_core_common; 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 if(i < this.columns.length-1) { 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"); self.columnMgr.updated = true; self.updateColumns(); - }, enc_column);*/ + }, enc_column); } // Store both nodes in the columnNodes array diff --git a/etemplate/js/et2_dataview_view_resizeable.js b/etemplate/js/et2_dataview_view_resizeable.js index fcd66fd72b..55df199076 100644 --- a/etemplate/js/et2_dataview_view_resizeable.js +++ b/etemplate/js/et2_dataview_view_resizeable.js @@ -16,8 +16,7 @@ * This set of functions is currently only supporting resizing in ew-direction */ -(function () -{ +(function() { // Define some constants var RESIZE_BORDER = 7; @@ -32,9 +31,14 @@ return (ol > (_elem.outerWidth(true) - RESIZE_BORDER)); } + var helper = null; + var overlay = null; + var didResize = false; + var resizeWidth = 0; + function startResize(_outerElem, _elem, _callback) { - if (this.overlay == null || this.helper == null) + if (overlay == null || helper == null) { // Prevent text selection _elem[0].onselectstart = function() { @@ -42,11 +46,11 @@ } // Reset the "didResize" flag - this.didResize = false; + didResize = false; // Create the resize helper var left = _elem.offset().left; - this.helper = $j(document.createElement("div")) + helper = $j(document.createElement("div")) .addClass("egwResizeHelper") .appendTo("body") .css("top", _elem.offset().top + "px") @@ -54,7 +58,7 @@ .css("height", _outerElem.outerHeight(true) + "px"); // Create the overlay which will be catching the mouse movements - this.overlay = $j(document.createElement("div")) + overlay = $j(document.createElement("div")) .addClass("egwResizeOverlay") .bind("mousemove", function(e) { @@ -65,7 +69,7 @@ }) .bind("mouseup", function() { - stopResize.call(); + stopResize(); // Reset text selection _elem[0].onselectstart = null; @@ -95,19 +99,7 @@ } } - /** - * 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) + this.et2_dataview_makeResizeable = function(_elem, _callback, _context) { // Get the table surrounding the given element - this element is used to // align the helper properly @@ -123,7 +115,7 @@ if (inResizeRegion(e.clientX, _elem)) { // Start the resizing - startResize.call(this, outerTable, _elem, function(_w) { + startResize(outerTable, _elem, function(_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 _elem.unbind(".resize"); } - - // Publish the et2_dataview_resizeable class - this.et2_dataview_resizeable = et2_dataview_resizeable; -} - }).call(window);