Skip to content

Commit 2121a10

Browse files
committed
Sortable demo (portlets): Cleanup.
1 parent d500e94 commit 2121a10

File tree

1 file changed

+42
-18
lines changed

1 file changed

+42
-18
lines changed

demos/sortable/portlets.html

Lines changed: 42 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,34 +11,58 @@
1111
<script src="../../ui/jquery.ui.sortable.js"></script>
1212
<link rel="stylesheet" href="../demos.css">
1313
<style>
14-
body { min-width: 520px; }
15-
.column { width: 170px; float: left; padding-bottom: 100px; }
16-
.portlet { margin: 0 1em 1em 0; }
17-
.portlet-header { margin: 0.3em; padding-bottom: 4px; padding-left: 0.2em; }
18-
.portlet-header .ui-icon { float: right; }
19-
.portlet-content { padding: 0.4em; }
20-
.ui-sortable-placeholder { border: 1px dotted black; visibility: visible !important; height: 50px !important; }
21-
.ui-sortable-placeholder * { visibility: hidden; }
14+
body {
15+
min-width: 520px;
16+
}
17+
.column {
18+
width: 170px;
19+
float: left;
20+
padding-bottom: 100px;
21+
}
22+
.portlet {
23+
margin: 0 1em 1em 0;
24+
padding: 0.3em;
25+
}
26+
.portlet-header {
27+
padding: 0.2em 0.3em;
28+
margin-bottom: 0.5em;
29+
position: relative;
30+
}
31+
.portlet-toggle {
32+
position: absolute;
33+
top: 50%;
34+
right: 0;
35+
margin-top: -8px;
36+
}
37+
.portlet-content {
38+
padding: 0.4em;
39+
}
40+
.portlet-placeholder {
41+
border: 1px dotted black;
42+
margin: 0 1em 1em 0;
43+
height: 50px;
44+
}
2245
</style>
2346
<script>
2447
$(function() {
2548
$( ".column" ).sortable({
26-
connectWith: ".column"
49+
connectWith: ".column",
50+
handle: ".portlet-header",
51+
cancel: ".portlet-toggle",
52+
placeholder: "portlet-placeholder ui-corner-all"
2753
});
2854

29-
$( ".portlet" ).addClass( "ui-widget ui-widget-content ui-helper-clearfix ui-corner-all" )
55+
$( ".portlet" )
56+
.addClass( "ui-widget ui-widget-content ui-helper-clearfix ui-corner-all" )
3057
.find( ".portlet-header" )
3158
.addClass( "ui-widget-header ui-corner-all" )
32-
.prepend( "<span class='ui-icon ui-icon-minusthick'></span>")
33-
.end()
34-
.find( ".portlet-content" );
59+
.prepend( "<span class='ui-icon ui-icon-minusthick portlet-toggle'></span>");
3560

36-
$( ".portlet-header .ui-icon" ).click(function() {
37-
$( this ).toggleClass( "ui-icon-minusthick" ).toggleClass( "ui-icon-plusthick" );
38-
$( this ).parents( ".portlet:first" ).find( ".portlet-content" ).toggle();
61+
$( ".portlet-toggle" ).click(function() {
62+
var icon = $( this );
63+
icon.toggleClass( "ui-icon-minusthick ui-icon-plusthick" );
64+
icon.closest( ".portlet" ).find( ".portlet-content" ).toggle();
3965
});
40-
41-
$( ".column" ).disableSelection();
4266
});
4367
</script>
4468
</head>

0 commit comments

Comments
 (0)