-
Notifications
You must be signed in to change notification settings - Fork 60
/
Copy pathdialog.xml
169 lines (136 loc) · 10.1 KB
/
dialog.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="../entries2html.xsl" ?>
<entry name="dialog" namespace="fn" type="widget" widgetnamespace="mobile" event-prefix="dialog" init-selector=":jqmData(role='dialog')" deprecated="1.4.0">
<title>Dialog Widget</title>
<desc>Opens content in an interactive overlay.</desc>
<longdesc>
<div class="warning">
<strong>Note:</strong> Dialogs are deprecated as of jQuery Mobile 1.4.0 and will be removed in 1.5.0. The <code>dialog</code> option provided by the <code>page.dialog</code> extension of the <a href="/page/">page</a> widget allows you to style a page as a dialog, however, the special navigational handling will be removed. You may also consider implementing dialogs using <a href="/popup/">popup</a> widgets.</div>
<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.</p>
<pre><code><![CDATA[
<a href="foo.html" data-rel="dialog">Open dialog</a>
]]></code></pre>
<iframe src="/resources/dialog/example1.html" style="width:100%;height:420px;border:0px"></iframe>
<p>You can open a dialog programmatically by calling the <a href="/jQuery.mobile.changePage/"><strong>$.mobile.changePage</strong></a> method:</p>
<pre><code><![CDATA[
// Dialog loaded via Ajax
$.mobile.changePage( "path/to/dialog.html", { role: "dialog" } );
// Dialog present in a multipage document
$.mobile.changePage( "#myDialog", { role: "dialog" } );
]]></code></pre>
<h3>Transitions</h3>
<p>By default, the dialog will open with a 'pop' transition. Like all pages, you can specify any page transition 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".<br />Possible values include: fade, <b>pop</b>, <b>flip</b>, turn, flow, slidefade, slide, slideup, slidedown, none. </p>
<pre><code><![CDATA[
<a href="foo.html" data-rel="dialog" data-transition="pop">Open dialog</a>
]]></code></pre>
<iframe src="/resources/dialog/example2.html" style="width:100%;height:420px;border:0px"></iframe>
<h3>Closing dialogs</h3>
<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 <b>"Chaining Dialogs"</b>. Similarly, a link that opens a popup will also leave the dialog in place.</p>
<p>If the dialog has a header the framework will add a close button at the left side of the header. You can change the position by adding <code>data-close-btn="right"</code> to the dialog container. If you don't want a close button in the header or add a custom close button, you can use <code>data-close-btn="none"</code>.</p>
<iframe src="/resources/dialog/example6.html" style="width:100%;height:420px;border:0px"></iframe>
<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>
<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>
<h3>Setting the close button text</h3>
<p>Just like the page plugin, you can set a dialog's close button text through an option or data attribute. 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.</p>
<h3>History & Back button behavior</h3>
<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>
<h3>Chaining Dialogs</h3>
<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>
<h3>Styling & theming</h3>
<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.</p>
<iframe src="/resources/dialog/example3.html" style="width:100%;height:420px;border:0px"></iframe>
<p>By default dialogs have rounded corners. The option corners can be set to false by adding <code>data-corners="false"</code> to the dialog container:</p>
<iframe src="/resources/dialog/example7.html" style="width:100%;height:420px;border:0px"></iframe>
<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. </p>
<iframe src="/resources/dialog/example4.html" style="width:100%;height:420px;border:0px"></iframe>
<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>
<iframe src="/resources/dialog/example5.html" style="width:100%;height:420px;border:0px"></iframe>
<h3>Dialog width and margins</h3>
<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>
<pre><code><![CDATA[
.ui-dialog-contain {
width: 92.5%;
max-width: 500px;
margin: 10% auto 15px auto;
padding: 0;
position: relative;
top: -15px;
}
]]></code></pre>
</longdesc>
<added>1.0</added>
<options>
<option name="closeBtn" default='"left"' example-value='"none"'>
<desc>
<p>Sets the position of the dialog close button in the header (left or right) or prevents the framework from adding a close button (none).</p>
<p>This option is also exposed as a data attribute: <code>data-close-btn</code>.</p>
</desc>
<type name="String" />
</option>
<option name="closeBtnText" default='"Close"' example-value='"Fermer"'>
<desc>
<p>Customizes the text of the close button which is helpful for translating this into different languages. The close button 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.</p>
<p>This option is also exposed as a data attribute: <code>data-close-btn-text="Fermer"</code>.</p>
</desc>
<type name="String" />
</option>
<option name="corners" default="true" example-value="false">
<desc>Sets whether to draw the dialo with rounded corners..
<p>This option is also exposed as a data attribute:<code>data-corners="false"</code>.</p>
</desc>
<type name="Boolean" />
</option>
<xi:include href="../includes/widget-option-defaults.xml" xmlns:xi="http://www.w3.org/2003/XInclude"/>
<xi:include href="../includes/widget-option-disabled.xml" xmlns:xi="http://www.w3.org/2003/XInclude"/>
<xi:include href="../includes/widget-option-initSelector.xml" xmlns:xi="http://www.w3.org/2003/XInclude"/>
<option name="overlayTheme" default='"a"' example-value='"b"'>
<desc>
<p>Dialogs appear to be floating above an overlay layer. This overlay adopts the swatch A content color by default, but the data-overlay-theme attribute can be added to the page wrapper to set the overlay to any swatch letter.</p>
<p> Possible values: swatch letter (a-z)</p>
<p>This option is also exposed as a data attribute: <code>data-overlay-theme="b"</code>.</p>
</desc>
<type name="String" />
</option>
</options>
<events>
<event name="create">
<desc>Triggered when a dialog is created</desc>
<argument name="event" type="Event">
<desc></desc>
</argument>
<argument name="ui" type="Object">
<desc></desc>
</argument>
</event>
</events>
<methods>
<method name="close">
<desc>Closes the dialog.</desc>
</method>
</methods>
<example>
<desc>A basic example of opening a page as a dialog by adding <code>data-rel="dialog"</code> to the anchor tag.</desc>
<html><![CDATA[
<div data-role="page" id="page1">
<div data-role="header">
<h1>jQuery Mobile Example</h1>
</div>
<div role="main" class="ui-content">
<a href="#dialogPage" data-rel="dialog">Open dialog</a>
</div>
<div data-role="footer">
<h2></h2>
</div>
</div>
<div data-role="page" id="dialogPage">
<div data-role="header">
<h2>Dialog</h2>
</div>
<div role="main" class="ui-content">
<p>I am a dialog</p>
</div>
</div>
]]></html>
</example>
<category slug="widgets"/>
</entry>