~ubuntu-branches/ubuntu/precise/whoopsie-daisy/precise-updates

« back to all changes in this revision

Viewing changes to backend/stats/static/js/yui/docs/calendar/calendar-simple.html

  • Committer: Package Import Robot
  • Author(s): Evan Dandrea
  • Date: 2012-04-18 13:04:36 UTC
  • Revision ID: package-import@ubuntu.com-20120418130436-vmt93p8fds516lws
Tags: 0.1.32
Fix failing tests on powerpc and ARM.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!DOCTYPE html>
 
2
<html lang="en">
 
3
<head>
 
4
    <meta charset="utf-8">
 
5
    <title>Example: Simple Calendar with Selection</title>
 
6
    <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Maven+Pro:400,700">
 
7
    <link rel="stylesheet" href="../../build/cssgrids/grids-min.css">
 
8
    <link rel="stylesheet" href="../assets/css/main.css">
 
9
    <link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
 
10
    <script src="../../build/yui/yui-min.js"></script>
 
11
</head>
 
12
<body>
 
13
 
 
14
<div id="doc">
 
15
    <h1>Example: Simple Calendar with Selection</h1>
 
16
 
 
17
    
 
18
 
 
19
    <div class="yui3-g">
 
20
        <div class="yui3-u-3-4">
 
21
            <div id="main">
 
22
                <div class="content"><style>
 
23
.example {
 
24
        font-size:15px;
 
25
}
 
26
 
 
27
.example h4 {
 
28
        border: none;
 
29
        text-transform: none;
 
30
}
 
31
 
 
32
.example th {
 
33
        background: none;
 
34
        color: #000;
 
35
        text-transform: none;
 
36
        border: none;
 
37
}
 
38
</style>
 
39
 
 
40
<div class="intro">
 
41
<p>
 
42
This example demonstrates how to instantiate a simple Calendar, with an initial date setting of September 2011. The Calendar is preconfigured to show the previous and next month's dates.
 
43
</p>
 
44
 
 
45
<p>
 
46
Try clicking on the toggle buttons to change the initial settings for showing the previous and next months' dates. You can also select dates in the calendar and see selected date on the right, reported via a <code>selectionChange</code> event, and formatted using DataType utility.
 
47
</p>
 
48
</div>
 
49
 
 
50
<div class="example yui3-skin-sam">
 
51
    <!-- Add an additional blue button style -->
 
52
<style>
 
53
.yui3-button {
 
54
    margin:10px 0px 10px 0px;
 
55
    color: #fff;
 
56
    background-color: #3476b7;
 
57
}
 
58
</style>
 
59
 
 
60
<div id="demo" class="yui3-skin-sam yui3-g">
 
61
  <div id="leftcolumn" class="yui3-u">
 
62
     <!-- Container for the calendar -->
 
63
     <div id="mycalendar"></div>
 
64
  </div>
 
65
  <div id="rightcolumn" class="yui3-u">
 
66
   <div id="links" style="padding-left:20px;">
 
67
      <!-- The buttons are created simply by assigning the correct CSS class -->
 
68
      <button id="togglePrevMonth" class="yui3-button">Toggle Previous Month's Dates</button><br>
 
69
      <button id="toggleNextMonth" class="yui3-button">Toggle Next Month's Dates</button><br>
 
70
      Selected date: <span id="selecteddate"></span>
 
71
   </div>
 
72
  </div>
 
73
</div>
 
74
 
 
75
<script type="text/javascript">
 
