OSDN Git Service

setup spinelz environment
[cloudmanganw/git_repo.git] / war / WEB-INF / classes / jp / sourceforge / manganetwork / page / javascripts / spinelz / grid_resizeEx.js
1 // Copyright (c) 2005 spinelz.org (http://script.spinelz.org/)\r
2 // \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
5 // \r
6 // Copyright (c) 2005 Thomas Fakes (http://craz8.com)\r
7 // \r
8 // This code is substantially based on code from script.aculo.us which has the \r
9 // following copyright and permission notice\r
10 //\r
11 // Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)\r
12 // \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
20 // \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
23 //\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
31 \r
32 ResizeableGridEx = Class.create();\r
33 Object.extend(Object.extend(ResizeableGridEx.prototype, Resizeable.prototype), {\r
34 \r
35   draw: function(event) {\r
36     \r
37     var pointer = [Event.pointerX(event), Event.pointerY(event)];\r
38     var style = this.element.style;\r
39     var newHeight = 0;\r
40     var newWidth = 0;\r
41     var newTop = 0;\r
42     var newLeft = 0;\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
48     }\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
54     }\r
55     if (this.currentDirection.indexOf('s') != -1) {\r
56       newHeight = this.startHeight + pointer[1] - this.startY;\r
57     }\r
58     if (this.currentDirection.indexOf('e') != -1) {\r
59       newWidth = this.startWidth + pointer[0] - this.startX;\r
60     }\r
61     var newStyle = {\r
62               height: newHeight,\r
63               width: newWidth,\r
64               top: newTop,\r
65               left: newLeft\r
66             }\r
67   if (this.options.draw) {\r
68       this.options.draw(newStyle, this.element);\r
69     }\r
70     \r
71     if (newHeight && newHeight > this.options.minHeight) {\r
72 \r
73       style.top = newStyle.top;\r
74     \r
75       style.height = newStyle.height + "px";\r
76   \r
77     }\r
78     if (newWidth && newWidth > this.options.minWidth) {\r
79     \r
80       style.left = newStyle.left;\r
81       style.width = newStyle.width + "px";\r
82       \r
83 \r
84     }\r
85     if(style.visibility=="hidden") style.visibility = ""; // fix gecko rendering\r
86   },\r
87 \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
92   var cursor = '';\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
97   \r
98   return cursor;\r
99   }\r
100 });\r