~smagoun/whoopsie/whoopsie-lp1017637

« back to all changes in this revision

Viewing changes to backend/stats/static/js/yui/docs/sortable/sortable-multi-out.html

  • Committer: Evan Dandrea
  • Date: 2012-05-09 05:53:45 UTC
  • Revision ID: evan.dandrea@canonical.com-20120509055345-z2j41tmcbf4as5uf
The backend now lives in lp:daisy and the website (errors.ubuntu.com) now lives in lp:errors.

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: Multiple Lists - Outer Join</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: Multiple Lists - Outer Join</h1>
16
 
 
17
 
    
18
 
        <a href="#toc" class="jump">Jump to Table of Contents</a>
19
 
    
20
 
 
21
 
    <div class="yui3-g">
22
 
        <div class="yui3-u-3-4">
23
 
            <div id="main">
24
 
                <div class="content"><div class="intro">
25
 
<p>This example makes multiple sortable lists that are outer joined together. In the example below you will see 2 lists.
26
 
Both lists are sortable, but List #1 can move its items into List #2 and they become sortable. However, List #2 <strong>can not</strong> move its items into List #1.</p>
27
 
</div>
28
 
 
29
 
<div class="example">
30
 
    <style>
31
 
    #demo h4 {
32
 
    margin: 10px auto;
33
 
    width: 165px;
34
 
    text-align: center;
35
 
}
36
 
#demo ul {
37
 
    margin: 0 auto;
38
 
    width: 165px;
39
 
    padding: 0;
40
 
}
41
 
#demo li {
42
 
    list-style-type: none;
43
 
    padding: 3px;
44
 
    width: 150px;
45
 
    margin: 6px;
46
 
    font-size: 114%;
47
 
    -moz-box-shadow: 3px 3px 5px rgba(0, 0, 0, 0.25);
48
 
    -webkit-box-shadow: 3px 3px 5px rgba(0, 0, 0, 0.25);
49
 
    box-shadow: 3px 3px 5px rgba(0, 0, 0, 0.25);
50
 
    cursor: move;
51
 
}
52
 
#demo li.one {
53
 
    background-color: #B6BFDA;
54
 
    border: 1px solid #7E869D;
55
 
}
56
 
#demo li.two {
57
 
    background-color: #F2C89F;
58
 
    border: 1px solid #B19C87;
59
 
    text-align: center;
60
 
}
61
 
 
62
 
    #demo .indent1{
63
 
    text-indent:0.8em;
64
 
}
65
 
#demo .indent2{
66
 
    text-indent:1.6em;
67
 
}
68
 
#demo .indent3{
69
 
    text-indent:2.4em;
70
 
}
71
 
#demo .indent4{
72
 
    text-indent:3.2em;
73
 
}
74
 
#demo .indent5{
75
 
    text-indent:4.0em;
76
 
}
77
 
#demo .indent6{
78
 
    text-indent:4.8em;
79
 
}
80
 
#demo .indent7{
81
 
    text-indent:5.6em;
82
 
}
83
 
#demo .indent8{
84
 
    text-indent:6.4em;
85
 
}
86
 
#demo .indent9{
87
 
    text-indent:7.2em;
88
 
}
89
 
#demo .indent10{
90
 
    text-indent:8.0em;
91
 
}
92
 
 
93
 
    .example .arrow {
94
 
    display: none;
95
 
    height: 28px;
96
 
    margin: 10px auto;
97
 
    width: 300px;
98
 
    position: relative;
99
 
    background-repeat: no-repeat;
100
 
}
101
 
 
102
 
.example .arrow em {
103
 
    display: block;
104
 
    position: absolute;
105
 
    top: 0;
106
 
    right: 0;
107
 
    height: 28px;
108
 
    width: 19px;
109
 
    background-repeat: no-repeat;
110
 
}
111
 
 
112
 
.example .arrow div {
113
 
    height: 8px;
114
 
    position: relative;
115
 
    top: 10px;
116
 
    margin: 0 5px;
117
 
    font-size: 1px; /* for IE */
118
 
    background-color: #d9d9d9;
119
 
}
120
 
 
121
 
.example .arrow-full {
122
 
    display: block;
123
 
    background-image: url(../assets/sortable/arrow-left.png);
124
 
}
125
 
 
126
 
.example .arrow-full em {
127
 
    background-image: url(../assets/sortable/arrow-right.png);
128
 
}
129
 
 
130
 
.example .arrow-out {
131
 
    display: block;
132
 
}
133
 
 
134
 
.example .arrow-out em {
135
 
    background-image: url(../assets/sortable/arrow-right.png);
136
 
}
137
 
 
138
 
.example .arrow-in {
139
 
    display: block;
140
 
    background-image: url(../assets/sortable/arrow-left.png);
141
 
}
142
 
 
143
 
    </style>
144
 
    
145
 
    <div id="demo" class="yui3-g">
146
 
    <div class="yui3-u-1-2">
147
 
        <h4 class="no-toc">List 1</h4>
148
 
        <ul id="list1">
149
 
            <li class="one indent1">1</li>
150
 
            <li class="one indent2">2</li>
151
 
            <li class="one indent3">3</li>
152
 
            <li class="one indent4">4</li>
153
 
            <li class="one indent5">5</li>
154
 
            <li class="one indent6">6</li>
155
 
            <li class="one indent7">7</li>
156
 
            <li class="one indent8">8</li>
157
 
            <li class="one indent9">9</li>
158
 
            <li class="one indent10">10</li>
159
 
        </ul>
160
 
        </div>
161
 
    <div class="yui3-u-1-2">
162
 
        <h4 class="no-toc">List 2</h4>
163
 
        <ul id="list2">
164
 
            <li class="two">A</li>
165
 
            <li class="two">B</li>
166
 
            <li class="two">C</li>
167
 
            <li class="two">D</li>
168
 
            <li class="two">E</li>
169
 
            <li class="two">F</li>
170
 
            <li class="two">G</li>
171
 
            <li class="two">H</li>
172
 
            <li class="two">I</li>
173
 
            <li class="two">J</li>
174
 
        </ul>
175
 
    </div>
176
 
</div>
177
 
 
178
 
        <div class="yui3-u-1 arrow arrow-out"><div></div><em></em></div>
179
 
 
180
 
    
181
 
    <script>
182
 
    YUI().use('dd-constrain', 'sortable', function(Y) {
183
 
    var list1 = new Y.Sortable({
184
 
        container: '#list1',
185
 
        nodes: 'li',
186
 
        opacity: '.1'
187
 
    });
188
 
 
189
 
    var list2 = new Y.Sortable({
190
 
        container: '#list2',
191
 
        nodes: 'li',
192
 
        opacity: '.1'
193
 
    });
194
 
 
195
 
    list1.join(list2, 'outer');
196
 
});
197
 
 
198
 
 
199
 
    </script>
200
 
</div>
201
 
 
202
 
<p><strong>Note: When using an outer or inner joined list, you must pick a moveType of 'move' or 'copy', the default 'swap' won't give you the results you expect.</strong></p>
203
 
<p>This example assumes that you have seen the Multiple Sortable Lists - Full Join example and continues from there.</p>
204
 
 
205
 
<h3 id="setting-up-the-list">Setting Up the List</h3>
206
 