76
YUI().use('calendar', 'datatype-date', 'cssbutton',  function(Y) {
 
77
    
 
78
    // Create a new instance of calendar, placing it in 
 
79
    // #mycalendar container, setting its width to 340px,
 
80
    // the flags for showing previous and next month's 
 
81
    // dates in available empty cells to true, and setting 
 
82
    // the date to today's date.          
 
83
    var calendar = new Y.Calendar({
 
84
      contentBox: "#mycalendar",
 
85
      width:'340px',
 
86
      showPrevMonth: true,
 
87
      showNextMonth: true,
 
88
      date: new Date()}).render();
 
89
    
 
90
    // Get a reference to Y.DataType.Date
 
91
    var dtdate = Y.DataType.Date;
 
92
 
 
93
    // Listen to calendar's selectionChange event.
 
94
    calendar.on("selectionChange", function (ev) {
 
95
 
 
96
      // Get the date from the list of selected
 
97
      // dates returned with the event (since only
 
98
      // single selection is enabled by default,
 
99
      // we expect there to be only one date)
 
100
      var newDate = ev.newSelection[0];
 
101
 
 
102
      // Format the date and output it to a DOM
 
103
      // element.
 
104
      Y.one("#selecteddate").setContent(dtdate.format(newDate));
 
105
    });
 
106
 
 
107
 
 
108
    // When the 'Show Previous Month' link is clicked,
 
109
    // modify the showPrevMonth property to show or hide
 
110
    // previous month's dates
 
111
    Y.one("#togglePrevMonth").on('click', function (ev) {
 
112
      ev.preventDefault();
 
113
      calendar.set('showPrevMonth', !(calendar.get("showPrevMonth")));      
 
114
    });
 
115
 
 
116
    // When the 'Show Next Month' link is clicked,
 
117
    // modify the showNextMonth property to show or hide
 
118
    // next month's dates
 
119
    Y.one("#toggleNextMonth").on('click', function (ev) {
 
120
      ev.preventDefault();
 
121
      calendar.set('showNextMonth', !(calendar.get("showNextMonth")));      
 
122
    });
 
123
});
 
124
</script>
 
125
 
 
126
</div>
 
127
 
 
128
<h2>Complete Example Source</h2>
 
129
 
 
130
<pre class="code prettyprint">&lt;!-- Add an additional blue button style --&gt;
 
131
&lt;style&gt;
 
132
.yui3-button {
 
133
    margin:10px 0px 10px 0px;
 
134
    color: #fff;
 
135
    background-color: #3476b7;
 
136
}
 
137
&lt;&#x2F;style&gt;
 
138
 
 
139
&lt;div id=&quot;demo&quot; class=&quot;yui3-skin-sam yui3-g&quot;&gt;
 
140
  &lt;div id=&quot;leftcolumn&quot; class=&quot;yui3-u&quot;&gt;
 
141
     &lt;!-- Container for the calendar --&gt;
 
142
     &lt;div id=&quot;mycalendar&quot;&gt;&lt;&#x2F;div&gt;
 
143
  &lt;&#x2F;div&gt;
 
144
  &lt;div id=&quot;rightcolumn&quot; class=&quot;yui3-u&quot;&gt;
 
145
   &lt;div id=&quot;links&quot; style=&quot;padding-left:20px;&quot;&gt;
 
146
      &lt;!-- The buttons are created simply by assigning the correct CSS class --&gt;
 
147
      &lt;button id=&quot;togglePrevMonth&quot; class=&quot;yui3-button&quot;&gt;Toggle Previous Month&#x27;s Dates&lt;&#x2F;button&gt;&lt;br&gt;
 
148
      &lt;button id=&quot;toggleNextMonth&quot; class=&quot;yui3-button&quot;&gt;Toggle Next Month&#x27;s Dates&lt;&#x2F;button&gt;&lt;br&gt;
 
149
      Selected date: &lt;span id=&quot;selecteddate&quot;&gt;&lt;&#x2F;span&gt;
 
150
   &lt;&#x2F;div&gt;
 
151
  &lt;&#x2F;div&gt;
 
152
&lt;&#x2F;div&gt;
 
153
 
 
154
&lt;script type=&quot;text&#x2F;javascript&quot;&gt;
 
