📄 explorer.js
字号:
/*
* File : $Source: /usr/local/cvs/opencms/modules/org.opencms.workplace.explorer/resources/system/workplace/resources/commons/explorer.js,v $
* Date : $Date: 2006/07/20 14:13:51 $
* Version: $Revision: 1.14 $
*
* This library is part of OpenCms -
* the Open Source Content Mananagement System
*
* Copyright (c) 2005 Alkacon Software GmbH (http://www.alkacon.com)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* For further information about Alkacon Software GmbH, please see the
* company website: http://www.alkacon.com
*
* For further information about OpenCms, please see the
* project website: http://www.opencms.org
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
var help_url="ExplorerAnsicht/index.html";
var flaturl="";
var mode="explorerview";
var showlinks=false;
var openfolderMethod="openFolder";
var showKon=true;
var autolock=false;
var plainresid=-1;
var win;
var buttonType=1;
var link_newresource="/system/workplace/commons/newresource.jsp";
var link_uploadresource="/system/workplace/commons/newresource_upload.jsp";
var link_showresource="/system/workplace/commons/displayresource.jsp";
var last_id=-1;
var active_mouse_id=-1;
var active_from_text=false;
var cancelNextOpen=false;
var selectedResources=new Array();
var selectedStyles=new Array();
var contextOpen=false;
var displayResource="/";
var g_histLoc=0;
var g_history=null;
var m_rootFolder="/";
function show_help(){
return help_url;
}
function windowStore(body, head, tree, files) {
this.body = body;
this.head = head;
this.tree = tree;
this.files = files.document;
this.fileswin = files;
}
function menuItem(name, link, target, rules){
this.name = name;
this.link = link;
this.target = target;
this.rules = rules;
}
// 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
function file(name, path, title, type, linkType, size, state, layoutstyle, project, dateLastModified, userWhoLastModified, dateCreated, userWhoCreated, dateReleased, dateExpired, permissions, lockedBy, lockType, lockedInProjectName, lockedInProjectId, isInsideCurrentProject){
this.name = name;
this.path = path;
this.title = title;
this.type = type;
this.linkType = linkType;
this.size = size;
this.state = state;
this.layoutstyle = layoutstyle;
this.project = project;
this.dateLastModified = dateLastModified;
this.userWhoLastModified = userWhoLastModified
this.dateCreated = dateCreated;
this.userWhoCreated = userWhoCreated;
this.dateReleased = dateReleased;
this.dateExpired = dateExpired;
this.permissions = permissions;
this.lockedBy = lockedBy;
this.lockType = lockType;
this.lockedInProjectName = lockedInProjectName;
this.lockedInProjectId = lockedInProjectId;
this.isInsideCurrentProject = (isInsideCurrentProject=='I') ? true : false;
this.isFolder = (size < 0) ? true : false;
}
function aF(name, path, title, type, linkType, size, state, layoutstyle, project, dateLastModified, userWhoLastModified, dateCreated, userWhoCreated, dateReleased, dateExpired, permissions, lockedBy, lockType, lockedInProjectName, lockedInProjectId, isInsideCurrentProject){
if(path == "") {
path=vr.actDirectory;
}
vi.liste[vi.liste.length] = new file(name, path, title, type, linkType, size, state, layoutstyle, project, dateLastModified, userWhoLastModified, dateCreated, userWhoCreated, dateReleased, dateExpired, permissions, lockedBy, lockType, lockedInProjectName, lockedInProjectId, isInsideCurrentProject);
}
function vars_index() {
this.icons = new Array();
this.liste = new Array();
this.lockIcons = new Array();
this.lockStatus = new Array();
this.iconPath;
this.skinPath;
this.newButtonActive;
this.check_name;
this.check_title;
this.check_type;
this.check_size;
this.check_permissions;
this.check_dateLastModified;
this.check_userWhoLastModified;
this.check_dateCreated;
this.check_userWhoCreated;
this.check_dateReleased;
this.check_dateExpired;
this.check_state;
this.check_lockedBy;
this.userName;
this.resource = new Array();
this.menus = new Array();
}
function res(text, nicename, icon, createLink, isEditable){
this.text = text;
this.nicename = nicename;
this.icon = icon;
this.createLink = createLink;
this.editable = isEditable;
}
function setDisplayResource(resource) {
displayResource = resource;
if (mode == "explorerview") {
win.head.forms.urlform.resource.value = displayResource.substring(getRootFolder().length - 1);
}
}
function getDisplayResource(param) {
if (param == "true") {
return displayResource.substring(getRootFolder().length - 1);
}
return displayResource;
}
function getRootFolder() {
if (m_rootFolder == null) {
return "/";
} else {
return m_rootFolder;
}
}
function setRootFolder(value) {
m_rootFolder = value;
}
function initHist() {
g_histLoc = 0;
g_history = new Array();
}
function addHist(entry) {
if (g_history[g_histLoc] != entry && entry.indexOf("siblings:") == -1) {
g_histLoc++;
g_history[g_histLoc] = entry;
}
}
function histGoBack() {
if (g_histLoc > 1) {
g_histLoc--;
setDisplayResource(g_history[g_histLoc]);
} else {
setDisplayResource(removeSiblingPrefix(getDisplayResource()));
}
openurl();
}
function dU(doc, pages, actpage) {
vi.locklength = 0;
vi.doc = doc;
updateWindowStore();
openfolderMethod="openFolder";
showCols(vr.viewcfg);
printList(doc);
if (mode == "explorerview") {
displayHead(win.head, pages, actpage);
}
}
function updateWindowStore() {
var theTree = null;
if (window.body.explorer_body && window.body.explorer_body.explorer_tree) {
theTree = window.body.explorer_body.explorer_tree;
}
if ((mode == "listview") || (mode == "galleryview")) {
var theDoc = null;
if (window.body.admin_content.tool_content) {
theDoc = window.body.admin_content.tool_content;
} else {
theDoc = window.body.admin_content;
}
if (window.body.admin_head) {
win = new windowStore(window.body.document, window.body.admin_head.document, theTree, theDoc);
} else {
win = new windowStore(window.body.document, null, theTree, theDoc);
}
} else {
try {
win = new windowStore(window.body.document, window.body.explorer_head.document, theTree, window.body.explorer_body.explorer_files);
} catch (e) {}
}
}
function rD() {
vi.liste = new Array();
vi.icons = new Array();
}
function showCols(cols) {
var check = new Array();
check[9] = 'vi.check_name';
check[0] = 'vi.check_title';
check[1] = 'vi.check_type';
check[3] = 'vi.check_size';
check[7] = 'vi.check_permissions';
check[2] = 'vi.check_dateLastModified';
check[10] = 'vi.check_dateCreated';
check[11] = 'vi.check_userWhoLastModified';
check[5] = 'vi.check_userWhoCreated';
check[12] = 'vi.check_dateReleased';
check[13] = 'vi.check_dateExpired';
check[4] = 'vi.check_state';
check[8] = 'vi.check_lockedBy';
for (i = 0; i <= 13; i++) {
if (i != 6) {
if ((cols & Math.pow(2, i)) > 0) {
eval(check[i] + "=true;");
} else {
eval(check[i] + "=false;");
}
}
}
}
// set the last selected menu id (from icon)
function setId(id) {
active_mouse_id = id;
active_from_text = false;
}
// set the last selected menu id (from link text)
function setId2(id) {
active_mouse_id = id;
active_from_text = true;
}
// handle the context menu to show
function handleContext(e) {
if (selectedResources.length > 1) {
// multi context menu
showContext(win.files, "multi", false);
} else {
// single context menu
if (active_mouse_id >= 0) {
showContext(win.files, active_mouse_id, true);
}
}
// stop event bubbling
e.cancelBubble = true;
if (e.stopPropagation) {
e.stopPropagation();
}
return false;
}
// builds the HTML for a context menu (single or multi context menu)
function showContext(doc, i, isSingleContext) {
var spanstart = "<span class=\"cmenorm\" onmouseover=\"className='cmehigh';\" onmouseout=\"className='cmenorm';\">";
var spanstartina = "<span class=\"inanorm\" onmouseover=\"className='inahigh';\" onmouseout=\"className='inanorm';\">";
var spanend = "</span>";
var menu = "";
// the type id of the current context menu
var typeId;
// the resource name needed for single context menu
var resourceName;
var access = true;
if (isSingleContext) {
resourceName = getResourceAbsolutePath(i);
typeId = vi.liste[i].type;
if ((typeof vi.resource[typeId] == 'undefined') || (vi.resource[typeId].editable == false)) {
// the user has no access to this resource type
access = false;
}
} else {
// multi context menu uses special menu type ID
typeId = "multi";
if (vi.menus[typeId] == null) {
// no multi context menu defined, do not show menu
return;
}
// set resource list in hidden form field value
var resourceList = "";
var isFirst = true;
for (i=0; i<selectedResources.length; i++) {
if (!isFirst) {
resourceList += "|";
}
resourceList += getResourceAbsolutePath(selectedResources[i]);
isFirst = false;
}
doc.forms["formmulti"].elements["resourcelist"].value = resourceList;
}
if (access) {
menu += "<div class=\"cm2\">";
menu += "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" class=\"cm\">";
var lastWasSeparator = false;
var firstEntryWritten = false;
for (a = 0; a < vi.menus[typeId].items.length; a++) {
// 0:unchanged, 1:changed, 2:new, 3:deleted
var result = -1;
if (vi.menus[typeId].items[a].name == "-") {
result = 1;
} else if (vr.actProject == vr.onlineProject) {
// online project
if (isSingleContext) {
if (vi.menus[typeId].items[a].rules.charAt(0) == 'i') {
result = 2;
} else {
if (vi.menus[typeId].items[a].rules.charAt(0) == 'a') {
if ((vi.menus[typeId].items[a].link.indexOf("showlinks=true") > 0)
&& (vi.liste[i].linkType == 0)) {
// special case: resource without siblings
result = 2;
} else {
result = (typeId == 0)?3:4;
}
}
}
} else {
// multi context menu
result = 2;
}
} else {
// offline project
if (isSingleContext) {
if (! vi.liste[i].isInsideCurrentProject) {
// resource is from online project
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -