зеркало из https://github.com/mozilla/pjs.git
Patch from Jan Varga <varga@utcru.sk> for filepicker localizability fixes,
improved keyboard navigation, and misc. cleanups. bug 45561. r=me,pavlov. a=waterson.
This commit is contained in:
Родитель
1952fea17d
Коммит
b03227c197
|
@ -1,4 +1,27 @@
|
||||||
/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||||
|
*
|
||||||
|
* The contents of this file are subject to the Mozilla Public
|
||||||
|
* License Version 1.1 (the "License"); you may not use this file
|
||||||
|
* except in compliance with the License. You may obtain a copy of
|
||||||
|
* the License at http://www.mozilla.org/MPL/
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS
|
||||||
|
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||||
|
* implied. See the License for the specific language governing
|
||||||
|
* rights and limitations under the License.
|
||||||
|
*
|
||||||
|
* The Original Code is mozilla.org code.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is Netscape Communications
|
||||||
|
* Corporation. Portions created by Netscape are
|
||||||
|
* Copyright (C) 2000 Netscape Communications Corporation. All
|
||||||
|
* Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
* Stuart Parmenter <pavlov@netscape.com>
|
||||||
|
* Brian Ryner <bryner@netscape.com>
|
||||||
|
* Jan Varga <varga@utcru.sk>
|
||||||
|
*/
|
||||||
|
|
||||||
const nsILocalFile = Components.interfaces.nsILocalFile;
|
const nsILocalFile = Components.interfaces.nsILocalFile;
|
||||||
const nsILocalFile_PROGID = "component://mozilla/file/local";
|
const nsILocalFile_PROGID = "component://mozilla/file/local";
|
||||||
|
@ -12,8 +35,16 @@ var filePickerMode;
|
||||||
var currentFilter;
|
var currentFilter;
|
||||||
var lastClicked;
|
var lastClicked;
|
||||||
|
|
||||||
|
var directoryTree;
|
||||||
|
var textInput;
|
||||||
|
|
||||||
|
var bundle = srGetStrBundle("chrome://global/locale/filepicker.properties");
|
||||||
|
|
||||||
function onLoad() {
|
function onLoad() {
|
||||||
|
|
||||||
|
directoryTree = document.getElementById("directoryTree");
|
||||||
|
textInput = document.getElementById("textInput");
|
||||||
|
|
||||||
if (window.arguments) {
|
if (window.arguments) {
|
||||||
var o = window.arguments[0];
|
var o = window.arguments[0];
|
||||||
retvals = o.retvals; /* set this to a global var so we can set return values */
|
retvals = o.retvals; /* set this to a global var so we can set return values */
|
||||||
|
@ -29,7 +60,6 @@ function onLoad() {
|
||||||
window.title = title;
|
window.title = title;
|
||||||
|
|
||||||
if (initialText) {
|
if (initialText) {
|
||||||
textInput = document.getElementById("textInput");
|
|
||||||
textInput.value = initialText;
|
textInput.value = initialText;
|
||||||
}
|
}
|
||||||
/* build filter popup */
|
/* build filter popup */
|
||||||
|
@ -63,7 +93,9 @@ function onLoad() {
|
||||||
retvals.buttonStatus = nsIFilePicker.returnCancel;
|
retvals.buttonStatus = nsIFilePicker.returnCancel;
|
||||||
addToHistory(sfile.path);
|
addToHistory(sfile.path);
|
||||||
|
|
||||||
getDirectoryContents(document.getElementById("directoryList"), sfile.directoryEntries);
|
getDirectoryContents(directoryTree, sfile.directoryEntries);
|
||||||
|
|
||||||
|
textInput.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
function onFilterChanged(target)
|
function onFilterChanged(target)
|
||||||
|
@ -132,7 +164,7 @@ function onOK()
|
||||||
case nsIFilePicker.modeSave:
|
case nsIFilePicker.modeSave:
|
||||||
if (isFile) {
|
if (isFile) {
|
||||||
// we need to pop up a dialog asking if you want to save
|
// we need to pop up a dialog asking if you want to save
|
||||||
rv = window.confirm(file.path + "already exists. Do you want to replace it?");
|
rv = window.confirm(file.path + " " + bundle.GetStringFromName("confirmFileReplacing"));
|
||||||
if (rv)
|
if (rv)
|
||||||
ret = nsIFilePicker.returnReplace;
|
ret = nsIFilePicker.returnReplace;
|
||||||
else
|
else
|
||||||
|
@ -168,26 +200,49 @@ function onCancel()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function onClick(e) {
|
// node corresponds to treerow
|
||||||
|
function doConfirm(node) {
|
||||||
var file = Components.classes[nsILocalFile_PROGID].createInstance(nsILocalFile);
|
var file = Components.classes[nsILocalFile_PROGID].createInstance(nsILocalFile);
|
||||||
file.initWithPath(e.target.parentNode.getAttribute("path"));
|
file.initWithPath(node.getAttribute("path"));
|
||||||
|
|
||||||
if (!file.isDirectory()) {
|
if (file.isDirectory()) {
|
||||||
|
gotoDirectory(file.path);
|
||||||
|
}
|
||||||
|
else if (file.isFile()) {
|
||||||
|
/* what about symlinks? what if they symlink to a directory? */
|
||||||
|
return doOKButton();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function onClick(e) {
|
||||||
|
if ( e.detail == 2 )
|
||||||
|
doConfirm(e.target.parentNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
function onKeyup(e) {
|
||||||
|
if (directoryTree.selectedItems.length == 0 ) {
|
||||||
|
directoryTree.selectItem(directoryTree.getItemAtIndex(0));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e.keyCode == 13) {
|
||||||
|
doConfirm(e.target.selectedItems[0].firstChild);
|
||||||
|
}
|
||||||
|
else if (e.keyCode == 8)
|
||||||
|
goUp();
|
||||||
|
}
|
||||||
|
|
||||||
|
function onSelect(e) {
|
||||||
|
if (e.target.selectedItems.length != 1)
|
||||||
|
return;
|
||||||
|
var file = Components.classes[nsILocalFile_PROGID].createInstance(nsILocalFile);
|
||||||
|
var path = e.target.selectedItems[0].firstChild.getAttribute("path");
|
||||||
|
file.initWithPath(path);
|
||||||
|
if (file.isFile()) {
|
||||||
textInput = document.getElementById("textInput");
|
textInput = document.getElementById("textInput");
|
||||||
textInput.value = file.leafName;
|
textInput.value = file.leafName;
|
||||||
lastClicked = file.leafName;
|
lastClicked = file.leafName;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e.detail == 2) {
|
|
||||||
if (file.isDirectory()) {
|
|
||||||
gotoDirectory(file.path);
|
|
||||||
}
|
|
||||||
else if (file.isFile()) {
|
|
||||||
/* what about symlinks? what if they symlink to a directory? */
|
|
||||||
return doOKButton();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function dirSort(e1, e2)
|
function dirSort(e1, e2)
|
||||||
|
@ -352,11 +407,9 @@ function getDirectoryContents(parentElement, dirContents)
|
||||||
}
|
}
|
||||||
|
|
||||||
function clearTree() {
|
function clearTree() {
|
||||||
var tree = document.getElementById("directoryList");
|
|
||||||
|
|
||||||
/* lets make an assumption that the tree children are at the end of the tree... */
|
/* lets make an assumption that the tree children are at the end of the tree... */
|
||||||
if (tree.lastChild)
|
if (directoryTree.lastChild)
|
||||||
tree.removeChild(tree.lastChild);
|
directoryTree.removeChild(directoryTree.lastChild);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -392,7 +445,7 @@ function loadDirectory() {
|
||||||
if (sfile.isDirectory()) {
|
if (sfile.isDirectory()) {
|
||||||
clearTree();
|
clearTree();
|
||||||
try {
|
try {
|
||||||
getDirectoryContents(document.getElementById("directoryList"), sfile.directoryEntries);
|
getDirectoryContents(directoryTree, sfile.directoryEntries);
|
||||||
} catch(ex) { dump("getDirectoryContents() failed\n"); }
|
} catch(ex) { dump("getDirectoryContents() failed\n"); }
|
||||||
addToHistory(sfile.path);
|
addToHistory(sfile.path);
|
||||||
textInput = document.getElementById("textInput");
|
textInput = document.getElementById("textInput");
|
||||||
|
|
|
@ -1,20 +1,45 @@
|
||||||
<?xml version="1.0"?> <!-- -*- Mode: HTML -*- -->
|
<?xml version="1.0"?> <!-- -*- Mode: HTML -*- -->
|
||||||
|
|
||||||
|
<!--
|
||||||
|
- The contents of this file are subject to the Mozilla Public
|
||||||
|
- License Version 1.1 (the "License"); you may not use this file
|
||||||
|
- except in compliance with the License. You may obtain a copy of
|
||||||
|
- the License at http://www.mozilla.org/MPL/
|
||||||
|
|
||||||
|
- Software distributed under the License is distributed on an "AS
|
||||||
|
- IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||||
|
- implied. See the License for the specific language governing
|
||||||
|
- rights and limitations under the License.
|
||||||
|
|
||||||
|
- The Original Code is mozilla.org code.
|
||||||
|
|
||||||
|
- The Initial Developer of the Original Code is Netscape
|
||||||
|
- Communications Corporation. Portions created by Netscape are
|
||||||
|
- Copyright (C) 2000 Netscape Communications Corporation.
|
||||||
|
- All Rights Reserved.
|
||||||
|
|
||||||
|
- Contributor(s):
|
||||||
|
- Stuart Parmenter <pavlov@netscape.com>
|
||||||
|
- Brian Ryner <bryner@netscape.com>
|
||||||
|
- Jan Varga <varga@utcru.sk>
|
||||||
|
-->
|
||||||
|
|
||||||
<?xml-stylesheet href="chrome://global/skin/filepicker.css" type="text/css"?>
|
<?xml-stylesheet href="chrome://global/skin/filepicker.css" type="text/css"?>
|
||||||
|
|
||||||
<?xul-overlay href="chrome://global/content/dialogOverlay.xul"?>
|
<?xul-overlay href="chrome://global/content/dialogOverlay.xul"?>
|
||||||
|
|
||||||
<window id="main-window" xmlns:html="http://www.w3.org/1999/xhtml"
|
<window id="main-window"
|
||||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
|
||||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||||
align="vertical"
|
orient="vertical"
|
||||||
onload="onLoad();"
|
onload="onLoad();"
|
||||||
width="426" height="300"
|
width="426" height="300"
|
||||||
class="dialog">
|
class="dialog"
|
||||||
|
persist="screenX screenY">
|
||||||
|
|
||||||
<html:script src="chrome://global/content/filepicker.js"/>
|
<script src="chrome://global/content/strres.js"/>
|
||||||
|
<script src="chrome://global/content/filepicker.js"/>
|
||||||
|
|
||||||
<box align="horizontal" autostretch="never">
|
<box autostretch="never">
|
||||||
<!-- History list needs hooked up
|
<!-- History list needs hooked up
|
||||||
<text value="Look in:"/>
|
<text value="Look in:"/>
|
||||||
<menulist id="lookInMenuList" flex="1">
|
<menulist id="lookInMenuList" flex="1">
|
||||||
|
@ -26,8 +51,9 @@
|
||||||
<button value=".." onclick="goUp();"/>
|
<button value=".." onclick="goUp();"/>
|
||||||
</box>
|
</box>
|
||||||
|
|
||||||
<box align="horizontal" flex="1">
|
<box flex="1">
|
||||||
<tree id="directoryList" flex="1">
|
<tree id="directoryTree" flex="1"
|
||||||
|
onkeyup="onKeyup(event)" onselect="onSelect(event)">
|
||||||
<treecolgroup>
|
<treecolgroup>
|
||||||
<treecol flex="1"/>
|
<treecol flex="1"/>
|
||||||
<treecol flex="1"/>
|
<treecol flex="1"/>
|
||||||
|
@ -43,12 +69,12 @@
|
||||||
</tree>
|
</tree>
|
||||||
</box>
|
</box>
|
||||||
|
|
||||||
<box align="horizontal" autostretch="never" style="margin-top: 5px">
|
<box autostretch="never" style="margin-top: 5px">
|
||||||
<text value="File name:"/>
|
<text value="File name:"/>
|
||||||
<textfield id="textInput" onkeypress="if (event.which == 13) { onOK(); }" flex="1"/>
|
<textfield id="textInput" onkeypress="if (event.which == 13) { onOK(); }" flex="1"/>
|
||||||
</box>
|
</box>
|
||||||
|
|
||||||
<box align="horizontal" autostretch="never">
|
<box autostretch="never">
|
||||||
<text value="Files of type:"/>
|
<text value="Files of type:"/>
|
||||||
<menulist id="filterMenuList" flex="1" oncommand="onFilterChanged(event.target);"/>
|
<menulist id="filterMenuList" flex="1" oncommand="onFilterChanged(event.target);"/>
|
||||||
</box>
|
</box>
|
||||||
|
|
|
@ -12,3 +12,5 @@ xmlTitle=XML Files
|
||||||
xmlFilter=*.xml
|
xmlFilter=*.xml
|
||||||
xulTitle=XUL Files
|
xulTitle=XUL Files
|
||||||
xulFilter=*.xul
|
xulFilter=*.xul
|
||||||
|
|
||||||
|
confirmFileReplacing=already exists. Do you want to replace it?
|
||||||
|
|
Загрузка…
Ссылка в новой задаче