From 05f934548b3dee7f3407500a31396a14b49af2a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Sat, 13 Jun 2015 22:16:07 +0200 Subject: [PATCH] Moved angular-native-dragdrop to bower --- bower.json | 3 +- public/app/components/require.config.js | 4 +- public/test/test-main.js | 2 +- .../angular-native-dragdrop/.bower.json | 37 ++ .../angular-native-dragdrop/Gulpfile.js | 15 + public/vendor/angular-native-dragdrop/LICENSE | 10 + .../vendor/angular-native-dragdrop/README.md | 35 ++ .../vendor/angular-native-dragdrop/bower.json | 27 ++ .../demo/css/styles.css | 29 ++ .../angular-native-dragdrop/demo/index.html | 129 ++++++ .../angular-native-dragdrop/demo/js/app.js | 46 +++ .../docs/css/styles.css | 32 ++ .../angular-native-dragdrop/docs/index.html | 323 +++++++++++++++ .../angular-native-dragdrop/draganddrop.js | 370 +++++++++++++++++ .../angular-native-dragdrop/package.json | 24 ++ .../vendor/angular-other/angular-dragdrop.js | 381 ------------------ 16 files changed, 1081 insertions(+), 386 deletions(-) create mode 100644 public/vendor/angular-native-dragdrop/.bower.json create mode 100644 public/vendor/angular-native-dragdrop/Gulpfile.js create mode 100644 public/vendor/angular-native-dragdrop/LICENSE create mode 100644 public/vendor/angular-native-dragdrop/README.md create mode 100644 public/vendor/angular-native-dragdrop/bower.json create mode 100644 public/vendor/angular-native-dragdrop/demo/css/styles.css create mode 100644 public/vendor/angular-native-dragdrop/demo/index.html create mode 100644 public/vendor/angular-native-dragdrop/demo/js/app.js create mode 100644 public/vendor/angular-native-dragdrop/docs/css/styles.css create mode 100644 public/vendor/angular-native-dragdrop/docs/index.html create mode 100644 public/vendor/angular-native-dragdrop/draganddrop.js create mode 100644 public/vendor/angular-native-dragdrop/package.json delete mode 100644 public/vendor/angular-other/angular-dragdrop.js diff --git a/bower.json b/bower.json index 7ef6ce1a8fa..8646eb1d19f 100644 --- a/bower.json +++ b/bower.json @@ -17,6 +17,7 @@ "angular": "~1.4.0", "angular-route": "~1.4.0", "angular-mocks": "~1.4.0", - "angular-sanitize": "~1.4.0" + "angular-sanitize": "~1.4.0", + "angular-native-dragdrop": "~1.1.0" } } diff --git a/public/app/components/require.config.js b/public/app/components/require.config.js index 44c2c7aaa8d..44dd21476e3 100644 --- a/public/app/components/require.config.js +++ b/public/app/components/require.config.js @@ -1,4 +1,3 @@ - require.config({ urlArgs: 'bust=' + (new Date().getTime()), baseUrl: 'public/app', @@ -17,7 +16,7 @@ require.config({ angular: '../vendor/angular/angular', 'angular-route': '../vendor/angular-route/angular-route', 'angular-sanitize': '../vendor/angular-sanitize/angular-sanitize', - 'angular-dragdrop': '../vendor/angular-other/angular-dragdrop', + 'angular-dragdrop': '../vendor/angular-native-dragdrop/draganddrop', 'angular-strap': '../vendor/angular-other/angular-strap', timepicker: '../vendor/angular-other/timepicker', datepicker: '../vendor/angular-other/datepicker', @@ -101,5 +100,4 @@ require.config({ 'bootstrap-tagsinput': ['jquery'], }, - waitSeconds: 60, }); diff --git a/public/test/test-main.js b/public/test/test-main.js index 720a34b31df..59bd4cbe1ee 100644 --- a/public/test/test-main.js +++ b/public/test/test-main.js @@ -21,7 +21,7 @@ require.config({ 'angular-route': '../vendor/angular-route/angular-route', 'angular-sanitize': '../vendor/angular-sanitize/angular-sanitize', angularMocks: '../vendor/angular-mocks/angular-mocks', - 'angular-dragdrop': '../vendor/angular-other/angular-dragdrop', + 'angular-dragdrop': '../vendor/angular-native-dragdrop/draganddrop', 'angular-strap': '../vendor/angular-other/angular-strap', timepicker: '../vendor/angular-other/timepicker', datepicker: '../vendor/angular-other/datepicker', diff --git a/public/vendor/angular-native-dragdrop/.bower.json b/public/vendor/angular-native-dragdrop/.bower.json new file mode 100644 index 00000000000..d270f02ab32 --- /dev/null +++ b/public/vendor/angular-native-dragdrop/.bower.json @@ -0,0 +1,37 @@ +{ + "name": "angular-native-dragdrop", + "version": "1.1.0", + "homepage": "http://angular-dragdrop.github.io/angular-dragdrop", + "authors": [ + "ganarajpr" + ], + "description": "Angular HTML5 Drag and Drop directive written in pure with no dependency on JQuery.", + "main": "draganddrop.js", + "keywords": [ + "angular", + "drag", + "drop", + "html5" + ], + "dependencies": { + "angular": "~1.3" + }, + "license": "MIT", + "ignore": [ + "**/.*", + "node_modules", + "bower_components", + "test", + "tests" + ], + "_release": "1.1.0", + "_resolution": { + "type": "version", + "tag": "1.1.0", + "commit": "737981e86bd32a5432fa9edf09059ca3c0f22049" + }, + "_source": "git://github.com/angular-dragdrop/angular-dragdrop.git", + "_target": "~1.1.0", + "_originalSource": "angular-native-dragdrop", + "_direct": true +} \ No newline at end of file diff --git a/public/vendor/angular-native-dragdrop/Gulpfile.js b/public/vendor/angular-native-dragdrop/Gulpfile.js new file mode 100644 index 00000000000..0aa3bdfff72 --- /dev/null +++ b/public/vendor/angular-native-dragdrop/Gulpfile.js @@ -0,0 +1,15 @@ +/* jshint -W097 */ +'use strict'; + +/* global require */ +var jshint = require('gulp-jshint'); +var stylish = require('jshint-stylish'); +var gulp = require('gulp'); + +gulp.task('lint', function() { + return gulp.src('./draganddrop.js') + .pipe(jshint()) + .pipe(jshint.reporter(stylish)); +}); + +gulp.task('default', ['lint']); diff --git a/public/vendor/angular-native-dragdrop/LICENSE b/public/vendor/angular-native-dragdrop/LICENSE new file mode 100644 index 00000000000..d239cb9e0d3 --- /dev/null +++ b/public/vendor/angular-native-dragdrop/LICENSE @@ -0,0 +1,10 @@ + +The MIT License + +Copyright (c) 2015 Ganaraj P R, [Nebithi](http://www.nebithi.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/public/vendor/angular-native-dragdrop/README.md b/public/vendor/angular-native-dragdrop/README.md new file mode 100644 index 00000000000..e668ec4cef4 --- /dev/null +++ b/public/vendor/angular-native-dragdrop/README.md @@ -0,0 +1,35 @@ +#Angular-DragDrop +[![Build status](http://img.shields.io/travis/angular-dragdrop/angular-dragdrop.svg?style=flat)](https://travis-ci.org/angular-dragdrop/angular-dragdrop) +[![Gitter](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/ganarajpr/angular-dragdrop?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) + +Angular-DragDrop is a angular HTML5 Drag and Drop directive written in pure with no dependency on JQuery. + +This is based on the work done by Jason Turim. While this [blog post](http://jasonturim.wordpress.com/2013/09/01/angularjs-drag-and-drop/) was the inspiration for creating a native Drag and Drop solution, the intention was to create something that was more generic. + +This implementation is mainly different from the one posted in the blog in the following areas : + +1. Angular-DragDrop does not create an isolate scope. This has huge benefits when it comes to working with other directives. **NOTE :** It also does not pollute the scope with any variables or functions. + +2. It does not depend on any kind of an ID attribute ( being either present or generated on the fly ). + +3. It allows one to create channels on which different drag and drop directive combinations can work on in the same page ( more on this later ) . + +Pull requests are welcome. + +[Documentation](http://angular-dragdrop.github.io/angular-dragdrop/) + +#Looking for Active Contributors. + +This repo needs active contributers and maintainers. If you are interested in being one of the people who would like to actively maintain this repo, please let me know. + + + +The MIT License + +Copyright (c) 2014 Ganaraj P R, [Nebithi](http://www.nebithi.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/public/vendor/angular-native-dragdrop/bower.json b/public/vendor/angular-native-dragdrop/bower.json new file mode 100644 index 00000000000..af96e3b4444 --- /dev/null +++ b/public/vendor/angular-native-dragdrop/bower.json @@ -0,0 +1,27 @@ +{ + "name": "angular-native-dragdrop", + "version": "1.0.8", + "homepage": "http://angular-dragdrop.github.io/angular-dragdrop", + "authors": [ + "ganarajpr" + ], + "description": "Angular HTML5 Drag and Drop directive written in pure with no dependency on JQuery.", + "main": "draganddrop.js", + "keywords": [ + "angular", + "drag", + "drop", + "html5" + ], + "dependencies": { + "angular": "~1.3" + }, + "license": "MIT", + "ignore": [ + "**/.*", + "node_modules", + "bower_components", + "test", + "tests" + ] +} diff --git a/public/vendor/angular-native-dragdrop/demo/css/styles.css b/public/vendor/angular-native-dragdrop/demo/css/styles.css new file mode 100644 index 00000000000..4dd18383697 --- /dev/null +++ b/public/vendor/angular-native-dragdrop/demo/css/styles.css @@ -0,0 +1,29 @@ +body { + background-color: #f8f7f8; +} + +.heading { + border-bottom: 1px solid #b7b7b7; + padding-bottom: 10px; + margin-bottom: 10px; +} + +.topRow { + margin-bottom: 30px; +} + +.on-drag-enter { + background-color : #677ba6; +} + +.on-drag-enter-custom { + background-color : #d78cc7; +} + +.on-drag-hover { + background-color : #3eb352; +} + +.on-drag-hover-custom { + background-color : #d7a931; +} \ No newline at end of file diff --git a/public/vendor/angular-native-dragdrop/demo/index.html b/public/vendor/angular-native-dragdrop/demo/index.html new file mode 100644 index 00000000000..b945a19e835 --- /dev/null +++ b/public/vendor/angular-native-dragdrop/demo/index.html @@ -0,0 +1,129 @@ + + + + + + Angular DragDrop (Demo) + + + + + + + + + + +
+
+

+ Drag and drop between the two lists. +

+
+ +

Beasts

+ +

Left column of beasts is not draggable and accepts both beasts and priests

+ +
+ +
+
+
    +
  • + {{man}} +
  • +
+
+
+
    +
  • + {{woman}} +
  • +
+
+
+ +
+ +

Priests

+ +
+ +
+
+
    +
  • + {{man}} +
  • +
+
+
+
    +
  • + {{woman}} +
  • +
+
+
+ +
+ +

Terrorists

+ +

Each terrorist list item accepts a new terrorist. Shows inserting into a particular + position in an array.

+ +
+ + +
+
+
    +
  • + {{man}} +
  • +
+
+
+
    +
  • + {{woman}} +
  • +
+
+
+
+ + + diff --git a/public/vendor/angular-native-dragdrop/demo/js/app.js b/public/vendor/angular-native-dragdrop/demo/js/app.js new file mode 100644 index 00000000000..7fca20ac0ce --- /dev/null +++ b/public/vendor/angular-native-dragdrop/demo/js/app.js @@ -0,0 +1,46 @@ +angular.module('app', [ + 'hljs', + 'ang-drag-drop' +]).controller('MainCtrl', function($scope) { + $scope.men = [ + 'John', + 'Jack', + 'Mark', + 'Ernie', + 'Mike (Locked)' + ]; + + + $scope.women = [ + 'Jane', + 'Jill', + 'Betty', + 'Mary' + ]; + + $scope.addText = ''; + + $scope.dropValidateHandler = function($drop, $event, $data) { + if ($data === 'Mike (Locked)') { + return false; + } + if ($drop.element[0] === $event.srcElement.parentNode) { + // Don't allow moving to same container + return false; + } + return true; + }; + + $scope.dropSuccessHandler = function($event, index, array) { + array.splice(index, 1); + }; + + $scope.onDrop = function($event, $data, array, index) { + if (index !== undefined) { + array.splice(index, 0, $data); + } else { + array.push($data); + } + }; + +}); diff --git a/public/vendor/angular-native-dragdrop/docs/css/styles.css b/public/vendor/angular-native-dragdrop/docs/css/styles.css new file mode 100644 index 00000000000..d4480e8b536 --- /dev/null +++ b/public/vendor/angular-native-dragdrop/docs/css/styles.css @@ -0,0 +1,32 @@ +.content { + margin : 50px auto; + font-size: 1.0em; + line-height: 1.5em; +} + +.content a{ + color: #677BA6; + cursor: pointer; +} + +body { + background-color: #f8f7f8; +} + +.jumbotron h1, +.jumbotron p{ + font-family: 'Open Sans'; +} + +.heading{ + border-bottom: 1px solid #b7b7b7; + padding-bottom: 10px; + margin-bottom: 10px; +} + +.ribbon{ + position: fixed; + top : 0; + right : 0; + z-index: 2000; +} \ No newline at end of file diff --git a/public/vendor/angular-native-dragdrop/docs/index.html b/public/vendor/angular-native-dragdrop/docs/index.html new file mode 100644 index 00000000000..25603db4e34 --- /dev/null +++ b/public/vendor/angular-native-dragdrop/docs/index.html @@ -0,0 +1,323 @@ + + + + Angular DragDrop + + + + + + + + + + +Fork me on GitHub +
+
+

Angular Drag and Drop

+ +

Angular-DragDrop is a AngularJS HTML5 Drag and Drop directive written in pure with no dependency on JQuery.

+ + +
+ + +
+
+

Directives

+
+ +

ui-draggable

+ +

+ directive in module ngDragDrop +

+ +

The ui-draggable attribute tells Angular that the element is draggable. ui-draggable + takes an expression as the attribute value. The expression should evaluate to either true or false. + You can toggle the draggability of an element using this expression. +

+ + +

Additional Attributes

+ +

drag

+ +

The drag property is used to assign the data that needs to be passed along with the dragging + element.

+
+

drag-handle-class

+ +

The class used to mark child elements of draggable object to be used as drag handle. Default class name is + drag-handle.

+
+ NOTE: If attribute is not present drag handle feature is not active. +
+
+

on-drop-success

+ +

The on-drop-success attribute takes a function. We can consider this to be an on-drop-success + handler function. + This can be useful if you need to do some post processing after the dragged element is dropped successfully on + the drop site. + +

+ NOTE: This callback function is only called when the drop succeeds. +
+ You can request the drag-end event ( very similiar to requesting the click event in + ng-click ) + by passing $event in the event handler. +

+ +
+

on-drop-failure

+ +

The on-drop-failure attribute takes a function. We can consider this to be an on-drop-failure + handler function. + This can be useful if you need to do some post processing after the dragged element is dropped unsuccessfully on + any drop site. + +

+ NOTE: This callback function is only called when the drop fails. +
+ You can request the drag-end event ( very similiar to requesting the click event in + ng-click ) + by passing $event in the event handler. +

+ + +
+

Usage

+ +

+ +

+ ... + +
+

+ +

Details

+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ParamTypeDetails
ui-draggableExpression that should be + evaluated. The given expression should resolve to true or false. +
dragTakes any JSON convertable $scope variable.
drag-handle-classClass name used to mark child elements of draggable object to be used as drag handle.
If attribute + is not present drag handle feature is not used.
If attribute is present but have no value + drag-handle used as default.
on-drop-successTakes any $scope function. Can also pass $event.
on-drop-failureTakes any $scope function. Can also pass $event.
drag-channelTakes a string that can be used as the channel name for the dragging operation. + Default channel is "defaultchannel" +
+

+
+ +

Events

+ +

On start of dragging an Angular Event ANGULAR_DRAG_START is dispatched from the + $rootScope. The event also carries + carries the information about the channel in which the dragging has started. +

+ +

On end of dragging an Angular Event ANGULAR_DRAG_END is dispatched from the $rootScope. + The event also carries + carries the information about the channel in which the dragging has started. +

+ +

When hovering a draggable element on top of a drop area an Angular Event ANGULAR_HOVER + is dispatched from the $rootScope. + The event also carries the information about the channel in which the dragging has started. +

+ +
+ +

ui-on-drop

+ +

+ directive in module ngDragDrop +

+ +

The ui-on-drop attribute tells Angular that the element is a drop site. ui-on-drop + takes a function as the attribute value. The function will be called when a valid dragged element is dropped in + that location. + A valid dragged element is one which has the same channel as the drop location. + +

+ NOTE : This callback function is only called when the drop succeeds. +
+ The ui-on-drop callback can request additional parameters. The data that is dragged is available to the + callback as $data and its channel as $channel. Apart from this the drop event is exposed as $event. +

+

Additional Attributes

+ +

drop-channel

+ +

The channel that the drop site accepts. The dragged element should have the same channel as this drop site for it + to be droppable at this location. It is possible to provide comma separated list of channels. + +

+ NOTE: Also special value of drag-channel attribute is available to accept + dragged element with any channel value — * +
+

+ +
+ +

drop-validate

+ +

Extra validation that makes sure that the drop site accepts the dragged element beyond having the same channel. If + not defined, no extra validation is made. + +

+ NOTE: This callback function is called only if the channel condition is met, when the element + starts being dragged +
+

+ +
+ +

drag-enter-class

+ +

The class that will be added to the the droppable element when a dragged element ( which is droppable ) + enters the drop location. The default value for this is on-drag-enter

+ +

drag-hover-class

+ +

The class that will be added to the drop area element when hovering with an element. + The default value for this is on-drag-hover

+ +
+

Usage

+ +

+ +

+ ... +
+

+ +

Details

+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ParamTypeDetails
ui-on-dropTakes any $scope function. Can also pass $event, $data and $channel. +
drop-channelThe channel on which the drop has to listen for drag events.
+ Single value, comma separated list or special value * are possible
drop-validateTakes any $scope function. Can also pass $data and $channel +
drag-enter-classA class name that will be put on the droppable element when the dragged objects enters its boundaries. +
Default class name is on-drag-enter.
drag-hover-classA class name that will be put on the drop area when an element is dragged onto it.
Default class + name is on-drag-hover.
+

+
+

Demo

+ + + +
+ + + + + + diff --git a/public/vendor/angular-native-dragdrop/draganddrop.js b/public/vendor/angular-native-dragdrop/draganddrop.js new file mode 100644 index 00000000000..f45b47df4d9 --- /dev/null +++ b/public/vendor/angular-native-dragdrop/draganddrop.js @@ -0,0 +1,370 @@ +(function(angular) { + 'use strict'; + + function isDnDsSupported() { + return 'ondrag' in document.createElement('a'); + } + + if (!isDnDsSupported()) { + angular.module('ang-drag-drop', []); + return; + } + + if (window.jQuery && (-1 === window.jQuery.event.props.indexOf('dataTransfer'))) { + window.jQuery.event.props.push('dataTransfer'); + } + + var module = angular.module('ang-drag-drop', []); + + module.directive('uiDraggable', ['$parse', '$rootScope', '$dragImage', function($parse, $rootScope, $dragImage) { + return function(scope, element, attrs) { + var isDragHandleUsed = false, + dragHandleClass, + draggingClass = attrs.draggingClass || 'on-dragging', + dragTarget; + + element.attr('draggable', false); + + scope.$watch(attrs.uiDraggable, function(newValue) { + if (newValue) { + element.attr('draggable', newValue); + element.bind('dragend', dragendHandler); + element.bind('dragstart', dragstartHandler); + } + else { + element.removeAttr('draggable'); + element.unbind('dragend', dragendHandler); + element.unbind('dragstart', dragstartHandler); + } + + }); + + if (angular.isString(attrs.dragHandleClass)) { + isDragHandleUsed = true; + dragHandleClass = attrs.dragHandleClass.trim() || 'drag-handle'; + + element.bind('mousedown', function(e) { + dragTarget = e.target; + }); + } + + function dragendHandler(e) { + setTimeout(function() { + element.unbind('$destroy', dragendHandler); + }, 0); + var sendChannel = attrs.dragChannel || 'defaultchannel'; + $rootScope.$broadcast('ANGULAR_DRAG_END', e, sendChannel); + if (e.dataTransfer && e.dataTransfer.dropEffect !== 'none') { + if (attrs.onDropSuccess) { + var onDropSuccessFn = $parse(attrs.onDropSuccess); + scope.$evalAsync(function() { + onDropSuccessFn(scope, {$event: e}); + }); + } else { + if (attrs.onDropFailure) { + var onDropFailureFn = $parse(attrs.onDropFailure); + scope.$evalAsync(function() { + onDropFailureFn(scope, {$event: e}); + }); + } + } + } + element.removeClass(draggingClass); + } + + function dragstartHandler(e) { + var isDragAllowed = !isDragHandleUsed || dragTarget.classList.contains(dragHandleClass); + + if (isDragAllowed) { + var sendChannel = attrs.dragChannel || 'defaultchannel'; + var dragData = ''; + if (attrs.drag) { + dragData = scope.$eval(attrs.drag); + } + + var dragImage = attrs.dragImage || null; + + element.addClass(draggingClass); + element.bind('$destroy', dragendHandler); + + if (dragImage) { + var dragImageFn = $parse(attrs.dragImage); + scope.$apply(function() { + var dragImageParameters = dragImageFn(scope, {$event: e}); + if (dragImageParameters) { + if (angular.isString(dragImageParameters)) { + dragImageParameters = $dragImage.generate(dragImageParameters); + } + if (dragImageParameters.image) { + var xOffset = dragImageParameters.xOffset || 0, + yOffset = dragImageParameters.yOffset || 0; + e.dataTransfer.setDragImage(dragImageParameters.image, xOffset, yOffset); + } + } + }); + } + + var transferDataObject = {data: dragData, channel: sendChannel} + var transferDataText = angular.toJson(transferDataObject); + + e.dataTransfer.setData('text', transferDataText); + e.dataTransfer.effectAllowed = 'copyMove'; + + $rootScope.$broadcast('ANGULAR_DRAG_START', e, sendChannel, transferDataObject); + } + else { + e.preventDefault(); + } + } + }; + } + ]); + + module.directive('uiOnDrop', ['$parse', '$rootScope', function($parse, $rootScope) { + return function(scope, element, attr) { + var dragging = 0; //Ref. http://stackoverflow.com/a/10906204 + var dropChannel = attr.dropChannel || 'defaultchannel'; + var dragChannel = ''; + var dragEnterClass = attr.dragEnterClass || 'on-drag-enter'; + var dragHoverClass = attr.dragHoverClass || 'on-drag-hover'; + var customDragEnterEvent = $parse(attr.onDragEnter); + var customDragLeaveEvent = $parse(attr.onDragLeave); + + function onDragOver(e) { + if (e.preventDefault) { + e.preventDefault(); // Necessary. Allows us to drop. + } + + if (e.stopPropagation) { + e.stopPropagation(); + } + + var uiOnDragOverFn = $parse(attr.uiOnDragOver); + scope.$evalAsync(function() { + uiOnDragOverFn(scope, {$event: e, $channel: dropChannel}); + }); + + return false; + } + + function onDragLeave(e) { + if (e.preventDefault) { + e.preventDefault(); + } + + if (e.stopPropagation) { + e.stopPropagation(); + } + dragging--; + + if (dragging === 0) { + scope.$evalAsync(function() { + customDragLeaveEvent(scope, {$event: e, $channel: dropChannel}); + }); + element.addClass(dragEnterClass); + element.removeClass(dragHoverClass); + } + + var uiOnDragLeaveFn = $parse(attr.uiOnDragLeave); + scope.$evalAsync(function() { + uiOnDragLeaveFn(scope, {$event: e, $channel: dropChannel}); + }); + } + + function onDragEnter(e) { + if (e.preventDefault) { + e.preventDefault(); + } + + if (e.stopPropagation) { + e.stopPropagation(); + } + + if (dragging === 0) { + scope.$evalAsync(function() { + customDragEnterEvent(scope, {$event: e, $channel: dropChannel}); + }); + element.removeClass(dragEnterClass); + element.addClass(dragHoverClass); + } + dragging++; + + var uiOnDragEnterFn = $parse(attr.uiOnDragEnter); + scope.$evalAsync(function() { + uiOnDragEnterFn(scope, {$event: e, $channel: dropChannel}); + }); + + $rootScope.$broadcast('ANGULAR_HOVER', dragChannel); + } + + function onDrop(e) { + if (e.preventDefault) { + e.preventDefault(); // Necessary. Allows us to drop. + } + if (e.stopPropagation) { + e.stopPropagation(); // Necessary. Allows us to drop. + } + + var sendData = e.dataTransfer.getData('text'); + sendData = angular.fromJson(sendData); + + // Chrome doesn't set dropEffect, so we have to work it out ourselves + if (e.dataTransfer.dropEffect === 'none') { + if (e.dataTransfer.effectAllowed === 'copy' || + e.dataTransfer.effectAllowed === 'move') { + e.dataTransfer.dropEffect = e.dataTransfer.effectAllowed; + } else if (e.dataTransfer.effectAllowed === 'copyMove') { + e.dataTransfer.dropEffect = e.ctrlKey ? 'copy' : 'move'; + } + } + + var uiOnDropFn = $parse(attr.uiOnDrop); + scope.$evalAsync(function() { + uiOnDropFn(scope, {$data: sendData.data, $event: e, $channel: sendData.channel}); + }); + element.removeClass(dragEnterClass); + dragging = 0; + } + + function isDragChannelAccepted(dragChannel, dropChannel) { + if (dropChannel === '*') { + return true; + } + + var channelMatchPattern = new RegExp('(\\s|[,])+(' + dragChannel + ')(\\s|[,])+', 'i'); + + return channelMatchPattern.test(',' + dropChannel + ','); + } + + function preventNativeDnD(e) { + if (e.preventDefault) { + e.preventDefault(); + } + if (e.stopPropagation) { + e.stopPropagation(); + } + e.dataTransfer.dropEffect = 'none'; + return false; + } + + var deregisterDragStart = $rootScope.$on('ANGULAR_DRAG_START', function(_, e, channel, transferDataObject) { + dragChannel = channel; + + var valid = true; + + if (!isDragChannelAccepted(channel, dropChannel)) { + valid = false; + } + + if (valid && attr.dropValidate) { + var validateFn = $parse(attr.dropValidate); + valid = validateFn(scope, {$drop: {scope: scope, element:element}, $event:e, $data: transferDataObject.data, $channel: transferDataObject.channel}); + } + + if (valid) { + element.bind('dragover', onDragOver); + element.bind('dragenter', onDragEnter); + element.bind('dragleave', onDragLeave); + element.bind('drop', onDrop); + + element.addClass(dragEnterClass); + } else { + element.bind('dragover', preventNativeDnD); + element.bind('dragenter', preventNativeDnD); + element.bind('dragleave', preventNativeDnD); + element.bind('drop', preventNativeDnD); + + element.removeClass(dragEnterClass); + } + + }); + + + var deregisterDragEnd = $rootScope.$on('ANGULAR_DRAG_END', function(_, e, channel) { + element.unbind('dragover', onDragOver); + element.unbind('dragenter', onDragEnter); + element.unbind('dragleave', onDragLeave); + + element.unbind('drop', onDrop); + element.removeClass(dragHoverClass); + element.removeClass(dragEnterClass); + + element.unbind('dragover', preventNativeDnD); + element.unbind('dragenter', preventNativeDnD); + element.unbind('dragleave', preventNativeDnD); + element.unbind('drop', preventNativeDnD); + }); + + scope.$on('$destroy', function() { + deregisterDragStart(); + deregisterDragEnd(); + }); + + + attr.$observe('dropChannel', function(value) { + if (value) { + dropChannel = value; + } + }); + + + }; + } + ]); + + module.constant('$dragImageConfig', { + height: 20, + width: 200, + padding: 10, + font: 'bold 11px Arial', + fontColor: '#eee8d5', + backgroundColor: '#93a1a1', + xOffset: 0, + yOffset: 0 + }); + + module.service('$dragImage', ['$dragImageConfig', function(defaultConfig) { + var ELLIPSIS = '…'; + + function fitString(canvas, text, config) { + var width = canvas.measureText(text).width; + if (width < config.width) { + return text; + } + while (width + config.padding > config.width) { + text = text.substring(0, text.length - 1); + width = canvas.measureText(text + ELLIPSIS).width; + } + return text + ELLIPSIS; + } + + this.generate = function(text, options) { + var config = angular.extend({}, defaultConfig, options || {}); + var el = document.createElement('canvas'); + + el.height = config.height; + el.width = config.width; + + var canvas = el.getContext('2d'); + + canvas.fillStyle = config.backgroundColor; + canvas.fillRect(0, 0, config.width, config.height); + canvas.font = config.font; + canvas.fillStyle = config.fontColor; + + var title = fitString(canvas, text, config); + canvas.fillText(title, 4, config.padding + 4); + + var image = new Image(); + image.src = el.toDataURL(); + + return { + image: image, + xOffset: config.xOffset, + yOffset: config.yOffset + }; + }; + } + ]); + +}(angular)); diff --git a/public/vendor/angular-native-dragdrop/package.json b/public/vendor/angular-native-dragdrop/package.json new file mode 100644 index 00000000000..4e9871d3ee7 --- /dev/null +++ b/public/vendor/angular-native-dragdrop/package.json @@ -0,0 +1,24 @@ +{ + "name": "angular-native-dragdrop", + "version": "1.0.8", + "description": "Angular HTML5 Drag and Drop directive written in pure with no dependency on JQuery.", + "main": "draganddrop.js", + "scripts": { + "test": "gulp" + }, + "repository": { + "type": "git", + "url": "https://github.com/angular-dragdrop/angular-dragdrop.git" + }, + "author": "ganarajpr", + "license": "MIT", + "bugs": { + "url": "https://github.com/angular-dragdrop/angular-dragdrop/issues" + }, + "homepage": "http://angular-dragdrop.github.io/angular-dragdrop", + "devDependencies": { + "gulp": "^3.8.11", + "gulp-jshint": "^1.9.2", + "jshint-stylish": "^1.0.1" + } +} diff --git a/public/vendor/angular-other/angular-dragdrop.js b/public/vendor/angular-other/angular-dragdrop.js deleted file mode 100644 index 40fb1c9e814..00000000000 --- a/public/vendor/angular-other/angular-dragdrop.js +++ /dev/null @@ -1,381 +0,0 @@ -/** - * Created with IntelliJ IDEA. - * User: Ganaraj.Pr - * Date: 11/10/13 - * Time: 11:27 - * To change this template use File | Settings | File Templates. - */ - -(function(angular){ - -function isDnDsSupported(){ - return 'ondrag' in document.createElement("a"); -} - -if(!isDnDsSupported()){ - angular.module("ang-drag-drop", []); - return; -} - -if (window.jQuery && (-1 == window.jQuery.event.props.indexOf("dataTransfer"))) { - window.jQuery.event.props.push("dataTransfer"); -} - -var currentData; - -angular.module("ang-drag-drop",[]) - .directive("uiDraggable", [ - '$parse', - '$rootScope', - '$dragImage', - function ($parse, $rootScope, $dragImage) { - return function (scope, element, attrs) { - var dragData = "", - isDragHandleUsed = false, - dragHandleClass, - draggingClass = attrs.draggingClass || "on-dragging", - dragTarget; - - element.attr("draggable", false); - - attrs.$observe("uiDraggable", function (newValue) { - if(newValue){ - element.attr("draggable", newValue); - } - else{ - element.removeAttr("draggable"); - } - - }); - - if (attrs.drag) { - scope.$watch(attrs.drag, function (newValue) { - dragData = newValue || ""; - }); - } - - if (angular.isString(attrs.dragHandleClass)) { - isDragHandleUsed = true; - dragHandleClass = attrs.dragHandleClass.trim() || "drag-handle"; - - element.bind("mousedown", function (e) { - dragTarget = e.target; - }); - } - - function dragendHandler(e) { - setTimeout(function() { - element.unbind('$destroy', dragendHandler); - }, 0); - var sendChannel = attrs.dragChannel || "defaultchannel"; - $rootScope.$broadcast("ANGULAR_DRAG_END", sendChannel); - if (e.dataTransfer && e.dataTransfer.dropEffect !== "none") { - if (attrs.onDropSuccess) { - var fn = $parse(attrs.onDropSuccess); - scope.$evalAsync(function () { - fn(scope, {$event: e}); - }); - } else { - if (attrs.onDropFailure) { - var fn = $parse(attrs.onDropFailure); - scope.$evalAsync(function () { - fn(scope, {$event: e}); - }); - } - } - } - element.removeClass(draggingClass); - } - - element.bind("dragend", dragendHandler); - - element.bind("dragstart", function (e) { - var isDragAllowed = !isDragHandleUsed || dragTarget.classList.contains(dragHandleClass); - - if (isDragAllowed) { - var sendChannel = attrs.dragChannel || "defaultchannel"; - var sendData = angular.toJson({ data: dragData, channel: sendChannel }); - var dragImage = attrs.dragImage || null; - - element.addClass(draggingClass); - element.bind('$destroy', dragendHandler); - - if (dragImage) { - var dragImageFn = $parse(attrs.dragImage); - scope.$evalAsync(function() { - var dragImageParameters = dragImageFn(scope, {$event: e}); - if (dragImageParameters) { - if (angular.isString(dragImageParameters)) { - dragImageParameters = $dragImage.generate(dragImageParameters); - } - if (dragImageParameters.image) { - var xOffset = dragImageParameters.xOffset || 0, - yOffset = dragImageParameters.yOffset || 0; - e.dataTransfer.setDragImage(dragImageParameters.image, xOffset, yOffset); - } - } - }); - } - - e.dataTransfer.setData("dataToSend", sendData); - currentData = angular.fromJson(sendData); - e.dataTransfer.effectAllowed = "copyMove"; - $rootScope.$broadcast("ANGULAR_DRAG_START", sendChannel, currentData.data); - } - else { - e.preventDefault(); - } - }); - }; - } - ]) - .directive("uiOnDrop", [ - '$parse', - '$rootScope', - function ($parse, $rootScope) { - return function (scope, element, attr) { - var dragging = 0; //Ref. http://stackoverflow.com/a/10906204 - var dropChannel = attr.dropChannel || "defaultchannel" ; - var dragChannel = ""; - var dragEnterClass = attr.dragEnterClass || "on-drag-enter"; - var dragHoverClass = attr.dragHoverClass || "on-drag-hover"; - var customDragEnterEvent = $parse(attr.onDragEnter); - var customDragLeaveEvent = $parse(attr.onDragLeave); - - function onDragOver(e) { - if (e.preventDefault) { - e.preventDefault(); // Necessary. Allows us to drop. - } - - if (e.stopPropagation) { - e.stopPropagation(); - } - - var fn = $parse(attr.uiOnDragOver); - scope.$evalAsync(function () { - fn(scope, {$event: e, $channel: dropChannel}); - }); - - e.dataTransfer.dropEffect = e.shiftKey ? 'copy' : 'move'; - return false; - } - - function onDragLeave(e) { - if (e.preventDefault) { - e.preventDefault(); - } - - if (e.stopPropagation) { - e.stopPropagation(); - } - dragging--; - - if (dragging == 0) { - scope.$evalAsync(function () { - customDragEnterEvent(scope, {$event: e}); - }); - element.removeClass(dragHoverClass); - } - - var fn = $parse(attr.uiOnDragLeave); - scope.$evalAsync(function () { - fn(scope, {$event: e, $channel: dropChannel}); - }); - } - - function onDragEnter(e) { - if (e.preventDefault) { - e.preventDefault(); - } - - if (e.stopPropagation) { - e.stopPropagation(); - } - dragging++; - - var fn = $parse(attr.uiOnDragEnter); - scope.$evalAsync(function () { - fn(scope, {$event: e, $channel: dropChannel}); - }); - - $rootScope.$broadcast("ANGULAR_HOVER", dragChannel); - scope.$evalAsync(function () { - customDragLeaveEvent(scope, {$event: e}); - }); - element.addClass(dragHoverClass); - } - - function onDrop(e) { - if (e.preventDefault) { - e.preventDefault(); // Necessary. Allows us to drop. - } - if (e.stopPropagation) { - e.stopPropagation(); // Necessary. Allows us to drop. - } - - var sendData = e.dataTransfer.getData("dataToSend"); - sendData = angular.fromJson(sendData); - - var fn = $parse(attr.uiOnDrop); - scope.$evalAsync(function () { - fn(scope, {$data: sendData.data, $event: e, $channel: sendData.channel}); - }); - element.removeClass(dragEnterClass); - dragging = 0; - } - - function isDragChannelAccepted(dragChannel, dropChannel) { - if (dropChannel === "*") { - return true; - } - - var channelMatchPattern = new RegExp("(\\s|[,])+(" + dragChannel + ")(\\s|[,])+", "i"); - - return channelMatchPattern.test("," + dropChannel + ","); - } - - function preventNativeDnD(e) { - if (e.preventDefault) { - e.preventDefault(); - } - if (e.stopPropagation) { - e.stopPropagation(); - } - e.dataTransfer.dropEffect = "none"; - return false; - } - - var deregisterDragStart = $rootScope.$on("ANGULAR_DRAG_START", function (event, channel) { - dragChannel = channel; - if (isDragChannelAccepted(channel, dropChannel)) { - if (attr.dropValidate) { - var validateFn = $parse(attr.dropValidate); - var valid = validateFn(scope, {$data: currentData.data, $channel: currentData.channel}); - if (!valid) { - element.bind("dragover", preventNativeDnD); - element.bind("dragenter", preventNativeDnD); - element.bind("dragleave", preventNativeDnD); - element.bind("drop", preventNativeDnD); - return; - } - } - - element.bind("dragover", onDragOver); - element.bind("dragenter", onDragEnter); - element.bind("dragleave", onDragLeave); - - element.bind("drop", onDrop); - element.addClass(dragEnterClass); - } - else { - element.bind("dragover", preventNativeDnD); - element.bind("dragenter", preventNativeDnD); - element.bind("dragleave", preventNativeDnD); - element.bind("drop", preventNativeDnD); - } - - }); - - - - var deregisterDragEnd = $rootScope.$on("ANGULAR_DRAG_END", function (e, channel) { - dragChannel = ""; - if (isDragChannelAccepted(channel, dropChannel)) { - - element.unbind("dragover", onDragOver); - element.unbind("dragenter", onDragEnter); - element.unbind("dragleave", onDragLeave); - - element.unbind("drop", onDrop); - element.removeClass(dragHoverClass); - element.removeClass(dragEnterClass); - } - - element.unbind("dragover", preventNativeDnD); - element.unbind("dragenter", preventNativeDnD); - element.unbind("dragleave", preventNativeDnD); - element.unbind("drop", preventNativeDnD); - }); - - - var deregisterDragHover = $rootScope.$on("ANGULAR_HOVER", function (e, channel) { - if (isDragChannelAccepted(channel, dropChannel)) { - element.removeClass(dragHoverClass); - } - }); - - - scope.$on('$destroy', function () { - deregisterDragStart(); - deregisterDragEnd(); - deregisterDragHover(); - }); - - - attr.$observe('dropChannel', function (value) { - if (value) { - dropChannel = value; - } - }); - - - }; - } - ]) - .constant("$dragImageConfig", { - height: 20, - width: 200, - padding: 10, - font: 'bold 11px Arial', - fontColor: '#eee8d5', - backgroundColor: '#93a1a1', - xOffset: 0, - yOffset: 0 - }) - .service("$dragImage", [ - '$dragImageConfig', - function (defaultConfig) { - var ELLIPSIS = '…'; - - function fitString(canvas, text, config) { - var width = canvas.measureText(text).width; - if (width < config.width) { - return text; - } - while (width + config.padding > config.width) { - text = text.substring(0, text.length - 1); - width = canvas.measureText(text + ELLIPSIS).width; - } - return text + ELLIPSIS; - }; - - this.generate = function (text, options) { - var config = angular.extend({}, defaultConfig, options || {}); - var el = document.createElement('canvas'); - - el.height = config.height; - el.width = config.width; - - var canvas = el.getContext('2d'); - - canvas.fillStyle = config.backgroundColor; - canvas.fillRect(0, 0, config.width, config.height); - canvas.font = config.font; - canvas.fillStyle = config.fontColor; - - var title = fitString(canvas, text, config); - canvas.fillText(title, 4, config.padding + 4); - - var image = new Image(); - image.src = el.toDataURL(); - - return { - image: image, - xOffset: config.xOffset, - yOffset: config.yOffset - }; - } - } - ]); - -}(angular));