Moved angular-native-dragdrop to bower

pull/2165/head
Torkel Ödegaard 10 years ago
parent f22bffe98a
commit 05f934548b
  1. 3
      bower.json
  2. 4
      public/app/components/require.config.js
  3. 2
      public/test/test-main.js
  4. 37
      public/vendor/angular-native-dragdrop/.bower.json
  5. 15
      public/vendor/angular-native-dragdrop/Gulpfile.js
  6. 10
      public/vendor/angular-native-dragdrop/LICENSE
  7. 35
      public/vendor/angular-native-dragdrop/README.md
  8. 27
      public/vendor/angular-native-dragdrop/bower.json
  9. 29
      public/vendor/angular-native-dragdrop/demo/css/styles.css
  10. 129
      public/vendor/angular-native-dragdrop/demo/index.html
  11. 46
      public/vendor/angular-native-dragdrop/demo/js/app.js
  12. 32
      public/vendor/angular-native-dragdrop/docs/css/styles.css
  13. 323
      public/vendor/angular-native-dragdrop/docs/index.html
  14. 370
      public/vendor/angular-native-dragdrop/draganddrop.js
  15. 24
      public/vendor/angular-native-dragdrop/package.json
  16. 381
      public/vendor/angular-other/angular-dragdrop.js

@ -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"
}
}

@ -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,
});

@ -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',

@ -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
}

@ -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']);

@ -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.

@ -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.

@ -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"
]
}

@ -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;
}

@ -0,0 +1,129 @@
<!DOCTYPE html>
<html ng-app="app">
<head>
<meta charset="utf-8" />
<title>Angular DragDrop (Demo)</title>
<script>document.write('<base href="' + document.location + '" />');</script>
<link rel="stylesheet" href="css/styles.css" />
<script data-require="angular.js@1.3.x" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.js" data-semver="1.3.14"></script>
<script src="http://pc035860.github.io/angular-highlightjs/angular-highlightjs.min.js"></script>
<script src="js/app.js"></script>
<script src="../draganddrop.js"></script>
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" rel="stylesheet">
</head>
<body >
<div class="container">
<div class="row topRow">
<h4 class="heading">
Drag and drop between the two lists.
</h4>
</div>
<h3>Beasts</h3>
<p>Left column of beasts is not draggable and accepts both beasts and priests</p>
<hr>
<div class="row" ng-controller="MainCtrl">
<div class="col-xs-6">
<ul ui-on-drop="onDrop($event,$data,men)" drag-enter-class="on-drag-enter-custom"
drop-channel="beasts,priests"
drop-validate="dropValidateHandler($drop, $event, $data)">
<li ui-draggable="false" drag="man" drag-channel="beasts"
on-drop-success="dropSuccessHandler($event,$index,men)"
ng-repeat="man in men track by $index">
{{man}}
</li>
</ul>
</div>
<div class="col-xs-6">
<ul ui-on-drop="onDrop($event,$data,women)"
drop-channel="beasts"
drop-validate="dropValidateHandler($drop, $event, $data)">
<li ui-draggable="true" drag="woman" drag-channel="beasts"
on-drop-success="dropSuccessHandler($event,$index,women)"
ng-repeat="woman in women track by $index">
{{woman}}
</li>
</ul>
</div>
</div>
<hr>
<h3>Priests</h3>
<hr>
<div class="row" ng-controller="MainCtrl">
<div class="col-xs-6">
<ul ui-on-drop="onDrop($event,$data,men)"
drop-channel="priests"
drop-validate="dropValidateHandler($drop, $event, $data)">
<li ui-draggable="true" drag="man"
drag-channel="priests"
on-drop-success="dropSuccessHandler($event,$index,men)"
ng-repeat="man in men track by $index">
{{man}}
</li>
</ul>
</div>
<div class="col-xs-6">
<ul ui-on-drop="onDrop($event,$data,women)"
drop-channel="priests"
drop-validate="dropValidateHandler($drop, $event, $data)">
<li ui-draggable="true" drag="woman"
drag-channel="priests"
on-drop-success="dropSuccessHandler($event,$index,women)"
ng-repeat="woman in women track by $index">
{{woman}}
</li>
</ul>
</div>
</div>
<hr>
<h3>Terrorists</h3>
<p>Each terrorist list item accepts a new terrorist. Shows inserting into a particular
position in an array.</p>
<hr>
<div class="row" ng-controller="MainCtrl">
<div class="col-xs-6">
<ul>
<li ui-draggable="true" drag="man"
drag-channel="terrorists2"
drop-validate="dropValidateHandler($drop, $event, $data)"
drag-hover-class="on-drag-hover-custom"
on-drop-success="dropSuccessHandler($event,$index,men)"
ui-on-drop="onDrop($event,$data,men,$index)" drop-channel="terrorists1"
ng-repeat="man in men track by $index">
{{man}}
</li>
</ul>
</div>
<div class="col-xs-6">
<ul>
<li ui-draggable="true" drag="woman"
drag-channel="terrorists1"
drop-validate="dropValidateHandler($drop, $event, $data)"
drag-hover-class="on-drag-hover-custom"
ui-on-drop="onDrop($event,$data,women,$index)" drop-channel="terrorists2"
on-drop-success="dropSuccessHandler($event,$index,women)"
ng-repeat="woman in women track by $index">
{{woman}}
</li>
</ul>
</div>
</div>
</div>
</body>
</html>

