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