dragdrop.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // Copyright 2006 The Closure Library Authors. All Rights Reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS-IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. /**
  15. * @fileoverview Single Element Drag and Drop.
  16. *
  17. * Drag and drop implementation for sources/targets consisting of a single
  18. * element.
  19. *
  20. * @author eae@google.com (Emil A Eklund)
  21. * @see ../demos/dragdrop.html
  22. */
  23. goog.provide('goog.fx.DragDrop');
  24. goog.require('goog.fx.AbstractDragDrop');
  25. goog.require('goog.fx.DragDropItem');
  26. /**
  27. * Drag/drop implementation for creating drag sources/drop targets consisting of
  28. * a single HTML Element.
  29. *
  30. * @param {Element|string} element Dom Node, or string representation of node
  31. * id, to be used as drag source/drop target.
  32. * @param {Object=} opt_data Data associated with the source/target.
  33. * @throws Error If no element argument is provided or if the type is invalid
  34. * @extends {goog.fx.AbstractDragDrop}
  35. * @constructor
  36. * @struct
  37. */
  38. goog.fx.DragDrop = function(element, opt_data) {
  39. goog.fx.AbstractDragDrop.call(this);
  40. var item = new goog.fx.DragDropItem(element, opt_data);
  41. item.setParent(this);
  42. this.items_.push(item);
  43. };
  44. goog.inherits(goog.fx.DragDrop, goog.fx.AbstractDragDrop);