7604 |
25 Feb 19 |
nicklas |
/* $Id $ |
7604 |
25 Feb 19 |
nicklas |
2 |
------------------------------------------------------------------ |
7604 |
25 Feb 19 |
nicklas |
Copyright (C) 2013 Nicklas Nordborg |
7604 |
25 Feb 19 |
nicklas |
4 |
|
7604 |
25 Feb 19 |
nicklas |
This file is part of BASE - BioArray Software Environment. |
7604 |
25 Feb 19 |
nicklas |
Available at http://base.thep.lu.se/ |
7604 |
25 Feb 19 |
nicklas |
7 |
|
7604 |
25 Feb 19 |
nicklas |
BASE is free software; you can redistribute it and/or |
7604 |
25 Feb 19 |
nicklas |
modify it under the terms of the GNU General Public License |
7604 |
25 Feb 19 |
nicklas |
as published by the Free Software Foundation; either version 3 |
7604 |
25 Feb 19 |
nicklas |
of the License, or (at your option) any later version. |
7604 |
25 Feb 19 |
nicklas |
12 |
|
7604 |
25 Feb 19 |
nicklas |
BASE is distributed in the hope that it will be useful, |
7604 |
25 Feb 19 |
nicklas |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
7604 |
25 Feb 19 |
nicklas |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
7604 |
25 Feb 19 |
nicklas |
GNU General Public License for more details. |
7604 |
25 Feb 19 |
nicklas |
17 |
|
7604 |
25 Feb 19 |
nicklas |
You should have received a copy of the GNU General Public License |
7604 |
25 Feb 19 |
nicklas |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
7604 |
25 Feb 19 |
nicklas |
20 |
------------------------------------------------------------------ |
7604 |
25 Feb 19 |
nicklas |
21 |
|
7604 |
25 Feb 19 |
nicklas |
@author Nicklas |
7604 |
25 Feb 19 |
nicklas |
23 |
*/ |
7604 |
25 Feb 19 |
nicklas |
'use strict'; |
7604 |
25 Feb 19 |
nicklas |
25 |
|
7604 |
25 Feb 19 |
nicklas |
var Directories = function() |
7604 |
25 Feb 19 |
nicklas |
27 |
{ |
7604 |
25 Feb 19 |
nicklas |
var directories = {}; |
7604 |
25 Feb 19 |
nicklas |
29 |
|
7604 |
25 Feb 19 |
nicklas |
30 |
/** |
7604 |
25 Feb 19 |
nicklas |
Initialize the page. |
7604 |
25 Feb 19 |
nicklas |
32 |
*/ |
7604 |
25 Feb 19 |
nicklas |
directories.initPage = function() |
7604 |
25 Feb 19 |
nicklas |
34 |
{ |
7604 |
25 Feb 19 |
nicklas |
var pageId = Doc.getPageId(); |
7604 |
25 Feb 19 |
nicklas |
if (pageId == 'edit-page') |
7604 |
25 Feb 19 |
nicklas |
37 |
{ |
7604 |
25 Feb 19 |
nicklas |
// Save + Close buttons |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnSave', directories.save); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('close', App.closeWindow); |
7604 |
25 Feb 19 |
nicklas |
41 |
|
7604 |
25 Feb 19 |
nicklas |
// Tab validation |
7604 |
25 Feb 19 |
nicklas |
TabControl.addTabValidator('settings.info', directories.validateDirectory); |
7604 |
25 Feb 19 |
nicklas |
44 |
} |
7604 |
25 Feb 19 |
nicklas |
else if (pageId == 'list-page') |
7604 |
25 Feb 19 |
nicklas |
46 |
{ |
7604 |
25 Feb 19 |
nicklas |
IconStore.addDefaultIcons(); |
7604 |
25 Feb 19 |
nicklas |
IconStore.addIconSet('Search', 'search.png', 'search-selected.png'); |
7604 |
25 Feb 19 |
nicklas |
IconStore.addIconSet('FolderCompressed', 'folder-compressed.png', 'folder-compressed-selected.png'); |
7604 |
25 Feb 19 |
nicklas |
IconStore.addIconSet('FolderDeleted', 'folder-deleted.png'); |
7604 |
25 Feb 19 |
nicklas |
51 |
|
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('joust', 'joust-select', directories.onSelect); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('joust', 'joust-lazy-init', directories.lazyInit); |
7604 |
25 Feb 19 |
nicklas |
54 |
|
7604 |
25 Feb 19 |
nicklas |
Joust2.draw('joust'); |
7604 |
25 Feb 19 |
nicklas |
56 |
|
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnSearch', directories.searchOnClick); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnRefresh', directories.refresh); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnNewDirectory', directories.newDirectory); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('close', App.closeWindow); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnOk', directories.returnSelected); |
7604 |
25 Feb 19 |
nicklas |
62 |
|
7604 |
25 Feb 19 |
nicklas |
Joust2.select(Data.get('page-data', 'initial-directory'), !Data.int('page-data', 'sync-with-directory')); |
7983 |
22 Jun 21 |
nicklas |
64 |
|
7983 |
22 Jun 21 |
nicklas |
directories.initDragDrop(document); |
7604 |
25 Feb 19 |
nicklas |
66 |
} |
7604 |
25 Feb 19 |
nicklas |
67 |
} |
7983 |
22 Jun 21 |
nicklas |
68 |
|
7983 |
22 Jun 21 |
nicklas |
69 |
|
7983 |
22 Jun 21 |
nicklas |
var highlightedSubdir = null; |
7983 |
22 Jun 21 |
nicklas |
var highlightedElement = null; |
7983 |
22 Jun 21 |
nicklas |
var hideTooltipTimer = null; |
7983 |
22 Jun 21 |
nicklas |
directories.dragFiles = function(event) |
7983 |
22 Jun 21 |
nicklas |
74 |
{ |
7983 |
22 Jun 21 |
nicklas |
if (event.dataTransfer.types.indexOf('Files') == -1) return; // There are no files so we don't care |
7983 |
22 Jun 21 |
nicklas |
76 |
|
7983 |
22 Jun 21 |
nicklas |
// Stop all default things from happening |
7983 |
22 Jun 21 |
nicklas |
event.preventDefault(); |
7983 |
22 Jun 21 |
nicklas |
event.stopPropagation(); |
7983 |
22 Jun 21 |
nicklas |
80 |
|
7983 |
22 Jun 21 |
nicklas |
// Find out which directory we are uploading to |
7983 |
22 Jun 21 |
nicklas |
var subdir = event.currentTarget.item.path; |
7983 |
22 Jun 21 |
nicklas |
if (!subdir) |
7983 |
22 Jun 21 |
nicklas |
84 |
{ |
7983 |
22 Jun 21 |
nicklas |
event.dataTransfer.dropEffect = "none"; // No drop here! |
7983 |
22 Jun 21 |
nicklas |
return; |
7983 |
22 Jun 21 |
nicklas |
87 |
} |
7983 |
22 Jun 21 |
nicklas |
var allowUpload = event.currentTarget.item.allowUpload; |
7983 |
22 Jun 21 |
nicklas |
event.dataTransfer.dropEffect = allowUpload ? "copy" : "none"; |
7983 |
22 Jun 21 |
nicklas |
90 |
|
7983 |
22 Jun 21 |
nicklas |
// Highlight the current directory if it is a sub-directory |
7983 |
22 Jun 21 |
nicklas |
if (subdir != highlightedSubdir) |
7983 |
22 Jun 21 |
nicklas |
93 |
{ |
7983 |
22 Jun 21 |
nicklas |
if (highlightedElement) |
7983 |
22 Jun 21 |
nicklas |
95 |
{ |
7983 |
22 Jun 21 |
nicklas |
Doc.removeClass(highlightedElement, 'drop-upload'); |
7983 |
22 Jun 21 |
nicklas |
Doc.removeClass(highlightedElement, 'bg-filled-50'); |
7983 |
22 Jun 21 |
nicklas |
98 |
} |
7983 |
22 Jun 21 |
nicklas |
if (subdir) |
7983 |
22 Jun 21 |
nicklas |
100 |
{ |
7983 |
22 Jun 21 |
nicklas |
highlightedElement = event.currentTarget; |
7983 |
22 Jun 21 |
nicklas |
highlightedSubdir = subdir; |
7983 |
22 Jun 21 |
nicklas |
Doc.addClass(highlightedElement, 'drop-upload'); |
7983 |
22 Jun 21 |
nicklas |
Doc.addClass(highlightedElement, 'bg-filled-50'); |
7983 |
22 Jun 21 |
nicklas |
105 |
} |
7983 |
22 Jun 21 |
nicklas |
else |
7983 |
22 Jun 21 |
nicklas |
107 |
{ |
7983 |
22 Jun 21 |
nicklas |
highlightedElement = null; |
7983 |
22 Jun 21 |
nicklas |
highlightedSubdir = null; |
7983 |
22 Jun 21 |
nicklas |
110 |
} |
7983 |
22 Jun 21 |
nicklas |
111 |
} |
7983 |
22 Jun 21 |
nicklas |
112 |
|
7983 |
22 Jun 21 |
nicklas |
// Display tooltip |
7983 |
22 Jun 21 |
nicklas |
var tt = Doc.element('uploadTooltip'); |
7983 |
22 Jun 21 |
nicklas |
if (allowUpload) |
7983 |
22 Jun 21 |
nicklas |
116 |
{ |
7983 |
22 Jun 21 |
nicklas |
Doc.removeClass(tt, 'error'); |
7983 |
22 Jun 21 |
nicklas |
tt.innerHTML = 'Upload to '+subdir.replace(/\//g, '/<wbr>'); |
7983 |
22 Jun 21 |
nicklas |
119 |
} |
7983 |
22 Jun 21 |
nicklas |
else |
7983 |
22 Jun 21 |
nicklas |
121 |
{ |
7983 |
22 Jun 21 |
nicklas |
Doc.addClass(tt, 'error'); |
7983 |
22 Jun 21 |
nicklas |
tt.innerHTML = 'Not allowed to upload to '+subdir.replace(/\//g, '/<wbr>'); |
7983 |
22 Jun 21 |
nicklas |
124 |
} |
7983 |
22 Jun 21 |
nicklas |
tt.style.left = Math.max(0, Math.min(event.clientX-tt.clientWidth/2, window.innerWidth-tt.offsetWidth))+'px'; |
7983 |
22 Jun 21 |
nicklas |
tt.style.top = event.clientY < window.innerHeight-30-tt.offsetHeight ? (event.clientY+30)+'px' : (event.clientY-100-tt.offsetHeight)+'px'; |
7983 |
22 Jun 21 |
nicklas |
Doc.show(tt); |
7983 |
22 Jun 21 |
nicklas |
128 |
|
7983 |
22 Jun 21 |
nicklas |
// Set a timer for hiding the tooltip since we never get any event when dragging ends |
7983 |
22 Jun 21 |
nicklas |
if (hideTooltipTimer) clearTimeout(hideTooltipTimer); |
7983 |
22 Jun 21 |
nicklas |
hideTooltipTimer = setTimeout(directories.hideFileUploadTooltip, 500); |
7983 |
22 Jun 21 |
nicklas |
132 |
} |
7604 |
25 Feb 19 |
nicklas |
133 |
|
7983 |
22 Jun 21 |
nicklas |
directories.hideFileUploadTooltip = function() |
7983 |
22 Jun 21 |
nicklas |
135 |
{ |
7983 |
22 Jun 21 |
nicklas |
if (highlightedElement) |
7983 |
22 Jun 21 |
nicklas |
137 |
{ |
7983 |
22 Jun 21 |
nicklas |
Doc.removeClass(highlightedElement, 'drop-upload'); |
7983 |
22 Jun 21 |
nicklas |
Doc.removeClass(highlightedElement, 'bg-filled-50'); |
7983 |
22 Jun 21 |
nicklas |
highlightedElement = null; |
7983 |
22 Jun 21 |
nicklas |
highlightedSubdir = null; |
7983 |
22 Jun 21 |
nicklas |
142 |
} |
7983 |
22 Jun 21 |
nicklas |
Doc.hide('uploadTooltip'); |
7983 |
22 Jun 21 |
nicklas |
144 |
} |
7983 |
22 Jun 21 |
nicklas |
145 |
|
7983 |
22 Jun 21 |
nicklas |
var filesToUpload; |
7983 |
22 Jun 21 |
nicklas |
directories.dropFiles = function(event) |
7983 |
22 Jun 21 |
nicklas |
148 |
{ |
7983 |
22 Jun 21 |
nicklas |
if (event.dataTransfer.types.indexOf('Files') == -1) return; // There are no files so we don't care |
7983 |
22 Jun 21 |
nicklas |
150 |
|
7983 |
22 Jun 21 |
nicklas |
// Stop all default things from happening |
7983 |
22 Jun 21 |
nicklas |
event.preventDefault(); |
7983 |
22 Jun 21 |
nicklas |
event.stopPropagation(); |
7983 |
22 Jun 21 |
nicklas |
154 |
|
7983 |
22 Jun 21 |
nicklas |
var items = event.dataTransfer.items; |
7983 |
22 Jun 21 |
nicklas |
// Check if the dropped items are files or directories |
7983 |
22 Jun 21 |
nicklas |
filesToUpload = []; |
7988 |
30 Jun 21 |
nicklas |
for (var i = 0; i < items.length; i++) |
7983 |
22 Jun 21 |
nicklas |
159 |
{ |
7983 |
22 Jun 21 |
nicklas |
var fe = items[i].webkitGetAsEntry(); |
7988 |
30 Jun 21 |
nicklas |
if (fe.isFile || fe.isDirectory) |
7983 |
22 Jun 21 |
nicklas |
162 |
{ |
7988 |
30 Jun 21 |
nicklas |
filesToUpload[filesToUpload.length] = fe; |
7983 |
22 Jun 21 |
nicklas |
164 |
} |
7983 |
22 Jun 21 |
nicklas |
165 |
} |
7983 |
22 Jun 21 |
nicklas |
if (filesToUpload.length == 0) return; // Only directories |
7983 |
22 Jun 21 |
nicklas |
167 |
|
7983 |
22 Jun 21 |
nicklas |
// Open upload dialog |
7983 |
22 Jun 21 |
nicklas |
var url = '../upload/drag_drop_upload.jsp?ID='+App.getSessionId(); |
7983 |
22 Jun 21 |
nicklas |
url += '&toDir='+event.currentTarget.id; |
7988 |
30 Jun 21 |
nicklas |
url += '&numFiles='+filesToUpload.length; |
7989 |
01 Jul 21 |
nicklas |
Dialogs.openPopup(url, 'DragDropUpload', 700, 450); |
7983 |
22 Jun 21 |
nicklas |
173 |
} |
7983 |
22 Jun 21 |
nicklas |
174 |
|
7989 |
01 Jul 21 |
nicklas |
directories.getFilesToUpload = function() |
7989 |
01 Jul 21 |
nicklas |
176 |
{ |
7989 |
01 Jul 21 |
nicklas |
return filesToUpload; |
7989 |
01 Jul 21 |
nicklas |
178 |
} |
7989 |
01 Jul 21 |
nicklas |
179 |
|
7604 |
25 Feb 19 |
nicklas |
directories.validateDirectory = function() |
7604 |
25 Feb 19 |
nicklas |
181 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['directory']; |
7604 |
25 Feb 19 |
nicklas |
if (Strings.trim(frm.name.value) == '') |
7604 |
25 Feb 19 |
nicklas |
184 |
{ |
7604 |
25 Feb 19 |
nicklas |
Forms.showNotification(frm.name, 'You must enter a name'); |
7604 |
25 Feb 19 |
nicklas |
return false; |
7604 |
25 Feb 19 |
nicklas |
187 |
} |
7604 |
25 Feb 19 |
nicklas |
return true; |
7604 |
25 Feb 19 |
nicklas |
189 |
} |
7604 |
25 Feb 19 |
nicklas |
190 |
|
7604 |
25 Feb 19 |
nicklas |
// Submit the form |
7604 |
25 Feb 19 |
nicklas |
directories.save = function() |
7604 |
25 Feb 19 |
nicklas |
193 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['directory']; |
7604 |
25 Feb 19 |
nicklas |
if (TabControl.validateActiveTab('settings')) |
7604 |
25 Feb 19 |
nicklas |
196 |
{ |
7604 |
25 Feb 19 |
nicklas |
frm.submit(); |
7604 |
25 Feb 19 |
nicklas |
198 |
} |
7604 |
25 Feb 19 |
nicklas |
199 |
} |
7604 |
25 Feb 19 |
nicklas |
200 |
|
7604 |
25 Feb 19 |
nicklas |
201 |
/** |
7604 |
25 Feb 19 |
nicklas |
Handles click event in the directory tree. |
7604 |
25 Feb 19 |
nicklas |
203 |
*/ |
7604 |
25 Feb 19 |
nicklas |
directories.onSelect = function(event) |
7604 |
25 Feb 19 |
nicklas |
205 |
{ |
7604 |
25 Feb 19 |
nicklas |
var menuElement = event.target; |
7604 |
25 Feb 19 |
nicklas |
var menuItem = menuElement.item; |
7604 |
25 Feb 19 |
nicklas |
208 |
|
7604 |
25 Feb 19 |
nicklas |
var mode = Data.get('page-data', 'mode'); |
7604 |
25 Feb 19 |
nicklas |
if (mode == 'selectonedirectory') |
7604 |
25 Feb 19 |
nicklas |
211 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['directory']; |
7604 |
25 Feb 19 |
nicklas |
frm.directory_id.value = menuItem.id; |
7604 |
25 Feb 19 |
nicklas |
frm.path.value = menuItem.path; |
7604 |
25 Feb 19 |
nicklas |
//lastDirectoryId = directoryId; |
7604 |
25 Feb 19 |
nicklas |
216 |
} |
7604 |
25 Feb 19 |
nicklas |
else |
7604 |
25 Feb 19 |
nicklas |
218 |
{ |
7604 |
25 Feb 19 |
nicklas |
if (menuElement.id == 'search') |
7604 |
25 Feb 19 |
nicklas |
220 |
{ |
7604 |
25 Feb 19 |
nicklas |
var url = '../files/index.jsp?ID='+App.getSessionId(); |
7604 |
25 Feb 19 |
nicklas |
url += '&cmd=Search&subcontext=search'; |
7604 |
25 Feb 19 |
nicklas |
url += '&mode='+Data.get('page-data', 'mode'); |
7604 |
25 Feb 19 |
nicklas |
parent.frames['files'].location.href = url; |
7604 |
25 Feb 19 |
nicklas |
225 |
} |
7604 |
25 Feb 19 |
nicklas |
else |
7604 |
25 Feb 19 |
nicklas |
227 |
{ |
7604 |
25 Feb 19 |
nicklas |
var url = '../files/index.jsp?ID='+App.getSessionId(); |
7604 |
25 Feb 19 |
nicklas |
url += '&cmd=List&directory_id='+menuElement.id; |
7604 |
25 Feb 19 |
nicklas |
url += '&mode='+Data.get('page-data', 'mode'); |
7604 |
25 Feb 19 |
nicklas |
parent.frames['files'].location.href = url; |
7604 |
25 Feb 19 |
nicklas |
232 |
} |
7604 |
25 Feb 19 |
nicklas |
233 |
} |
7604 |
25 Feb 19 |
nicklas |
234 |
} |
7604 |
25 Feb 19 |
nicklas |
235 |
|
7604 |
25 Feb 19 |
nicklas |
236 |
|
7604 |
25 Feb 19 |
nicklas |
237 |
/** |
7604 |
25 Feb 19 |
nicklas |
Lazy loading of subdirectories |
7604 |
25 Feb 19 |
nicklas |
239 |
*/ |
7604 |
25 Feb 19 |
nicklas |
directories.lazyInit = function(event) |
7604 |
25 Feb 19 |
nicklas |
241 |
{ |
7604 |
25 Feb 19 |
nicklas |
var menuElement = event.target; |
7604 |
25 Feb 19 |
nicklas |
Doc.addClass(menuElement, 'working'); |
7604 |
25 Feb 19 |
nicklas |
try |
7604 |
25 Feb 19 |
nicklas |
245 |
{ |
7604 |
25 Feb 19 |
nicklas |
var request = Ajax.getXmlHttpRequest(); |
7604 |
25 Feb 19 |
nicklas |
var url = 'ajax.jsp?ID='+App.getSessionId(); |
7604 |
25 Feb 19 |
nicklas |
url += '&cmd=GetSubdirectories&item_id=' + menuElement.id; |
7604 |
25 Feb 19 |
nicklas |
request.open("GET", url, false); |
7604 |
25 Feb 19 |
nicklas |
request.send(null); |
7604 |
25 Feb 19 |
nicklas |
251 |
|
7604 |
25 Feb 19 |
nicklas |
var response = JSON.parse(request.responseText); |
7604 |
25 Feb 19 |
nicklas |
if (response.status != 'ok') |
7604 |
25 Feb 19 |
nicklas |
254 |
{ |
7604 |
25 Feb 19 |
nicklas |
Forms.showNotification(menuElement.id+'-outline', response.message); |
7604 |
25 Feb 19 |
nicklas |
256 |
} |
7604 |
25 Feb 19 |
nicklas |
257 |
|
7983 |
22 Jun 21 |
nicklas |
var childElements = Joust2.addChildren(menuElement, response.subdirs || []); |
7604 |
25 Feb 19 |
nicklas |
Joust2.toggle(menuElement); |
7983 |
22 Jun 21 |
nicklas |
directories.initDragDrop(childElements); |
7604 |
25 Feb 19 |
nicklas |
261 |
} |
7604 |
25 Feb 19 |
nicklas |
finally |
7604 |
25 Feb 19 |
nicklas |
263 |
{ |
7604 |
25 Feb 19 |
nicklas |
Doc.removeClass(menuElement, 'working'); |
7604 |
25 Feb 19 |
nicklas |
265 |
} |
7604 |
25 Feb 19 |
nicklas |
266 |
} |
7604 |
25 Feb 19 |
nicklas |
267 |
|
7983 |
22 Jun 21 |
nicklas |
// Add drag-drop event handlers to all joust items for file upload |
7983 |
22 Jun 21 |
nicklas |
directories.initDragDrop = function(element) |
7983 |
22 Jun 21 |
nicklas |
270 |
{ |
7983 |
22 Jun 21 |
nicklas |
var dirs = Doc.element(element).getElementsByClassName('joustitem'); |
7983 |
22 Jun 21 |
nicklas |
for (var i = 0; i < dirs.length; i++) |
7983 |
22 Jun 21 |
nicklas |
273 |
{ |
7983 |
22 Jun 21 |
nicklas |
Events.addEventHandler(dirs[i], 'dragover', directories.dragFiles); |
7983 |
22 Jun 21 |
nicklas |
Events.addEventHandler(dirs[i], 'drop', directories.dropFiles); |
7983 |
22 Jun 21 |
nicklas |
276 |
} |
7983 |
22 Jun 21 |
nicklas |
277 |
} |
7983 |
22 Jun 21 |
nicklas |
278 |
|
7983 |
22 Jun 21 |
nicklas |
279 |
|
7604 |
25 Feb 19 |
nicklas |
directories.searchOnClick = function() |
7604 |
25 Feb 19 |
nicklas |
281 |
{ |
7604 |
25 Feb 19 |
nicklas |
Doc.show('search'); |
7604 |
25 Feb 19 |
nicklas |
Joust2.select('search'); |
7604 |
25 Feb 19 |
nicklas |
284 |
} |
7604 |
25 Feb 19 |
nicklas |
285 |
|
7604 |
25 Feb 19 |
nicklas |
286 |
|
7604 |
25 Feb 19 |
nicklas |
directories.updateSearchResults = function(files, directories) |
7604 |
25 Feb 19 |
nicklas |
288 |
{ |
7604 |
25 Feb 19 |
nicklas |
var searchResults = Doc.element('search-text'); |
7604 |
25 Feb 19 |
nicklas |
if (searchResults) |
7604 |
25 Feb 19 |
nicklas |
291 |
{ |
7604 |
25 Feb 19 |
nicklas |
searchResults.innerHTML = 'Search results (' + (files + directories) + ')'; |
7604 |
25 Feb 19 |
nicklas |
293 |
} |
7604 |
25 Feb 19 |
nicklas |
294 |
|
7604 |
25 Feb 19 |
nicklas |
295 |
} |
7604 |
25 Feb 19 |
nicklas |
directories.refresh = function() |
7604 |
25 Feb 19 |
nicklas |
297 |
{ |
7604 |
25 Feb 19 |
nicklas |
location.reload(); |
7604 |
25 Feb 19 |
nicklas |
299 |
} |
7604 |
25 Feb 19 |
nicklas |
300 |
|
7604 |
25 Feb 19 |
nicklas |
directories.synchronizeTo = function(directoryId, parentId) |
7604 |
25 Feb 19 |
nicklas |
302 |
{ |
7604 |
25 Feb 19 |
nicklas |
var menuElement = Doc.element(directoryId); |
7604 |
25 Feb 19 |
nicklas |
if (!menuElement && parentId) |
7604 |
25 Feb 19 |
nicklas |
305 |
{ |
7604 |
25 Feb 19 |
nicklas |
var parentElement = Doc.element(parentId); |
7604 |
25 Feb 19 |
nicklas |
if (parentElement && parentElement.item.isLazy) |
7604 |
25 Feb 19 |
nicklas |
308 |
{ |
7604 |
25 Feb 19 |
nicklas |
Joust2.toggle(parentElement); |
7604 |
25 Feb 19 |
nicklas |
menuElement = Doc.element(directoryId); |
7604 |
25 Feb 19 |
nicklas |
311 |
} |
7604 |
25 Feb 19 |
nicklas |
312 |
} |
7604 |
25 Feb 19 |
nicklas |
313 |
|
7604 |
25 Feb 19 |
nicklas |
if (!menuElement) |
7604 |
25 Feb 19 |
nicklas |
315 |
{ |
7604 |
25 Feb 19 |
nicklas |
var url = '../directories/index.jsp?ID='+App.getSessionId(); |
7604 |
25 Feb 19 |
nicklas |
url += '&cmd=ViewItem&item_id='+directoryId; |
7604 |
25 Feb 19 |
nicklas |
url += '&mode='+Data.get('page-data', 'mode'); |
7604 |
25 Feb 19 |
nicklas |
parent.parent.location.href = url; |
7604 |
25 Feb 19 |
nicklas |
320 |
|
7604 |
25 Feb 19 |
nicklas |
321 |
} |
7604 |
25 Feb 19 |
nicklas |
else |
7604 |
25 Feb 19 |
nicklas |
323 |
{ |
7604 |
25 Feb 19 |
nicklas |
Joust2.select(menuElement); |
7604 |
25 Feb 19 |
nicklas |
325 |
} |
7604 |
25 Feb 19 |
nicklas |
326 |
} |
7604 |
25 Feb 19 |
nicklas |
327 |
|
7604 |
25 Feb 19 |
nicklas |
directories.newDirectory = function() |
7604 |
25 Feb 19 |
nicklas |
329 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['directory']; |
7604 |
25 Feb 19 |
nicklas |
Items.newItem('DIRECTORY', '&parent_id='+frm.directory_id.value); |
7604 |
25 Feb 19 |
nicklas |
332 |
} |
7604 |
25 Feb 19 |
nicklas |
333 |
|
7604 |
25 Feb 19 |
nicklas |
334 |
|
7604 |
25 Feb 19 |
nicklas |
directories.returnSelected = function() |
7604 |
25 Feb 19 |
nicklas |
336 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['directory']; |
7604 |
25 Feb 19 |
nicklas |
var callback = frm.callback.value; |
7604 |
25 Feb 19 |
nicklas |
var notifyTarget = window.opener.document.getElementById(callback); |
7604 |
25 Feb 19 |
nicklas |
var callbackMethod = window.opener[callback]; |
7604 |
25 Feb 19 |
nicklas |
341 |
|
7604 |
25 Feb 19 |
nicklas |
if (notifyTarget) |
7604 |
25 Feb 19 |
nicklas |
343 |
{ |
7604 |
25 Feb 19 |
nicklas |
// Send event to the target in the opener window |
7604 |
25 Feb 19 |
nicklas |
Events.sendCustomEvent(notifyTarget, 'base-selected', {'id': frm.directory_id.value, 'name': frm.path.value, 'itemType': 'DIRECTORY'}); |
7604 |
25 Feb 19 |
nicklas |
346 |
} |
7604 |
25 Feb 19 |
nicklas |
else if (callbackMethod) |
7604 |
25 Feb 19 |
nicklas |
348 |
{ |
7604 |
25 Feb 19 |
nicklas |
// Call the callback method in the opener window |
7604 |
25 Feb 19 |
nicklas |
callbackMethod.call(null, frm.directory_id.value, frm.path.value); |
7604 |
25 Feb 19 |
nicklas |
351 |
} |
7604 |
25 Feb 19 |
nicklas |
App.closeWindow(); |
7604 |
25 Feb 19 |
nicklas |
353 |
} |
7604 |
25 Feb 19 |
nicklas |
354 |
|
7604 |
25 Feb 19 |
nicklas |
355 |
|
7604 |
25 Feb 19 |
nicklas |
return directories; |
7604 |
25 Feb 19 |
nicklas |
357 |
}(); |
7604 |
25 Feb 19 |
nicklas |
358 |
|
7604 |
25 Feb 19 |
nicklas |
Doc.onLoad(Directories.initPage); |
7989 |
01 Jul 21 |
nicklas |
360 |
|
7989 |
01 Jul 21 |
nicklas |
// For compatibility with the drag-and-drop file upload |
7989 |
01 Jul 21 |
nicklas |
var FileManager = function() |
7989 |
01 Jul 21 |
nicklas |
363 |
{ |
7989 |
01 Jul 21 |
nicklas |
var fileManager = {}; |
7989 |
01 Jul 21 |
nicklas |
365 |
|
7989 |
01 Jul 21 |
nicklas |
fileManager.getFilesToUpload = function() |
7989 |
01 Jul 21 |
nicklas |
367 |
{ |
7989 |
01 Jul 21 |
nicklas |
return Directories.getFilesToUpload(); |
7989 |
01 Jul 21 |
nicklas |
369 |
} |
7989 |
01 Jul 21 |
nicklas |
370 |
|
7989 |
01 Jul 21 |
nicklas |
return fileManager; |
7989 |
01 Jul 21 |
nicklas |
372 |
}(); |