Path: blob/trunk/third_party/closure/goog/fx/dragdropgroup.js
4500 views
/**1* @license2* Copyright The Closure Library Authors.3* SPDX-License-Identifier: Apache-2.04*/56/**7* @fileoverview Multiple Element Drag and Drop.8*9* Drag and drop implementation for sources/targets consisting of multiple10* elements.11*12* @see ../demos/dragdrop.html13*/1415goog.provide('goog.fx.DragDropGroup');1617goog.require('goog.dom');18goog.require('goog.fx.AbstractDragDrop');19goog.require('goog.fx.DragDropItem');20212223/**24* Drag/drop implementation for creating drag sources/drop targets consisting of25* multiple HTML Elements (items). All items share the same drop target(s) but26* can be dragged individually.27*28* @extends {goog.fx.AbstractDragDrop}29* @constructor30* @struct31*/32goog.fx.DragDropGroup = function() {33'use strict';34goog.fx.AbstractDragDrop.call(this);35};36goog.inherits(goog.fx.DragDropGroup, goog.fx.AbstractDragDrop);373839/**40* Add item to drag object.41*42* @param {Element|string} element Dom Node, or string representation of node43* id, to be used as drag source/drop target.44* @param {Object=} opt_data Data associated with the source/target.45* @throws Error If no element argument is provided or if the type is46* invalid47* @override48*/49goog.fx.DragDropGroup.prototype.addItem = function(element, opt_data) {50'use strict';51var item = new goog.fx.DragDropItem(element, opt_data);52this.addDragDropItem(item);53};545556/**57* Add DragDropItem to drag object.58*59* @param {goog.fx.DragDropItem} item DragDropItem being added to the60* drag object.61* @throws Error If no element argument is provided or if the type is62* invalid63*/64goog.fx.DragDropGroup.prototype.addDragDropItem = function(item) {65'use strict';66item.setParent(this);67this.items_.push(item);68if (this.isInitialized()) {69this.initItem(item);70}71};727374/**75* Remove item from drag object.76*77* @param {Element|string} element Dom Node, or string representation of node78* id, that was previously added with addItem().79*/80goog.fx.DragDropGroup.prototype.removeItem = function(element) {81'use strict';82element = goog.dom.getElement(element);83for (var item, i = 0; item = this.items_[i]; i++) {84if (item.element == element) {85this.items_.splice(i, 1);86this.disposeItem(item);87break;88}89}90};919293/**94* Marks the supplied list of items as selected. A drag operation for any of the95* selected items will affect all of them.96*97* @param {Array<goog.fx.DragDropItem>} list List of items to select or null to98* clear selection.99*100* TODO(eae): Not yet implemented.101*/102goog.fx.DragDropGroup.prototype.setSelection = function(list) {103104};105106107