@ms-atlas-module/datastudio-datafactory 0.1.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of @ms-atlas-module/datastudio-datafactory might be problematic. Click here for more details.
- package/_generated/ClientResources.js +1549 -0
- package/_generated/Framework.js +97 -0
- package/_generated/Svg.js +201 -0
- package/bootstrapper/BreadcrumbsKnockoutBinding.js +25 -0
- package/bootstrapper/CSS/Callout.css +43 -0
- package/bootstrapper/CSS/Common.css +22 -0
- package/bootstrapper/CSS/FormFields.css +133 -0
- package/bootstrapper/CSS/InlineBlock.css +34 -0
- package/bootstrapper/CSS/ParameterGroups.css +77 -0
- package/bootstrapper/CSS/Pivot.css +25 -0
- package/bootstrapper/CSS/Wizard.css +197 -0
- package/bootstrapper/CalloutBinding.js +52 -0
- package/bootstrapper/CollapsibleKnockoutBinding.js +70 -0
- package/bootstrapper/CopyBinding.js +150 -0
- package/bootstrapper/FilterFlyoutKnockoutBinding.js +114 -0
- package/bootstrapper/FormFields.js +397 -0
- package/bootstrapper/InlineBlockBinding.js +69 -0
- package/bootstrapper/JQueryUIBindings.js +152 -0
- package/bootstrapper/KnockoutBindings.js +635 -0
- package/bootstrapper/LoadingBinding.js +54 -0
- package/bootstrapper/MonacoEditorKnockoutBinding.js +67 -0
- package/bootstrapper/ParameterGroupsBinding.js +289 -0
- package/bootstrapper/PivotKnockoutBinding.js +61 -0
- package/bootstrapper/StatusCalendarFlyoutKnockoutBinding.js +398 -0
- package/bootstrapper/StatusCalendarKnockoutBinding.js +107 -0
- package/bootstrapper/TelemetryKnockoutBinding.js +68 -0
- package/bootstrapper/WinJSButtonKnockoutBinding.js +72 -0
- package/bootstrapper/WinJSKnockoutBindings.js +49 -0
- package/bootstrapper/WizardBinding.js +611 -0
- package/bootstrapper/startup.js +29 -0
- package/libs/VivaGraphControl/Content/CSS/Graph.css +157 -0
- package/libs/VivaGraphControl/Content/CSS/LightTheme.css +699 -0
- package/libs/VivaGraphControl/Content/Scripts/Viva.Controls/Base/Base.TriggerableLifetimeManager.js +190 -0
- package/libs/VivaGraphControl/Content/Scripts/Viva.Controls/Controls/Base/Base.js +647 -0
- package/libs/VivaGraphControl/Content/Scripts/Viva.Controls/Controls/Base/Image.js +113 -0
- package/libs/VivaGraphControl/Content/Scripts/Viva.Controls/Controls/Base/KnockoutExtensions.js +1064 -0
- package/libs/VivaGraphControl/Content/Scripts/Viva.Controls/Controls/DockedBalloon.js +18 -0
- package/libs/VivaGraphControl/Content/Scripts/Viva.Controls/Controls/Visualization/Graph/Animation.js +192 -0
- package/libs/VivaGraphControl/Content/Scripts/Viva.Controls/Controls/Visualization/Graph/Commands/MoveNodes.js +83 -0
- package/libs/VivaGraphControl/Content/Scripts/Viva.Controls/Controls/Visualization/Graph/Geometry.js +167 -0
- package/libs/VivaGraphControl/Content/Scripts/Viva.Controls/Controls/Visualization/Graph/GraphEntityViewModel.js +260 -0
- package/libs/VivaGraphControl/Content/Scripts/Viva.Controls/Controls/Visualization/Graph/GraphViewModel.js +338 -0
- package/libs/VivaGraphControl/Content/Scripts/Viva.Controls/Controls/Visualization/Graph/GraphWidget.Constants.js +178 -0
- package/libs/VivaGraphControl/Content/Scripts/Viva.Controls/Controls/Visualization/Graph/GraphWidget.js +5190 -0
- package/libs/VivaGraphControl/Content/Scripts/Viva.Controls/Controls/Visualization/Graph/MouseCapture.js +148 -0
- package/libs/VivaGraphControl/Content/Scripts/Viva.Controls/Controls/Visualization/Graph/SvgUtils.js +164 -0
- package/libs/VivaGraphControl/Content/Scripts/Viva.Controls/Util/Detection.js +658 -0
- package/libs/VivaGraphControl/Content/Scripts/Viva.Controls/Util/Resize.js +241 -0
- package/libs/VivaGraphControl/Content/Scripts/Viva.Controls/Util/Util.Private.js +236 -0
- package/libs/VivaGraphControl/Content/Scripts/Viva.Controls/Util/Util.js +905 -0
- package/libs/WinJS/WinJs.min.js +61909 -0
- package/libs/WinJS/ui-light.css +8500 -0
- package/package.json +15 -0
- package/scripts/AppContext.js +262 -0
- package/scripts/ExposureControl.js +11 -0
- package/scripts/Framework/Model/ActivityWindowCache.js +390 -0
- package/scripts/Framework/Model/ArmDataFactoryCache.js +77 -0
- package/scripts/Framework/Model/Contracts/Activity.js +83 -0
- package/scripts/Framework/Model/Contracts/ActivityWindow.js +185 -0
- package/scripts/Framework/Model/Contracts/BaseEncodable.js +106 -0
- package/scripts/Framework/Model/Contracts/Common.js +19 -0
- package/scripts/Framework/Model/Contracts/DataArtifact.js +100 -0
- package/scripts/Framework/Model/Contracts/Diagram.js +9 -0
- package/scripts/Framework/Model/Contracts/Encodable.js +113 -0
- package/scripts/Framework/Model/Contracts/Gateway.js +98 -0
- package/scripts/Framework/Model/Contracts/LinkedService.js +200 -0
- package/scripts/Framework/Model/Contracts/Pipeline.js +197 -0
- package/scripts/Framework/Model/DataCache.js +105 -0
- package/scripts/Framework/Model/DataFactoryCache.js +24 -0
- package/scripts/Framework/Model/Filter.js +186 -0
- package/scripts/Framework/Model/Helpers/ActivityWindowHelper.js +185 -0
- package/scripts/Framework/Model/MonitoringView.js +40 -0
- package/scripts/Framework/Shared/Constants.js +27 -0
- package/scripts/Framework/Shared/DataConstants.js +61 -0
- package/scripts/Framework/Shared/Disposable.js +53 -0
- package/scripts/Framework/Shared/IconResources.js +59 -0
- package/scripts/Framework/Shared/Resources/IbizaSvgs.js +241 -0
- package/scripts/Framework/Shared/TypeDeclarations.js +4 -0
- package/scripts/Framework/Telemetry/Telemetry.js +78 -0
- package/scripts/Framework/UI/Breadcrumbs.js +84 -0
- package/scripts/Framework/UI/Command.js +231 -0
- package/scripts/Framework/UI/ContextMenu.js +80 -0
- package/scripts/Framework/UI/Loader.js +11 -0
- package/scripts/Framework/UI/Menu.js +65 -0
- package/scripts/Framework/UI/PanelMessage.js +25 -0
- package/scripts/Framework/UI/Refresh.js +70 -0
- package/scripts/Framework/UI/Spinner.js +61 -0
- package/scripts/Framework/UI/StatusCalendar.js +1070 -0
- package/scripts/Framework/UI/Toolbar.js +84 -0
- package/scripts/Framework/Util/Datetime.js +258 -0
- package/scripts/Framework/Util/Log.js +10 -0
- package/scripts/Framework/Util/ResourceIdUtil.js +56 -0
- package/scripts/Framework/Util/Security.js +73 -0
- package/scripts/Framework/Util/Util.js +332 -0
- package/scripts/Framework/Views/HoverFlyout.js +92 -0
- package/scripts/Handlers/ErrorHandler.js +176 -0
- package/scripts/Handlers/MessageHandler.js +115 -0
- package/scripts/Handlers/MonitoringViewHandler.js +199 -0
- package/scripts/Handlers/RoutingHandler.js +364 -0
- package/scripts/Handlers/WinJSHandlers.js +265 -0
- package/scripts/MonitoringViewContext.js +75 -0
- package/scripts/Services/AzureInsightsService.js +162 -0
- package/scripts/Services/AzureResourceManagerService.js +869 -0
- package/scripts/Services/BaseService.js +232 -0
- package/scripts/Services/DataFactoryService.js +204 -0
- package/scripts/Services/HDInsightArmService.js +59 -0
- package/scripts/ViewContext.js +9 -0
- package/stylesheets/main.css +1042 -0
- package/views/Edit/DateTimeFilterViewModel.js +211 -0
- package/views/Edit/FilterViewModel.js +131 -0
- package/views/Shared/ProvisioningState.js +11 -0
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
/// <reference path="../../Definitions/jquery.d.ts" />
|
|
2
|
+
define([
|
|
3
|
+
"require",
|
|
4
|
+
"exports",
|
|
5
|
+
"./Detection",
|
|
6
|
+
"../Base/Base.TriggerableLifetimeManager",
|
|
7
|
+
], function (require, exports, Detection, BaseTriggerableLifetimeManager) {
|
|
8
|
+
var Main;
|
|
9
|
+
(function (Main) {
|
|
10
|
+
"use strict";
|
|
11
|
+
var global = window,
|
|
12
|
+
$ = jQuery;
|
|
13
|
+
/**
|
|
14
|
+
* Hooks up cross browser resize detection event (ie, webkit, moz).
|
|
15
|
+
*
|
|
16
|
+
* @param element The element to monitor size changes.
|
|
17
|
+
* @param handler The resize event handler.
|
|
18
|
+
* @return The method to dispose the event.
|
|
19
|
+
*/
|
|
20
|
+
function track(element, handler) {
|
|
21
|
+
var width,
|
|
22
|
+
height,
|
|
23
|
+
elem,
|
|
24
|
+
resizeHandler,
|
|
25
|
+
resizeElement,
|
|
26
|
+
overflowEvent,
|
|
27
|
+
underflowEvent,
|
|
28
|
+
overflowHandler,
|
|
29
|
+
underflowHandler,
|
|
30
|
+
reset,
|
|
31
|
+
position,
|
|
32
|
+
overflowElement,
|
|
33
|
+
underflowElement,
|
|
34
|
+
overflowContentElement,
|
|
35
|
+
underflowContentElement;
|
|
36
|
+
// Don't allow multiple uses
|
|
37
|
+
if (
|
|
38
|
+
element.children(".azc-resize").length ||
|
|
39
|
+
element.children(".azc-overflow").length ||
|
|
40
|
+
element.children(".azc-underflow").length
|
|
41
|
+
) {
|
|
42
|
+
throw new Error(
|
|
43
|
+
"Resize tracker may only be attached once to an element."
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
// Save the initial state
|
|
47
|
+
width = element.width();
|
|
48
|
+
height = element.height();
|
|
49
|
+
// Handles geting the current sizes and calling the provided handler.
|
|
50
|
+
resizeHandler = function () {
|
|
51
|
+
var currentWidth = element.width(),
|
|
52
|
+
currentHeight = element.height();
|
|
53
|
+
if (currentHeight !== height || currentWidth !== width) {
|
|
54
|
+
width = currentWidth;
|
|
55
|
+
height = currentHeight;
|
|
56
|
+
handler(width, height);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
var lifetime =
|
|
60
|
+
new BaseTriggerableLifetimeManager.TriggerableLifetimeManager();
|
|
61
|
+
Detection.Detection.Features.Events.complete().then(function () {
|
|
62
|
+
if (Detection.Detection.Features.Events.divResize) {
|
|
63
|
+
var attachmentTarget = element[0];
|
|
64
|
+
// IE 10- only supports onresize with attachEvent
|
|
65
|
+
attachmentTarget.attachEvent("onresize", resizeHandler);
|
|
66
|
+
// Register the detach for disposal
|
|
67
|
+
lifetime.registerForDispose({
|
|
68
|
+
dispose: function () {
|
|
69
|
+
attachmentTarget.detachEvent("onresize", resizeHandler);
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
return lifetime;
|
|
73
|
+
} else if (Detection.Detection.Features.Events.svgResize) {
|
|
74
|
+
// IE 11 supports onresize on svg if there is an onresize attribute
|
|
75
|
+
element.append(
|
|
76
|
+
"<svg class='azc-resize' onresize='' style='position:absolute; left: 0; top:0; width:100%; height:100%; z-index:-1'></svg>"
|
|
77
|
+
);
|
|
78
|
+
resizeElement = element.children(".azc-resize");
|
|
79
|
+
resizeElement[0].onresize = resizeHandler;
|
|
80
|
+
// If the element is not positioned make it relative
|
|
81
|
+
// so that the detection svg can use absolute positioning
|
|
82
|
+
position = element.css("position");
|
|
83
|
+
if (position === "static") {
|
|
84
|
+
element.css("position", "relative");
|
|
85
|
+
}
|
|
86
|
+
// Register the detector for disposal
|
|
87
|
+
lifetime.registerForDispose({
|
|
88
|
+
dispose: function () {
|
|
89
|
+
resizeElement.remove();
|
|
90
|
+
// Restore original position
|
|
91
|
+
if (position === "static") {
|
|
92
|
+
element.css("position", position);
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
return lifetime;
|
|
97
|
+
} else if (Detection.Detection.Features.Events.overflowchanged) {
|
|
98
|
+
// Webkit supports overflowchanged event with event parameters to distinguish overflow/underflow.
|
|
99
|
+
overflowEvent = "overflowchanged";
|
|
100
|
+
underflowEvent = "overflowchanged";
|
|
101
|
+
overflowHandler = function (evt) {
|
|
102
|
+
if (
|
|
103
|
+
evt.originalEvent &&
|
|
104
|
+
(evt.originalEvent.horizontalOverflow === true ||
|
|
105
|
+
evt.originalEvent.verticalOverflow === true)
|
|
106
|
+
) {
|
|
107
|
+
resizeHandler();
|
|
108
|
+
reset();
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
underflowHandler = function (evt) {
|
|
112
|
+
if (
|
|
113
|
+
evt.originalEvent &&
|
|
114
|
+
(evt.originalEvent.horizontalOverflow === false ||
|
|
115
|
+
evt.originalEvent.verticalOverflow === false)
|
|
116
|
+
) {
|
|
117
|
+
resizeHandler();
|
|
118
|
+
reset();
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
} else if (
|
|
122
|
+
Detection.Detection.Features.Events.overflow &&
|
|
123
|
+
Detection.Detection.Features.Events.underflow
|
|
124
|
+
) {
|
|
125
|
+
// Mozilla supports overflow/underflow events
|
|
126
|
+
overflowEvent = "overflow";
|
|
127
|
+
underflowEvent = "underflow";
|
|
128
|
+
overflowHandler = function (evt) {
|
|
129
|
+
resizeHandler();
|
|
130
|
+
reset();
|
|
131
|
+
};
|
|
132
|
+
underflowHandler = function (evt) {
|
|
133
|
+
resizeHandler();
|
|
134
|
+
reset();
|
|
135
|
+
};
|
|
136
|
+
} else if (Detection.Detection.Features.Events.objResize) {
|
|
137
|
+
// If the element is not positioned make it relative
|
|
138
|
+
// so that the detection svg can use absolute positioning
|
|
139
|
+
position = element.css("position");
|
|
140
|
+
if (position === "static") {
|
|
141
|
+
element.css("position", "relative");
|
|
142
|
+
}
|
|
143
|
+
// Use resize event of object tag
|
|
144
|
+
element.append(
|
|
145
|
+
"<object class='azc-resize' type='text/html' style='position:absolute; left: 0; top:0; width:100%; height:100%; z-index:-1'></object>"
|
|
146
|
+
);
|
|
147
|
+
resizeElement = element.children(".azc-resize");
|
|
148
|
+
var obj = resizeElement[0];
|
|
149
|
+
resizeElement.on("load", function () {
|
|
150
|
+
obj.contentDocument.defaultView.addEventListener(
|
|
151
|
+
"resize",
|
|
152
|
+
resizeHandler
|
|
153
|
+
);
|
|
154
|
+
});
|
|
155
|
+
// Cause a load
|
|
156
|
+
obj.data = "about:blank";
|
|
157
|
+
// Register the detector for disposal
|
|
158
|
+
lifetime.registerForDispose({
|
|
159
|
+
dispose: function () {
|
|
160
|
+
resizeElement.remove();
|
|
161
|
+
// Restore original position
|
|
162
|
+
if (position === "static") {
|
|
163
|
+
element.css("position", position);
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
});
|
|
167
|
+
return lifetime;
|
|
168
|
+
} else {
|
|
169
|
+
// Unable to detect element resize changes in current browser.
|
|
170
|
+
// Instead we will do it on window changes
|
|
171
|
+
// This is imperfect but should always be present
|
|
172
|
+
window.addEventListener("resize", resizeHandler);
|
|
173
|
+
// Register the removal for disposal
|
|
174
|
+
lifetime.registerForDispose({
|
|
175
|
+
dispose: function () {
|
|
176
|
+
window.removeEventListener("resize", resizeHandler);
|
|
177
|
+
},
|
|
178
|
+
});
|
|
179
|
+
return lifetime;
|
|
180
|
+
}
|
|
181
|
+
// Resets the overflow and underflow detection element sizes.
|
|
182
|
+
reset = function () {
|
|
183
|
+
// Put the overflowElement in an underflow state such that an increase of 1px will cause an overflow.
|
|
184
|
+
overflowContentElement.width(width);
|
|
185
|
+
overflowContentElement.height(height);
|
|
186
|
+
// Puts the underflowElement in an overflow state such that a decrease of 1px will cause an underflow.
|
|
187
|
+
underflowContentElement.width(width + 1);
|
|
188
|
+
underflowContentElement.height(height + 1);
|
|
189
|
+
};
|
|
190
|
+
// If the element is not positioned make it relative
|
|
191
|
+
// so that the detection elements can use absolute positioning
|
|
192
|
+
position = element.css("position");
|
|
193
|
+
if (position === "static") {
|
|
194
|
+
element.css("position", "relative");
|
|
195
|
+
}
|
|
196
|
+
// Append the overflow/underflow detection elements
|
|
197
|
+
element.append(
|
|
198
|
+
"<div class='azc-underflow' style='position:absolute; left: 0; top:0; width:100%; height:100%; overflow:hidden; z-index:-1'>" +
|
|
199
|
+
"<div class='azc-underflow-content'></div>" +
|
|
200
|
+
"</div>" +
|
|
201
|
+
"<div class='azc-overflow' style='position:absolute; left:0; top:0; width:100%; height:100%; overflow:hidden; z-index:-1'>" +
|
|
202
|
+
"<div class='azc-overflow-content'></div>" +
|
|
203
|
+
"</div>"
|
|
204
|
+
);
|
|
205
|
+
// Save the overflow/underflow detection elements
|
|
206
|
+
overflowElement = element.children(".azc-overflow");
|
|
207
|
+
underflowElement = element.children(".azc-underflow");
|
|
208
|
+
overflowContentElement = overflowElement.children(
|
|
209
|
+
".azc-overflow-content"
|
|
210
|
+
);
|
|
211
|
+
underflowContentElement = underflowElement.children(
|
|
212
|
+
".azc-underflow-content"
|
|
213
|
+
);
|
|
214
|
+
// Initialize the overflow/underflow detection elements
|
|
215
|
+
reset();
|
|
216
|
+
// Hook up the overflow/underflow events
|
|
217
|
+
overflowElement.on(overflowEvent, overflowHandler);
|
|
218
|
+
underflowElement.on(underflowEvent, underflowHandler);
|
|
219
|
+
// Register the detector for disposal
|
|
220
|
+
lifetime.registerForDispose({
|
|
221
|
+
dispose: function () {
|
|
222
|
+
// Unhook the overflow/underflow events
|
|
223
|
+
overflowElement.off(overflowEvent, overflowHandler);
|
|
224
|
+
underflowElement.off(underflowEvent, underflowHandler);
|
|
225
|
+
// Remove the overflow/underflow detection elements
|
|
226
|
+
overflowElement.remove();
|
|
227
|
+
underflowElement.remove();
|
|
228
|
+
// Restore original position
|
|
229
|
+
if (position === "static") {
|
|
230
|
+
element.css("position", position);
|
|
231
|
+
}
|
|
232
|
+
},
|
|
233
|
+
});
|
|
234
|
+
return lifetime;
|
|
235
|
+
});
|
|
236
|
+
return lifetime;
|
|
237
|
+
}
|
|
238
|
+
Main.track = track;
|
|
239
|
+
})(Main || (Main = {}));
|
|
240
|
+
return Main;
|
|
241
|
+
});
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
/// <reference path="../../Definitions/hammer.d.ts" />
|
|
2
|
+
define(["require", "exports"], function (require, exports) {
|
|
3
|
+
var Main;
|
|
4
|
+
(function (Main) {
|
|
5
|
+
"use strict";
|
|
6
|
+
// IE11- does not support custom types. We will store those types in the "Text" type with proper separators.
|
|
7
|
+
// However, we cannot read the "Text" type when we are NOT in a drop event. This is a problem when trying
|
|
8
|
+
// to read the "types" variable. So we save the types in a local variable when we setData with Text.
|
|
9
|
+
// This would cause a problem if someone is using the DataTransfer polyfill from a drag-n-drop not set with this polyfill.
|
|
10
|
+
// The data coming back from types would be empty.
|
|
11
|
+
var legacyDataTransfer = null,
|
|
12
|
+
savedTypes,
|
|
13
|
+
global = window;
|
|
14
|
+
var DataTransfer2 = (function () {
|
|
15
|
+
function DataTransfer2(dataTransfer) {
|
|
16
|
+
this._prefixCode = ";;;";
|
|
17
|
+
this._dataTransfer = dataTransfer;
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(DataTransfer2.prototype, "dropEffect", {
|
|
20
|
+
get: function () {
|
|
21
|
+
return this._dataTransfer.dropEffect;
|
|
22
|
+
},
|
|
23
|
+
set: function (value) {
|
|
24
|
+
if (
|
|
25
|
+
value !== "none" &&
|
|
26
|
+
value !== "copy" &&
|
|
27
|
+
value !== "link" &&
|
|
28
|
+
value !== "move"
|
|
29
|
+
) {
|
|
30
|
+
throw new Error(
|
|
31
|
+
"Drop effect must be either none, copy, link, or move."
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
this._dataTransfer.dropEffect = value;
|
|
35
|
+
},
|
|
36
|
+
enumerable: true,
|
|
37
|
+
configurable: true,
|
|
38
|
+
});
|
|
39
|
+
Object.defineProperty(DataTransfer2.prototype, "effectAllowed", {
|
|
40
|
+
get: function () {
|
|
41
|
+
return this._dataTransfer.effectAllowed;
|
|
42
|
+
},
|
|
43
|
+
set: function (value) {
|
|
44
|
+
if (
|
|
45
|
+
value !== "none" &&
|
|
46
|
+
value !== "copy" &&
|
|
47
|
+
value !== "copyLink" &&
|
|
48
|
+
value !== "copyMove" &&
|
|
49
|
+
value !== "link" &&
|
|
50
|
+
value !== "linkMove" &&
|
|
51
|
+
value !== "move" &&
|
|
52
|
+
value !== "all" &&
|
|
53
|
+
value !== "uninitialized"
|
|
54
|
+
) {
|
|
55
|
+
throw new Error(
|
|
56
|
+
"Effect allowed must be either none, copy, copyLink, copyMove, link, linkMove, move, all, or uninitialized."
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
this._dataTransfer.effectAllowed = value;
|
|
60
|
+
},
|
|
61
|
+
enumerable: true,
|
|
62
|
+
configurable: true,
|
|
63
|
+
});
|
|
64
|
+
Object.defineProperty(DataTransfer2.prototype, "types", {
|
|
65
|
+
get: function () {
|
|
66
|
+
// TODO TypeScript 0.9.5, Need to cast, lib.d.ts is incorrect
|
|
67
|
+
var types = this._dataTransfer.types,
|
|
68
|
+
i,
|
|
69
|
+
hasType,
|
|
70
|
+
legacyData,
|
|
71
|
+
temporaryTypes;
|
|
72
|
+
// If we never checked for legacy, let's do it now
|
|
73
|
+
if (legacyDataTransfer === null) {
|
|
74
|
+
this.getData("");
|
|
75
|
+
}
|
|
76
|
+
// Let's check now if we need to reconstruct the types (IE11-)
|
|
77
|
+
if (legacyDataTransfer) {
|
|
78
|
+
// In IE, we might not be able to call getText depending on the event we are
|
|
79
|
+
// In this case, we will pick savedTypes.
|
|
80
|
+
// However, using the savedTypes from a drag-n-drop not using this polyfill would give stale data.
|
|
81
|
+
hasType = false;
|
|
82
|
+
legacyData = this._getLegacyData();
|
|
83
|
+
for (var type in legacyData) {
|
|
84
|
+
if (legacyData.hasOwnProperty(type) && legacyData[type] !== "") {
|
|
85
|
+
hasType = true;
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return Object.keys(hasType ? legacyData : savedTypes);
|
|
90
|
+
}
|
|
91
|
+
if (types) {
|
|
92
|
+
// Some browsers don't have the types as an array (IE11- & Firefox)
|
|
93
|
+
if (!types["forEach"]) {
|
|
94
|
+
temporaryTypes = types;
|
|
95
|
+
types = [];
|
|
96
|
+
for (i = 0; i < temporaryTypes.length; i++) {
|
|
97
|
+
types.push(temporaryTypes[i]);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return types;
|
|
102
|
+
},
|
|
103
|
+
enumerable: true,
|
|
104
|
+
configurable: true,
|
|
105
|
+
});
|
|
106
|
+
Object.defineProperty(DataTransfer2.prototype, "files", {
|
|
107
|
+
get: function () {
|
|
108
|
+
return this._dataTransfer.files;
|
|
109
|
+
},
|
|
110
|
+
enumerable: true,
|
|
111
|
+
configurable: true,
|
|
112
|
+
});
|
|
113
|
+
/**
|
|
114
|
+
* Returns true if the script detected that the transfer is using a legacy system.
|
|
115
|
+
*
|
|
116
|
+
* @return True if legacy is used.
|
|
117
|
+
*/
|
|
118
|
+
DataTransfer2.isLegacyDataTransfer = function () {
|
|
119
|
+
// If we never checked for legacyDataTransfer, let's make a guess with a method.
|
|
120
|
+
if (legacyDataTransfer === null) {
|
|
121
|
+
// TODO TypeScript 0.9.5: setDragImage doesn't exist in lib.d.ts
|
|
122
|
+
// Browsers are not set yet on the name of the class. Chrome uses Clipboard, the others use DataTransfer.
|
|
123
|
+
var dataTransferVariable =
|
|
124
|
+
global["DataTransfer"] || global["Clipboard"];
|
|
125
|
+
return !dataTransferVariable.prototype["setDragImage"];
|
|
126
|
+
}
|
|
127
|
+
return legacyDataTransfer;
|
|
128
|
+
};
|
|
129
|
+
DataTransfer2.prototype.setDragImage = function (image, x, y) {
|
|
130
|
+
if (this._dataTransfer["setDragImage"]) {
|
|
131
|
+
this._dataTransfer["setDragImage"](image, x, y);
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
DataTransfer2.prototype.addElement = function (element) {
|
|
135
|
+
if (this._dataTransfer["addElement"]) {
|
|
136
|
+
this._dataTransfer["addElement"](element);
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
DataTransfer2.prototype.getData = function (format) {
|
|
140
|
+
this._checkFormat(format);
|
|
141
|
+
if (legacyDataTransfer) {
|
|
142
|
+
return this._getLegacyDataTransfer(format);
|
|
143
|
+
} else {
|
|
144
|
+
try {
|
|
145
|
+
legacyDataTransfer = false;
|
|
146
|
+
return this._dataTransfer.getData(format);
|
|
147
|
+
} catch (ex) {
|
|
148
|
+
// The browser doesn't support custom mime type (IE11-)
|
|
149
|
+
legacyDataTransfer = true;
|
|
150
|
+
return this.getData(format);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
DataTransfer2.prototype.setData = function (format, data) {
|
|
155
|
+
this._checkFormat(format);
|
|
156
|
+
if (legacyDataTransfer) {
|
|
157
|
+
this._setLegacyDataTransfer(format, data);
|
|
158
|
+
} else {
|
|
159
|
+
try {
|
|
160
|
+
legacyDataTransfer = false;
|
|
161
|
+
this._dataTransfer.setData(format, data);
|
|
162
|
+
} catch (ex) {
|
|
163
|
+
// The browser doesn't support custom mime type (IE11-)
|
|
164
|
+
legacyDataTransfer = true;
|
|
165
|
+
this.setData(format, data);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
DataTransfer2.prototype.clearData = function (format) {
|
|
170
|
+
this._checkFormat(format);
|
|
171
|
+
if (legacyDataTransfer) {
|
|
172
|
+
this._clearLegacyDataTransfer(format);
|
|
173
|
+
} else {
|
|
174
|
+
try {
|
|
175
|
+
legacyDataTransfer = false;
|
|
176
|
+
this._dataTransfer.clearData(format);
|
|
177
|
+
} catch (ex) {
|
|
178
|
+
// The browser doesn't support custom mime type (IE11-)
|
|
179
|
+
legacyDataTransfer = true;
|
|
180
|
+
this.clearData(format);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
DataTransfer2.prototype._checkFormat = function (format) {
|
|
185
|
+
if (format && format.toLowerCase() !== format) {
|
|
186
|
+
throw new Error("Format must be in lowercase.");
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
DataTransfer2.prototype._getLegacyData = function () {
|
|
190
|
+
var allData = this._dataTransfer.getData("Text");
|
|
191
|
+
if (allData) {
|
|
192
|
+
if (allData.substr(0, this._prefixCode.length) === this._prefixCode) {
|
|
193
|
+
return JSON.parse(allData.substr(this._prefixCode.length));
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
return { Text: allData };
|
|
197
|
+
};
|
|
198
|
+
DataTransfer2.prototype._stringifyLegacyData = function (allData) {
|
|
199
|
+
return this._prefixCode + JSON.stringify(allData);
|
|
200
|
+
};
|
|
201
|
+
DataTransfer2.prototype._getLegacyDataTransfer = function (format) {
|
|
202
|
+
return this._getLegacyData()[format] || "";
|
|
203
|
+
};
|
|
204
|
+
DataTransfer2.prototype._setLegacyDataTransfer = function (format, data) {
|
|
205
|
+
var allData = this._getLegacyData();
|
|
206
|
+
allData[format] = data;
|
|
207
|
+
// Let's save the type... IE11 cannot read the types in a dragover event
|
|
208
|
+
savedTypes = allData;
|
|
209
|
+
this._dataTransfer.setData("Text", this._stringifyLegacyData(allData));
|
|
210
|
+
};
|
|
211
|
+
DataTransfer2.prototype._clearLegacyDataTransfer = function (format) {
|
|
212
|
+
savedTypes = {};
|
|
213
|
+
if (format) {
|
|
214
|
+
var allData = this._getLegacyData();
|
|
215
|
+
delete allData[format];
|
|
216
|
+
savedTypes = allData;
|
|
217
|
+
}
|
|
218
|
+
this._dataTransfer.setData(
|
|
219
|
+
"Text",
|
|
220
|
+
this._stringifyLegacyData(savedTypes)
|
|
221
|
+
);
|
|
222
|
+
};
|
|
223
|
+
return DataTransfer2;
|
|
224
|
+
})();
|
|
225
|
+
Main.DataTransfer2 = DataTransfer2;
|
|
226
|
+
// We need to clear the saved types once the dragend is emited.
|
|
227
|
+
document.addEventListener(
|
|
228
|
+
"dragend",
|
|
229
|
+
function () {
|
|
230
|
+
savedTypes = {};
|
|
231
|
+
},
|
|
232
|
+
false
|
|
233
|
+
);
|
|
234
|
+
})(Main || (Main = {}));
|
|
235
|
+
return Main;
|
|
236
|
+
});
|