jquery.droppable.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /**
  2. * EasyUI for jQuery 1.6.10
  3. *
  4. * Copyright (c) 2009-2018 www.jeasyui.com. All rights reserved.
  5. *
  6. * Licensed under the freeware license: http://www.jeasyui.com/license_freeware.php
  7. * To use it on other terms please contact us: info@jeasyui.com
  8. *
  9. */
  10. (function($){
  11. function _1(_2){
  12. $(_2).addClass("droppable");
  13. $(_2).bind("_dragenter",function(e,_3){
  14. $.data(_2,"droppable").options.onDragEnter.apply(_2,[e,_3]);
  15. });
  16. $(_2).bind("_dragleave",function(e,_4){
  17. $.data(_2,"droppable").options.onDragLeave.apply(_2,[e,_4]);
  18. });
  19. $(_2).bind("_dragover",function(e,_5){
  20. $.data(_2,"droppable").options.onDragOver.apply(_2,[e,_5]);
  21. });
  22. $(_2).bind("_drop",function(e,_6){
  23. $.data(_2,"droppable").options.onDrop.apply(_2,[e,_6]);
  24. });
  25. };
  26. $.fn.droppable=function(_7,_8){
  27. if(typeof _7=="string"){
  28. return $.fn.droppable.methods[_7](this,_8);
  29. }
  30. _7=_7||{};
  31. return this.each(function(){
  32. var _9=$.data(this,"droppable");
  33. if(_9){
  34. $.extend(_9.options,_7);
  35. }else{
  36. _1(this);
  37. $.data(this,"droppable",{options:$.extend({},$.fn.droppable.defaults,$.fn.droppable.parseOptions(this),_7)});
  38. }
  39. });
  40. };
  41. $.fn.droppable.methods={options:function(jq){
  42. return $.data(jq[0],"droppable").options;
  43. },enable:function(jq){
  44. return jq.each(function(){
  45. $(this).droppable({disabled:false});
  46. });
  47. },disable:function(jq){
  48. return jq.each(function(){
  49. $(this).droppable({disabled:true});
  50. });
  51. }};
  52. $.fn.droppable.parseOptions=function(_a){
  53. var t=$(_a);
  54. return $.extend({},$.parser.parseOptions(_a,["accept"]),{disabled:(t.attr("disabled")?true:undefined)});
  55. };
  56. $.fn.droppable.defaults={accept:null,disabled:false,onDragEnter:function(e,_b){
  57. },onDragOver:function(e,_c){
  58. },onDragLeave:function(e,_d){
  59. },onDrop:function(e,_e){
  60. }};
  61. })(jQuery);