Tizen 2.0 Release
[platform/framework/web/web-ui-fw.git] / libs / js / jquery-mobile-1.2.0 / docs / pages / dialog / index.html
1 <!DOCTYPE html> 
2 <html>
3         <head>
4         <meta charset="utf-8">
5         <meta name="viewport" content="width=device-width, initial-scale=1"> 
6         <title>jQuery Mobile Docs - Dialogs</title> 
7         <link rel="stylesheet"  href="../../../css/themes/default/jquery.mobile.css" />  
8         <link rel="stylesheet" href="../../_assets/css/jqm-docs.css"/>
9
10         <script src="../../../js/jquery.js"></script>
11         <script src="../../../docs/_assets/js/jqm-docs.js"></script>
12         <script src="../../../js/"></script>
13
14 </head> 
15 <body> 
16
17         <div data-role="page" class="type-interior">
18
19                 <div data-role="header" data-theme="f">
20                 <h1>Dialogs</h1>
21                 <a href="../../../" data-icon="home" data-iconpos="notext" data-direction="reverse">Home</a>
22                 <a href="../../nav.html" data-icon="search" data-iconpos="notext" data-rel="dialog" data-transition="fade">Search</a>
23         </div><!-- /header -->
24
25         <div data-role="content" class="ui-body">
26                 <div class="content-primary">
27                         <form action="#" method="get">
28                         
29             <h2>Dialog</h2>
30             
31             <ul data-role="controlgroup" data-type="horizontal" class="localnav">
32                                 <li><a href="index.html" data-role="button" data-transition="fade" class="ui-btn-active">Basics</a></li>
33                                 <li><a href="options.html" data-role="button" data-transition="fade">Options</a></li>
34                                 <li><a href="methods.html" data-role="button" data-transition="fade">Methods</a></li>
35                                 <li><a href="events.html" data-role="button" data-transition="fade">Events</a></li>
36                         </ul>
37             
38                         <p>Any page can be presented as a modal dialog by adding the <code>data-rel="dialog"</code> attribute to the page anchor link. When the "dialog" attribute is applied, the framework adds styles to add rounded corners, margins around the page and a dark background to make the "dialog" appear to be suspended above the page. If the dialog has a header the framework will also add a close button at the left side of the header.</p>
39
40                         <p>
41                         <code>
42                         &lt;a href=&quot;foo.html&quot; data-rel=&quot;dialog&quot;&gt;Open dialog&lt;/a&gt;
43                         </code>
44                         </p>
45         
46                         <a href="../dialog.html" data-role="button" data-inline="true" data-rel="dialog" data-transition="pop">Open dialog</a>
47
48
49
50                         <h2>Transitions</h2>
51                         <p>By default, the dialog will open with a 'pop' transition.  Like all pages, you can specify any <a href="page-transitions.html">page transition</a> you want on the dialog by adding the <code>data-transition</code> attribute to the link. To make it feel more dialog-like, we recommend specifying a transition of "pop", "slidedown" or "flip".</p>
52
53 <code>
54 &lt;a href=&quot;foo.html&quot; data-rel=&quot;dialog&quot; data-transition=&quot;pop&quot;&gt;Open dialog&lt;/a&gt;
55 </code>
56
57                         <div>
58                         <a href="../dialog.html" data-role="button" data-inline="true" data-rel="dialog" data-transition="pop">data-transition="pop"</a>
59                         <a href="../dialog.html" data-role="button" data-inline="true" data-rel="dialog" data-transition="slidedown">data-transition="slidedown"</a>
60                         <a href="../dialog.html" data-role="button" data-inline="true" data-rel="dialog" data-transition="flip">data-transition="flip"</a>
61                         </div>
62
63
64                         <h2>Closing dialogs</h2>
65                         <p>When any link is clicked within a dialog, the framework will automatically close the dialog and transition to the requested page, just as if the dialog were a normal page. Nevertheless, dialogs can also be chained, as explained below under <strong>"Chaining Dialogs"</strong>. Similarly, a link that opens a popup will also leave the dialog in place.</p>
66                         <p>To create a "cancel" button in a dialog, just link to the page that triggered the dialog to open and add the <code>data-rel="back"</code> attribute to your link. This pattern of linking to the previous page is also usable in non-JS devices as well.</p>
67                         <p>For JavaScript-generated links, you can simply set the href attribute to "#" and use the <code>data-rel="back"</code> attribute. You can also call the dialog's <code>close()</code> method to programmatically close dialogs, for example: <code>$('.ui-dialog').dialog('close')</code>. </p>
68
69                         <h3>Setting the close button text</h3>
70                         <p>Just like the page plugin, you can set a dialog's close button text through an option or data attribute. 
71                         This option is used to customize the text of the close button which is helpful for translating this into different languages. This is displayed as an icon-only button by default so the text isn't visible on-screen, but is read by screen readers so this is an important accessibility feature.
72                         The option can be configured for all dialogs by binding to the <code>mobileinit</code> event and setting the <code>$.mobile.dialog.prototype.options.closeBtnText</code> property to a string of your choosing, or you can place the data attribute <code>data-close-btn-text</code> to configure the text from your markup.
73                         </p>
74
75                         <h2>History &amp; Back button behavior</h2>
76                         <p>Since dialogs are typically used to support actions within a page, the framework does not include dialogs in the hash state history tracking. This means that dialogs will not appear in your browsing history chronology when the Back button is clicked. For example, if you are on a page, click a link to open a dialog, close the dialog, then navigate to another page, if you were to click the browser's Back button at that point you will navigate back to the first page, not the dialog.</p>
77
78                         <h2>Chaining Dialogs</h2>
79                         <p>Please note: If a dialog opens another dialog (chaining), closing the last one with a link of type <code>data-rel="back"</code> will always navigate to the previous dialog until the root-page of type <code>data-role="page"</code> is reached. This guarantees a consistent navigation between dialogs.</p>
80
81                         <h2>Styling &amp; theming</h2>
82                         <p>Dialogs can be styled with different theme swatches, just like any page by adding <code>data-theme</code> attributes to the header, content, or footer containers. Here is an example of a different dialog design:</p>
83                                 <a href="../dialog-alt.html" data-role="button" data-inline="true" data-rel="dialog" data-transition="pop">An alternate color scheme</a>
84
85                         <p>Dialogs appear to be floating above an overlay layer. This overlay adopts the swatch "a" content color by default, but the <code>data-overlay-theme</code> attribute can be added to the page wrapper to set the overlay to any swatch letter. Here is an example of a dialog with the overlay set to swatch "e":</p>
86                                 <a href="../dialog-overlay.html" data-role="button" data-inline="true" data-rel="dialog" data-transition="pop">Custom overlay swatch</a>
87
88
89                         <p>Dialogs can also be used more like a control sheet to offer multiple buttons if you simply remove the top margin from the dialog's inner container element. For example, if your dialog page had a class of <code>my-dialog</code>, you could add this CSS to pin that dialog to the top: <code>.ui-dialog.my-dialog .ui-dialog-contain { margin-top: 0 }</code>, or you could just apply that style to all dialogs with <code>.ui-dialog .ui-dialog-contain { margin-top: 0 }</code>.</p>
90                                                 <a href="../dialog-buttons.html" data-role="button" data-inline="true" data-rel="dialog" data-transition="slidedown">Share photos...</a>
91
92                         <h2>Dialog width and margins</h2>
93                         <p>For the sake of readability, dialogs have a default <code>width</code> of 92.5% and a <code>max-width</code> of 500 pixels. There is also a 10% top <code>margin</code> to give dialogs larger top margin on larger screens, but collapse to a small margin on smartphones. The dialog's inner container is shifted towards the <code>top</code> with 15px to hide the corner styling if a dialog is used as a control sheet (see above). To override these styles, add the following CSS override rule to your stylesheet and tweak as needed:</p>
94
95 <pre><code>
96 .ui-dialog-contain {
97         <strong>width: 92.5%;</strong>
98         <strong>max-width: 500px;</strong>
99         <strong>margin: 10% auto 15px auto;</strong>
100         padding: 0;
101         position: relative;
102         <strong>top: -15px;</strong>
103 }
104 </code></pre>
105
106
107
108
109
110         </div><!--/content-primary -->          
111
112         <div class="content-secondary">
113
114                 <div data-role="collapsible" data-collapsed="true" data-theme="b" data-content-theme="d">
115
116                                 <h3>More in this section</h3>
117
118                                 <ul data-role="listview" data-theme="c" data-dividertheme="d">
119
120                                                                 <li data-role="list-divider">Pages &amp; Dialogs</li>
121                                                                 <li><a href="../page-anatomy.html">Anatomy of a page</a></li>
122                                                                 <li><a href="../page-template.html" data-ajax="false">Single page template</a></li>
123                                                                 <li><a href="../multipage-template.html" data-ajax="false">Multi-page template</a></li>
124                                                                 <li><a href="../page-titles.html">Page titles</a></li>
125                                                                 <li><a href="../page-links.html">Linking pages</a></li>
126                                                                 <li><a href="../page-transitions.html">Page transitions</a></li>
127                                                                 <li><a href="../loader.html">Page loading widget</a></li>
128                                                                 <li data-theme="a"><a href="index.html">Dialogs</a></li>
129                                                                 <li><a href="../popup/index.html">Popups</a></li>
130                                                                 <li><a href="../page-cache.html">Prefetching &amp; caching pages</a></li>
131                                                                 <li><a href="../page-navmodel.html">Ajax, hashes &amp; history</a></li>
132                                                                 <li><a href="../page-dynamic.html">Dynamically injecting pages</a></li>
133                                                                 <li><a href="../page-scripting.html">Scripting pages</a></li>
134                                                                 <li><a href="../phonegap.html">PhoneGap apps</a></li>
135                                                                 <li><a href="../touchoverflow.html">touchOverflow feature</a></li>
136                                                                 <li><a href="../pages-themes.html">Theming pages</a></li>
137                                 </ul>
138                 </div>
139         </div>          
140
141 </div><!-- /content -->
142
143 <div data-role="footer" class="footer-docs" data-theme="c">
144                 <p class="jqm-version"></p>
145                 <p>&copy; 2012 jQuery Foundation and other contributors</p>
146 </div>
147
148 </div><!-- /page -->
149
150 </body>
151 </html>