зеркало из https://github.com/mozilla/gecko-dev.git
New File->Open dialog
This commit is contained in:
Родитель
d90c49acb9
Коммит
766962d434
|
@ -0,0 +1,107 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (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/NPL/
|
||||
*
|
||||
* 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 Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
var toolkit;
|
||||
var browser;
|
||||
var dialog;
|
||||
|
||||
function onLoad() {
|
||||
dialog = new Object;
|
||||
dialog.input = document.getElementById( "dialog.input" );
|
||||
dialog.ok = document.getElementById( "dialog.ok" );
|
||||
dialog.cancel = document.getElementById( "dialog.cancel" );
|
||||
dialog.help = document.getElementById( "dialog.help" );
|
||||
dialog.newWindow = document.getElementById( "dialog.newWindow" );
|
||||
dialog.args = document.getElementById( "args" );
|
||||
|
||||
toolkit = XPAppCoresManager.Find( "toolkitCore" );
|
||||
if ( !toolkit ) {
|
||||
toolkit = new ToolkitCore();
|
||||
toolkit.Init( "toolkitCore" );
|
||||
}
|
||||
|
||||
browser = XPAppCoresManager.Find( dialog.args.getAttribute( "value" ) );
|
||||
if ( !browser ) {
|
||||
dump( "unable to get browser app core\n" );
|
||||
//toolkit.CloseWindow( window );
|
||||
}
|
||||
}
|
||||
|
||||
function onTyping( key ) {
|
||||
// Look for enter key...
|
||||
if ( key == 13 ) {
|
||||
// If ok button not disabled, go for it.
|
||||
if ( !dialog.ok.disabled ) {
|
||||
open();
|
||||
}
|
||||
} else {
|
||||
// Check for valid input.
|
||||
if ( dialog.input.value == "" ) {
|
||||
// No input, disable ok button if enabled.
|
||||
if ( !dialog.ok.disabled ) {
|
||||
dialog.ok.setAttribute( "disabled", "" );
|
||||
}
|
||||
} else {
|
||||
// Input, enable ok button if disabled.
|
||||
if ( dialog.ok.disabled ) {
|
||||
dialog.ok.removeAttribute( "disabled" );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function open() {
|
||||
if ( dialog.ok.disabled ) {
|
||||
return;
|
||||
}
|
||||
|
||||
var url = dialog.input.value;
|
||||
|
||||
if ( !dialog.newWindow.checked ) {
|
||||
/* Load url in opener. */
|
||||
browser.loadUrl( url );
|
||||
} else {
|
||||
/* User wants new window. */
|
||||
toolkit.ShowWindowWithArgs( "resource:/res/samples/navigator.xul", window.opener, url );
|
||||
}
|
||||
|
||||
/* Close dialog. */
|
||||
//toolkit.CloseWindow( window );
|
||||
}
|
||||
|
||||
function choose() {
|
||||
/* Use existing browser "open" logic. */
|
||||
browser.openWindow();
|
||||
//toolkit.CloseWindow( window );
|
||||
}
|
||||
|
||||
function cancel() {
|
||||
if ( dialog.cancel.disabled ) {
|
||||
return;
|
||||
}
|
||||
//toolkit.CloseWindow( window );
|
||||
}
|
||||
|
||||
function help() {
|
||||
if ( dialog.help.disabled ) {
|
||||
return;
|
||||
}
|
||||
dump( "openLocation::help() not implemented\n" );
|
||||
}
|
|
@ -0,0 +1,95 @@
|
|||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet href="xul.css" type="text/css"?>
|
||||
|
||||
<!DOCTYPE window>
|
||||
|
||||
<window xmlns:html="http://www.w3.org/TR/REC-html40"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
onload="onLoad()"
|
||||
title="Open Location"
|
||||
width="420"
|
||||
height="190">
|
||||
|
||||
<html:script language="javascript" src="openLocation.js">
|
||||
</html:script>
|
||||
|
||||
<broadcaster id="args" value=""/>
|
||||
|
||||
<!--
|
||||
<box align="vertical">
|
||||
<box align="horizontal">
|
||||
Enter the World Wide Web location (URL) you would like to open. Use
|
||||
the Choose File... button to select a local file:
|
||||
</box>
|
||||
<box align="horizontal">
|
||||
<box align="horizontal" flex="100">
|
||||
<html:input id="dialog.input"/>
|
||||
</box>
|
||||
<box align="horizontal">
|
||||
<html:button onclick="choose()">Choose File...</html:button>
|
||||
</box>
|
||||
</box>
|
||||
<box align="horizontal" flex="100">
|
||||
<box flex="100">
|
||||
<html:input id="dialog.newWindow" type="checkbox"/>Open in new window
|
||||
</box>
|
||||
<box>
|
||||
<html:button onclick="open()">Open</html:button>
|
||||
</box>
|
||||
<box>
|
||||
<html:button onclick="cancel()">Cancel</html:button>
|
||||
</box>
|
||||
<box>
|
||||
<html:button onclick="help()" disabled="">Help</html:button>
|
||||
</box>
|
||||
</box>
|
||||
</box>
|
||||
-->
|
||||
<html:center>
|
||||
<html:p/>
|
||||
<html:table width="400" cellspacing="5">
|
||||
<html:tr>
|
||||
<html:td>
|
||||
Enter the World Wide Web location (URL) you would like to open. Use
|
||||
the Choose File... button to select a local file:
|
||||
</html:td>
|
||||
</html:tr>
|
||||
<html:tr>
|
||||
<html:td>
|
||||
<html:table cellspacing="5">
|
||||
<html:tr>
|
||||
<html:td width="275">
|
||||
<html:input id="dialog.input" style="width:275;" onkeyup="onTyping(event.which)"/>
|
||||
</html:td>
|
||||
<html:td width="100">
|
||||
<html:button onclick="choose()">Choose File...</html:button>
|
||||
</html:td>
|
||||
</html:tr>
|
||||
</html:table>
|
||||
</html:td>
|
||||
</html:tr>
|
||||
<html:tr>
|
||||
<html:td>
|
||||
<html:table cellspacing="5">
|
||||
<html:tr>
|
||||
<html:td width="165">
|
||||
<html:input id="dialog.newWindow" type="checkbox"/>Open in new window
|
||||
</html:td>
|
||||
<html:td width="70">
|
||||
<html:button id="dialog.ok" onclick="open()" disabled="">Open</html:button>
|
||||
</html:td>
|
||||
<html:td width="70">
|
||||
<html:button id="dialog.cancel" onclick="cancel()" disabled="">Cancel</html:button>
|
||||
</html:td>
|
||||
<html:td width="70">
|
||||
<html:button id="dialog.help" onclick="help()" disabled="">Help</html:button>
|
||||
</html:td>
|
||||
</html:tr>
|
||||
</html:table>
|
||||
</html:td>
|
||||
</html:tr>
|
||||
</html:table>
|
||||
<html:p/>
|
||||
</html:center>
|
||||
|
||||
</window>
|
Загрузка…
Ссылка в новой задаче