<p>First we need to create the HTML structure for the lists. Since <code>Sortable</code> uses <code>Y.DD.Delegate</code>, we need to set up the delegation containers (<code>#list1, #lists2</code>) and the list items (<code>li</code>).</p>
207
 
 
208
 
<pre class="code prettyprint">&lt;div id=&quot;demo&quot; class=&quot;yui3-g&quot;&gt;
209
 
    &lt;div class=&quot;yui3-u-1-2&quot;&gt;
210
 
        &lt;h4 class=&quot;no-toc&quot;&gt;List 1&lt;&#x2F;h4&gt;
211
 
        &lt;ul id=&quot;list1&quot;&gt;
212
 
            &lt;li class=&quot;one&quot;&gt;1&lt;&#x2F;li&gt;
213
 
            &lt;li class=&quot;one&quot;&gt;2&lt;&#x2F;li&gt;
214
 
            &lt;li class=&quot;one&quot;&gt;3&lt;&#x2F;li&gt;
215
 
            &lt;li class=&quot;one&quot;&gt;4&lt;&#x2F;li&gt;
216
 
            &lt;li class=&quot;one&quot;&gt;5&lt;&#x2F;li&gt;
217
 
            &lt;li class=&quot;one&quot;&gt;6&lt;&#x2F;li&gt;
218
 
            &lt;li class=&quot;one&quot;&gt;7&lt;&#x2F;li&gt;
219
 
            &lt;li class=&quot;one&quot;&gt;8&lt;&#x2F;li&gt;
220
 
            &lt;li class=&quot;one&quot;&gt;9&lt;&#x2F;li&gt;
221
 
            &lt;li class=&quot;one&quot;&gt;10&lt;&#x2F;li&gt;
222
 
        &lt;&#x2F;ul&gt;
223
 
        &lt;&#x2F;div&gt;
224
 
    &lt;div class=&quot;yui3-u-1-2&quot;&gt;
225
 
        &lt;h4 class=&quot;no-toc&quot;&gt;List 2&lt;&#x2F;h4&gt;
226
 
        &lt;ul id=&quot;list2&quot;&gt;
227
 
            &lt;li class=&quot;two&quot;&gt;A&lt;&#x2F;li&gt;
228
 
            &lt;li class=&quot;two&quot;&gt;B&lt;&#x2F;li&gt;
229
 
            &lt;li class=&quot;two&quot;&gt;C&lt;&#x2F;li&gt;
230
 
            &lt;li class=&quot;two&quot;&gt;D&lt;&#x2F;li&gt;
231
 
            &lt;li class=&quot;two&quot;&gt;E&lt;&#x2F;li&gt;
232
 
            &lt;li class=&quot;two&quot;&gt;F&lt;&#x2F;li&gt;
233
 
            &lt;li class=&quot;two&quot;&gt;G&lt;&#x2F;li&gt;
234
 
            &lt;li class=&quot;two&quot;&gt;H&lt;&#x2F;li&gt;
235
 
            &lt;li class=&quot;two&quot;&gt;I&lt;&#x2F;li&gt;
236
 
            &lt;li class=&quot;two&quot;&gt;J&lt;&#x2F;li&gt;
237
 
        &lt;&#x2F;ul&gt;
238
 
    &lt;&#x2F;div&gt;
239
 
&lt;&#x2F;div&gt;</pre>
240
 
 
241
 
 
242
 
<p>Now we give the lists some CSS to make them visible.</p>
243
 
 
244
 
<pre class="code prettyprint">#demo h4 {
245
 
    margin: 10px auto;
246
 
    width: 165px;
247
 
    text-align: center;
248
 
}
249
 
#demo ul {
250
 
    margin: 0 auto;
251
 
    width: 165px;
252
 
    padding: 0;
253
 
}
254
 
#demo li {
255
 
    list-style-type: none;
256
 
    padding: 3px;
257
 
    width: 150px;
258
 
    margin: 6px;
259
 
    font-size: 114%;
260
 
    -moz-box-shadow: 3px 3px 5px rgba(0, 0, 0, 0.25);
261
 
    -webkit-box-shadow: 3px 3px 5px rgba(0, 0, 0, 0.25);
262
 
    box-shadow: 3px 3px 5px rgba(0, 0, 0, 0.25);
263
 
    cursor: move;
264
 
}
265
 
#demo li.one {
266
 
    background-color: #B6BFDA;
267
 
    border: 1px solid #7E869D;
268
 
}
269
 
#demo li.two {
270
 
    background-color: #F2C89F;
271
 
    border: 1px solid #B19C87;
272
 
    text-align: center;
273
 
}</pre>
274
 
 
275
 
 
276
 
<h3 id="setting-up-the-yui-instance">Setting Up the YUI Instance</h3>
277
 
<p>Now we need to create our YUI instance and tell it to load the <code>sortable</code> module.</p>
278
 
<p>In this example we are also going to attach a <code>DD</code> plugin to the <code>Sortable</code> instances.</p>
279
 
 
280
 
<pre class="code prettyprint">YUI().use(&#x27;dd-constrain&#x27;, &#x27;sortable&#x27;</pre>
281
 
 
282
 
 
283
 
<h3 id="making-the-lists-draggable">Making the Lists Draggable</h3>
284
 
<p>Now that we have a YUI instance with the <code>sortable</code> module, we need to instantiate a <code>Sortable</code> instance on each of the lists.</p>
285
 
 
286
 
<pre class="code prettyprint">YUI().use(&#x27;dd-constrain&#x27;, &#x27;sortable&#x27;, function(Y) {
287
 
    var list1 = new Y.Sortable({
288
 
        container: &#x27;#list1&#x27;,
289
 
        nodes: &#x27;li&#x27;,
290
 
        opacity: &#x27;.1&#x27;
291
 
    });
292
 
 
293
 
    var list2 = new Y.Sortable({
294
 
        container: &#x27;#list2&#x27;,
295
 
        nodes: &#x27;li&#x27;,
296
 
        opacity: &#x27;.1&#x27;
297
 
    });
298
 
 
299
 
});</pre>
300
 
 
301
 
 
302
 
<h3 id="applying-a-dd-plugin">Applying a DD Plugin</h3>
303
 
<p>Since <code>Sortable</code> uses <code>DD.Delegate</code>, there is a dd instance available after instantiation.</p>
304
 
<p>The <code>DD.Delegate</code> reference is found on the <code>.delegate</code> property of the <code>Sortable</code>.
305
 
This <code>DD.Delegate</code> instance has a <code>DD.Drag</code> instance bound to the <code>dd</code> property on the <code>DD.Delegate</code>
306
 
</p>
307
 
 
308
 
<pre class="code prettyprint">list1.delegate.dd.plug(Y.Plugin.DDConstrained, {
309
 
    constrain2node: &#x27;#demo&#x27;
310
 
});
311
 
list2.delegate.dd.plug(Y.Plugin.DDConstrained, {
312
 
    constrain2node: &#x27;#demo&#x27;
313
 
});</pre>
314
 
 
315
 
<p>Applying the <code>Plugin.DDConstrained</code> to the <code>Sortable</code> instance.</p>
316
 
 
317
 
<pre class="code prettyprint">YUI().use(&#x27;dd-constrain&#x27;, &#x27;sortable&#x27;, function(Y) {
318
 
    var list1 = new Y.Sortable({
319
 
        container: &#x27;#list1&#x27;,
320
 
        nodes: &#x27;li&#x27;,
321
 
        opacity: &#x27;.1&#x27;
322
 
    });
323
 
 
324
 
    var list2 = new Y.Sortable({
325
 
        container: &#x27;#list2&#x27;,
326
 
        nodes: &#x27;li&#x27;,
327
 
        opacity: &#x27;.1&#x27;
328
 
    });
329
 
 
330
 
    list1.delegate.dd.plug(Y.Plugin.DDConstrained, {
331
 
        constrain2node: &#x27;#demo&#x27;
332
 
    });
333
 
    list2.delegate.dd.plug(Y.Plugin.DDConstrained, {
334
 
        constrain2node: &#x27;#demo&#x27;
335
 
    });
336
 
 
337
 
});</pre>
338
 
 
339
 
 
340
 
 
341
 
<h3 id="joining-the-lists">Joining the Lists</h3>
342
 
<p>Joining the lists is as simple as calling the <code>join</code> method on one list passing in another list. By default, we use a full join which joins both lists both ways.</p>
343
 
<p>You can optionally specify the join type: <code>inner</code> or <code>outer</code>. The <code>moveType</code> can also be specified on the list: <code>swap</code>, <code>move</code> or <code>copy</code>. <code>swap</code> is the default, as seen in this example.</p>
344
 
 
345
 
<pre class="code prettyprint">list1.join(list2);              &#x2F;&#x2F;Full join &lt;-- both ways --&gt;
346
 
