drag2.htm 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  5. <title></title>
  6. <link href="../../lib/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
  7. <script src="../../lib/jquery/jquery-1.5.2.min.js" type="text/javascript"></script>
  8. <script src="../../lib/ligerUI/js/core/base.js" type="text/javascript"></script>
  9. <script src="../../lib/ligerUI/js/plugins/ligerDrag.js" type="text/javascript"></script>
  10. <script type="text/javascript">
  11. $(function ()
  12. {
  13. $('.box,.receive').ligerDrag({ proxy: 'clone', revert: true, receive: '.receive',
  14. onStartDrag: function ()
  15. {
  16. this.set({ cursor: "not-allowed" });
  17. },
  18. onDragEnter: function (receive, source, e)
  19. {
  20. this.set({ cursor: "pointer" });
  21. //this.proxy.html("释放注入颜色");
  22. },
  23. onDragLeave: function (receive, source, e)
  24. {
  25. this.set({ cursor: "not-allowed" });
  26. //this.proxy.html("");
  27. },
  28. onDrop: function (receive, source, e)
  29. {
  30. if (!this.proxy) return;
  31. this.proxy.hide();
  32. var bgcolor = this.proxy.css('backgroundColor');
  33. if (this.target.hasClass("receive"))
  34. {
  35. //颜色调换
  36. this.target.css("backgroundColor", $(receive).css("backgroundColor"));
  37. }
  38. $(receive).css("backgroundColor", bgcolor);
  39. }
  40. });
  41. });
  42. </script>
  43. <style type="text/css">
  44. .proxy
  45. {
  46. border: 1px splid #333;
  47. position: absolute;
  48. z-index: 4;
  49. background: #f1f1f1;
  50. }
  51. .box
  52. {
  53. width: 80px;
  54. height: 80px;
  55. border: 2px solid #bbb;
  56. float: left;
  57. margin: 5px;
  58. }
  59. .receive
  60. {
  61. width: 120px;
  62. height: 120px;
  63. border: 1px solid #bbb;
  64. float: left;
  65. margin: 4px;
  66. }
  67. .txt
  68. {
  69. margin: 2px;
  70. width: 60px;
  71. border: 1px solid #333;
  72. }
  73. </style>
  74. </head>
  75. <body style="padding: 10px">
  76. <div>
  77. <div class="box" style="background: #A6DBD8;">
  78. </div>
  79. <div class="box" style="background: #AFCCF1;">
  80. </div>
  81. <div class="box" style="background: #DA9188;">
  82. </div>
  83. <div class="box" style="background: #9CD88A;">
  84. </div>
  85. <div class="box" style="background: #D09CC5;">
  86. </div>
  87. <div class="box" style="background: #E2DC6B;">
  88. </div>
  89. <div class="box" style="background: #F2f2f2;">
  90. </div>
  91. </div>
  92. <div style=" position:absolute; top:160px; width:400px; ">
  93. <div class="receive">
  94. </div>
  95. <div class="receive">
  96. </div>
  97. <div class="receive">
  98. </div>
  99. <div class="receive">
  100. </div>
  101. <div class="receive">
  102. </div>
  103. <div class="receive">
  104. </div>
  105. </div>
  106. <div id="message">
  107. </div>
  108. <div style="display: none">
  109. </div>
  110. </body>
  111. </html>