@ -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);
}
};
});

@ -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;
}

@ -0,0 +1,323 @@
<!DOCTYPE html>
<html ng-app="app">
<head>
<title>Angular DragDrop</title>
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="css/styles.css"/>
<link rel="stylesheet" href="http://yandex.st/highlightjs/7.3/styles/github.min.css">
<script src="http://yandex.st/highlightjs/7.3/highlight.min.js"></script>
<script data-require="angular.js@1.3.x" src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"
data-semver="1.3.x"></script>
<script src="http://pc035860.github.io/angular-highlightjs/angular-highlightjs.min.js"></script>
</head>
<body>
<header class="navbar navbar-default navbar-fixed-top" role="banner">
<div class="container">
<div class="navbar-header">
<a href="#" class="navbar-brand">Angular DragDrop</a>
</div>
</div>
</header>
<a class="ribbon" href="https://github.com/angular-dragdrop/angular-dragdrop"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub"></a>
<div class="jumbotron">
<div class="container">
<h1>Angular Drag and Drop</h1>
<p>Angular-DragDrop is a <a href="http://www.angularjs.org">AngularJS</a> HTML5 Drag and Drop directive written in pure with no dependency on JQuery.</p>
<iframe src="http://ghbtns.com/github-btn.html?user=angular-dragdrop&repo=angular-dragdrop&type=watch&count=true"
allowtransparency="true" frameborder="0" scrolling="0" width="110" height="20"></iframe>
<iframe src="http://ghbtns.com/github-btn.html?user=angular-dragdrop&repo=angular-dragdrop&type=fork&count=true"
allowtransparency="true" frameborder="0" scrolling="0" width="110" height="20"></iframe>
</div>
</div>
<div class="container content">
<h2>Directives</h2>
<hr>
<h3 class="text-info"><em>ui-draggable</em></h3>
<p>
directive in module <em>ngDragDrop</em>
</p>
<p>The <code>ui-draggable</code> attribute tells Angular that the element is draggable. <code>ui-draggable</code>
takes an expression as the attribute value. The expression should evaluate to either <code>true</code> or <code>false</code>.
You can toggle the draggability of an element using this expression.
</p>
<h3 class="heading"><strong>Additional Attributes</strong></h3>
<h4 class="text-info"><em>drag</em></h4>
<p>The <code>drag</code> property is used to assign the data that needs to be passed along with the dragging
element.</p>
<hr>
<h4 class="text-info"><em>drag-handle-class</em></h4>
<p>The class used to mark child elements of draggable object to be used as drag handle. Default class name is
<code>drag-handle</code>.</p>
<div>
<strong>NOTE</strong>: If attribute is not present drag handle feature is not active.
</div>
<hr>
<h4 class="text-info"><em>on-drop-success</em></h4>
<p>The <code>on-drop-success</code> 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.
<div>
<strong>NOTE</strong>: This callback function is only called when the drop succeeds.
</div>
You can request the <code>drag-end</code> event ( very similiar to requesting the click event in
<code>ng-click</code> )
by passing <code>$event</code> in the event handler.
</p>
<hr>
<h4 class="text-info"><em>on-drop-failure</em></h4>
<p>The <code>on-drop-failure</code> 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.
<div>
<strong>NOTE</strong>: This callback function is only called when the drop fails.
</div>
You can request the <code>drag-end</code> event ( very similiar to requesting the click event in
<code>ng-click</code> )
by passing <code>$event</code> in the event handler.
</p>
<hr>
<h3 class="heading"><strong>Usage</strong></h3>
<p>
<div hljs>
<ANY ui-draggable="{expression}"
drag="dragData"
drag-handle-class="my-drag-handle"
on-drop-success="onDropSuccessHandler($event)"
on-drop-failure="onDropFailureHandler($event)"
drag-channel="mydropchannel">...
</ANY>
</div>
</p>
<h3 class="heading"><strong>Details</strong></h3>
<p>
<table class="table table-bordered">
<thead>
<tr>
<td>Param</td>
<td>Type</td>
<td>Details</td>
</tr>
</thead>
<tbody>
<tr>
<td>ui-draggable</td>
<td><label class="text-muted">expression</label></td>
<td><a target="_blank" href="http://docs.angularjs.org/guide/expression">Expression</a> that should be
evaluated. The given expression should resolve to true or false.
</td>
</tr>
<tr>
<td>drag</td>
<td><label class="text-muted">variable</label></td>
<td>Takes any JSON convertable <code>$scope</code> variable.</td>
</tr>
<tr>
<td>drag-handle-class</td>
<td><label class="text-muted">string</label></td>
<td>Class name used to mark child elements of draggable object to be used as drag handle. <br/>If attribute
is not present drag handle feature is not used. <br/>If attribute is present but have no value
<code>drag-handle</code> used as default.</td>
</tr>
<tr>
<td>on-drop-success</td>
<td><label class="text-muted">function</label></td>
<td>Takes any <code>$scope</code> function. Can also pass <code>$event</code>.</td>
</tr>
<tr>
<td>on-drop-failure</td>
<td><label class="text-muted">function</label></td>
<td>Takes any <code>$scope</code> function. Can also pass <code>$event</code>.</td>
</tr>
<tr>
<td>drag-channel</td>
<td><label class="text-muted">string</label></td>
<td>Takes a string that can be used as the channel name for the dragging operation.
Default channel is <code>"defaultchannel"</code>
</td>
</tr>
</tbody>
</table>
</p>
<hr>
<h3 class="heading"><strong>Events</strong></h3>
<p>On start of dragging an Angular Event <code>ANGULAR_DRAG_START</code> is dispatched from the
<code>$rootScope</code>. The event also carries
carries the information about the channel in which the dragging has started.
</p>
<p>On end of dragging an Angular Event <code>ANGULAR_DRAG_END</code> is dispatched from the <code>$rootScope</code>.
The event also carries
carries the information about the channel in which the dragging has started.
</p>
<p>When hovering a draggable element on top of a drop area an Angular Event <code>ANGULAR_HOVER</code>
is dispatched from the <code>$rootScope</code>.
The event also carries the information about the channel in which the dragging has started.
</p>
<hr>
<h3 class="text-info"><em>ui-on-drop</em></h3>
<p>
directive in module <em>ngDragDrop</em>
</p>
<p>The <code>ui-on-drop</code> attribute tells Angular that the element is a drop site. <code>ui-on-drop</code>
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.
<div>
<strong>NOTE</strong> : This callback function is only called when the drop succeeds.
</div>
The <code>ui-on-drop</code> callback can request additional parameters. The data that is dragged is available to the
callback as <code>$data</code> and its channel as <code>$channel</code>. Apart from this the drop event is exposed as <code>$event</code>.
</p>
<h3 class="heading"><strong>Additional Attributes</strong></h3>
<h4 class="text-info"><em>drop-channel</em></h4>
<p>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.
<div>
<strong>NOTE</strong>: Also special value of <code>drag-channel</code> attribute is available to accept
dragged element with any channel value — <code>*</code>
</div>
</p>
<hr>
<h4 class="text-info"><em>drop-validate</em></h4>
<p>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.
<div>
<strong>NOTE</strong>: This callback function is called only if the channel condition is met, when the element
starts being dragged
</div>
</p>
<hr>
<h4 class="text-info"><em>drag-enter-class</em></h4>
<p>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 <code>on-drag-enter</code></p>
<h4 class="text-info"><em>drag-hover-class</em></h4>
<p>The class that will be added to the drop area element when hovering with an element.
The default value for this is <code>on-drag-hover</code></p>
<hr>
<h3 class="heading"><strong>Usage</strong></h3>
<p>
<div hljs>
<ANY ui-on-drop="onDrop($data,$channel,$event)" drop-channel="mydropchannel" drag-enter-class="dragEnter">...</ANY>
</div>
</p>
<h3 class="heading"><strong>Details</strong></h3>
<p>
<table class="table table-bordered">
<thead>
<tr>
<td>Param</td>
<td>Type</td>
<td>Details</td>
</tr>
</thead>
<tbody>
<tr>
<td>ui-on-drop</td>
<td><label class="text-muted">function</label></td>
<td>Takes any <code>$scope</code> function. Can also pass <code>$event</code>, <code>$data</code> and <code>$channel</code>.
</td>
</tr>
<tr>
<td>drop-channel</td>
<td><label class="text-muted">expression</label></td>
<td>The channel on which the drop has to listen for drag events. <br/>
Single value, comma separated list or special value <code>*</code> are possible</td>
</tr>
<tr>
<td>drop-validate</td>
<td><label class="text-muted">function</label></td>
<td>Takes any <code>$scope</code> function. Can also pass <code>$data</code> and <code>$channel</code>
</td>
</tr>
<tr>
<td>drag-enter-class</td>
<td><label class="text-muted">string</label></td>
<td>A class name that will be put on the droppable element when the dragged objects enters its boundaries.
<br/>Default class name is <code>on-drag-enter</code>.</td>
</tr>
<td>drag-hover-class</td>
<td><label class="text-muted">string</label></td>
<td>A class name that will be put on the drop area when an element is dragged onto it. <br/>Default class
name is <code>on-drag-hover</code>.</td>
</tr>
</tbody>
</table>
</p>
<hr>
<h3 class="heading"><strong>Demo</strong></h3>
<iframe style="width: 100%; height: 500px" src="http://embed.plnkr.co/5RLvCpDPoRcEk6u77dBM" frameborder="0" allowfullscreen="allowfullscreen"></iframe>
<iframe style="width: 100%; height: 500px" src="http://embed.plnkr.co/xRmz4TlCvlJKxybGrhQH" frameborder="0" allowfullscreen="allowfullscreen"></iframe>
</div>
<footer class="navbar navbar-default navbar-fixed-bottom"></footer>
<script type="text/javascript" src="../js/app.js"></script>
<script>
(function (i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r;
i[r] = i[r] || function () {
(i[r].q = i[r].q || []).push(arguments)
}, i[r].l = 1 * new Date();
a = s.createElement(o),
m = s.getElementsByTagName(o)[0];
a.async = 1;
a.src = g;
m.parentNode.insertBefore(a, m)
})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
ga('create', 'UA-44888767-1', 'ganarajpr.github.io');
ga('send', 'pageview');
</script>
</body>
</html>

@ -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));

@ -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"
}
}

@ -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));
Loading…
Cancel
Save