index.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. <!DOCTYPE html>
  2. <html ng-app="app">
  3. <head>
  4. <title>Angular DragDrop</title>
  5. <link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" rel="stylesheet">
  6. <link rel="stylesheet" href="css/styles.css"/>
  7. <link rel="stylesheet" href="http://yandex.st/highlightjs/7.3/styles/github.min.css">
  8. <script src="http://yandex.st/highlightjs/7.3/highlight.min.js"></script>
  9. <script data-require="angular.js@1.3.x" src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"
  10. data-semver="1.3.x"></script>
  11. <script src="http://pc035860.github.io/angular-highlightjs/angular-highlightjs.min.js"></script>
  12. </head>
  13. <body>
  14. <header class="navbar navbar-default navbar-fixed-top" role="banner">
  15. <div class="container">
  16. <div class="navbar-header">
  17. <a href="#" class="navbar-brand">Angular DragDrop</a>
  18. </div>
  19. </div>
  20. </header>
  21. <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>
  22. <div class="jumbotron">
  23. <div class="container">
  24. <h1>Angular Drag and Drop</h1>
  25. <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>
  26. <iframe src="http://ghbtns.com/github-btn.html?user=angular-dragdrop&repo=angular-dragdrop&type=watch&count=true"
  27. allowtransparency="true" frameborder="0" scrolling="0" width="110" height="20"></iframe>
  28. <iframe src="http://ghbtns.com/github-btn.html?user=angular-dragdrop&repo=angular-dragdrop&type=fork&count=true"
  29. allowtransparency="true" frameborder="0" scrolling="0" width="110" height="20"></iframe>
  30. </div>
  31. </div>
  32. <div class="container content">
  33. <h2>Directives</h2>
  34. <hr>
  35. <h3 class="text-info"><em>ui-draggable</em></h3>
  36. <p>
  37. directive in module <em>ngDragDrop</em>
  38. </p>
  39. <p>The <code>ui-draggable</code> attribute tells Angular that the element is draggable. <code>ui-draggable</code>
  40. takes an expression as the attribute value. The expression should evaluate to either <code>true</code> or <code>false</code>.
  41. You can toggle the draggability of an element using this expression.
  42. </p>
  43. <h3 class="heading"><strong>Additional Attributes</strong></h3>
  44. <h4 class="text-info"><em>drag</em></h4>
  45. <p>The <code>drag</code> property is used to assign the data that needs to be passed along with the dragging
  46. element.</p>
  47. <hr>
  48. <h4 class="text-info"><em>drag-handle-class</em></h4>
  49. <p>The class used to mark child elements of draggable object to be used as drag handle. Default class name is
  50. <code>drag-handle</code>.</p>
  51. <div>
  52. <strong>NOTE</strong>: If attribute is not present drag handle feature is not active.
  53. </div>
  54. <hr>
  55. <h4 class="text-info"><em>on-drop-success</em></h4>
  56. <p>The <code>on-drop-success</code> attribute takes a function. We can consider this to be an on-drop-success
  57. handler function.
  58. This can be useful if you need to do some post processing after the dragged element is dropped successfully on
  59. the drop site.
  60. <div>
  61. <strong>NOTE</strong>: This callback function is only called when the drop succeeds.
  62. </div>
  63. You can request the <code>drag-end</code> event ( very similiar to requesting the click event in
  64. <code>ng-click</code> )
  65. by passing <code>$event</code> in the event handler.
  66. </p>
  67. <hr>
  68. <h4 class="text-info"><em>on-drop-failure</em></h4>
  69. <p>The <code>on-drop-failure</code> attribute takes a function. We can consider this to be an on-drop-failure
  70. handler function.
  71. This can be useful if you need to do some post processing after the dragged element is dropped unsuccessfully on
  72. any drop site.
  73. <div>
  74. <strong>NOTE</strong>: This callback function is only called when the drop fails.
  75. </div>
  76. You can request the <code>drag-end</code> event ( very similiar to requesting the click event in
  77. <code>ng-click</code> )
  78. by passing <code>$event</code> in the event handler.
  79. </p>
  80. <hr>
  81. <h3 class="heading"><strong>Usage</strong></h3>
  82. <p>
  83. <div hljs>
  84. <ANY ui-draggable="{expression}"
  85. drag="dragData"
  86. drag-handle-class="my-drag-handle"
  87. on-drop-success="onDropSuccessHandler($event)"
  88. on-drop-failure="onDropFailureHandler($event)"
  89. drag-channel="mydropchannel">...
  90. </ANY>
  91. </div>
  92. </p>
  93. <h3 class="heading"><strong>Details</strong></h3>
  94. <p>
  95. <table class="table table-bordered">
  96. <thead>
  97. <tr>
  98. <td>Param</td>
  99. <td>Type</td>
  100. <td>Details</td>
  101. </tr>
  102. </thead>
  103. <tbody>
  104. <tr>
  105. <td>ui-draggable</td>
  106. <td><label class="text-muted">expression</label></td>
  107. <td><a target="_blank" href="http://docs.angularjs.org/guide/expression">Expression</a> that should be
  108. evaluated. The given expression should resolve to true or false.
  109. </td>
  110. </tr>
  111. <tr>
  112. <td>drag</td>
  113. <td><label class="text-muted">variable</label></td>
  114. <td>Takes any JSON convertable <code>$scope</code> variable.</td>
  115. </tr>
  116. <tr>
  117. <td>drag-handle-class</td>
  118. <td><label class="text-muted">string</label></td>
  119. <td>Class name used to mark child elements of draggable object to be used as drag handle. <br/>If attribute
  120. is not present drag handle feature is not used. <br/>If attribute is present but have no value
  121. <code>drag-handle</code> used as default.</td>
  122. </tr>
  123. <tr>
  124. <td>on-drop-success</td>
  125. <td><label class="text-muted">function</label></td>
  126. <td>Takes any <code>$scope</code> function. Can also pass <code>$event</code>.</td>
  127. </tr>
  128. <tr>
  129. <td>on-drop-failure</td>
  130. <td><label class="text-muted">function</label></td>
  131. <td>Takes any <code>$scope</code> function. Can also pass <code>$event</code>.</td>
  132. </tr>
  133. <tr>
  134. <td>drag-channel</td>
  135. <td><label class="text-muted">string</label></td>
  136. <td>Takes a string that can be used as the channel name for the dragging operation.
  137. Default channel is <code>"defaultchannel"</code>
  138. </td>
  139. </tr>
  140. </tbody>
  141. </table>
  142. </p>
  143. <hr>
  144. <h3 class="heading"><strong>Events</strong></h3>
  145. <p>On start of dragging an Angular Event <code>ANGULAR_DRAG_START</code> is dispatched from the
  146. <code>$rootScope</code>. The event also carries
  147. carries the information about the channel in which the dragging has started.
  148. </p>
  149. <p>On end of dragging an Angular Event <code>ANGULAR_DRAG_END</code> is dispatched from the <code>$rootScope</code>.
  150. The event also carries
  151. carries the information about the channel in which the dragging has started.
  152. </p>
  153. <p>When hovering a draggable element on top of a drop area an Angular Event <code>ANGULAR_HOVER</code>
  154. is dispatched from the <code>$rootScope</code>.
  155. The event also carries the information about the channel in which the dragging has started.
  156. </p>
  157. <hr>
  158. <h3 class="text-info"><em>ui-on-drop</em></h3>
  159. <p>
  160. directive in module <em>ngDragDrop</em>
  161. </p>
  162. <p>The <code>ui-on-drop</code> attribute tells Angular that the element is a drop site. <code>ui-on-drop</code>
  163. takes a function as the attribute value. The function will be called when a valid dragged element is dropped in
  164. that location.
  165. A valid dragged element is one which has the same channel as the drop location.
  166. <div>
  167. <strong>NOTE</strong> : This callback function is only called when the drop succeeds.
  168. </div>
  169. The <code>ui-on-drop</code> callback can request additional parameters. The data that is dragged is available to the
  170. callback as <code>$data</code> and its channel as <code>$channel</code>. Apart from this the drop event is exposed as <code>$event</code>.
  171. </p>
  172. <h3 class="heading"><strong>Additional Attributes</strong></h3>
  173. <h4 class="text-info"><em>drop-channel</em></h4>
  174. <p>The channel that the drop site accepts. The dragged element should have the same channel as this drop site for it
  175. to be droppable at this location. It is possible to provide comma separated list of channels.
  176. <div>
  177. <strong>NOTE</strong>: Also special value of <code>drag-channel</code> attribute is available to accept
  178. dragged element with any channel value — <code>*</code>
  179. </div>
  180. </p>
  181. <hr>
  182. <h4 class="text-info"><em>drop-validate</em></h4>
  183. <p>Extra validation that makes sure that the drop site accepts the dragged element beyond having the same channel. If
  184. not defined, no extra validation is made.
  185. <div>
  186. <strong>NOTE</strong>: This callback function is called only if the channel condition is met, when the element
  187. starts being dragged
  188. </div>
  189. </p>
  190. <hr>
  191. <h4 class="text-info"><em>drag-enter-class</em></h4>
  192. <p>The class that will be added to the the droppable element when a dragged element ( which is droppable )
  193. enters the drop location. The default value for this is <code>on-drag-enter</code></p>
  194. <h4 class="text-info"><em>drag-hover-class</em></h4>
  195. <p>The class that will be added to the drop area element when hovering with an element.
  196. The default value for this is <code>on-drag-hover</code></p>
  197. <hr>
  198. <h3 class="heading"><strong>Usage</strong></h3>
  199. <p>
  200. <div hljs>
  201. <ANY ui-on-drop="onDrop($data,$channel,$event)" drop-channel="mydropchannel" drag-enter-class="dragEnter">...</ANY>
  202. </div>
  203. </p>
  204. <h3 class="heading"><strong>Details</strong></h3>
  205. <p>
  206. <table class="table table-bordered">
  207. <thead>
  208. <tr>
  209. <td>Param</td>
  210. <td>Type</td>
  211. <td>Details</td>
  212. </tr>
  213. </thead>
  214. <tbody>
  215. <tr>
  216. <td>ui-on-drop</td>
  217. <td><label class="text-muted">function</label></td>
  218. <td>Takes any <code>$scope</code> function. Can also pass <code>$event</code>, <code>$data</code> and <code>$channel</code>.
  219. </td>
  220. </tr>
  221. <tr>
  222. <td>drop-channel</td>
  223. <td><label class="text-muted">expression</label></td>
  224. <td>The channel on which the drop has to listen for drag events. <br/>
  225. Single value, comma separated list or special value <code>*</code> are possible</td>
  226. </tr>
  227. <tr>
  228. <td>drop-validate</td>
  229. <td><label class="text-muted">function</label></td>
  230. <td>Takes any <code>$scope</code> function. Can also pass <code>$data</code> and <code>$channel</code>
  231. </td>
  232. </tr>
  233. <tr>
  234. <td>drag-enter-class</td>
  235. <td><label class="text-muted">string</label></td>
  236. <td>A class name that will be put on the droppable element when the dragged objects enters its boundaries.
  237. <br/>Default class name is <code>on-drag-enter</code>.</td>
  238. </tr>
  239. <td>drag-hover-class</td>
  240. <td><label class="text-muted">string</label></td>
  241. <td>A class name that will be put on the drop area when an element is dragged onto it. <br/>Default class
  242. name is <code>on-drag-hover</code>.</td>
  243. </tr>
  244. </tbody>
  245. </table>
  246. </p>
  247. <hr>
  248. <h3 class="heading"><strong>Demo</strong></h3>
  249. <iframe style="width: 100%; height: 500px" src="http://embed.plnkr.co/5RLvCpDPoRcEk6u77dBM" frameborder="0" allowfullscreen="allowfullscreen"></iframe>
  250. <iframe style="width: 100%; height: 500px" src="http://embed.plnkr.co/xRmz4TlCvlJKxybGrhQH" frameborder="0" allowfullscreen="allowfullscreen"></iframe>
  251. </div>
  252. <footer class="navbar navbar-default navbar-fixed-bottom"></footer>
  253. <script type="text/javascript" src="../js/app.js"></script>
  254. <script>
  255. (function (i, s, o, g, r, a, m) {
  256. i['GoogleAnalyticsObject'] = r;
  257. i[r] = i[r] || function () {
  258. (i[r].q = i[r].q || []).push(arguments)
  259. }, i[r].l = 1 * new Date();
  260. a = s.createElement(o),
  261. m = s.getElementsByTagName(o)[0];
  262. a.async = 1;
  263. a.src = g;
  264. m.parentNode.insertBefore(a, m)
  265. })(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
  266. ga('create', 'UA-44888767-1', 'ganarajpr.github.io');
  267. ga('send', 'pageview');
  268. </script>
  269. </body>
  270. </html>