list1.join(list2, &#x27;outer&#x27;);     &#x2F;&#x2F;Outer join --&gt; one way --&gt;
347
 
list1.join(list2, &#x27;inner&#x27;);     &#x2F;&#x2F;Inner join &lt;-- one way &lt;--</pre>
348
 
 
349
 
 
350
 
 
351
 
<h3 id="putting-it-together">Putting it together</h3>
352
 
 
353
 
<pre class="code prettyprint">YUI().use(&#x27;dd-constrain&#x27;, &#x27;sortable&#x27;, function(Y) {
354
 
    var list1 = new Y.Sortable({
355
 
        container: &#x27;#list1&#x27;,
356
 
        nodes: &#x27;li&#x27;,
357
 
        opacity: &#x27;.1&#x27;
358
 
    });
359
 
 
360
 
    var list2 = new Y.Sortable({
361
 
        container: &#x27;#list2&#x27;,
362
 
        nodes: &#x27;li&#x27;,
363
 
        opacity: &#x27;.1&#x27;
364
 
    });
365
 
 
366
 
    list1.join(list2, &#x27;outer&#x27;);
367
 
});</pre>
368
 
 
369
 
</div>
370
 
            </div>
371
 
        </div>
372
 
 
373
 
        <div class="yui3-u-1-4">
374
 
            <div class="sidebar">
375
 
                
376
 
                    <div id="toc" class="sidebox">
377
 
                        <div class="hd">
378
 
                            <h2 class="no-toc">Table of Contents</h2>
379
 
                        </div>
380
 
 
381
 
                        <div class="bd">
382
 
                            <ul class="toc">
383
 
<li>
384
 
<a href="#setting-up-the-list">Setting Up the List</a>
385
 
</li>
386
 
<li>
387
 
<a href="#setting-up-the-yui-instance">Setting Up the YUI Instance</a>
388
 
</li>
389
 
<li>
390
 
<a href="#making-the-lists-draggable">Making the Lists Draggable</a>
391
 
</li>
392
 
<li>
393
 
<a href="#applying-a-dd-plugin">Applying a DD Plugin</a>
394
 
</li>
395
 
<li>
396
 
<a href="#joining-the-lists">Joining the Lists</a>
397
 
</li>
398
 
<li>
399
 
<a href="#putting-it-together">Putting it together</a>
400
 
</li>
401
 
</ul>
402
 
                        </div>
403
 
                    </div>
404
 
                
405
 
 
406
 
                
407
 
                    <div class="sidebox">
408
 
                        <div class="hd">
409
 
                            <h2 class="no-toc">Examples</h2>
410
 
                        </div>
411
 
 
412
 
                        <div class="bd">
413
 
                            <ul class="examples">
414
 
                                
415
 
                                    
416
 
                                        <li data-description="Create a simple sortable list.">
417
 
                                            <a href="simple-sortable.html">Simple Sortable List</a>
418
 
                                        </li>
419
 
                                    
420
 
                                
421
 
                                    
422
 
                                        <li data-description="Sortable list example with floated nodes.">
423
 
                                            <a href="sortable-float.html">Floated List</a>
424
 
                                        </li>
425
 
                                    
426
 
                                
427
 
                                    
428
 
                                        <li data-description="Multiple Sortable Lists that are separate from one another.">
429
 
                                            <a href="sortable-multi.html">Multiple Lists</a>
430
 
                                        </li>
431
 
                                    
432
 
                                
433
 
                                    
434
 
                                        <li data-description="Multiple Sortable Lists that are fully joined together.">
435
 
                                            <a href="sortable-multi-full.html">Multiple Lists - Full Join</a>
436
 
                                        </li>
437
 
                                    
438
 
                                
439
 
                                    
440
 
                                        <li data-description="Multiple Sortable Lists that are outer joined together.">
441
 
                                            <a href="sortable-multi-out.html">Multiple Lists - Outer Join</a>
442
 
                                        </li>
443
 
                                    
444
 
                                
445
 
                                    
446
 
                                        <li data-description="Multiple Sortable Lists that are inner joined together.">
447
 
                                            <a href="sortable-multi-in.html">Multiple Lists - Inner Join</a>
448
 
                                        </li>
449
 
                                    
450
 
                                
451
 
                                    
452
 
                                        <li data-description="A fish sorting example. Multiple sortable lists with floated nodes that are outer joined together.">
453
 
                                            <a href="sortable-fish.html">Fish Sort - Multi Outer Join</a>
454
 
                                        </li>
455
 
                                    
456
 
                                
457
 
                            </ul>
458
 
                        </div>
459
 
                    </div>
460
 
                
461
 
 
462
 
                
463
 
            </div>
464
 
        </div>
465
 
    </div>
466
 
</div>
467
 
 
468
 
<script src="../assets/vendor/prettify/prettify-min.js"></script>
469
 
<script>prettyPrint();</script>
470
 
 
471
 
</body>
472
 
</html>