1 // Copyright (c) 2005 spinelz.org (http://script.spinelz.org/)
\r
3 // This code is substantially based on code from Thomas Fakes(http://craz8.com)
\r
4 // which has the following copyright and permission notice
\r
6 // Copyright (c) 2005 Thomas Fakes (http://craz8.com)
\r
8 // This code is substantially based on code from script.aculo.us which has the
\r
9 // following copyright and permission notice
\r
11 // Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
\r
13 // Permission is hereby granted, free of charge, to any person obtaining
\r
14 // a copy of this software and associated documentation files (the
\r
15 // "Software"), to deal in the Software without restriction, including
\r
16 // without limitation the rights to use, copy, modify, merge, publish,
\r
17 // distribute, sublicense, and/or sell copies of the Software, and to
\r
18 // permit persons to whom the Software is furnished to do so, subject to
\r
19 // the following conditions:
\r
21 // The above copyright notice and this permission notice shall be
\r
22 // included in all copies or substantial portions of the Software.
\r
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
\r
25 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
\r
26 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
\r
27 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
\r
28 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
\r
29 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
\r
30 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\r
32 ResizeableGridEx = Class.create();
\r
33 Object.extend(Object.extend(ResizeableGridEx.prototype, Resizeable.prototype), {
\r
35 draw: function(event) {
\r
37 var pointer = [Event.pointerX(event), Event.pointerY(event)];
\r
38 var style = this.element.style;
\r
43 if (this.currentDirection.indexOf('n') != -1) {
\r
44 var pointerMoved = this.startY - pointer[1];
\r
45 var margin = Element.getStyle(this.element, 'margin-top') || "0";
\r
46 newHeight = this.startHeight + pointerMoved;
\r
47 newTop = (this.startTop - pointerMoved - parseInt(margin)) + "px";
\r
49 if (this.currentDirection.indexOf('w') != -1) {
\r
50 var pointerMoved = this.startX - pointer[0];
\r
51 var margin = Element.getStyle(this.element, 'margin-left') || "0";
\r
52 newWidth = this.startWidth + pointerMoved;
\r
53 newLeft = (this.startLeft - pointerMoved - parseInt(margin)) + "px";
\r
55 if (this.currentDirection.indexOf('s') != -1) {
\r
56 newHeight = this.startHeight + pointer[1] - this.startY;
\r
58 if (this.currentDirection.indexOf('e') != -1) {
\r
59 newWidth = this.startWidth + pointer[0] - this.startX;
\r
67 if (this.options.draw) {
\r
68 this.options.draw(newStyle, this.element);
\r
71 if (newHeight && newHeight > this.options.minHeight) {
\r
73 style.top = newStyle.top;
\r
75 style.height = newStyle.height + "px";
\r
78 if (newWidth && newWidth > this.options.minWidth) {
\r
80 style.left = newStyle.left;
\r
81 style.width = newStyle.width + "px";
\r
85 if(style.visibility=="hidden") style.visibility = ""; // fix gecko rendering
\r
88 directions: function(event) {
\r
89 var pointer = [Event.pointerX(event) + Grid.scrollLeft, Event.pointerY(event) + Grid.scrollTop];
\r
90 //var pointer = [Event.pointerX(event), Event.pointerY(event)];
\r
91 var offsets = Position.cumulativeOffset(this.element);
\r
93 if (this.between(pointer[1] - offsets[1], 0, this.options.top)) cursor += 'n';
\r
94 if (this.between((offsets[1] + this.element.offsetHeight) - pointer[1], 0, this.options.bottom)) cursor += 's';
\r
95 if (this.between(pointer[0] - offsets[0], 0, this.options.left)) cursor += 'w';
\r
96 if (this.between((offsets[0] + this.element.offsetWidth) - pointer[0], 0, this.options.right)) cursor += 'e';
\r