⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 explorer.js

📁 cms是开源的框架
💻 JS
📖 第 1 页 / 共 4 页
字号:
						if (vi.menus[typeId].items[a].rules.charAt(1) == 'i') {
							result = (vi.menus[typeId].items[a].name == "-")?1:2;
						} else {
							if (vi.menus[typeId].items[a].rules.charAt(1) == 'a') {
								if (vi.menus[typeId].items[a].name == "-") {
									result = 1;
								} else {
									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 {
						// resource is in this project => we have to differ 4 cases
						if (vi.liste[i].lockedBy == '') {
							// resource is not locked...
							if (autolock) {
								// autolock is enabled
								display = vi.menus[typeId].items[a].rules.charAt(vi.liste[i].state + 6);
							} else {
								// autolock is disabled
								display = vi.menus[typeId].items[a].rules.charAt(vi.liste[i].state + 2);
							}
						} else {
							var isSharedLock = (vi.liste[i].lockType == 1 || vi.liste[i].lockType == 2)?true:false;
							if (vi.liste[i].lockedInProjectId == vr.actProject) {
								// locked in this project from ...
								if (vi.liste[i].lockedBy == vr.userName) {
									// ... the current user ...
									if (isSharedLock) {
										// ... as shared lock
										display = vi.menus[typeId].items[a].rules.charAt(vi.liste[i].state + 14);
									} else {
										// ... as exclusive lock
										display = vi.menus[typeId].items[a].rules.charAt(vi.liste[i].state + 10);
									}

								} else {
									// ... someone else
									display = vi.menus[typeId].items[a].rules.charAt(vi.liste[i].state + 14);
								}
							} else {
								// locked in an other project ...
								display = vi.menus[typeId].items[a].rules.charAt(vi.liste[i].state + 14);
							}
						}
						if (display == 'i') {
							result = 2;
						} else {
							if (display == '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 = 3;
				}
			}
			switch (result) {
				case 1:
					// separator line
					if ((firstEntryWritten) && (!lastWasSeparator) && (a != (vi.menus[typeId].items.length - 1))) {
						menu += "<tr><td class=\"cmsep\"><span class=\"cmsep\"></div></td></tr>";
						lastWasSeparator = true;
					}
					break;
				case 2:
					// inactive entry
					menu += "<tr><td>" + spanstartina + vi.menus[typeId].items[a].name + spanend + "</td></tr>";
					lastWasSeparator = false;
					firstEntryWritten = true;
					break;
				case 3:
				case 4:
					// active entry
					var link;
					if (isSingleContext) {
						link = "href=\"" + vi.menus[typeId].items[a].link;
						if (link.indexOf("?") > 0) {
							link += "&";
						} else {
							link += "?";
						}

						link += "resource=" + resourceName + "\"";
						if (result == 4) {
							// href has a target set
							link += " target=" + vi.menus[typeId].items[a].target;
						}

						menu += "<tr><td><a class=\"cme\" " + link + ">" + spanstart + vi.menus[typeId].items[a].name + spanend + "</a></td></tr>";
					} else {
						// multi context menu
						link = "href=\"javascript:top.submitMultiAction('" + vi.menus[typeId].items[a].link + "');\"";
						menu += "<tr><td><a class=\"cme\" " + link + ">" + spanstart + vi.menus[typeId].items[a].name + spanend + "</a></td></tr>";
					}
					lastWasSeparator = false;
					firstEntryWritten = true;
					break;
				default:
					// alert("Undefined result for menu " + a);
					break;
			}
		} // end for ...
		menu += "</table></div>";
		
		var el = doc.getElementById("contextmenu");
		el.innerHTML = menu;
		var x = 12;
		el.style.left = x + "px";
		el.style.visibility = "visible";
		// calculate menu y position after setting visibility to avoid display errors
		var y = getMenuPosY(doc, active_mouse_id);
		el.style.top =  y + "px";
	} // end if (access)
	last_id = active_mouse_id;
	contextOpen = true;
}


// closes a context menu
function closeContext() {

	var cm = win.files.getElementById("contextmenu");
	cm.style.visibility = "hidden";
	contextOpen = false;
}


// submits a selected multi action
function submitMultiAction(dialog) {

	var doc = win.files;
	doc.forms["formmulti"].action = dialog;
	doc.forms["formmulti"].submit();
}

// handle the mouse clicks
function handleOnClick(e) {

	e = checkEvent(e);
	cancelNextOpen = (selectedResources.length > 0);
	if (contextOpen) {
		// close eventually open context menu
		closeContext();	
		if (active_mouse_id == last_id) {
			// clicked on same icon again, leave handler
			return false;
		}
	}
	// unselect resources;
	toggleSelectionStyle(false);
	selectedStyles = new Array();
	
	var btp = e.button;	
	var keyHold = e.shiftKey || e.ctrlKey || e.altKey;
	if (keyHold) {
		// stop event bubbling
		e.cancelBubble = true;
		if (e.stopPropagation) {
			e.stopPropagation();
		}
	}
	if ((active_mouse_id < 0) || (active_from_text && !keyHold && (selectedResources.length <= 1) && (btp != 2))) {
		// no icon clicked, reset selected resources and leave handler
		last_id = -1;
		selectedResources = new Array();
		return true;
	}

	if (e.shiftKey) {
		// shift pressed, mark resources
		if (last_id >= 0) {
			// mark resources from last clicked to current one
			var incrementor = 1;
			if (last_id < active_mouse_id) {
				incrementor = -1;
			}
			var count = active_mouse_id;
			selectedResources = new Array();
			selectedResources[selectedResources.length] = count;
			while (count != last_id) {
				count += incrementor;
				selectedResources[selectedResources.length] = count;

			}
		} else {
			// first click, mark single resource	
			selectedResources = new Array();
			selectedResources[selectedResources.length] = active_mouse_id;
		}
		last_id = active_mouse_id;
	} else if (e.ctrlKey || e.altKey) {
		// control or alt key pressed, add or remove resource from marked resources
		var found = false;
		for (i=0; i<selectedResources.length; i++) {
			if (selectedResources[i] == active_mouse_id) {
				// resource was previously selected, remove it from selection
				selectedResources[i] = -1;
				found = true;
				i = selectedResources.length;
			}
		}
		if (found) {
			// remove resource from selection array, rebuild array
			var tempResources = new Array();
			for (i=0; i<selectedResources.length; i++) {
				if (selectedResources[i] > -1) {
					tempResources[tempResources.length] = selectedResources[i];
				}
			}
			selectedResources = tempResources;
		} else {
			// not found, add resource to selection
			selectedResources[selectedResources.length] = active_mouse_id;
		}
	} else {
		// common click, mark currently clicked resource if not clicked before
		if (active_mouse_id != last_id) {
			var clickedMarked = false;
			for (i=0; i<selectedResources.length; i++) {
				if (selectedResources[i] == active_mouse_id) {
					clickedMarked = true;
				}
			}
			if (!clickedMarked || selectedResources.length <= 1) {
				// left mouse button clicked or only one resource selected, select the current resource
				selectedResources = new Array();
				selectedResources[selectedResources.length] = active_mouse_id;
			}
		}
		toggleSelectionStyle(true);
		cancelNextOpen = keyHold || (selectedResources.length > 0);
		return handleContext(e);
	}
	toggleSelectionStyle(true);
	cancelNextOpen = keyHold || (selectedResources.length > 0);

	return false;
}


// check if the event object is available and gets it if necessary
function checkEvent(e) {

	// fix for IE if window access is refused in some cases
	try {
		win.files.getElementById("contextmenu");
	} catch (e) {
		updateWindowStore();
	} 
	// check event
	if (!e) {
		e = win.fileswin.event;
	}
	return e;
}

// toggles the style of the selected resources
function toggleSelectionStyle(isSelected) {

	var doc = win.files;
	var styleName = "selected";
	if (! isSelected) {
		styleName = "unselected";
	}

	for (i=0; i<selectedResources.length; i++) {
		var last_id_style = "";
		var ah = doc.getElementById("a" + selectedResources[i]);
		var td = doc.getElementById("td3_" + selectedResources[i]);
		if (ah == null) {
			ah = td;
		}
		var rowStyle;
		if (ah != null) {
			last_id_style = ah.className;
			if (isSelected) {
				selectedStyles[selectedResources[i]] = last_id_style;
			}

			if (isSelected) {
				ah.className = styleName;
			} else {
				var cls = selectedStyles[selectedResources[i]];
				if (cls.charAt(cls.length - 1) == 'i') {
					cls = cls.substring(0, cls.length-1);
				}
				ah.className = cls;
			}

			rowStyle = styleName;
			if (last_id_style == "fd") {
				rowStyle += " fd";
				td.className = rowStyle;
			} else {
				td.className = ah.className;
			}
		}			

		for (k=0; k<3; k++) {
			// change style of columns 0 to 2
			try {
				var elem = doc.getElementById("td" + k + "_" + selectedResources[i]);
				if (elem.className != "fd") {
					elem.className = rowStyle;
				}
			} catch (e) {}
		}
	}
}

function linkOver(obj, id) {

	var cls = obj.className;
	if (cls.charAt(cls.length - 1) != 'i') {
		cls = cls + 'i';
	}
	obj.className = cls;
	active_mouse_id = id;
	active_from_text = true;
}

function linkOut(obj) {
	
	var cls = obj.className;
	if (cls.charAt(cls.length - 1) == 'i') {
		cls = cls.substring(0, cls.length-1);
	}
	obj.className = cls;
	active_mouse_id = -1;
	active_from_text = false;
}


function printList(wo) {
	var i;
	var lockedBystring;
	var ssclass;
	var temp =
	"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">"
	+ "<html><head>"
	+ "<meta HTTP-EQUIV=\"content-type\" CONTENT=\"text/html; charset="
	+ top.frames.head.encoding
	+ "\">\n"
	+ "<script language=\"JavaScript\">\n"
	+ "document.oncontextmenu = new Function('return false;');\n"
	+ "document.onmousedown = new Function('return false;');\n"
	+ "document.onmouseup = top.handleOnClick;\n"
	+ "</script>"
	+ "<style type='text/css'>\n"
	+ "body { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; padding: 0px; margin: 0px; background-color: Window; } "
	+ "p, td { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; white-space: nowrap; } "
	+ "td.t { white-space: nowrap; background-color:ThreedFace; border-right: 1px solid ThreedDarkShadow; border-top: 1px solid ThreeDHighlight; border-bottom: 1px solid ThreedDarkShadow; border-left: 1px solid ThreeDHighlight; } "
	+ "td.t125 { white-space: nowrap; width: 125px; background-color:ThreedFace; border-right: 1px solid ThreedDarkShadow; border-top: 1px solid ThreeDHighlight; border-bottom: 1px solid ThreedDarkShadow; border-left: 1px solid ThreeDHighlight; } "
	+ "td.t100 { white-space: nowrap; width: 100px; background-color:ThreedFace; border-right: 1px solid ThreedDarkShadow; border-top: 1px solid ThreeDHighlight; border-bottom: 1px solid ThreedDarkShadow; border-left: 1px solid ThreeDHighlight; } "
	+ "td.t75 { white-space: nowrap; width: 75px; background-color:ThreedFace; border-right: 1px solid ThreedDarkShadow; border-top: 1px solid ThreeDHighlight; border-bottom: 1px solid ThreedDarkShadow; border-left: 1px solid ThreeDHighlight; } "
	+ "a { text-decoration: none; cursor: pointer; } "

	+ "td.fc { color: #b40000; } "
	+ "a.fc { color: #b40000; } "
	+ "a.fci { text-decoration: underline; color: #000088; } "

	+ "td.fn { color: #0000aa; } "
	+ "a.fn { color: #0000aa; } "
	+ "a.fni { text-decoration: underline; color: #000088; } "

	+ "td.fd { color: #000000; text-decoration: line-through; } "
	+ "a.fd { color: #000000; text-decoration: line-through; } "
	+ "a.fdi { text-decoration: line-through underline; color: #000088; } "

	+ "td.fp { color: #888888; } "
	+ "a.fp { color: #888888; } "
	+ "a.fpi { text-decoration: underline; color: #000088; } "

	+ "td.nf { color:#000000; } "
	+ "a.nf { color:#000000; } "
	+ "a.nfi { text-decoration: underline; color: #000088; } "

	+ "div.cm { position: absolute; visibility: hidden; top: 0px; left: 0px; background-color: ThreeDFace; z-index: 100; border-left: 1px solid ThreeDFace; border-top: 1px solid ThreeDFace; border-bottom: 1px solid ThreedDarkShadow; border-right: 1px solid ThreedDarkShadow; filter:progid:DXImageTransform.Microsoft.Shadow(color=ThreeDShadow, Direction=135, Strength=3); } "
	+ "div.cm2 { border-left: 1px solid ThreeDHighlight; border-top: 1px solid ThreeDHighlight; border-bottom: 1px solid ThreeDShadow; border-right: 1px solid ThreeDShadow; } "
	+ "table.cm { width: 150px; } "
	+ "span.cmsep { display: block; width: 100%; height: 1px; font-size: 0px; background-color: ThreeDShadow; padding: 0px; border-bottom: 1px solid ThreeDHighlight;} "
	+ "td.cmsep { box-sizing: border-box; -moz-box-sizing: border-box; padding: 2px; } "
	+ "a.cme { color: MenuText; text-decoration: none;} "

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -