ferngully-aurelia-tools
Version:
Ferngully Tools for Aurelia
79 lines • 3.29 kB
JavaScript
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
import { autoinject } from "aurelia-framework";
import { DialogService } from "aurelia-dialog";
import { BrowserService } from "./browser-service";
import { PLATFORM } from 'aurelia-framework';
var CommonDialogs = (function () {
function CommonDialogs(dialogService, browserService) {
this.dialogService = dialogService;
this.browserService = browserService;
}
CommonDialogs.prototype.prompt = function (options, settings) {
if (typeof options === "string") {
options = { text: options, ok: true };
}
var defaultSettings = {
keyboard: ["Escape"]
};
if (!settings) {
settings = defaultSettings;
}
else {
Object.apply(defaultSettings, settings);
}
settings.viewModel = PLATFORM.moduleName('ferngully-aurelia-tools/resources/commonDialogs/prompt');
settings.model = options;
this.adjustScroll();
return this.dialogService.open(settings)
.whenClosed(function (result) {
return Promise.resolve({ wasCancelled: result.wasCancelled });
});
};
;
CommonDialogs.prototype.askForText = function (options, settings) {
if (typeof options === "string") {
options = { text: options, ok: true, cancel: true };
}
var defaultSettings = {
keyboard: ["Escape"]
};
if (!settings) {
settings = defaultSettings;
}
else {
Object.apply(defaultSettings, settings);
}
settings.viewModel = PLATFORM.moduleName('ferngully-aurelia-tools/resources/commonDialogs/askForText');
settings.model = options;
this.adjustScroll();
return this.dialogService.open(settings)
.whenClosed(function (result) {
return result.wasCancelled ? null : result.output;
});
};
;
CommonDialogs.prototype.adjustScroll = function () {
if (this.browserService.verticalScrollBarIsShowing()) {
$('body').addClass("showVerticalScroll");
}
else {
$('body').removeClass("showVerticalScroll");
}
};
CommonDialogs = __decorate([
autoinject,
__metadata("design:paramtypes", [DialogService,
BrowserService])
], CommonDialogs);
return CommonDialogs;
}());
export { CommonDialogs };
//# sourceMappingURL=dialog-service.js.map