191e8cec1ddc897f366752e7c2e343c0ac1e375a
[redakcja.git] / project / static / js / resize_area.js
1         \r
2         EditAreaLoader.prototype.start_resize_area= function(){\r
3                 var d=document,a,div,width,height,father;\r
4                 \r
5                 d.onmouseup= editAreaLoader.end_resize_area;\r
6                 d.onmousemove= editAreaLoader.resize_area;\r
7                 editAreaLoader.toggle(editAreaLoader.resize["id"]);             \r
8                 \r
9                 a       = editAreas[editAreaLoader.resize["id"]]["textarea"];\r
10                 div     = d.getElementById("edit_area_resize");\r
11                 if(!div){\r
12                         div= d.createElement("div");\r
13                         div.id="edit_area_resize";\r
14                         div.style.border="dashed #888888 1px";\r
15                 }\r
16                 width   = a.offsetWidth -2;\r
17                 height  = a.offsetHeight -2;\r
18                 \r
19                 div.style.display       = "block";\r
20                 div.style.width         = width+"px";\r
21                 div.style.height        = height+"px";\r
22                 father= a.parentNode;\r
23                 father.insertBefore(div, a);\r
24                 \r
25                 a.style.display="none";\r
26                                 \r
27                 editAreaLoader.resize["start_top"]= calculeOffsetTop(div);\r
28                 editAreaLoader.resize["start_left"]= calculeOffsetLeft(div);            \r
29         };\r
30         \r
31         EditAreaLoader.prototype.end_resize_area= function(e){\r
32                 var d=document,div,a,width,height;\r
33                 \r
34                 d.onmouseup="";\r
35                 d.onmousemove="";               \r
36                 \r
37                 div             = d.getElementById("edit_area_resize");         \r
38                 a= editAreas[editAreaLoader.resize["id"]]["textarea"];\r
39                 width   = Math.max(editAreas[editAreaLoader.resize["id"]]["settings"]["min_width"], div.offsetWidth-4);\r
40                 height  = Math.max(editAreas[editAreaLoader.resize["id"]]["settings"]["min_height"], div.offsetHeight-4);\r
41                 if(editAreaLoader.isIE==6){\r
42                         width-=2;\r
43                         height-=2;      \r
44                 }\r
45                 a.style.width           = width+"px";\r
46                 a.style.height          = height+"px";\r
47                 div.style.display       = "none";\r
48                 a.style.display         = "inline";\r
49                 a.selectionStart        = editAreaLoader.resize["selectionStart"];\r
50                 a.selectionEnd          = editAreaLoader.resize["selectionEnd"];\r
51                 editAreaLoader.toggle(editAreaLoader.resize["id"]);\r
52                 \r
53                 return false;\r
54         };\r
55         \r
56         EditAreaLoader.prototype.resize_area= function(e){              \r
57                 var allow,newHeight,newWidth;\r
58                 allow   = editAreas[editAreaLoader.resize["id"]]["settings"]["allow_resize"];\r
59                 if(allow=="both" || allow=="y")\r
60                 {\r
61                         newHeight       = Math.max(20, getMouseY(e)- editAreaLoader.resize["start_top"]);\r
62                         document.getElementById("edit_area_resize").style.height= newHeight+"px";\r
63                 }\r
64                 if(allow=="both" || allow=="x")\r
65                 {\r
66                         newWidth= Math.max(20, getMouseX(e)- editAreaLoader.resize["start_left"]);\r
67                         document.getElementById("edit_area_resize").style.width= newWidth+"px";\r
68                 }\r
69                 \r
70                 return false;\r
71         };\r
72         \r
73         editAreaLoader.waiting_loading["resize_area.js"]= "loaded";\r