Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
seleniumhq
GitHub Repository: seleniumhq/selenium
Path: blob/trunk/third_party/closure/goog/fx/dragdropgroup.js
4500 views
1
/**
2
* @license
3
* Copyright The Closure Library Authors.
4
* SPDX-License-Identifier: Apache-2.0
5
*/
6
7
/**
8
* @fileoverview Multiple Element Drag and Drop.
9
*
10
* Drag and drop implementation for sources/targets consisting of multiple
11
* elements.
12
*
13
* @see ../demos/dragdrop.html
14
*/
15
16
goog.provide('goog.fx.DragDropGroup');
17
18
goog.require('goog.dom');
19
goog.require('goog.fx.AbstractDragDrop');
20
goog.require('goog.fx.DragDropItem');
21
22
23
24
/**
25
* Drag/drop implementation for creating drag sources/drop targets consisting of
26
* multiple HTML Elements (items). All items share the same drop target(s) but
27
* can be dragged individually.
28
*
29
* @extends {goog.fx.AbstractDragDrop}
30
* @constructor
31
* @struct
32
*/
33
goog.fx.DragDropGroup = function() {
34
'use strict';
35
goog.fx.AbstractDragDrop.call(this);
36
};
37
goog.inherits(goog.fx.DragDropGroup, goog.fx.AbstractDragDrop);
38
39
40
/**
41
* Add item to drag object.
42
*
43
* @param {Element|string} element Dom Node, or string representation of node
44
* id, to be used as drag source/drop target.
45
* @param {Object=} opt_data Data associated with the source/target.
46
* @throws Error If no element argument is provided or if the type is
47
* invalid
48
* @override
49
*/
50
goog.fx.DragDropGroup.prototype.addItem = function(element, opt_data) {
51
'use strict';
52
var item = new goog.fx.DragDropItem(element, opt_data);
53
this.addDragDropItem(item);
54
};
55
56
57
/**
58
* Add DragDropItem to drag object.
59
*
60
* @param {goog.fx.DragDropItem} item DragDropItem being added to the
61
* drag object.
62
* @throws Error If no element argument is provided or if the type is
63
* invalid
64
*/
65
goog.fx.DragDropGroup.prototype.addDragDropItem = function(item) {
66
'use strict';
67
item.setParent(this);
68
this.items_.push(item);
69
if (this.isInitialized()) {
70
this.initItem(item);
71
}
72
};
73
74
75
/**
76
* Remove item from drag object.
77
*
78
* @param {Element|string} element Dom Node, or string representation of node
79
* id, that was previously added with addItem().
80
*/
81
goog.fx.DragDropGroup.prototype.removeItem = function(element) {
82
'use strict';
83
element = goog.dom.getElement(element);
84
for (var item, i = 0; item = this.items_[i]; i++) {
85
if (item.element == element) {
86
this.items_.splice(i, 1);
87
this.disposeItem(item);
88
break;
89
}
90
}
91
};
92
93
94
/**
95
* Marks the supplied list of items as selected. A drag operation for any of the
96
* selected items will affect all of them.
97
*
98
* @param {Array<goog.fx.DragDropItem>} list List of items to select or null to
99
* clear selection.
100
*
101
* TODO(eae): Not yet implemented.
102
*/
103
goog.fx.DragDropGroup.prototype.setSelection = function(list) {
104
105
};
106
107