Skip to content

Commit

Permalink
fix(update): Updated to latest plugin version
Browse files Browse the repository at this point in the history
Fixes #19
  • Loading branch information
plwalters committed Aug 19, 2015
1 parent 6a9502d commit 018f4dd
Show file tree
Hide file tree
Showing 32 changed files with 376 additions and 304 deletions.
17 changes: 8 additions & 9 deletions dist/amd/attach-focus.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,23 @@ define(['exports', 'aurelia-templating'], function (exports, _aureliaTemplating)
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }

var AttachFocus = (function () {
_createClass(AttachFocus, null, [{
key: 'inject',
value: [Element],
enumerable: true
}]);

function AttachFocus(element) {
_classCallCheck(this, _AttachFocus);

this.element = element;
}

var _AttachFocus = AttachFocus;

_AttachFocus.prototype.attached = function attached() {
AttachFocus.prototype.attached = function attached() {
this.element.focus();
};

_createClass(_AttachFocus, null, [{
key: 'inject',
value: [Element],
enumerable: true
}]);

var _AttachFocus = AttachFocus;
AttachFocus = _aureliaTemplating.customAttribute('attach-focus')(AttachFocus) || AttachFocus;
return AttachFocus;
})();
Expand Down
32 changes: 20 additions & 12 deletions dist/amd/dialog-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,35 @@ define(['exports', './lifecycle'], function (exports, _lifecycle) {
this.close(false, result);
};

DialogController.prototype.close = function close(success, result) {
DialogController.prototype.error = function error(message) {
var _this = this;

return _lifecycle.invokeLifecycle(this.viewModel, 'deactivate').then(function () {
return _this._renderer.hideDialog(_this).then(function () {
return _this._renderer.destroyDialogHost(_this).then(function () {
_this.behavior.unbind();
_this._reject(message);
});
});
});
};

DialogController.prototype.close = function close(ok, result) {
var _this2 = this;

return _lifecycle.invokeLifecycle(this.viewModel, 'canDeactivate').then(function (canDeactivate) {
if (canDeactivate) {
return _lifecycle.invokeLifecycle(_this.viewModel, 'deactivate').then(function () {
return _this._renderer.hideDialog(_this).then(function () {
return _this._renderer.destroyDialogHost(_this).then(function () {
_this.behavior.unbind();

if (success) {
_this._resolve(result);
} else {
_this._reject(result);
return _lifecycle.invokeLifecycle(_this2.viewModel, 'deactivate').then(function () {
return _this2._renderer.hideDialog(_this2).then(function () {
return _this2._renderer.destroyDialogHost(_this2).then(function () {
_this2.behavior.unbind();
if (ok) {
_this2._resolve(result);
}
});
});
});
}

return Promise.reject();
});
};

Expand Down
49 changes: 24 additions & 25 deletions dist/amd/dialog-footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,26 @@ define(['exports', 'aurelia-templating', './dialog-controller'], function (expor
var DialogFooter = (function () {
var _instanceInitializers = {};

_createDecoratedClass(DialogFooter, [{
key: 'buttons',
decorators: [_aureliaTemplating.bindable],
initializer: function initializer() {
return [];
},
enumerable: true
}, {
key: 'useDefaultButtons',
decorators: [_aureliaTemplating.bindable],
initializer: function initializer() {
return false;
},
enumerable: true
}], [{
key: 'inject',
value: [_dialogController.DialogController],
enumerable: true
}], _instanceInitializers);

function DialogFooter(controller) {
_classCallCheck(this, _DialogFooter);

Expand All @@ -22,46 +42,25 @@ define(['exports', 'aurelia-templating', './dialog-controller'], function (expor
this.controller = controller;
}

var _DialogFooter = DialogFooter;

_DialogFooter.prototype.close = function close(buttonValue) {
DialogFooter.prototype.close = function close(buttonValue) {
if (DialogFooter.isCancelButton(buttonValue)) {
this.controller.cancel(buttonValue);
} else {
this.controller.ok(buttonValue);
}
};

_DialogFooter.prototype.useDefaultButtonsChanged = function useDefaultButtonsChanged(newValue) {
DialogFooter.prototype.useDefaultButtonsChanged = function useDefaultButtonsChanged(newValue) {
if (newValue) {
this.buttons = ['Cancel', 'Ok'];
}
};

_DialogFooter.isCancelButton = function isCancelButton(value) {
DialogFooter.isCancelButton = function isCancelButton(value) {
return value === 'Cancel';
};

_createDecoratedClass(_DialogFooter, [{
key: 'buttons',
decorators: [_aureliaTemplating.bindable],
initializer: function initializer() {
return [];
},
enumerable: true
}, {
key: 'useDefaultButtons',
decorators: [_aureliaTemplating.bindable],
initializer: function initializer() {
return false;
},
enumerable: true
}], [{
key: 'inject',
value: [_dialogController.DialogController],
enumerable: true
}], _instanceInitializers);

var _DialogFooter = DialogFooter;
DialogFooter = _aureliaTemplating.customElement('dialog-footer')(DialogFooter) || DialogFooter;
return DialogFooter;
})();
Expand Down
13 changes: 6 additions & 7 deletions dist/amd/dialog-header.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,19 @@ define(['exports', 'aurelia-templating', './dialog-controller'], function (expor
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }

var DialogHeader = (function () {
_createClass(DialogHeader, null, [{
key: 'inject',
value: [_dialogController.DialogController],
enumerable: true
}]);

function DialogHeader(controller) {
_classCallCheck(this, _DialogHeader);

this.controller = controller;
}

var _DialogHeader = DialogHeader;

_createClass(_DialogHeader, null, [{
key: 'inject',
value: [_dialogController.DialogController],
enumerable: true
}]);

DialogHeader = _aureliaTemplating.customElement('dialog-header')(DialogHeader) || DialogHeader;
return DialogHeader;
})();
Expand Down
49 changes: 33 additions & 16 deletions dist/amd/dialog-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,34 @@ define(["exports", "aurelia-templating"], function (exports, _aureliaTemplating)

var DialogRenderer = (function () {
function DialogRenderer() {
var _this = this;

_classCallCheck(this, DialogRenderer);

this.defaultSettings = {
lock: true
lock: true,
centerHorizontalOnly: false
};

this.dialogControllers = [];

document.addEventListener('keyup', function (e) {
if (e.keyCode === 27) {
var top = _this.dialogControllers[_this.dialogControllers.length - 1];
if (top && top.settings.lock !== true) {
top.cancel();
}
}
});
}

DialogRenderer.prototype.createDialogHost = function createDialogHost(controller) {
var _this2 = this;

var settings = controller.settings,
emptyParameters = {},
modalOverlay = document.createElement("dialog-overlay"),
modalContainer = document.createElement("dialog-container");
modalOverlay = document.createElement('dialog-overlay'),
modalContainer = document.createElement('dialog-container');

modalOverlay.style.zIndex = getNextZIndex();
modalContainer.style.zIndex = getNextZIndex();
Expand All @@ -53,15 +69,11 @@ define(["exports", "aurelia-templating"], function (exports, _aureliaTemplating)
controller.slot.add(controller.view);

controller.showDialog = function () {
_this2.dialogControllers.push(controller);

controller.slot.attached();
controller.centerDialog();

document.onkeypress = function (e) {
if (e.keyCode === 27 && settings.lock !== true) {
controller.cancel();
}
};

modalOverlay.onclick = function () {
if (!settings.lock) {
controller.cancel();
Expand All @@ -78,12 +90,17 @@ define(["exports", "aurelia-templating"], function (exports, _aureliaTemplating)
resolve();
};

modalOverlay.classList.add("active");
modalContainer.classList.add("active");
modalOverlay.classList.add('active');
modalContainer.classList.add('active');
});
};

controller.hideDialog = function () {
var i = _this2.dialogControllers.indexOf(controller);
if (i !== -1) {
_this2.dialogControllers.splice(i, 1);
}

return new Promise(function (resolve, reject) {
modalContainer.addEventListener(transitionEvent, onTransitionEnd);

Expand All @@ -92,8 +109,8 @@ define(["exports", "aurelia-templating"], function (exports, _aureliaTemplating)
resolve();
};

modalOverlay.classList.remove("active");
modalContainer.classList.remove("active");
modalOverlay.classList.remove('active');
modalContainer.classList.remove('active');
});
};

Expand All @@ -107,11 +124,11 @@ define(["exports", "aurelia-templating"], function (exports, _aureliaTemplating)
controller.centerDialog = function () {
var child = modalContainer.children[0];

child.style.marginLeft = -(child.offsetWidth / 2) + 'px';

if (!settings.centerHorizontalOnly) {
child.style.marginLeft = -(child.offsetWidth / 2) + "px";
child.style.marginTop = -(child.offsetHeight / 2) + 'px';
}

child.style.marginTop = -(child.offsetHeight / 2) + "px";
};

return Promise.resolve();
Expand Down
16 changes: 6 additions & 10 deletions dist/amd/dialog-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ define(['exports', 'aurelia-metadata', 'aurelia-dependency-injection', 'aurelia-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }

var DialogService = (function () {
_createClass(DialogService, null, [{
key: 'inject',
value: [_aureliaDependencyInjection.Container, _aureliaTemplating.CompositionEngine, _dialogRenderer.DialogRenderer],
enumerable: true
}]);

function DialogService(container, compositionEngine, renderer) {
_classCallCheck(this, DialogService);

Expand All @@ -34,7 +40,6 @@ define(['exports', 'aurelia-metadata', 'aurelia-dependency-injection', 'aurelia-
settings = Object.assign({}, this.renderer.defaultSettings, settings);

return new Promise(function (resolve, reject) {
console.log('creating');
var childContainer = _this.container.createChild(),
controller = new _dialogController.DialogController(_this.renderer, settings, resolve, reject),
instruction = {
Expand All @@ -43,7 +48,6 @@ define(['exports', 'aurelia-metadata', 'aurelia-dependency-injection', 'aurelia-
childContainer: childContainer,
model: settings.model
};
console.log(controller);

childContainer.registerInstance(_dialogController.DialogController, controller);

Expand All @@ -61,20 +65,12 @@ define(['exports', 'aurelia-metadata', 'aurelia-dependency-injection', 'aurelia-
return _this.renderer.showDialog(controller);
});
});
} else {
return Promise.reject();
}
});
});
});
};

_createClass(DialogService, null, [{
key: 'inject',
value: [_aureliaDependencyInjection.Container, _aureliaTemplating.CompositionEngine, _dialogRenderer.DialogRenderer],
enumerable: true
}]);

return DialogService;
})();

Expand Down
12 changes: 6 additions & 6 deletions dist/amd/examples/common-dialogs.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ define(['exports', './prompt', '../dialog-service'], function (exports, _prompt,
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }

var CommonDialogs = (function () {
_createClass(CommonDialogs, null, [{
key: 'inject',
value: [_dialogService.DialogService],
enumerable: true
}]);

function CommonDialogs(dialogService) {
_classCallCheck(this, CommonDialogs);

Expand All @@ -18,12 +24,6 @@ define(['exports', './prompt', '../dialog-service'], function (exports, _prompt,
return this.dialogService.open({ viewModel: _prompt.Prompt, model: question });
};

_createClass(CommonDialogs, null, [{
key: 'inject',
value: [_dialogService.DialogService],
enumerable: true
}]);

return CommonDialogs;
})();

Expand Down
12 changes: 6 additions & 6 deletions dist/amd/examples/prompt.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ define(['exports', '../dialog-controller'], function (exports, _dialogController
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }

var Prompt = (function () {
_createClass(Prompt, null, [{
key: 'inject',
value: [_dialogController.DialogController],
enumerable: true
}]);

function Prompt(controller) {
_classCallCheck(this, Prompt);

Expand All @@ -21,12 +27,6 @@ define(['exports', '../dialog-controller'], function (exports, _dialogController
this.question = question;
};

_createClass(Prompt, null, [{
key: 'inject',
value: [_dialogController.DialogController],
enumerable: true
}]);

return Prompt;
})();

Expand Down
Loading

0 comments on commit 018f4dd

Please sign in to comment.