jquery.droppable.js 1.8 KB

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