JavaScript DHTML/Ext JS/Dialog — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Версия 09:59, 26 мая 2010
Содержание
Hide dialog
<html>
<head>
<title>Hello World Window</title>
<link rel="stylesheet" type="text/css" href="ext-3.0.0/resources/css/ext-all.css" />
<script type="text/javascript" src="ext-3.0.0/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="ext-3.0.0/ext-all.js"></script>
</head>
<body>
<script type="text/javascript">
Ext.onReady(function() {
Ext.MessageBox.show({
title : "Wait",
msg : "Deleting...",
progressText : "Initializing...",
width : 300,
progress : true,
closable : false
});
var updateFn = function(num){
return function(){
if(num == 99){
Ext.MessageBox.updateProgress(100, "All Items deleted!");
Ext.MessageBox.hide.defer(1500, Ext.MessageBox);
}
else{
var i = num/100;
var pct = i;
Ext.MessageBox.updateProgress(i, pct + "% completed");
}
};
};
for (var i = 1; i < 100; i++){
setTimeout(updateFn(i), i * 50+1);
}
});
</script>
<div id="div1">asdf</div>
</body>
</html>
Model window dialog
<html>
<head>
<title>Hello World Window</title>
<link rel="stylesheet" type="text/css" href="ext-3.0.0/resources/css/ext-all.css" />
<script type="text/javascript" src="ext-3.0.0/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="ext-3.0.0/ext-all.js"></script>
</head>
<body>
<script type="text/javascript">
Ext.onReady(function() {
var win = new Ext.Window({
height : 305,
width : 200,
modal : true,
title : "Rigid window",
html : "Unable to move or resize.",
plain : true,
border : false,
resizable : false,
draggable : false,
closable : false,
buttonAlign : "center",
buttons : [
{
text : "OK",
handler : function() {
win.close();
}
}
]
})
win.show();
});
</script>
<div id="div1">asdf</div>
</body>
</html>
Multiline dialog box
<!--
/*!
* Ext JS Library 3.0.0
* Copyright(c) 2006-2009 Ext JS, LLC
* licensing@extjs.ru
* http://www.extjs.ru/license
*/
-->
<html>
<head>
<title>Hello World Window</title>
<link rel="stylesheet" type="text/css" href="ext-3.0.0/resources/css/ext-all.css" />
<script type="text/javascript" src="ext-3.0.0/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="ext-3.0.0/ext-all.js"></script>
</head>
<!-- Revised from demo code in ext3.0.0 -->
<body>
<script type="text/javascript">
/*!
* Ext JS Library 3.0.0
* Copyright(c) 2006-2009 Ext JS, LLC
* licensing@extjs.ru
* http://www.extjs.ru/license
*/
Ext.onReady(function(){
Ext.get("mb1").on("click", function(e){
Ext.MessageBox.show({
title: "Address",
msg: "Please enter your address:",
width:300,
buttons: Ext.MessageBox.OKCANCEL,
multiline: true,
fn: showResultText,
animEl: "mb3"
});
});
//Add these values dynamically so they aren"t hard-coded in the html
Ext.fly("info").dom.value = Ext.MessageBox.INFO;
Ext.fly("question").dom.value = Ext.MessageBox.QUESTION;
Ext.fly("warning").dom.value = Ext.MessageBox.WARNING;
Ext.fly("error").dom.value = Ext.MessageBox.ERROR;
function showResult(btn){
Ext.example.msg("Button Click", "You clicked the {0} button", btn);
};
function showResultText(btn, text){
Ext.example.msg("Button Click", "You clicked the {0} button and entered the text "{1}".", btn, text);
};
});
</script>
<button id="mb1">Show</button>
</body>
</html>
Not closable dialog
<html>
<head>
<title>Hello World Window</title>
<link rel="stylesheet" type="text/css" href="ext-3.0.0/resources/css/ext-all.css" />
<script type="text/javascript" src="ext-3.0.0/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="ext-3.0.0/ext-all.js"></script>
</head>
<body>
<script type="text/javascript">
Ext.onReady(function() {
Ext.MessageBox.show({
title : "Wait",
msg : "Deleting...",
progressText : "Initializing...",
width : 300,
progress : true,
closable : false
});
var updateFn = function(num){
return function(){
if(num == 99){
Ext.MessageBox.updateProgress(100, "All Items deleted!");
Ext.MessageBox.hide.defer(1500, Ext.MessageBox);
}
else{
var i = num/100;
var pct = i;
Ext.MessageBox.updateProgress(i, pct + "% completed");
}
};
};
for (var i = 1; i < 100; i++){
setTimeout(updateFn(i), i * 50+1);
}
});
</script>
<div id="div1">asdf</div>
</body>
</html>
Progress dialog demo
<html>
<head>
<title>Hello World Window</title>
<link rel="stylesheet" type="text/css" href="ext-3.0.0/resources/css/ext-all.css" />
<script type="text/javascript" src="ext-3.0.0/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="ext-3.0.0/ext-all.js"></script>
</head>
<body>
<script type="text/javascript">
Ext.onReady(function() {
Ext.MessageBox.show({
title : "Wait",
msg : "Deleting...",
progressText : "Initializing...",
width : 300,
progress : true,
closable : false
});
var updateFn = function(num){
return function(){
if(num == 99){
Ext.MessageBox.updateProgress(100, "All Items deleted!");
Ext.MessageBox.hide.defer(1500, Ext.MessageBox);
}
else{
var i = num/100;
var pct = i;
Ext.MessageBox.updateProgress(i, pct + "% completed");
}
};
};
for (var i = 1; i < 100; i++){
setTimeout(updateFn(i), i * 50+1);
}
});
</script>
<div id="div1">asdf</div>
</body>
</html>
Set call back function for dialog
<html>
<head>
<title>Hello World Window</title>
<link rel="stylesheet" type="text/css" href="ext-3.0.0/resources/css/ext-all.css" />
<script type="text/javascript" src="ext-3.0.0/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="ext-3.0.0/ext-all.js"></script>
</head>
<body>
<script type="text/javascript">
Ext.onReady(function() {
var myCallback = function(btn, text) {
alert("You pressed " + btn);
if (text) {
alert("You entered : " + text)
}
}
Ext.Msg.show({
title : "Hold on there cowboy!",
msg : "Are you sure you want to reboot the internet?",
width : 300,
buttons : Ext.MessageBox.YESNOCANCEL,
fn : myCallback,
icon : Ext.MessageBox.ERROR
})
});
</script>
<div id="div1">asdf</div>
</body>
</html>
Update progress dialog
<html>
<head>
<title>Hello World Window</title>
<link rel="stylesheet" type="text/css" href="ext-3.0.0/resources/css/ext-all.css" />
<script type="text/javascript" src="ext-3.0.0/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="ext-3.0.0/ext-all.js"></script>
</head>
<body>
<script type="text/javascript">
Ext.onReady(function() {
Ext.MessageBox.show({
title : "Wait",
msg : "Deleting...",
progressText : "Initializing...",
width : 300,
progress : true,
closable : false
});
var updateFn = function(num){
return function(){
if(num == 99){
Ext.MessageBox.updateProgress(100, "All Items deleted!");
Ext.MessageBox.hide.defer(1500, Ext.MessageBox);
}
else{
var i = num/100;
var pct = i;
Ext.MessageBox.updateProgress(i, pct + "% completed");
}
};
};
for (var i = 1; i < 100; i++){
setTimeout(updateFn(i), i * 50+1);
}
});
</script>
<div id="div1">asdf</div>
</body>
</html>
Wait Dialog: Dialog with indefinite progress bar and custom icon (will close after 8 sec).
<!--
/*!
* Ext JS Library 3.0.0
* Copyright(c) 2006-2009 Ext JS, LLC
* licensing@extjs.ru
* http://www.extjs.ru/license
*/
-->
<html>
<head>
<title>Hello World Window</title>
<link rel="stylesheet" type="text/css" href="ext-3.0.0/resources/css/ext-all.css" />
<script type="text/javascript" src="ext-3.0.0/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="ext-3.0.0/ext-all.js"></script>
</head>
<!-- Revised from demo code in ext3.0.0 -->
<body>
<script type="text/javascript">
/*!
* Ext JS Library 3.0.0
* Copyright(c) 2006-2009 Ext JS, LLC
* licensing@extjs.ru
* http://www.extjs.ru/license
*/
Ext.onReady(function(){
Ext.get("mb1").on("click", function(e){
Ext.MessageBox.show({
msg: "Saving your data, please wait...",
progressText: "Saving...",
width:300,
wait:true,
waitConfig: {interval:200},
icon:"ext-mb-download", //custom class in msg-box.html
animEl: "mb7"
});
setTimeout(function(){
//This simulates a long-running operation like a database save or XHR call.
//In real code, this would be in a callback function.
Ext.MessageBox.hide();
Ext.example.msg("Done", "Your fake data was saved!");
}, 8000);
});
//Add these values dynamically so they aren"t hard-coded in the html
Ext.fly("info").dom.value = Ext.MessageBox.INFO;
Ext.fly("question").dom.value = Ext.MessageBox.QUESTION;
Ext.fly("warning").dom.value = Ext.MessageBox.WARNING;
Ext.fly("error").dom.value = Ext.MessageBox.ERROR;
function showResult(btn){
Ext.example.msg("Button Click", "You clicked the {0} button", btn);
};
function showResultText(btn, text){
Ext.example.msg("Button Click", "You clicked the {0} button and entered the text "{1}".", btn, text);
};
});
</script>
<button id="mb1">Show</button>
</body>
</html>