initial import
[roojs1] / examples / dialog / msg-box.js
1 /*
2  * Based on:
3  * Ext JS Library 1.1.1
4  * Copyright(c) 2006-2007, Ext JS, LLC.
5  *
6  * Originally Released Under LGPL - original licence link has changed is not relivant.
7  *
8  * Fork - LGPL
9  * <script type="text/javascript">
10  */
11 Roo.BLANK_IMAGE_URL  = "../../images/default/s.gif";
12  \r
13 Roo.onReady(function(){\r
14     Roo.get('mb1').on('click', function(e){\r
15         Roo.MessageBox.confirm('Confirm', 'Are you sure you want to do that?', showResult);\r
16     });\r
17 \r
18     Roo.get('mb2').on('click', function(e){\r
19         Roo.MessageBox.prompt('Name', 'Please enter your name:', showResultText);\r
20     });\r
21 \r
22     Roo.get('mb3').on('click', function(e){\r
23         Roo.MessageBox.show({\r
24            title: 'Address',\r
25            msg: 'Please enter your address:',\r
26            width:300,\r
27            buttons: Roo.MessageBox.OKCANCEL,\r
28            multiline: true,\r
29            fn: showResultText,\r
30            animEl: 'mb3'\r
31        });\r
32     });\r
33 \r
34     Roo.get('mb4').on('click', function(e){\r
35         Roo.MessageBox.show({\r
36            title:'Save Changes?',\r
37            msg: 'Your are closing a tab that has unsaved changes. Would you like to save your changes?',\r
38            buttons: Roo.MessageBox.YESNOCANCEL,\r
39            fn: showResult,\r
40            animEl: 'mb4'\r
41        });\r
42     });\r
43 \r
44     Roo.get('mb6').on('click', function(){\r
45         Roo.MessageBox.show({\r
46            title: 'Please wait...',\r
47            msg: 'Initializing...',\r
48            width:240,\r
49            progress:true,\r
50            closable:false,\r
51            animEl: 'mb6'\r
52        });\r
53 \r
54        // this hideous block creates the bogus progress\r
55        var f = function(v){\r
56             return function(){\r
57                 if(v == 11){\r
58                     Roo.MessageBox.hide();\r
59                 }else{\r
60                     Roo.MessageBox.updateProgress(v/10, 'Loading item ' + v + ' of 10...');\r
61                 }\r
62            };\r
63        };\r
64        for(var i = 1; i < 12; i++){\r
65            setTimeout(f(i), i*1000);\r
66        }\r
67     });\r
68 \r
69     Roo.get('mb7').on('click', function(){\r
70         Roo.MessageBox.alert('Status', 'Changes saved successfully.', showResult);\r
71     });\r
72 \r
73 \r
74     function showResult(btn){\r
75         Roo.example.msg('Button Click', 'You clicked the {0} button', btn);\r
76     };\r
77 \r
78     function showResultText(btn, text){\r
79         Roo.example.msg('Button Click', 'You clicked the {0} button and entered the text "{1}".', btn, text);\r
80     };\r
81 });