66 * gridstack.js may be freely distributed under the MIT license.
77*/
88
9- import { GridStack } from '../gridstack' ;
9+ import { GridStack , GridStackElement } from '../gridstack' ;
1010import { GridStackDragDropPlugin , DDOpts , DDKey , DDDropOpt , DDCallback , DDValue } from '../gridstack-dragdrop-plugin' ;
11- import { GridItemHTMLElement } from '../types' ;
11+ import { GridItemHTMLElement , DDDragInOpt } from '../types' ;
1212
1313// TODO: TEMPORARY until can remove jquery-ui drag&drop and this class and use HTML5 instead !
1414// see https://stackoverflow.com/questions/35345760/importing-jqueryui-with-typescript-and-requirejs
@@ -66,6 +66,12 @@ export class JQueryUIGridStackDragDropPlugin extends GridStackDragDropPlugin {
6666 return this ;
6767 }
6868
69+ public dragIn ( el : GridStackElement , opts : DDDragInOpt ) : GridStackDragDropPlugin {
70+ let $el : JQuery = $ ( el ) ;
71+ $el . draggable ( opts ) ;
72+ return this ;
73+ }
74+
6975 public droppable ( el : GridItemHTMLElement , opts : DDOpts | DDDropOpt , key ?: DDKey , value ?: DDValue ) : GridStackDragDropPlugin {
7076 let $el : JQuery = $ ( el ) ;
7177 if ( typeof opts . accept === 'function' && ! opts . _accept ) {
@@ -82,6 +88,11 @@ export class JQueryUIGridStackDragDropPlugin extends GridStackDragDropPlugin {
8288 return Boolean ( $el . data ( 'ui-droppable' ) ) ;
8389 }
8490
91+ public isDraggable ( el : GridStackElement ) : boolean {
92+ let $el : JQuery = $ ( el ) ;
93+ return Boolean ( $el . data ( 'ui-draggable' ) ) ;
94+ }
95+
8596 public on ( el : GridItemHTMLElement , name : string , callback : DDCallback ) : GridStackDragDropPlugin {
8697 let $el : JQuery = $ ( el ) ;
8798 $el . on ( name , ( event , ui ) => { callback ( event as any , ui . draggable ? ui . draggable . get ( 0 ) : event . target ) } ) ;
@@ -97,17 +108,3 @@ export class JQueryUIGridStackDragDropPlugin extends GridStackDragDropPlugin {
97108
98109// finally register ourself
99110GridStackDragDropPlugin . registerPlugin ( JQueryUIGridStackDragDropPlugin ) ;
100-
101- /* OLD code for reference
102- function JQueryUIGridStackDragDropPlugin(grid) {
103- GridStack.DragDropPlugin.call(this, grid);
104- }
105-
106- GridStack.DragDropPlugin.registerPlugin(JQueryUIGridStackDragDropPlugin);
107-
108- JQueryUIGridStackDragDropPlugin.prototype = Object.create(GridStack.DragDropPlugin.prototype);
109- JQueryUIGridStackDragDropPlugin.prototype.constructor = JQueryUIGridStackDragDropPlugin;
110- ....
111- scope.JQueryUIGridStackDragDropPlugin = JQueryUIGridStackDragDropPlugin;
112- return JQueryUIGridStackDragDropPlugin;
113- */
0 commit comments