angular-sortablejs
Advanced tools
Comparing version 2.2.3-0 to 2.3.0-0
import { ElementRef, OnInit, OnChanges, OnDestroy, NgZone, SimpleChanges, ChangeDetectorRef } from '@angular/core'; | ||
import { SortablejsOptions } from './sortablejs-options'; | ||
import { SortablejsService } from './sortablejs.service'; | ||
import { SortablejsBindingTarget } from './sortablejs-binding-target'; | ||
export declare class SortablejsDirective implements OnInit, OnChanges, OnDestroy { | ||
private globalConfig; | ||
private sortablejsService; | ||
private service; | ||
private element; | ||
private zone; | ||
private cdr; | ||
items: any[] | any; | ||
sortablejs: SortablejsBindingTarget; | ||
inputOptions: SortablejsOptions; | ||
private _sortable; | ||
runInsideAngular: boolean; | ||
constructor(globalConfig: SortablejsOptions, sortablejsService: SortablejsService, element: ElementRef, zone: NgZone, cdr: ChangeDetectorRef); | ||
constructor(globalConfig: SortablejsOptions, service: SortablejsService, element: ElementRef, zone: NgZone, cdr: ChangeDetectorRef); | ||
ngOnInit(): void; | ||
ngOnChanges(changes: SimpleChanges): void; | ||
ngOnDestroy(): void; | ||
private getBindings(); | ||
private readonly options; | ||
private proxyEvent(eventName, event); | ||
private readonly bindingEnabled; | ||
private readonly isItemsFormArray; | ||
private readonly overridenOptions; | ||
} |
@@ -6,7 +6,8 @@ "use strict"; | ||
var sortablejs_service_1 = require("./sortablejs.service"); | ||
var sortablejs_1 = require("sortablejs"); | ||
var sortablejs_bindings_1 = require("./sortablejs-bindings"); | ||
var OriginalSortable = require('sortablejs'); | ||
var SortablejsDirective = (function () { | ||
function SortablejsDirective(globalConfig, sortablejsService, element, zone, cdr) { | ||
function SortablejsDirective(globalConfig, service, element, zone, cdr) { | ||
this.globalConfig = globalConfig; | ||
this.sortablejsService = sortablejsService; | ||
this.service = service; | ||
this.element = element; | ||
@@ -20,7 +21,7 @@ this.zone = zone; | ||
if (this.runInsideAngular) { | ||
this._sortable = sortablejs_1.default.create(this.element.nativeElement, this.options); | ||
this._sortable = OriginalSortable.create(this.element.nativeElement, this.options); | ||
} | ||
else { | ||
this.zone.runOutsideAngular(function () { | ||
_this._sortable = sortablejs_1.default.create(_this.element.nativeElement, _this.options); | ||
_this._sortable = OriginalSortable.create(_this.element.nativeElement, _this.options); | ||
}); | ||
@@ -47,2 +48,13 @@ } | ||
}; | ||
SortablejsDirective.prototype.getBindings = function () { | ||
if (this.sortablejs) { | ||
return new sortablejs_bindings_1.SortablejsBindings([]); | ||
} | ||
else if (this.sortablejs instanceof sortablejs_bindings_1.SortablejsBindings) { | ||
return this.sortablejs; | ||
} | ||
else { | ||
return new sortablejs_bindings_1.SortablejsBindings([this.sortablejs]); | ||
} | ||
}; | ||
Object.defineProperty(SortablejsDirective.prototype, "options", { | ||
@@ -61,16 +73,2 @@ get: function () { | ||
}; | ||
Object.defineProperty(SortablejsDirective.prototype, "bindingEnabled", { | ||
get: function () { | ||
return !!this.items; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(SortablejsDirective.prototype, "isItemsFormArray", { | ||
get: function () { | ||
return !!this.items.at && !!this.items.insert && !!this.items.reset; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(SortablejsDirective.prototype, "overridenOptions", { | ||
@@ -81,26 +79,10 @@ get: function () { | ||
onAdd: function (event) { | ||
if (_this.bindingEnabled) { | ||
_this.sortablejsService.onremove = function (item) { | ||
if (_this.isItemsFormArray) { | ||
_this.items.insert(event.newIndex, item); | ||
} | ||
else { | ||
_this.items.splice(event.newIndex, 0, item); | ||
} | ||
}; | ||
} | ||
_this.service.onremove = function (items) { return _this.getBindings().injectIntoEvery(event.newIndex, items); }; | ||
_this.proxyEvent('onAdd', event); | ||
}, | ||
onRemove: function (event) { | ||
if (_this.bindingEnabled) { | ||
var item = void 0; | ||
if (_this.isItemsFormArray) { | ||
item = _this.items.at(event.oldIndex); | ||
_this.items.removeAt(event.oldIndex); | ||
} | ||
else { | ||
item = _this.items.splice(event.oldIndex, 1)[0]; | ||
} | ||
_this.sortablejsService.onremove(item); | ||
_this.sortablejsService.onremove = null; | ||
var bindings = _this.getBindings(); | ||
if (bindings.provided) { | ||
_this.service.onremove(bindings.extractFromEvery(event.oldIndex)); | ||
_this.service.onremove = null; | ||
} | ||
@@ -110,12 +92,4 @@ _this.proxyEvent('onRemove', event); | ||
onUpdate: function (event) { | ||
if (_this.bindingEnabled) { | ||
if (_this.isItemsFormArray) { | ||
var relocated = _this.items.at(event.oldIndex); | ||
_this.items.removeAt(event.oldIndex); | ||
_this.items.insert(event.newIndex, relocated); | ||
} | ||
else { | ||
_this.items.splice(event.newIndex, 0, _this.items.splice(event.oldIndex, 1)[0]); | ||
} | ||
} | ||
var bindings = _this.getBindings(); | ||
bindings.injectIntoEvery(event.newIndex, bindings.extractFromEvery(event.oldIndex)); | ||
_this.proxyEvent('onUpdate', event); | ||
@@ -143,3 +117,3 @@ } | ||
SortablejsDirective.propDecorators = { | ||
'items': [{ type: core_1.Input, args: ['sortablejs',] },], | ||
'sortablejs': [{ type: core_1.Input, args: ['sortablejs',] },], | ||
'inputOptions': [{ type: core_1.Input, args: ['sortablejsOptions',] },], | ||
@@ -146,0 +120,0 @@ 'runInsideAngular': [{ type: core_1.Input },], |
@@ -1,1 +0,1 @@ | ||
[{"__symbolic":"module","version":3,"metadata":{"SortablejsDirective":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Directive"},"arguments":[{"selector":"[sortablejs]"}]}],"members":{"items":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"},"arguments":["sortablejs"]}]}],"inputOptions":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"},"arguments":["sortablejsOptions"]}]}],"runInsideAngular":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"__ctor__":[{"__symbolic":"constructor","parameterDecorators":[[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Optional"}},{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject"},"arguments":[{"__symbolic":"reference","module":"./globals","name":"GLOBALS"}]}],null,null,null,null],"parameters":[{"__symbolic":"reference","module":"./sortablejs-options","name":"SortablejsOptions"},{"__symbolic":"reference","module":"./sortablejs.service","name":"SortablejsService"},{"__symbolic":"reference","module":"@angular/core","name":"ElementRef"},{"__symbolic":"reference","module":"@angular/core","name":"NgZone"},{"__symbolic":"reference","module":"@angular/core","name":"ChangeDetectorRef"}]}],"ngOnInit":[{"__symbolic":"method"}],"ngOnChanges":[{"__symbolic":"method"}],"ngOnDestroy":[{"__symbolic":"method"}],"proxyEvent":[{"__symbolic":"method"}]}}}},{"__symbolic":"module","version":1,"metadata":{"SortablejsDirective":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Directive"},"arguments":[{"selector":"[sortablejs]"}]}],"members":{"items":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"},"arguments":["sortablejs"]}]}],"inputOptions":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"},"arguments":["sortablejsOptions"]}]}],"runInsideAngular":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"__ctor__":[{"__symbolic":"constructor","parameterDecorators":[[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Optional"}},{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject"},"arguments":[{"__symbolic":"reference","module":"./globals","name":"GLOBALS"}]}],null,null,null,null],"parameters":[{"__symbolic":"reference","module":"./sortablejs-options","name":"SortablejsOptions"},{"__symbolic":"reference","module":"./sortablejs.service","name":"SortablejsService"},{"__symbolic":"reference","module":"@angular/core","name":"ElementRef"},{"__symbolic":"reference","module":"@angular/core","name":"NgZone"},{"__symbolic":"reference","module":"@angular/core","name":"ChangeDetectorRef"}]}],"ngOnInit":[{"__symbolic":"method"}],"ngOnChanges":[{"__symbolic":"method"}],"ngOnDestroy":[{"__symbolic":"method"}],"proxyEvent":[{"__symbolic":"method"}]}}}}] | ||
[{"__symbolic":"module","version":3,"metadata":{"SortablejsDirective":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Directive"},"arguments":[{"selector":"[sortablejs]"}]}],"members":{"sortablejs":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"},"arguments":["sortablejs"]}]}],"inputOptions":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"},"arguments":["sortablejsOptions"]}]}],"runInsideAngular":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"__ctor__":[{"__symbolic":"constructor","parameterDecorators":[[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Optional"}},{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject"},"arguments":[{"__symbolic":"reference","module":"./globals","name":"GLOBALS"}]}],null,null,null,null],"parameters":[{"__symbolic":"reference","module":"./sortablejs-options","name":"SortablejsOptions"},{"__symbolic":"reference","module":"./sortablejs.service","name":"SortablejsService"},{"__symbolic":"reference","module":"@angular/core","name":"ElementRef"},{"__symbolic":"reference","module":"@angular/core","name":"NgZone"},{"__symbolic":"reference","module":"@angular/core","name":"ChangeDetectorRef"}]}],"ngOnInit":[{"__symbolic":"method"}],"ngOnChanges":[{"__symbolic":"method"}],"ngOnDestroy":[{"__symbolic":"method"}],"getBindings":[{"__symbolic":"method"}],"proxyEvent":[{"__symbolic":"method"}]}}}},{"__symbolic":"module","version":1,"metadata":{"SortablejsDirective":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Directive"},"arguments":[{"selector":"[sortablejs]"}]}],"members":{"sortablejs":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"},"arguments":["sortablejs"]}]}],"inputOptions":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"},"arguments":["sortablejsOptions"]}]}],"runInsideAngular":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"__ctor__":[{"__symbolic":"constructor","parameterDecorators":[[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Optional"}},{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject"},"arguments":[{"__symbolic":"reference","module":"./globals","name":"GLOBALS"}]}],null,null,null,null],"parameters":[{"__symbolic":"reference","module":"./sortablejs-options","name":"SortablejsOptions"},{"__symbolic":"reference","module":"./sortablejs.service","name":"SortablejsService"},{"__symbolic":"reference","module":"@angular/core","name":"ElementRef"},{"__symbolic":"reference","module":"@angular/core","name":"NgZone"},{"__symbolic":"reference","module":"@angular/core","name":"ChangeDetectorRef"}]}],"ngOnInit":[{"__symbolic":"method"}],"ngOnChanges":[{"__symbolic":"method"}],"ngOnDestroy":[{"__symbolic":"method"}],"getBindings":[{"__symbolic":"method"}],"proxyEvent":[{"__symbolic":"method"}]}}}}] |
{ | ||
"name": "angular-sortablejs", | ||
"version": "2.2.3-0", | ||
"version": "2.3.0-0", | ||
"description": "SortableJS for Angular", | ||
@@ -42,3 +42,2 @@ "main": "./dist/index.js", | ||
"@types/node": "7.0.12", | ||
"@types/sortablejs": "1.3.31", | ||
"@types/systemjs": "0.20.2", | ||
@@ -45,0 +44,0 @@ "git-validate": "2.2.2", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
38008
11
38
323