Debian Codegraph @

closure-library/closure/goog/demos/dialog.html

raw
1 <!DOCTYPE html>
2 <html>
3 <!--
4 Copyright 2010 The Closure Library Authors. All Rights Reserved.
5
6 Use of this source code is governed by the Apache License, Version 2.0.
7 See the COPYING file for details.
8 -->
9 <head>
10 <title>goog.ui.Dialog</title>
11 <script src="../base.js"></script>
12 <script>
13 goog.require('goog.events');
14 goog.require('goog.events.EventType');
15 goog.require('goog.html.testing');
16 goog.require('goog.ui.Dialog');
17 </script>
18 <link rel="stylesheet" href="css/demo.css">
19 <link rel="stylesheet" href="../css/dialog.css">
20 <style>
21 .modal-dialog {
22 width: 430px;
23 }
24 </style>
25 </head>
26
27 <body>
28 <h1>goog.ui.Dialog</h1>
29 <div><input id="openOnKeyDown" type="checkbox">
30 <label>Enable open on keydown</label>
31 <span>(use "Space" to open dialog with no Iframe, "Enter" to open with Iframe
32 mask</span>
33 </div>
34 <div><input id="swapModalOnShift" type="checkbox">
35 <label>Enable modal change with shift when the dialog is open</label>
36 </div>
37 <button onclick="showDialog(dialog1);">
38 Open Dialog (no Iframe)</button>
39 <br>
40 <button onclick="showDialog(dialog2);">
41 Open Dialog (w/ Iframe mask)
42 </button>
43
44
45 <fieldset style="margin-top: 2em;">
46 <legend>A sample web page</legend>
47 <h2>
48 A World Beyond AJAX: Accessing Google's APIs from Flash and
49 Non-JavaScript Environments
50 </h2>
51 <cite>Vadim Spivak (Google)</cite>
52
53 <p>
54 AJAX isn't the only way to access Google APIs. Learn how to use Google's
55 services from Flash and other non-JavaScript programming environments.
56 We'll show you how easy it is to augment your site with dynamic search
57 and feed data from non-JavaScript environments.
58 </p>
59
60 <p>
61 Participants should be familiar with general web application
62 development.
63 </p>
64
65 <p>Select Element:
66 <select>
67 <option>Option 1</option>
68 <option>Option 2</option>
69 <option>Option 3</option>
70 </select>
71 </p>
72
73 <p>
74 <object width="425" height="344">
75 <param name="movie"
76 value="http://www.youtube.com/v/7fbz8WOec1g&hl=en&fs=1&"></param>
77 <param name="allowFullScreen" value="true"></param>
78 <param name="allowscriptaccess" value="always"></param>
79 <embed
80 src="http://www.youtube.com/v/7fbz8WOec1g&hl=en&fs=1&"
81 type="application/x-shockwave-flash" allowscriptaccess="always"
82 allowfullscreen="true" width="425" height="344"></embed>
83 </object>
84 </p>
85 </fieldset>
86 <script>
87 goog.events.listen(document, goog.events.EventType.KEYDOWN, function(e) {
88 var code = e.keyCode;
89 if (goog.dom.getElement('openOnKeyDown').checked) {
90 switch (code) {
91 case goog.events.KeyCodes.MAC_ENTER:
92 case goog.events.KeyCodes.ENTER:
93 showDialog(dialog1);
94 break;
95 case goog.events.KeyCodes.SPACE:
96 showDialog(dialog2);
97 break;
98 default:
99 // no-op
100 }
101 }
102 if (goog.dom.getElement('swapModalOnShift').checked) {
103 switch (code) {
104 case goog.events.KeyCodes.SHIFT:
105 if (currDialog && currDialog.isVisible()) {
106 currDialog.setModal(!currDialog.getModal());
107 }
108 break;
109 default:
110 // no-op
111 }
112 }
113 });
114
115 var dialog1 = new goog.ui.Dialog();
116 dialog1.setSafeHtmlContent(goog.html.testing.newSafeHtmlForTest(
117 '<img src="http://images.icanhascheezburger.com/' +
118 'completestore/2009/3/25/128825075025577352.jpg" ' +
119 'width="400" height="255"><br>' +
120 'Lorem ipsum dolor sit amet, consectetuer' +
121 'adipiscing elit. Aenean sollicitudin ultrices urna. Proin vehicula ' +
122 'mauris ac est. Ut scelerisque, risus ut facilisis dictum, est massa ' +
123 'lacinia lorem, in fermentum purus ligula quis nunc. Duis porttitor ' +
124 'euismod risus. Nam hendrerit lacus vehicula augue. Duis ante.'));
125 dialog1.setTitle('My favorite LOLCat');
126
127 dialog1.setButtonSet(goog.ui.Dialog.ButtonSet.CONTINUE_SAVE_CANCEL);
128
129 goog.events.listen(dialog1, goog.ui.Dialog.EventType.SELECT, function(e) {
130 alert('You chose: ' + e.key);
131 });
132
133
134 var dialog2 = new goog.ui.Dialog(null, true);
135 dialog2.setTextContent('Some windowed elements leak through standard ' +
136 'divs so we add an iframe to mask the nasties.');
137 dialog2.setTitle('I have an Iframe mask :)');
138
139 dialog2.setButtonSet(goog.ui.Dialog.ButtonSet.YES_NO_CANCEL);
140
141 goog.events.listen(dialog2, goog.ui.Dialog.EventType.SELECT, function(e) {
142 alert('You chose: ' + e.key);
143 });
144
145 var currDialog;
146
147 function showDialog(dialog) {
148 currDialog = dialog;
149 dialog.setVisible(true);
150 }
151
152 </script>
153 </body>
154 </html>