155
YUI().use(&#x27;calendar&#x27;, &#x27;datatype-date&#x27;, &#x27;cssbutton&#x27;,  function(Y) {
 
156
    
 
157
    &#x2F;&#x2F; Create a new instance of calendar, placing it in 
 
158
    &#x2F;&#x2F; #mycalendar container, setting its width to 340px,
 
159
    &#x2F;&#x2F; the flags for showing previous and next month&#x27;s 
 
160
    &#x2F;&#x2F; dates in available empty cells to true, and setting 
 
161
    &#x2F;&#x2F; the date to today&#x27;s date.          
 
162
    var calendar = new Y.Calendar({
 
163
      contentBox: &quot;#mycalendar&quot;,
 
164
      width:&#x27;340px&#x27;,
 
165
      showPrevMonth: true,
 
166
      showNextMonth: true,
 
167
      date: new Date()}).render();
 
168
    
 
169
    &#x2F;&#x2F; Get a reference to Y.DataType.Date
 
170
    var dtdate = Y.DataType.Date;
 
171
 
 
172
    &#x2F;&#x2F; Listen to calendar&#x27;s selectionChange event.
 
173
    calendar.on(&quot;selectionChange&quot;, function (ev) {
 
174
 
 
175
      &#x2F;&#x2F; Get the date from the list of selected
 
176
      &#x2F;&#x2F; dates returned with the event (since only
 
177
      &#x2F;&#x2F; single selection is enabled by default,
 
178
      &#x2F;&#x2F; we expect there to be only one date)
 
179
      var newDate = ev.newSelection[0];
 
180
 
 
181
      &#x2F;&#x2F; Format the date and output it to a DOM
 
182
      &#x2F;&#x2F; element.
 
183
      Y.one(&quot;#selecteddate&quot;).setContent(dtdate.format(newDate));
 
184
    });
 
185
 
 
186
 
 
187
    &#x2F;&#x2F; When the &#x27;Show Previous Month&#x27; link is clicked,
 
188
    &#x2F;&#x2F; modify the showPrevMonth property to show or hide
 
189
    &#x2F;&#x2F; previous month&#x27;s dates
 
190
    Y.one(&quot;#togglePrevMonth&quot;).on(&#x27;click&#x27;, function (ev) {
 
191
      ev.preventDefault();
 
192
      calendar.set(&#x27;showPrevMonth&#x27;, !(calendar.get(&quot;showPrevMonth&quot;)));      
 
193
    });
 
194
 
 
195
    &#x2F;&#x2F; When the &#x27;Show Next Month&#x27; link is clicked,
 
196
    &#x2F;&#x2F; modify the showNextMonth property to show or hide
 
197
    &#x2F;&#x2F; next month&#x27;s dates
 
198
    Y.one(&quot;#toggleNextMonth&quot;).on(&#x27;click&#x27;, function (ev) {
 
199
      ev.preventDefault();
 
200
      calendar.set(&#x27;showNextMonth&#x27;, !(calendar.get(&quot;showNextMonth&quot;)));      
 
201
    });
 
202
});
 
203
&lt;&#x2F;script&gt;</pre>
 
204
 
 
205
</div>
 
206
            </div>
 
207
        </div>
 
208
 
 
209
        <div class="yui3-u-1-4">
 
210
            <div class="sidebar">
 
211
                
 
212
 
 
213
                
 
214
                    <div class="sidebox">
 
215
                        <div class="hd">
 
216
                            <h2 class="no-toc">Examples</h2>
 
217
                        </div>
 
218
 
 
219
                        <div class="bd">
 
220
                            <ul class="examples">
 
221
                                
 
222
                                    
 
223
                                        <li data-description="How to create a single-pane calendar with selectable dates">
 
224
                                            <a href="calendar-simple.html">Simple Calendar with Selection</a>
 
225
                                        </li>
 
226
                                    
 
227
                                
 
228
                                    
 
229
                                        <li data-description="How to create a multi-pane calendar with custom-rendered cells and multiple date selection.">
 
230
                                            <a href="calendar-multipane.html">Two-Pane Calendar with Custom Rendering and Multiple Selection</a>
 
231
                                        </li>
 
232
                                    
 
233
                                
 
234
                            </ul>
 
235
                        </div>
 
236
                    </div>
 
237
                
 
238
 
 
239
                
 
240
            </div>
 
241
        </div>
 
242
    </div>
 
243
</div>
 
244
 
 
245
<script src="../assets/vendor/prettify/prettify-min.js"></script>
 
246
<script>prettyPrint();</script>
 
247
 
 
248
</body>
 
249
</html>