event refactor, landing on HEAD!
[freeside.git] / httemplate / elements / fckeditor / editor / filemanager / browser / default / frmfolders.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">\r
2 <!--\r
3  * FCKeditor - The text editor for Internet - http://www.fckeditor.net\r
4  * Copyright (C) 2003-2007 Frederico Caldeira Knabben\r
5  *\r
6  * == BEGIN LICENSE ==\r
7  *\r
8  * Licensed under the terms of any of the following licenses at your\r
9  * choice:\r
10  *\r
11  *  - GNU General Public License Version 2 or later (the "GPL")\r
12  *    http://www.gnu.org/licenses/gpl.html\r
13  *\r
14  *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")\r
15  *    http://www.gnu.org/licenses/lgpl.html\r
16  *\r
17  *  - Mozilla Public License Version 1.1 or later (the "MPL")\r
18  *    http://www.mozilla.org/MPL/MPL-1.1.html\r
19  *\r
20  * == END LICENSE ==\r
21  *\r
22  * This page shows the list of folders available in the parent folder\r
23  * of the current folder.\r
24 -->\r
25 <html>\r
26         <head>\r
27                 <link href="browser.css" type="text/css" rel="stylesheet">\r
28                 <script type="text/javascript" src="js/common.js"></script>\r
29                 <script language="javascript">\r
30 \r
31 var sActiveFolder ;\r
32 \r
33 var bIsLoaded = false ;\r
34 var iIntervalId ;\r
35 \r
36 var oListManager = new Object() ;\r
37 \r
38 oListManager.Init = function()\r
39 {\r
40         this.Table = document.getElementById('tableFiles') ;\r
41         this.UpRow = document.getElementById('trUp') ;\r
42 \r
43         this.TableRows = new Object() ;\r
44 }\r
45 \r
46 oListManager.Clear = function()\r
47 {\r
48         // Remove all other rows available.\r
49         while ( this.Table.rows.length > 1 )\r
50                 this.Table.deleteRow(1) ;\r
51 \r
52         // Reset the TableRows collection.\r
53         this.TableRows = new Object() ;\r
54 }\r
55 \r
56 oListManager.AddItem = function( folderName, folderPath )\r
57 {\r
58         // Create the new row.\r
59         var oRow = this.Table.insertRow(-1) ;\r
60         oRow.className = 'FolderListFolder' ;\r
61 \r
62         // Build the link to view the folder.\r
63         var sLink = '<a href="#" onclick="OpenFolder(\'' + folderPath + '\');return false;">' ;\r
64 \r
65         // Add the folder icon cell.\r
66         var oCell = oRow.insertCell(-1) ;\r
67         oCell.width = 16 ;\r
68         oCell.innerHTML = sLink + '<img alt="" src="images/spacer.gif" width="16" height="16" border="0"></a>' ;\r
69 \r
70         // Add the folder name cell.\r
71         oCell = oRow.insertCell(-1) ;\r
72         oCell.noWrap = true ;\r
73         oCell.innerHTML = '&nbsp;' + sLink + folderName + '</a>' ;\r
74 \r
75         this.TableRows[ folderPath ] = oRow ;\r
76 }\r
77 \r
78 oListManager.ShowUpFolder = function( upFolderPath )\r
79 {\r
80         this.UpRow.style.display = ( upFolderPath != null ? '' : 'none' ) ;\r
81 \r
82         if ( upFolderPath != null )\r
83         {\r
84                 document.getElementById('linkUpIcon').onclick = document.getElementById('linkUp').onclick = function()\r
85                 {\r
86                         LoadFolders( upFolderPath ) ;\r
87                         return false ;\r
88                 }\r
89         }\r
90 }\r
91 \r
92 function CheckLoaded()\r
93 {\r
94         if ( window.top.IsLoadedActualFolder\r
95                 && window.top.IsLoadedCreateFolder\r
96                 && window.top.IsLoadedUpload\r
97                 && window.top.IsLoadedResourcesList )\r
98         {\r
99                 window.clearInterval( iIntervalId ) ;\r
100                 bIsLoaded = true ;\r
101                 OpenFolder( sActiveFolder ) ;\r
102         }\r
103 }\r
104 \r
105 function OpenFolder( folderPath )\r
106 {\r
107         sActiveFolder = folderPath ;\r
108 \r
109         if ( ! bIsLoaded )\r
110         {\r
111                 if ( ! iIntervalId )\r
112                         iIntervalId = window.setInterval( CheckLoaded, 100 ) ;\r
113                 return ;\r
114         }\r
115 \r
116         // Change the style for the select row (to show the opened folder).\r
117         for ( var sFolderPath in oListManager.TableRows )\r
118         {\r
119                 oListManager.TableRows[ sFolderPath ].className =\r
120                         ( sFolderPath == folderPath ? 'FolderListCurrentFolder' : 'FolderListFolder' ) ;\r
121         }\r
122 \r
123         // Set the current folder in all frames.\r
124         window.parent.frames['frmActualFolder'].SetCurrentFolder( oConnector.ResourceType, folderPath ) ;\r
125         window.parent.frames['frmCreateFolder'].SetCurrentFolder( oConnector.ResourceType, folderPath ) ;\r
126         window.parent.frames['frmUpload'].SetCurrentFolder( oConnector.ResourceType, folderPath ) ;\r
127 \r
128         // Load the resources list for this folder.\r
129         window.parent.frames['frmResourcesList'].LoadResources( oConnector.ResourceType, folderPath ) ;\r
130 }\r
131 \r
132 function LoadFolders( folderPath )\r
133 {\r
134         // Clear the folders list.\r
135         oListManager.Clear() ;\r
136 \r
137         // Get the parent folder path.\r
138         var sParentFolderPath ;\r
139         if ( folderPath != '/' )\r
140                 sParentFolderPath = folderPath.substring( 0, folderPath.lastIndexOf( '/', folderPath.length - 2 ) + 1 ) ;\r
141 \r
142         // Show/Hide the Up Folder.\r
143         oListManager.ShowUpFolder( sParentFolderPath ) ;\r
144 \r
145         if ( folderPath != '/' )\r
146         {\r
147                 sActiveFolder = folderPath ;\r
148                 oConnector.CurrentFolder = sParentFolderPath ;\r
149                 oConnector.SendCommand( 'GetFolders', null, GetFoldersCallBack ) ;\r
150         }\r
151         else\r
152                 OpenFolder( '/' ) ;\r
153 }\r
154 \r
155 function GetFoldersCallBack( fckXml )\r
156 {\r
157         if ( oConnector.CheckError( fckXml ) != 0 )\r
158                 return ;\r
159 \r
160         // Get the current folder path.\r
161         var oNode = fckXml.SelectSingleNode( 'Connector/CurrentFolder' ) ;\r
162         var sCurrentFolderPath = oNode.attributes.getNamedItem('path').value ;\r
163 \r
164         var oNodes = fckXml.SelectNodes( 'Connector/Folders/Folder' ) ;\r
165 \r
166         for ( var i = 0 ; i < oNodes.length ; i++ )\r
167         {\r
168                 var sFolderName = oNodes[i].attributes.getNamedItem('name').value ;\r
169                 oListManager.AddItem( sFolderName, sCurrentFolderPath + sFolderName + "/" ) ;\r
170         }\r
171 \r
172         OpenFolder( sActiveFolder ) ;\r
173 }\r
174 \r
175 function SetResourceType( type )\r
176 {\r
177         oConnector.ResourceType = type ;\r
178         LoadFolders( '/' ) ;\r
179 }\r
180 \r
181 window.onload = function()\r
182 {\r
183         oListManager.Init() ;\r
184         LoadFolders( '/' ) ;\r
185 }\r
186                 </script>\r
187         </head>\r
188         <body class="FileArea" bottomMargin="10" leftMargin="10" topMargin="10" rightMargin="10">\r
189                 <table id="tableFiles" cellSpacing="0" cellPadding="0" width="100%" border="0">\r
190                         <tr id="trUp" style="DISPLAY: none">\r
191                                 <td width="16"><a id="linkUpIcon" href="#"><img alt="" src="images/FolderUp.gif" width="16" height="16" border="0"></a></td>\r
192                                 <td nowrap width="100%">&nbsp;<a id="linkUp" href="#">..</a></td>\r
193                         </tr>\r
194                 </table>\r
195         </body>\r
196 </html>\r