Advertisement
Guest User

Untitled

a guest
Jan 17th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. // There's the gallery and the trash
  2. var $gallery = $("#gallery"),
  3. $lapalma = $("#Lapalma"),
  4. $elhierro = $("#Elhierro"),
  5. $lagomera = $("#Lagomera"),
  6. $tenerife = $("#Tenerife"),
  7. $grancanaria = $("#Grancanaria"),
  8. $lanzarote = $("#Lanzarote"),
  9. $fuerteventura = $("#Fuerteventura");
  10.  
  11. // Let the gallery items be draggable
  12. $("li", $gallery).draggable({
  13. cancel: "a.ui-icon", // clicking an icon won't initiate dragging
  14. revert: "invalid", // when not dropped, the item will revert back to its initial position
  15. containment: "document",
  16. helper: "clone",
  17. cursor: "move"
  18. });
  19.  
  20. ///// EL HIERRO
  21.  
  22. // Let the trash be droppable, accepting the gallery items
  23. $elhierro.droppable({
  24. accept: "#gallery > li[isla='elhierro']",
  25. classes: {
  26. "ui-droppable-active": "ui-state-highlight"
  27. },
  28. drop: function(event, ui) {
  29. deleteImage(ui.draggable, $(this));
  30. }
  31. });
  32.  
  33. ///// FUERTEVENTURA
  34.  
  35. // Let the trash be droppable, accepting the gallery items
  36. $fuerteventura.droppable({
  37. accept: "#gallery > li[isla='fuerteventura']",
  38. classes: {
  39. "ui-droppable-active": "ui-state-highlight"
  40. },
  41. drop: function(event, ui) {
  42. deleteImage(ui.draggable, $(this));
  43. }
  44. });
  45.  
  46. // Image deletion function
  47. function deleteImage($item, $isla) {
  48. $item.fadeOut(function() {
  49. var $list = $("ul", $isla).length
  50. ? $("ul", $isla)
  51. : $("<ul class='gallery ui-helper-reset'/>").appendTo($isla);
  52.  
  53. $item.find("a.ui-icon-trash").remove();
  54. $item.appendTo($list).fadeIn(function() {
  55. $item
  56. .animate({ width: "48px" })
  57. .find("img")
  58. .animate({ height: "36px" });
  59. });
  60. });
  61. }
  62.  
  63. // Resolve the icons behavior with event delegation
  64. $("ul.gallery > li").on("click", function(event) {
  65. var $item = $(this),
  66. $target = $(event.target);
  67.  
  68. if ($target.is("a.ui-icon-trash")) {
  69. deleteImage($item);
  70. } else if ($target.is("a.ui-icon-zoomin")) {
  71. viewLargerImage($target);
  72. } else if ($target.is("a.ui-icon-refresh")) {
  73. recycleImage($item);
  74. }
  75.  
  76. return false;
  77. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement