Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 27th, 2012  |  syntax: None  |  size: 3.32 KB  |  hits: 17  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.  
  2. <style>
  3.         .demo {width:800px; margin: 0 auto;}
  4.         #sortable { list-style-type: none; margin: 0; padding: 0; position:relative;}
  5.         li {margin: 3px 3px 3px 0; padding: 1px; font-size: 4em; text-align: center; }
  6.  
  7.         .ui-state-default, { border: 1px solid #cccccc; background: #f6f6f6 url(images/ui-bg_glass_100_f6f6f6_1x400.png) 100% 100% repeat-x; font-weight: bold; color: #1c94c4; }
  8.         .ui-state-highlight { height: 1.5em; line-height: 1.2em; }
  9.        
  10.         .one{width: 100px; height: 100px; float:left; clear:both;}
  11.         .two {width: 50px; height: 50px; float:right; clear:both;}
  12.         .three {width: 50px; height: 50px; float:right; clear:both;}
  13.         .four {width: 25px; height: 25px; float:left; clear:both;}
  14.         .five {width: 25px; height: 25px; float:left;}
  15.         .six {width: 25px; height: 25px; float:left;}
  16.         .seven {width: 25px; height: 25px; float:left;}
  17.        
  18.         .big {margin: 3px 3px 3px 0; padding: 1px; float: left; width: 200px; height: 190px; text-align: center; overflow: hidden;}
  19.         .medium {margin: 3px 3px 3px 0; padding: 1px; float: left; width: 150px; height: 145px; text-align: center; overflow:hidden;}
  20.         .small {margin: 3px 3px 3px 0; padding: 1px; float: left; width: 100px; height: 100px; text-align: center; overflow: hidden;}
  21.        
  22.         .high { position: relative; width:500px; height:200px; }
  23.         .right { position:relative; width:400px; height:150px; }
  24.         .low { position:relative; width:750px; height:100px; }
  25.  
  26. </style>
  27.  
  28. </head>
  29. <body>
  30.  
  31. <div class="demo">
  32.  
  33. <ul class="box high">
  34.         <li class="ui-state-default big"><div rel="item" id="1">1</div></li>
  35.         </ul>
  36.        
  37. <ul class="box right"> 
  38.         <li class="ui-state-default medium"><div rel="item" id="2">2</div></li>
  39.         <li class="ui-state-default medium"><div rel="item" id="3">3</div></li>
  40. </ul>
  41.  
  42. <ul class="box low">
  43.         <li class="ui-state-default small"><div id="4">4</div></li>
  44.         <li class="ui-state-default small"><div id="5">5</div></li>
  45.         <li class="ui-state-default small"><div id="6">6</div></li>
  46.         <li class="ui-state-default small"><div id="7">7</div></li>  
  47. </div>
  48.  
  49. <script type="text/javascript">
  50.  
  51. var $j = jQuery.noConflict();
  52.  
  53. $j( ".box" ).sortable({
  54.         connectWith: ".box"
  55.         });
  56.        
  57. $j( ".box" ).disableSelection();
  58.  
  59.  
  60. $j( ".high" ).sortable({ update: function(event, ui) {
  61.         render();
  62.         style();
  63. }});
  64.  
  65. $j( ".right" ).sortable({ update: function(event, ui) {
  66.         render();
  67.         style();
  68. }});
  69.  
  70. $j( ".low" ).sortable({ update: function(event, ui) {
  71.         render();
  72.         style();
  73. }});
  74.  
  75.  
  76. function render() {
  77.        
  78.         var uls = $j('ul');
  79.        
  80.         var lis1 = $j(uls[0]).children('li');
  81.         var lis2 = $j(uls[1]).children('li');
  82.         var lis3 = $j(uls[2]).children('li');
  83.        
  84.         if (lis1.length == 0) {
  85.                 uls[0].appendChild(lis2[0]);
  86.         };
  87.        
  88.         if (lis1.length == 2) {
  89.                 $j(lis1[1]).insertBefore($j(lis2[0]));
  90.         };
  91.        
  92.         if (lis2.length == 1) {
  93.                 uls[1].appendChild(lis3[0]);
  94.         };
  95.        
  96.         if (lis2.length == 3) {
  97.                 $j(lis2[2]).insertBefore($j(lis3[0]));
  98.         };
  99. }
  100.  
  101. function style() {
  102.         var uls = $j('ul');
  103.        
  104.         var lis1 = $j(uls[0]).children('li');
  105.         var lis2 = $j(uls[1]).children('li');
  106.         var lis3 = $j(uls[2]).children('li');
  107.        
  108.         for (i=0; i<=lis1.length; i++) {
  109.                 $j(lis1[i]).attr("class", "ui-state-default big");
  110.         };
  111.        
  112.         for (i=0; i<=lis2.length; i++) {
  113.                 $j(lis2[i]).attr("class", "ui-state-default medium");
  114.         };
  115.        
  116.         for (i=0; i<=lis3.length; i++) {
  117.                 $j(lis3[i]).attr("class", "ui-state-default small");
  118.         };
  119.        
  120. }
  121.  
  122.  
  123. </script>