/*global QUnit,sinon*/
sap.ui.define([
"jquery.sap.global",
"./TestControl",
"sap/ui/core/dnd/DropInfo",
"sap/ui/base/ManagedObject",
"sap/ui/core/ElementMetadata",
"sap/base/Log"
], function(jQuery, TestControl, DropInfo, ManagedObject, ElementMetadata, Log) {
"use strict";
QUnit.test("Default values", function(assert) {
var oDropInfo = new DropInfo();
assert.strictEqual(oDropInfo.getTargetAggregation(), "", "Default value of targetAggregation is correct");
assert.strictEqual(oDropInfo.getGroupName(), "", "Default value of targetAggregation is correct");
assert.strictEqual(oDropInfo.getDropEffect(), "Move", "Default value of dropEffect is correct");
assert.strictEqual(oDropInfo.getDropPosition(), "On", "Default value of dropPosition is correct");
assert.strictEqual(oDropInfo.getDropLayout(), "Default", "Default value of dropLayout is correct");
assert.strictEqual(oDropInfo.getEnabled(), true, "Default value of enabled is correct");
assert.strictEqual(oDropInfo.isDraggable(), false, "DropInfo is not draggable.");
oDropInfo.destroy();
});
QUnit.test("invalidation", function(assert) {
var oDropInfo = new DropInfo();
var fnInvalidateSpy = sinon.spy(oDropInfo, "invalidate");
oDropInfo.setEnabled(false);
assert.strictEqual(fnInvalidateSpy.callCount, 0, "Invalidation has not happened for enabled property");
oDropInfo.setGroupName("abc");
assert.strictEqual(fnInvalidateSpy.callCount, 0, "Invalidation has not happened for groupName property");
oDropInfo.setTargetAggregation("items");
assert.strictEqual(fnInvalidateSpy.callCount, 0, "Invalidation has not happened for targetAggregation property");
oDropInfo.setDropEffect("Copy");
assert.strictEqual(fnInvalidateSpy.callCount, 0, "Invalidation has not happened for dropEffect property");
oDropInfo.setDropPosition("Between");
assert.strictEqual(fnInvalidateSpy.callCount, 0, "Invalidation has not happened for dropPosition property");
oDropInfo.setDropLayout("Horizontal");
assert.strictEqual(fnInvalidateSpy.callCount, 0, "Invalidation has not happened for dropLayout property");
oDropInfo.destroy();
});
QUnit.test("TemporaryDropPosition", function(assert) {
var oDropInfo = new DropInfo();
oDropInfo.sTemporaryDropPosition = "Between";
assert.strictEqual(oDropInfo.getDropPosition(), "On", "Public API returns the correct DropPosition value");
assert.strictEqual(oDropInfo.getDropPosition(true), "Between", "Temporary DropPosition is returned when 1st param is true");
oDropInfo.destroy();
});
QUnit.test("getDropLayout", function(assert) {
var oDropInfo = new DropInfo({
targetAggregation: "test"
});
var oControl = new TestControl({
dragDropConfig: oDropInfo
});
assert.strictEqual(oDropInfo.getDropLayout(true), "Horizontal", "Default value is taken from metadata.dnd.layout");
oDropInfo.setDropLayout("Vertical");
assert.strictEqual(oDropInfo.getDropLayout(), "Vertical", "Public API returned the control value");
assert.strictEqual(oDropInfo.getDropLayout(true), "Vertical", "Nothing to detect property value is returned");
oControl.destroy();
});
QUnit.test("isDroppable - An unrelated element", function(assert) {
var oDropInfo = new DropInfo();
var oManagedObject = new ManagedObject();
assert.notOk(oDropInfo.isDroppable(undefined), "Not droppable: Drag target is not specified");
assert.notOk(oDropInfo.isDroppable(oManagedObject), "Not droppable: Drag target is not an instanceof Element");
oManagedObject.destroy();
oDropInfo.destroy();
});
QUnit.test("isDroppable - Test control not known to the DropInfo", function(assert) {
var oDropInfo = new DropInfo();
var oControl = new TestControl();
assert.notOk(oDropInfo.isDroppable(oControl), "Not droppable: The drop target is not known");
oDropInfo.destroy();
oControl.destroy();
});
QUnit.test("isDroppable - The control itself", function(assert) {
var oDropInfo = new DropInfo();
var oControl = new TestControl({
dragDropConfig: oDropInfo
});
assert.ok(oDropInfo.isDroppable(oControl), "Droppable: The drop target is the control itself");
oDropInfo.setTargetAggregation("children");
assert.notOk(oDropInfo.isDroppable(oControl), "Not Droppable: targetAggregation is defined");
oControl.destroy();
});
QUnit.test("isDroppable - Aggregated child element", function(assert) {
var oDropInfo = new DropInfo({
targetAggregation: "children"
});
var oControl = new TestControl();
var oParent = new TestControl({
dragDropConfig: oDropInfo,
children: oControl
});
assert.ok(oDropInfo.isDroppable(oControl), "Droppable: Child control is in the defined targetAggregation");
oDropInfo.setTargetAggregation("thereIsNoSuchAnAggregationName");
assert.notOk(oDropInfo.isDroppable(oControl), "Not Droppable: Child control is not in the defined targetAggregation");
oParent.destroy();
});
QUnit.test("isDroppable - Empty Aggregation", function(assert) {
var oDropInfo = new DropInfo({
targetAggregation: "children"
});
var oControl = new TestControl({
dragDropConfig: oDropInfo
});
var oEvent = new jQuery.Event("dragenter");
oControl.placeAt("qunit-fixture");
sap.ui.getCore().applyChanges();
oEvent.target = oControl.getDomRef("children");
assert.notOk(oDropInfo.isDroppable(oControl, oEvent), "Not Droppable: event target is the defined targetAggregation DOM");
assert.strictEqual(oEvent.getMark("DragWithin"), undefined, "Event is not marked as found aggregation name");
oEvent.target = oControl.getDomRef("children").firstChild;
assert.ok(oDropInfo.isDroppable(oControl, oEvent), "Droppable: event target is in the defined targetAggregation DOM");
assert.strictEqual(oEvent.getMark("DragWithin"), "children", "Event is not marked for the found aggregation name");
oEvent.target = oControl.getDomRef("title");
assert.notOk(oDropInfo.isDroppable(oControl, oEvent), "Not Droppable: event target is in the valid targetAggregation DOM");
oEvent.target = oControl.getDomRef();
assert.notOk(oDropInfo.isDroppable(oControl, oEvent), "Not Droppable: targetAggregation is defined control self is not the drop target.");
oControl.destroy();
});
QUnit.test("isDroppable - Enabled", function(assert) {
var oDropInfo = new DropInfo({
enabled: false
});
var oControl = new TestControl({
dragDropConfig: oDropInfo
});
assert.notOk(oDropInfo.isDroppable(oControl), "Not droppable: DropInfo is not enabled");
oDropInfo.setEnabled(true);
assert.ok(oDropInfo.isDroppable(oControl), "Droppable: DropInfo is enabled and drop target is the control itself");
oControl.destroy();
});
QUnit.test("isDroppable - metadata disallows", function(assert) {
var oDropInfo = new DropInfo();
var oChild = new TestControl();
var oParent = new TestControl({
dragDropConfig: oDropInfo,
children: oChild
});
var fnLogSpy = this.spy(Log, "warning");
this.stub(ElementMetadata.prototype, "getDragDropInfo").returns({droppable: false});
assert.notOk(oDropInfo.isDroppable(oParent), "Not droppable: Element metadata does not allow droppping");
assert.strictEqual(fnLogSpy.callCount, 1, "Not droppable is logged");
oDropInfo.setTargetAggregation("children");
assert.notOk(oDropInfo.isDroppable(oChild), "Not droppable: Aggregation metadata does not allow dropping");
assert.strictEqual(fnLogSpy.callCount, 2, "Not droppable is logged again");
oParent.destroy();
});
QUnit.test("fireDragEnter - invalid parameters", function(assert) {
var oDragEnterEvent = new jQuery.Event("dragenter");
var fnDragEnterSpy = sinon.spy();
var oDropInfo = new DropInfo({
dragEnter: fnDragEnterSpy
});
oDropInfo.fireDragEnter();
assert.ok(fnDragEnterSpy.notCalled, "dragEnter event is not fired, there is no parameter");
oDropInfo.fireDragEnter(oDragEnterEvent);
assert.ok(fnDragEnterSpy.notCalled, "dragEnter event is not fired, dragSession does not exist");
oDropInfo.destroy();
});
QUnit.test("fireDragEnter - event parameters", function(assert) {
var fnDragEnterSpy = sinon.spy(function(oEvent) {
var mParameters = oEvent.getParameters();
assert.ok(mParameters.dragSession, "dragSession exists");
assert.strictEqual(mParameters.target, oControl, "target is valid");
assert.strictEqual(mParameters.browserEvent, oDragEnterEvent.originalEvent, "browserEvent is valid");
});
var oDropInfo = new DropInfo({
dragEnter: fnDragEnterSpy
});
var oControl = new TestControl({
title: "Control",
dragDropConfig: oDropInfo
});
var oDragEnterEvent = new jQuery.Event("dragstart");
oDragEnterEvent.dragSession = {
getDropControl: function() {
return oControl;
}
};
var bEventValue = oDropInfo.fireDragEnter(oDragEnterEvent);
assert.ok(fnDragEnterSpy.calledOnce, "dragEnter event is fired once");
assert.ok(bEventValue, "dragEnter event is returned true");
oDropInfo.detachDragEnter(fnDragEnterSpy);
oDropInfo.attachDragEnter(function(oEvent) {
oEvent.preventDefault();
});
bEventValue = oDropInfo.fireDragEnter(oDragEnterEvent);
assert.notOk(bEventValue, "default is prevented for dragEnter event");
oControl.destroy();
});
QUnit.test("fireDragOver - invalid parameters", function(assert) {
var oDragOverEvent = new jQuery.Event("dragover");
var fnDragOverSpy = sinon.spy();
var oDropInfo = new DropInfo({
dragOver: fnDragOverSpy
});
oDropInfo.fireDragOver();
assert.ok(fnDragOverSpy.notCalled, "dragOver event is not fired, there is no parameter");
oDropInfo.fireDragOver(oDragOverEvent);
assert.ok(fnDragOverSpy.notCalled, "dragOver event is not fired, dragSession does not exist");
oDropInfo.destroy();
});
QUnit.test("fireDragOver - event parameters", function(assert) {
var fnDragOverSpy = sinon.spy(function(oEvent) {
var mParameters = oEvent.getParameters();
assert.ok(mParameters.dragSession, "dragSession exists");
assert.strictEqual(mParameters.target, oControl, "target is valid");
assert.strictEqual(mParameters.dropPosition, "On", "dropPosition is valid");
assert.strictEqual(mParameters.browserEvent, oDragOverEvent.originalEvent, "browserEvent is valid");
});
var oDropInfo = new DropInfo({
dragOver: fnDragOverSpy
});
var oControl = new TestControl({
title: "Control",
dragDropConfig: oDropInfo
});
var oDragOverEvent = new jQuery.Event("dragstart");
oDragOverEvent.dragSession = {
getDropControl: function() {
return oControl;
},
getDropPosition: function() {
return "On";
}
};
var bEventValue = oDropInfo.fireDragOver(oDragOverEvent);
assert.ok(fnDragOverSpy.calledOnce, "dragOver event is fired once");
assert.ok(bEventValue, "dragOver event is returned true");
oControl.destroy();
});
QUnit.test("fireDrop - invalid parameters", function(assert) {
var oDropEvent = new jQuery.Event("drop");
var fnDropSpy = sinon.spy();
var oDropInfo = new DropInfo({
drop: fnDropSpy
});
oDropInfo.fireDrop();
assert.ok(fnDropSpy.notCalled, "drop event is not fired, there is no parameter");
oDropInfo.fireDrop(oDropEvent);
assert.ok(fnDropSpy.notCalled, "drop event is not fired, dragSession does not exist");
oDropInfo.destroy();
});
QUnit.test("fireDrop - event parameters", function(assert) {
var fnDropSpy = sinon.spy(function(oEvent) {
var mParameters = oEvent.getParameters();
assert.ok(mParameters.dragSession, "dragSession exists");
assert.strictEqual(mParameters.browserEvent, oDropEvent.originalEvent, "browserEvent is valid");
assert.strictEqual(mParameters.draggedControl, oControl, "draggedControl is valid");
assert.strictEqual(mParameters.draggedControl, oControl, "droppedControl is valid");
assert.strictEqual(mParameters.dropPosition, "On", "dropPosition is valid");
});
var oDropInfo = new DropInfo({
drop: fnDropSpy
});
var oControl = new TestControl({
title: "Control",
dragDropConfig: oDropInfo
});
var oDropEvent = new jQuery.Event("dragstart");
oDropEvent.dragSession = {
getDropControl: function() {
return oControl;
},
getDragControl: function() {
return oControl;
},
getDropPosition: function() {
return oDropInfo.getDropPosition();
}
};
oDropInfo.fireDrop(oDropEvent);
assert.ok(fnDropSpy.calledOnce, "drop event is fired once");
oControl.destroy();
});
});
(function($) {
'use strict';
$(document).ready(function() {
/*
$("#dropper-default").dateDropper({
dropWidth: 200,
dropPrimaryColor: "#1abc9c",
dropBorder: "1px solid #1abc9c"
}),
$("#dropper-animation").dateDropper({
dropWidth: 200,
init_animation: "bounce",
dropPrimaryColor: "#1abc9c",
dropBorder: "1px solid #1abc9c"
}),
$("#dropper-format").dateDropper({
dropWidth: 200,
format: "F S, Y",
dropPrimaryColor: "#1abc9c",
dropBorder: "1px solid #1abc9c"
}),
$("#dropper-lang").dateDropper({
dropWidth: 200,
format: "F S, Y",
dropPrimaryColor: "#1abc9c",
dropBorder: "1px solid #1abc9c",
lang: "ar"
}),
$("#dropper-lock").dateDropper({
dropWidth: 200,
format: "F S, Y",
dropPrimaryColor: "#1abc9c",
dropBorder: "1px solid #1abc9c",
lock: "from"
}),
$("#dropper-max-year").dateDropper({
dropWidth: 200,
dropPrimaryColor: "#1abc9c",
dropBorder: "1px solid #1abc9c",
maxYear: "2020"
}),
$("#dropper-min-year").dateDropper({
dropWidth: 200,
dropPrimaryColor: "#1abc9c",
dropBorder: "1px solid #1abc9c",
minYear: "1990"
}),
$("#year-range").dateDropper({
dropWidth: 200,
dropPrimaryColor: "#1abc9c",
dropBorder: "1px solid #1abc9c",
yearsRange: "5"
}),
$("#dropper-width").dateDropper({
dropPrimaryColor: "#1abc9c",
dropBorder: "1px solid #1abc9c",
dropWidth: 500
}),
$("#dropper-dangercolor").dateDropper({
dropWidth: 200,
dropPrimaryColor: "#e74c3c",
dropBorder: "1px solid #e74c3c",
}),
$("#dropper-backcolor").dateDropper({
dropWidth: 200,
dropPrimaryColor: "#1abc9c",
dropBorder: "1px solid #1abc9c",
dropBackgroundColor: "#bdc3c7"
}),
$("#dropper-txtcolor").dateDropper({
dropWidth: 200,
dropPrimaryColor: "#46627f",
dropBorder: "1px solid #46627f",
dropTextColor: "#FFF",
dropBackgroundColor: "#e74c3c"
}),
$("#dropper-radius").dateDropper({
dropWidth: 200,
dropPrimaryColor: "#1abc9c",
dropBorder: "1px solid #1abc9c",
dropBorderRadius: "0"
}),
$("#dropper-border").dateDropper({
dropWidth: 200,
dropPrimaryColor: "#1abc9c",
dropBorder: "2px solid #1abc9c"
}),
$("#dropper-shadow").dateDropper({
dropWidth: 200,
dropPrimaryColor: "#1abc9c",
dropBorder: "1px solid #1abc9c",
dropBorderRadius: "20px",
dropShadow: "0 0 20px 0 rgba(26, 188, 156, 0.6)"
}),
*/
$('#inlinedatetimepicker').datetimepicker({
inline: true,
sideBySide: true
});
$('#datepicker').datetimepicker({
format: 'L'
});
$('#timepicker').datetimepicker({
format: 'LT'
});
$('.demo').each( function() {
//
// Dear reader, it's actually very easy to initialize MiniColors. For example:
//
// $(selector).minicolors();
//
// The way I've done it below is just for the demo, so don't get confused
// by it. Also, data- attributes aren't supported at this time...they're
// only used for this demo.
//
$(this).minicolors({
control: $(this).attr('data-control') || 'hue',
defaultValue: $(this).attr('data-defaultValue') || '',
format: $(this).attr('data-format') || 'hex',
keywords: $(this).attr('data-keywords') || '',
inline: $(this).attr('data-inline') === 'true',
letterCase: $(this).attr('data-letterCase') || 'lowercase',
opacity: $(this).attr('data-opacity'),
position: $(this).attr('data-position') || 'bottom left',
swatches: $(this).attr('data-swatches') ? $(this).attr('data-swatches').split('|') : [],
change: function(value, opacity) {
if( !value ) return;
if( opacity ) value += ', ' + opacity;
if( typeof console === 'object' ) {
console.log(value);
}
},
theme: 'bootstrap'
});
});
})
})(jQuery);
define([
'../../Core/defaultValue',
'../../Core/defined',
'../../Core/defineProperties',
'../../Core/DeveloperError',
'../../Core/Event',
'../../Core/wrapFunction',
'../../DataSources/CzmlDataSource',
'../../DataSources/GeoJsonDataSource',
'../../DataSources/KmlDataSource',
'../getElement'
], function(
defaultValue,
defined,
defineProperties,
DeveloperError,
Event,
wrapFunction,
CzmlDataSource,
GeoJsonDataSource,
KmlDataSource,
getElement) {
'use strict';
/**
* A mixin which adds default drag and drop support for CZML files to the Viewer widget.
* Rather than being called directly, this function is normally passed as
* a parameter to {@link Viewer#extend}, as shown in the example below.
* @exports viewerDragDropMixin
*
* @param {Viewer} viewer The viewer instance.
* @param {Object} [options] Object with the following properties:
* @param {Element|String} [options.dropTarget=viewer.container] The DOM element which will serve as the drop target.
* @param {Boolean} [options.clearOnDrop=true] When true, dropping files will clear all existing data sources first, when false, new data sources will be loaded after the existing ones.
* @param {Boolean} [options.flyToOnDrop=true] When true, dropping files will fly to the data source once it is loaded.
* @param {Boolean} [options.clampToGround=true] When true, datasources are clamped to the ground.
* @param {DefaultProxy} [options.proxy] The proxy to be used for KML network links.
*
* @exception {DeveloperError} Element with id <options.dropTarget> does not exist in the document.
* @exception {DeveloperError} dropTarget is already defined by another mixin.
* @exception {DeveloperError} dropEnabled is already defined by another mixin.
* @exception {DeveloperError} dropError is already defined by another mixin.
* @exception {DeveloperError} clearOnDrop is already defined by another mixin.
*
* @example
* // Add basic drag and drop support and pop up an alert window on error.
* var viewer = new Cesium.Viewer('cesiumContainer');
* viewer.extend(Cesium.viewerDragDropMixin);
* viewer.dropError.addEventListener(function(viewerArg, source, error) {
* window.alert('Error processing ' + source + ':' + error);
* });
*/
function viewerDragDropMixin(viewer, options) {
//>>includeStart('debug', pragmas.debug);
if (!defined(viewer)) {
throw new DeveloperError('viewer is required.');
}
if (viewer.hasOwnProperty('dropTarget')) {
throw new DeveloperError('dropTarget is already defined by another mixin.');
}
if (viewer.hasOwnProperty('dropEnabled')) {
throw new DeveloperError('dropEnabled is already defined by another mixin.');
}
if (viewer.hasOwnProperty('dropError')) {
throw new DeveloperError('dropError is already defined by another mixin.');
}
if (viewer.hasOwnProperty('clearOnDrop')) {
throw new DeveloperError('clearOnDrop is already defined by another mixin.');
}
if (viewer.hasOwnProperty('flyToOnDrop')) {
throw new DeveloperError('flyToOnDrop is already defined by another mixin.');
}
//>>includeEnd('debug');
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
//Local variables to be closed over by defineProperties.
var dropEnabled = true;
var flyToOnDrop = defaultValue(options.flyToOnDrop, true);
var dropError = new Event();
var clearOnDrop = defaultValue(options.clearOnDrop, true);
var dropTarget = defaultValue(options.dropTarget, viewer.container);
var clampToGround = defaultValue(options.clampToGround, true);
var proxy = options.proxy;
dropTarget = getElement(dropTarget);
defineProperties(viewer, {
/**
* Gets or sets the element to serve as the drop target.
* @memberof viewerDragDropMixin.prototype
* @type {Element}
*/
dropTarget : {
//TODO See https://github.com/AnalyticalGraphicsInc/cesium/issues/832
get : function() {
return dropTarget;
},
set : function(value) {
//>>includeStart('debug', pragmas.debug);
if (!defined(value)) {
throw new DeveloperError('value is required.');
}
//>>includeEnd('debug');
unsubscribe(dropTarget, handleDrop);
dropTarget = value;
subscribe(dropTarget, handleDrop);
}
},
/**
* Gets or sets a value indicating if drag and drop support is enabled.
* @memberof viewerDragDropMixin.prototype
* @type {Element}
*/
dropEnabled : {
get : function() {
return dropEnabled;
},
set : function(value) {
if (value !== dropEnabled) {
if (value) {
subscribe(dropTarget, handleDrop);
} else {
unsubscribe(dropTarget, handleDrop);
}
dropEnabled = value;
}
}
},
/**
* Gets the event that will be raised when an error is encountered during drop processing.
* @memberof viewerDragDropMixin.prototype
* @type {Event}
*/
dropError : {
get : function() {
return dropError;
}
},
/**
* Gets or sets a value indicating if existing data sources should be cleared before adding the newly dropped sources.
* @memberof viewerDragDropMixin.prototype
* @type {Boolean}
*/
clearOnDrop : {
get : function() {
return clearOnDrop;
},
set : function(value) {
clearOnDrop = value;
}
},
/**
* Gets or sets a value indicating if the camera should fly to the data source after it is loaded.
* @memberof viewerDragDropMixin.prototype
* @type {Boolean}
*/
flyToOnDrop : {
get : function() {
return flyToOnDrop;
},
set : function(value) {
flyToOnDrop = value;
}
},
/**
* Gets or sets the proxy to be used for KML.
* @memberof viewerDragDropMixin.prototype
* @type {DefaultProxy}
*/
proxy : {
get : function() {
return proxy;
},
set : function(value) {
proxy = value;
}
},
/**
* Gets or sets a value indicating if the datasources should be clamped to the ground
* @memberof viewerDragDropMixin.prototype
* @type {Boolean}
*/
clampToGround : {
get : function() {
return clampToGround;
},
set : function(value) {
clampToGround = value;
}
}
});
function handleDrop(event) {
stop(event);
if (clearOnDrop) {
viewer.entities.removeAll();
viewer.dataSources.removeAll();
}
var files = event.dataTransfer.files;
var length = files.length;
for (var i = 0; i < length; i++) {
var file = files[i];
var reader = new FileReader();
reader.onload = createOnLoadCallback(viewer, file, proxy, clampToGround);
reader.onerror = createDropErrorCallback(viewer, file);
reader.readAsText(file);
}
}
//Enable drop by default;
subscribe(dropTarget, handleDrop);
//Wrap the destroy function to make sure all events are unsubscribed from
viewer.destroy = wrapFunction(viewer, viewer.destroy, function() {
viewer.dropEnabled = false;
});
//Specs need access to handleDrop
viewer._handleDrop = handleDrop;
}
function stop(event) {
event.stopPropagation();
event.preventDefault();
}
function unsubscribe(dropTarget, handleDrop) {
var currentTarget = dropTarget;
if (defined(currentTarget)) {
currentTarget.removeEventListener('drop', handleDrop, false);
currentTarget.removeEventListener('dragenter', stop, false);
currentTarget.removeEventListener('dragover', stop, false);
currentTarget.removeEventListener('dragexit', stop, false);
}
}
function subscribe(dropTarget, handleDrop) {
dropTarget.addEventListener('drop', handleDrop, false);
dropTarget.addEventListener('dragenter', stop, false);
dropTarget.addEventListener('dragover', stop, false);
dropTarget.addEventListener('dragexit', stop, false);
}
function createOnLoadCallback(viewer, file, proxy, clampToGround) {
var scene = viewer.scene;
return function(evt) {
var fileName = file.name;
try {
var loadPromise;
if (/\.czml$/i.test(fileName)) {
loadPromise = CzmlDataSource.load(JSON.parse(evt.target.result), {
sourceUri : fileName
});
} else if (/\.geojson$/i.test(fileName) || /\.json$/i.test(fileName) || /\.topojson$/i.test(fileName)) {
loadPromise = GeoJsonDataSource.load(JSON.parse(evt.target.result), {
sourceUri : fileName,
clampToGround : clampToGround
});
} else if (/\.(kml|kmz)$/i.test(fileName)) {
loadPromise = KmlDataSource.load(file, {
sourceUri : fileName,
proxy : proxy,
camera : scene.camera,
canvas : scene.canvas
});
} else {
viewer.dropError.raiseEvent(viewer, fileName, 'Unrecognized file: ' + fileName);
return;
}
if (defined(loadPromise)) {
viewer.dataSources.add(loadPromise).then(function(dataSource) {
if (viewer.flyToOnDrop) {
viewer.flyTo(dataSource);
}
}).otherwise(function(error) {
viewer.dropError.raiseEvent(viewer, fileName, error);
});
}
} catch (error) {
viewer.dropError.raiseEvent(viewer, fileName, error);
}
};
}
function createDropErrorCallback(viewer, file) {
return function(evt) {
viewer.dropError.raiseEvent(viewer, file.name, evt.target.error);
};
}
return viewerDragDropMixin;
});
/*!
* ${copyright}
*/
sap.ui.define([
"sap/ui/Device",
"../UIArea",
"sap/ui/thirdparty/jquery",
// jQuery Plugin "control"
"sap/ui/dom/jquery/control"
],
function(Device, UIArea, jQuery) {
"use strict";
var DnD = {},
oDragControl = null, // the control being dragged
oDropControl = null, // the current drop target control
oValidDropControl = null, // the control which the dragged control can be dropped on based on the valid drop info
aValidDragInfos = [], // valid DragInfos configured for the currently dragged source
aValidDropInfos = [], // valid DropInfos configured for the current drop target
oDragSession = null, // stores active drag session throughout a drag activity
$DropIndicator, // drop position indicator
$GhostContainer, // container to place custom ghosts
sCalculatedDropPosition, // calculated position of the drop action relative to the valid dropped control.
iTargetEnteringTime; // timestamp of drag enter
function addStyleClass(oElement, sStyleClass) {
if (!oElement) {
return;
}
if (oElement.addStyleClass) {
oElement.addStyleClass(sStyleClass);
} else {
oElement.$().addClass(sStyleClass);
}
}
function removeStyleClass(oElement, sStyleClass) {
if (!oElement) {
return;
}
if (oElement.removeStyleClass) {
oElement.removeStyleClass(sStyleClass);
} else {
oElement.$().removeClass(sStyleClass);
}
}
function dispatchEvent(oEvent, sEventName) {
var oControl = jQuery(oEvent.target).control(0, true);
if (!oControl) {
return;
}
var oNewEvent = jQuery.Event(null, oEvent);
oNewEvent.type = sEventName;
oControl.getUIArea()._handleEvent(oNewEvent);
}
function setDragGhost(oDragControl, oEvent) {
if (Device.browser.msie || !oDragControl || !oDragControl.getDragGhost) {
return;
}
var oDragGhost = oDragControl.getDragGhost();
if (!oDragGhost) {
return;
}
if (!$GhostContainer) {
$GhostContainer = jQuery('<div class="sapUiDnDGhostContainer"></div>');
jQuery(document.body).append($GhostContainer);
}
$GhostContainer.append(oDragGhost);
window.setTimeout(function() { $GhostContainer.empty(); }, 0);
var oOriginalEvent = oEvent.originalEvent;
oOriginalEvent.dataTransfer.setDragImage(oDragGhost, oOriginalEvent.offsetX, oOriginalEvent.offsetY);
}
function createDragSession(oEvent) {
var mData = {},
mIndicatorConfig,
oDataTransfer = oEvent.originalEvent.dataTransfer,
setTransferData = function(sType, sData) {
// set to original dataTransfer object if type is supported by the current browser (non-text causes error in IE+Edge)
if (oDataTransfer && sType == "text" || (Device.browser != "msie" && Device.browser != "edge")) {
oDataTransfer.setData(sType, sData);
}
};
/**
* When a user requests to drag some controls that can be dragged, a drag session is started.
* The drag session can be used to transfer data between applications or between dragged and dropped controls.
* Please see provided APIs for more details.
*
* <b>Note:</b> This object only exists during a drag-and-drop operation.
*
* @namespace
* @name sap.ui.core.dnd.DragSession
* @static
* @abstract
* @public
*/
return /** @lends sap.ui.core.dnd.DragSession */ {
/**
* Sets string data with any MIME type.
* <b>Note:</b> This works in all browsers, apart from Internet Explorer and Microsoft Edge. It also works if you navigate between
* different windows.
*
* @param {string} sKey The key of the data
* @param {string} sData Data
* @public
*/
setData: function(sKey, sData) {
sData = "" + sData;
mData[sKey] = sData;
setTransferData(sKey, sData);
},
/**
* Returns the data that has been set via <code>setData</code> method.
*
* @param {string} sKey The key of the data
* @returns {string} Data
* @public
*/
getData: function(sKey) {
return mData[sKey];
},
/**
* Sets string data with plain text MIME type.
* <b>Note:</b> This works in all browsers, including Internet Explorer and Microsoft Edge. It also works if you navigate between
* different windows.
*
* @param {string} sData Data
* @public
*/
setTextData: function(sData) {
sData = "" + sData;
mData["text/plain"] = sData;
mData["text"] = sData;
setTransferData("text/plain", sData);
setTransferData("text", sData);
},
/**
* Returns the data that has been set via <code>setTextData</code> method.
*
* @returns {string} Data
* @public
*/
getTextData: function() {
return mData["text/plain"];
},
/**
* Sets any type of data (even functions, pointers, anything non-serializable) with any MIME type.
* This works in all browsers, including Internet Explorer and Microsoft Edge, but only within a UI5 application within the same
* window/frame.
*
* @param {string} sKey The key of the data
* @param {any} vData Data
*/
setComplexData: function(sKey, vData) {
mData[sKey] = vData;
},
/**
* Returns the data that has been set via <code>setComplexData</code> method.
*
* @param {string} sKey The key of the data
* @returns {any} The previously set data or undefined
* @public
*/
getComplexData: function(sKey) {
return mData[sKey];
},
/**
* Returns the drop indicator.
*
* @returns {HTMLElement|null} Drop indicator's DOM reference
* @protected
*/
getIndicator: function() {
return $DropIndicator && $DropIndicator[0];
},
/**
* Defines the visual configuration of the drop indicator for the current <code>DropInfo</code>.
*
* @param {object} mConfig Custom styles of the drop indicator.
* @protected
*/
setIndicatorConfig: function(mConfig) {
mIndicatorConfig = mConfig;
},
/**
* Returns the visual configuration of the drop indicator.
*
* @returns {object} Drop indicator configuration
* @protected
*/
getIndicatorConfig: function(mConfig) {
return mIndicatorConfig;
},
/**
* Returns the dragged control, if available within the same UI5 application frame.
*
* @returns {sap.ui.core.Element|null}
* @protected
*/
getDragControl: function() {
return oDragControl;
},
/**
* The valid drop target underneath the dragged control.
*
* @returns {sap.ui.core.Element|null}
* @protected
*/
getDropControl: function() {
return oValidDropControl;
},
/**
* Set the valid drop control.
*
* @protected
*/
setDropControl: function(oControl) {
oValidDropControl = oControl;
},
/**
* Returns the drop configuration corresponding to the drop control.
*
* @returns {sap.ui.core.dnd.DropInfo|null}
* @protected
*/
getDropInfo: function() {
return aValidDropInfos[0] || null;
},
/**
* Returns the calculated position of the drop action relative to the valid dropped control.
*
* @returns {String}
* @protected
*/
getDropPosition: function() {
return sCalculatedDropPosition;
}
};
}
function closeDragSession(oEvent) {
hideDropIndicator();
removeStyleClass(oDragControl, "sapUiDnDDragging");
oDragControl = oDropControl = oValidDropControl = oDragSession = null;
sCalculatedDropPosition = "";
aValidDragInfos = [];
aValidDropInfos = [];
}
function getDropIndicator() {
if ($DropIndicator) {
return $DropIndicator;
}
$DropIndicator = jQuery("<div class='sapUiDnDIndicator'></div>");
jQuery(sap.ui.getCore().getStaticAreaRef()).append($DropIndicator);
return $DropIndicator;
}
function hideDropIndicator() {
if ($DropIndicator) {
$DropIndicator.removeAttr("style").hide();
}
}
function showDropIndicator(oEvent, oDropTarget, sDropPosition, sDropLayout) {
if (!oDropTarget) {
return;
}
var mIndicatorConfig = oEvent.dragSession && oEvent.dragSession.getIndicatorConfig(),
mClientRect = oDropTarget.getBoundingClientRect(),
iPageYOffset = window.pageYOffset,
iPageXOffset = window.pageXOffset,
$Indicator = getDropIndicator(),
sRelativePosition,
mStyle = {},
mDropRect = {
top: mClientRect.top + iPageYOffset,
bottom: mClientRect.bottom + iPageYOffset,
left: mClientRect.left + iPageXOffset,
right: mClientRect.right + iPageXOffset,
width: mClientRect.width,
height: mClientRect.height
};
if (!sDropPosition || sDropPosition == "On") {
sRelativePosition = "On";
sDropLayout = "";
} else if (sDropLayout == "Horizontal") {
var iCursorX = oEvent.pageX - mDropRect.left;
mStyle.height = mDropRect.height;
mStyle.top = mDropRect.top;
if (sDropPosition == "Between") {
mStyle.width = "";
if (iCursorX < mDropRect.width * 0.5) {
sRelativePosition = "Before";
mStyle.left = mDropRect.left;
} else {
sRelativePosition = "After";
mStyle.left = mDropRect.right;
}
} else if (sDropPosition == "OnOrBetween") {
if (iCursorX < mDropRect.width * 0.25) {
sRelativePosition = "Before";
mStyle.left = mDropRect.left;
mStyle.width = "";
} else if (iCursorX > mDropRect.width * 0.75) {
sRelativePosition = "After";
mStyle.left = mDropRect.right;
mStyle.width = "";
} else {
sRelativePosition = "On";
}
}
} else {
var iCursorY = oEvent.pageY - mDropRect.top;
mStyle.width = mDropRect.width;
mStyle.left = mDropRect.left;
if (sDropPosition == "Between") {
mStyle.height = "";
if (iCursorY < mDropRect.height * 0.5) {
sRelativePosition = "Before";
mStyle.top = mDropRect.top;
} else {
sRelativePosition = "After";
mStyle.top = mDropRect.bottom;
}
} else if (sDropPosition == "OnOrBetween") {
if (iCursorY < mDropRect.height * 0.25) {
sRelativePosition = "Before";
mStyle.top = mDropRect.top;
mStyle.height = "";
} else if (iCursorY > mDropRect.height * 0.75) {
sRelativePosition = "After";
mStyle.top = mDropRect.bottom;
mStyle.height = "";
} else {
sRelativePosition = "On";
}
}
}
if (mIndicatorConfig && mIndicatorConfig.display == "none") {
return sRelativePosition;
}
if (sRelativePosition == "On") {
mStyle.top = mDropRect.top;
mStyle.left = mDropRect.left;
mStyle.width = mDropRect.width;
mStyle.height = mDropRect.height;
sDropPosition = sRelativePosition;
} else {
sDropPosition = "Between";
}
$Indicator.attr("data-drop-layout", sDropLayout);
$Indicator.attr("data-drop-position", sDropPosition);
$Indicator.css(jQuery.extend(mStyle, mIndicatorConfig)).show();
return sRelativePosition;
}
function getDragDropConfigs(oControl) {
var oParent = oControl.getParent(),
aSelfConfigs = (oControl.getDragDropConfig) ? oControl.getDragDropConfig() : [],
aParentConfigs = (oParent && oParent.getDragDropConfig) ? oParent.getDragDropConfig() : [];
return aSelfConfigs.concat(aParentConfigs);
}
function getValidDragInfos(oDragControl) {
var aDragDropConfigs = getDragDropConfigs(oDragControl);
return aDragDropConfigs.filter(function(oDragOrDropInfo) {
return oDragOrDropInfo.isDraggable(oDragControl);
});
}
function getValidDropInfos(oDropControl, aDragInfos, oEvent) {
var aDragDropConfigs = getDragDropConfigs(oDropControl);
aDragInfos = aDragInfos || [];
return aDragDropConfigs.filter(function(oDragOrDropInfo) {
// DragDropInfo defined at the drop target is irrelevant we only need DropInfos
return !oDragOrDropInfo.isA("sap.ui.core.dnd.IDragInfo");
}).concat(aDragInfos).filter(function(oDropInfo) {
if (!oDropInfo.isDroppable(oDropControl, oEvent)) {
return false;
}
// master group matches always
var sDropGroupName = oDropInfo.getGroupName();
if (!sDropGroupName) {
return true;
}
// group name matching
return aDragInfos.some(function(oDragInfo) {
return oDragInfo.getGroupName() == sDropGroupName;
});
});
}
function setDropEffect(oEvent, oDropInfo) {
// allow dropping
oEvent.preventDefault();
// set visual drop indicator from drop info
var sDropEffect = oDropInfo.getDropEffect().toLowerCase();
oEvent.originalEvent.dataTransfer.dropEffect = sDropEffect;
}
function showDropPosition(oEvent, oDropInfo, oValidDropControl) {
// no target aggregation so entire control is the target
var sTargetAggregation = oDropInfo.getTargetAggregation();
if (!sTargetAggregation) {
return showDropIndicator(oEvent, oValidDropControl.getDomRef());
}
// whether the current DOM element corresponds to the configured aggregation
var oTargetDomRef;
if (oEvent.getMark("DragWithin") == sTargetAggregation) {
oTargetDomRef = oValidDropControl.getDomRefForSetting(sTargetAggregation);
}
// not dragging over an aggregated child of the element
oTargetDomRef = oTargetDomRef || oValidDropControl.getDomRef();
// let the user know the drop position
return showDropIndicator(oEvent, oTargetDomRef, oDropInfo.getDropPosition(true), oDropInfo.getDropLayout(true));
}
// before controls handle UIArea events
DnD.preprocessEvent = function(oEvent) {
if (oDragSession && oEvent.type.indexOf("dr") == 0) {
// attach dragSession to all drag events
oEvent.dragSession = oDragSession;
}
var sEventHandler = "onbefore" + oEvent.type;
if (DnD[sEventHandler]) {
DnD[sEventHandler](oEvent);
}
};
// after controls handle UIArea events
DnD.postprocessEvent = function(oEvent) {
var sEventHandler = "onafter" + oEvent.type;
if (DnD[sEventHandler]) {
DnD[sEventHandler](oEvent);
}
};
DnD.onbeforedragstart = function(oEvent) {
// draggable implicitly
if (!oEvent.target.draggable) {
return;
}
// the text inside input fields should still be selectable
if (/^(input|textarea)$/i.test(document.activeElement.tagName)) {
return;
}
// identify the control being dragged
oDragControl = jQuery(oEvent.target).control(0, true);
if (!oDragControl) {
return;
}
// identify and remember the applicable DragInfos
aValidDragInfos = getValidDragInfos(oDragControl);
if (!aValidDragInfos.length) {
return;
}
// firefox needs data set to allow dragging
if (Device.browser.firefox && oEvent.originalEvent.dataTransfer.types.length === 0) {
oEvent.originalEvent.dataTransfer.setData("ui5/dummyDataForFirefox", "data");
}
// create the drag session object and attach to the event
oEvent.dragSession = oDragSession = createDragSession(oEvent);
};
DnD.onafterdragstart = function(oEvent) {
// drag is not possible if preventDefault is called for dragstart event
if (!aValidDragInfos.length || oEvent.isDefaultPrevented()) {
closeDragSession();
return;
}
// fire dragstart event of valid DragInfos and filter if preventDefault is called
aValidDragInfos = oEvent.isMarked("NonDraggable") ? [] : aValidDragInfos.filter(function(oDragInfo) {
return oDragInfo.fireDragStart(oEvent);
});
// check whether drag is possible
if (!aValidDragInfos.length) {
oEvent.preventDefault();
closeDragSession();
return;
}
// set custom drag ghost
setDragGhost(oDragControl, oEvent);
// set dragging class of the drag source
addStyleClass(oDragControl, "sapUiDnDDragging");
};
DnD.onbeforedragenter = function(oEvent) {
// check whether we remain within the same control
var oControl = jQuery(oEvent.target).control(0, true);
if (oControl && oDropControl === oControl) {
oEvent.setMark("DragWithin", "SameControl");
} else {
iTargetEnteringTime = Date.now();
oDropControl = oControl;
}
var aDropInfos = [];
oValidDropControl = oControl;
// find the first valid drop control and corresponding valid DropInfos at the control hierarchy
for (var i = 0; i < 20 && oValidDropControl; i++, oValidDropControl = oValidDropControl.getParent()) {
aDropInfos = getValidDropInfos(oValidDropControl, aValidDragInfos, oEvent);
if (aDropInfos.length) {
break;
}
}
// if we are not dragging within the same control we can update valid drop infos
if (oEvent.getMark("DragWithin") != "SameControl") {
aValidDropInfos = aDropInfos;
if (oDragSession) {
oDragSession.setIndicatorConfig(null);
}
}
// no valid drop info found
if (!aValidDropInfos.length) {
oValidDropControl = null;
} else if (!oDragSession) {
// something is dragged from outside the browser
oEvent.dragSession = oDragSession = createDragSession(oEvent);
}
};
DnD.onafterdragenter = function(oEvent) {
// drop is not possible if there is no valid drop control or dragenter event is marked as NonDroppable
if (!oValidDropControl || oEvent.isMarked("NonDroppable")) {
aValidDropInfos = [];
} else if (oEvent.getMark("DragWithin") != "SameControl") {
// fire dragenter event of valid DropInfos and filter if preventDefault is called
aValidDropInfos = aValidDropInfos.filter(function(oDropInfo) {
return oDropInfo.fireDragEnter(oEvent);
});
}
// set drop effect and drop position
var oValidDropInfo = aValidDropInfos[0];
if (!oValidDropInfo || oValidDropInfo.getDropEffect() == "None") {
hideDropIndicator();
sCalculatedDropPosition = "";
} else {
setDropEffect(oEvent, oValidDropInfo);
sCalculatedDropPosition = showDropPosition(oEvent, oValidDropInfo, oValidDropControl);
}
};
DnD.onbeforedragover = function(oEvent) {
// handle longdragover event
var iCurrentTime = Date.now();
if (iCurrentTime - iTargetEnteringTime >= 1000) {
dispatchEvent(oEvent, "longdragover");
iTargetEnteringTime = iCurrentTime;
}
};
DnD.onafterdragover = function(oEvent) {
var oValidDropInfo = aValidDropInfos[0];
// let the browser do the default if there is no valid drop info
if (!oValidDropInfo || oValidDropInfo.getDropEffect() == "None") {
return;
}
// fire dragover events of valid DropInfos
aValidDropInfos.forEach(function(oDropInfo) {
oDropInfo.fireDragOver(oEvent);
});
// browsers drop effect must be set on dragover always
setDropEffect(oEvent, oValidDropInfo);
// drop position is set already at dragenter it should not be changed for DropPosition=On
if (oValidDropInfo && oValidDropInfo.getDropPosition(true) == "On") {
return;
}
// drop indicator position may change depending on the mouse pointer location
sCalculatedDropPosition = showDropPosition(oEvent, oValidDropInfo, oValidDropControl);
};
DnD.onbeforedrop = function(oEvent) {
// prevent default action
if (aValidDropInfos.length) {
oEvent.preventDefault();
}
};
DnD.onafterdrop = function(oEvent) {
// fire drop events of valid DropInfos
aValidDropInfos.forEach(function(oDropInfo) {
oDropInfo.fireDrop(oEvent);
});
// dragend event is not dispatched if the dragged element is removed
this.iDragEndTimer = window.requestAnimationFrame(this.onafterdragend.bind(this, oEvent));
};
DnD.onafterdragend = function(oEvent) {
// cleanup the timer if there is a waiting job on the queue
this.iDragEndTimer = window.cancelAnimationFrame(this.iDragEndTimer);
// fire dragend event of valid DragInfos
aValidDragInfos.forEach(function(oDragInfo) {
oDragInfo.fireDragEnd(oEvent);
});
// finalize drag session
closeDragSession();
};
// process the events of the UIArea
UIArea.addEventPreprocessor(DnD.preprocessEvent);
UIArea.addEventPostprocessor(DnD.postprocessEvent);
return DnD;
}, /* bExport= */ true);
/*=========================================================================================
File Name: date-time-dropper.js
Description: Datepicker and Timepicker plugins based on jQuery
----------------------------------------------------------------------------------------
Item Name: Modern Admin - Clean Bootstrap 4 Dashboard HTML Template
Version: 3.0
Author: GeeksLabs
Author URL: http://www.themeforest.net/user/geekslabs
==========================================================================================*/
$(document).ready(function(){
/********************************************
* Date Dropper *
********************************************/
// Options
// Animate
$('#animate').dateDropper({
dropWidth: 200
});
// Init Animation
$('#init_animation').dateDropper({
dropWidth: 200,
init_animation: 'bounce'
});
// Format
$('#format').dateDropper({
dropWidth: 200,
format: 'j l, F, Y'
});
// Lang
$('#lang').dateDropper({
dropWidth: 200,
lang: 'ar' // Arabic
});
// Lock
$('#lock').dateDropper({
dropWidth: 200,
lock: 'from' // To select date after today, 'to' to select date before today
});
// Max Year
$('#maxYear').dateDropper({
dropWidth: 200,
maxYear: '2020'
});
// Min Year
$('#minYear').dateDropper({
dropWidth: 200,
minYear: '2001'
});
// Years Range
$('#yearsRange').dateDropper({
dropWidth: 200,
yearsRange: '5'
});
// Styles
// Drop Primary Color
$('#dropPrimaryColor').dateDropper({
dropWidth: 200,
dropPrimaryColor: '#F6BB42',
dropBorder: '1px solid #F6BB42'
});
// Drop Text Color
$('#dropTextColor').dateDropper({
dropWidth: 200,
dropPrimaryColor: '#10617E',
dropBorder: '1px solid #10617E',
dropBackgroundColor: '#23b1e3',
dropTextColor: '#FFF'
});
// Drop Background Color
$('#dropBackgroundColor').dateDropper({
dropWidth: 200,
dropBackgroundColor: '#ACDAEC',
});
// Drop Border
$('#dropBorder').dateDropper({
dropWidth: 200,
dropPrimaryColor: '#2fb594',
dropBorder: '1px solid #2dad8d',
});
// Drop Border Radius
$('#dropBorderRadius').dateDropper({
dropWidth: 200,
dropPrimaryColor: '#e8273a',
dropBorder: '1px solid #e71e32',
dropBorderRadius: '0'
});
// Drop Shadow
$('#dropShadow').dateDropper({
dropWidth: 200,
dropPrimaryColor: '#fa4420',
dropBorder: '1px solid #fa4420',
dropBorderRadius: '20',
dropShadow: '0 0 10px 0 rgba(250, 68, 32, 0.6)'
});
// Drop Width
$('#dropWidth').dateDropper({
dropWidth: 250
});
// Drop Text Weight
$('#dropTextWeight').dateDropper({
dropWidth: 200,
dropTextWeight: 'normal'
});
/********************************************
* Time Dropper *
********************************************/
// Options
// Auto Switch
$('#autoswitch').timeDropper();
// Meridians
$('#meridians').timeDropper({
meridians: true
});
// Format
$('#timeformat').timeDropper({
format: 'HH:mm A'
});
// Mousewheel
$('#mousewheel').timeDropper({
mousewheel: true
});
// Init Animation
$('#time_init_animation').timeDropper({
init_animation: 'dropDown',
meridians: true
});
// Set Current Time
$('#setCurrentTime').timeDropper();
// Styles
// Primary Color
$('#primaryColor').timeDropper({
primaryColor: '#2fb594',
borderColor: '#2fb594'
});
// Text Color
$('#textColor').timeDropper({
primaryColor: '#2fb594',
textColor: '#e8273a'
});
// Background Color
$('#backgroundColor').timeDropper({
primaryColor: '#FFF',
backgroundColor: '#fa4420',
borderColor: '#781602',
textColor: '#781602'
});
// Border Color
$('#borderColor').timeDropper({
primaryColor: '#FFF',
backgroundColor: '#23b1e3',
borderColor: '#FFF',
textColor: '#FFF'
});
});
Accelerate Your Automation Test Cycles With LambdaTest
Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.