Comparing version 0.5.3 to 0.5.4
@@ -162,18 +162,32 @@ "use strict"; | ||
it("calls setup() and teardown() on backend", function () { | ||
expect(backend.isActive).to.equal(undefined); | ||
expect(backend.didCallSetup).to.equal(undefined); | ||
expect(backend.didCallTeardown).to.equal(undefined); | ||
var sourceHandle = registry.addSource(Types.FOO, new NormalSource()); | ||
expect(backend.isActive).to.equal(true); | ||
expect(backend.didCallSetup).to.equal(true); | ||
expect(backend.didCallTeardown).to.equal(undefined); | ||
backend.didCallSetup = undefined; | ||
backend.didCallTeardown = undefined; | ||
var targetHandle = registry.addTarget(Types.FOO, new NormalTarget()); | ||
expect(backend.isActive).to.equal(true); | ||
expect(backend.didCallSetup).to.equal(undefined); | ||
expect(backend.didCallTeardown).to.equal(undefined); | ||
backend.didCallSetup = undefined; | ||
backend.didCallTeardown = undefined; | ||
registry.removeSource(sourceHandle); | ||
expect(backend.isActive).to.equal(true); | ||
expect(backend.didCallSetup).to.equal(undefined); | ||
expect(backend.didCallTeardown).to.equal(undefined); | ||
backend.didCallSetup = undefined; | ||
backend.didCallTeardown = undefined; | ||
registry.removeTarget(targetHandle); | ||
expect(backend.isActive).to.equal(false); | ||
expect(backend.didCallSetup).to.equal(undefined); | ||
expect(backend.didCallTeardown).to.equal(true); | ||
backend.didCallSetup = undefined; | ||
backend.didCallTeardown = undefined; | ||
registry.addTarget(Types.BAR, new NormalTarget()); | ||
expect(backend.isActive).to.equal(true); | ||
expect(backend.didCallSetup).to.equal(true); | ||
expect(backend.didCallTeardown).to.equal(undefined); | ||
}); | ||
@@ -180,0 +194,0 @@ |
@@ -10,11 +10,10 @@ "use strict"; | ||
this.actions = actions; | ||
this.isActive = undefined; | ||
} | ||
TestBackend.prototype.setup = function setup() { | ||
this.isActive = true; | ||
this.didCallSetup = true; | ||
}; | ||
TestBackend.prototype.teardown = function teardown() { | ||
this.isActive = false; | ||
this.didCallTeardown = true; | ||
}; | ||
@@ -21,0 +20,0 @@ |
@@ -28,6 +28,9 @@ "use strict"; | ||
DragDropManager.prototype.handleRefCountChange = function handleRefCountChange() { | ||
if (this.flux.refCountStore.hasRefs()) { | ||
var shouldSetUp = this.flux.refCountStore.hasRefs(); | ||
if (shouldSetUp && !this.isSetUp) { | ||
this.backend.setup(); | ||
} else { | ||
this.isSetUp = true; | ||
} else if (!shouldSetUp && this.isSetUp) { | ||
this.backend.teardown(); | ||
this.isSetUp = false; | ||
} | ||
@@ -34,0 +37,0 @@ }; |
@@ -25,15 +25,11 @@ "use strict"; | ||
this.createActions("dragDropActions", DragDropActions, manager); | ||
this.dragDropActions = this.getActions("dragDropActions"); | ||
this.dragDropActions = this.createActions("dragDropActions", DragDropActions, manager); | ||
this.dragDropActionIds = this.getActionIds("dragDropActions"); | ||
this.createActions("registryActions", RegistryActions); | ||
this.registryActions = this.getActions("registryActions"); | ||
this.registryActions = this.createActions("registryActions", RegistryActions); | ||
this.registryActionIds = this.getActionIds("registryActions"); | ||
this.createStore("dragOperationStore", DragOperationStore, this); | ||
this.dragOperationStore = this.getStore("dragOperationStore"); | ||
this.dragOperationStore = this.createStore("dragOperationStore", DragOperationStore, this); | ||
this.createStore("refCountStore", RefCountStore, this); | ||
this.refCountStore = this.getStore("refCountStore"); | ||
this.refCountStore = this.createStore("refCountStore", RefCountStore, this); | ||
} | ||
@@ -40,0 +36,0 @@ |
{ | ||
"name": "dnd-core", | ||
"version": "0.5.3", | ||
"version": "0.5.4", | ||
"description": "Drag and drop sans the GUI", | ||
@@ -5,0 +5,0 @@ "main": "dist-modules/index.js", |
213234
2236